brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 6c5bdef Raw
101 lines · c
1// The encoding used for conditional codes used in BR instructions2 3#ifndef LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H4#define LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H5 6#include "llvm/ADT/StringSwitch.h"7 8namespace llvm {9namespace LPCC {10enum CondCode {11  ICC_T = 0,   //  true12  ICC_F = 1,   //  false13  ICC_HI = 2,  //  high14  ICC_UGT = 2, //  unsigned greater than15  ICC_LS = 3,  //  low or same16  ICC_ULE = 3, //  unsigned less than or equal17  ICC_CC = 4,  //  carry cleared18  ICC_ULT = 4, //  unsigned less than19  ICC_CS = 5,  //  carry set20  ICC_UGE = 5, //  unsigned greater than or equal21  ICC_NE = 6,  //  not equal22  ICC_EQ = 7,  //  equal23  ICC_VC = 8,  //  oVerflow cleared24  ICC_VS = 9,  //  oVerflow set25  ICC_PL = 10, //  plus26  ICC_MI = 11, //  minus27  ICC_GE = 12, //  greater than or equal28  ICC_LT = 13, //  less than29  ICC_GT = 14, //  greater than30  ICC_LE = 15, //  less than or equal31  UNKNOWN32};33 34inline static StringRef lanaiCondCodeToString(LPCC::CondCode CC) {35  switch (CC) {36  case LPCC::ICC_T:37    return "t"; // true38  case LPCC::ICC_F:39    return "f"; // false40  case LPCC::ICC_NE:41    return "ne"; // not equal42  case LPCC::ICC_EQ:43    return "eq"; // equal44  case LPCC::ICC_VC:45    return "vc"; // oVerflow cleared46  case LPCC::ICC_VS:47    return "vs"; // oVerflow set48  case LPCC::ICC_PL:49    return "pl"; // plus50  case LPCC::ICC_MI:51    return "mi"; // minus52  case LPCC::ICC_GE:53    return "ge"; // greater than or equal54  case LPCC::ICC_LT:55    return "lt"; // less than56  case LPCC::ICC_GT:57    return "gt"; // greater than58  case LPCC::ICC_LE:59    return "le"; // less than or equal60  case LPCC::ICC_UGT:61    return "ugt"; // high | unsigned greater than62  case LPCC::ICC_ULE:63    return "ule"; // low or same | unsigned less or equal64  case LPCC::ICC_ULT:65    return "ult"; // carry cleared | unsigned less than66  case LPCC::ICC_UGE:67    return "uge"; // carry set | unsigned than or equal68  default:69    llvm_unreachable("Invalid cond code");70  }71}72 73inline 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 t95      .Default(LPCC::UNKNOWN);96}97} // namespace LPCC98} // namespace llvm99 100#endif // LLVM_LIB_TARGET_LANAI_LANAICONDCODE_H101