1 // The encoding used for conditional codes used in BR instructions
3 #ifndef LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H
4 #define LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H
6 #include "llvm/ADT/StringSwitch.h"
14 ICC_UGT
= 2, // unsigned greater than
15 ICC_LS
= 3, // low or same
16 ICC_ULE
= 3, // unsigned less than or equal
17 ICC_CC
= 4, // carry cleared
18 ICC_ULT
= 4, // unsigned less than
19 ICC_CS
= 5, // carry set
20 ICC_UGE
= 5, // unsigned greater than or equal
21 ICC_NE
= 6, // not equal
23 ICC_VC
= 8, // oVerflow cleared
24 ICC_VS
= 9, // oVerflow set
27 ICC_GE
= 12, // greater than or equal
28 ICC_LT
= 13, // less than
29 ICC_GT
= 14, // greater than
30 ICC_LE
= 15, // less than or equal
34 inline static StringRef
lanaiCondCodeToString(LPCC::CondCode CC
) {
41 return "ne"; // not equal
45 return "vc"; // oVerflow cleared
47 return "vs"; // oVerflow set
53 return "ge"; // greater than or equal
55 return "lt"; // less than
57 return "gt"; // greater than
59 return "le"; // less than or equal
61 return "ugt"; // high | unsigned greater than
63 return "ule"; // low or same | unsigned less or equal
65 return "ult"; // carry cleared | unsigned less than
67 return "uge"; // carry set | unsigned than or equal
69 llvm_unreachable("Invalid cond code");
73 inline static CondCode
suffixToLanaiCondCode(StringRef S
) {
74 return StringSwitch
<CondCode
>(S
)
75 .EndsWith("f", LPCC::ICC_F
)
76 .EndsWith("hi", LPCC::ICC_HI
)
77 .EndsWith("ugt", LPCC::ICC_UGT
)
78 .EndsWith("ls", LPCC::ICC_LS
)
79 .EndsWith("ule", LPCC::ICC_ULE
)
80 .EndsWith("cc", LPCC::ICC_CC
)
81 .EndsWith("ult", LPCC::ICC_ULT
)
82 .EndsWith("cs", LPCC::ICC_CS
)
83 .EndsWith("uge", LPCC::ICC_UGE
)
84 .EndsWith("ne", LPCC::ICC_NE
)
85 .EndsWith("eq", LPCC::ICC_EQ
)
86 .EndsWith("vc", LPCC::ICC_VC
)
87 .EndsWith("vs", LPCC::ICC_VS
)
88 .EndsWith("pl", LPCC::ICC_PL
)
89 .EndsWith("mi", LPCC::ICC_MI
)
90 .EndsWith("ge", LPCC::ICC_GE
)
91 .EndsWith("lt", LPCC::ICC_LT
)
92 .EndsWith("gt", LPCC::ICC_GT
)
93 .EndsWith("le", LPCC::ICC_LE
)
94 .EndsWith("t", LPCC::ICC_T
) // Has to be after others with suffix t
95 .Default(LPCC::UNKNOWN
);
100 #endif // LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H