#ifndef LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H
#define LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H
#include "llvm/ADT/StringSwitch.h"
namespace llvm {
namespace LPCC {
enum CondCode {
ICC_T = 0, ICC_F = 1, ICC_HI = 2, ICC_UGT = 2, ICC_LS = 3, ICC_ULE = 3, ICC_CC = 4, ICC_ULT = 4, ICC_CS = 5, ICC_UGE = 5, ICC_NE = 6, ICC_EQ = 7, ICC_VC = 8, ICC_VS = 9, ICC_PL = 10, ICC_MI = 11, ICC_GE = 12, ICC_LT = 13, ICC_GT = 14, ICC_LE = 15, UNKNOWN
};
inline static StringRef lanaiCondCodeToString(LPCC::CondCode CC) {
switch (CC) {
case LPCC::ICC_T:
return "t"; case LPCC::ICC_F:
return "f"; case LPCC::ICC_NE:
return "ne"; case LPCC::ICC_EQ:
return "eq"; case LPCC::ICC_VC:
return "vc"; case LPCC::ICC_VS:
return "vs"; case LPCC::ICC_PL:
return "pl"; case LPCC::ICC_MI:
return "mi"; case LPCC::ICC_GE:
return "ge"; case LPCC::ICC_LT:
return "lt"; case LPCC::ICC_GT:
return "gt"; case LPCC::ICC_LE:
return "le"; case LPCC::ICC_UGT:
return "ugt"; case LPCC::ICC_ULE:
return "ule"; case LPCC::ICC_ULT:
return "ult"; case LPCC::ICC_UGE:
return "uge"; default:
llvm_unreachable("Invalid cond code");
}
}
inline static CondCode suffixToLanaiCondCode(StringRef S) {
return StringSwitch<CondCode>(S)
.EndsWith("f", LPCC::ICC_F)
.EndsWith("hi", LPCC::ICC_HI)
.EndsWith("ugt", LPCC::ICC_UGT)
.EndsWith("ls", LPCC::ICC_LS)
.EndsWith("ule", LPCC::ICC_ULE)
.EndsWith("cc", LPCC::ICC_CC)
.EndsWith("ult", LPCC::ICC_ULT)
.EndsWith("cs", LPCC::ICC_CS)
.EndsWith("uge", LPCC::ICC_UGE)
.EndsWith("ne", LPCC::ICC_NE)
.EndsWith("eq", LPCC::ICC_EQ)
.EndsWith("vc", LPCC::ICC_VC)
.EndsWith("vs", LPCC::ICC_VS)
.EndsWith("pl", LPCC::ICC_PL)
.EndsWith("mi", LPCC::ICC_MI)
.EndsWith("ge", LPCC::ICC_GE)
.EndsWith("lt", LPCC::ICC_LT)
.EndsWith("gt", LPCC::ICC_GT)
.EndsWith("le", LPCC::ICC_LE)
.EndsWith("t", LPCC::ICC_T) .Default(LPCC::UNKNOWN);
}
} }
#endif