[TableGen] Add support for negative immediates to AsmMatcherEmitter
authorHal Finkel <hfinkel@anl.gov>
Thu, 15 Jan 2015 01:33:00 +0000 (01:33 +0000)
committerHal Finkel <hfinkel@anl.gov>
Thu, 15 Jan 2015 01:33:00 +0000 (01:33 +0000)
This adds support for creating an InstAlias with a negative immediate, i.e.:

  def NOT : InstAlias<"not $dst, $src", (XORI GR32:$dst, GR32:$src, -1)>;

by resolving this problem:

RISCVGenAsmMatcher.inc:95:11: error: expected '= constant-expression' or end of enumerator definition
  CVT_imm_-1,
  ^^^^^^^^^^

Patch by Jordy Potman, thanks!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226073 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmMatcherEmitter.cpp

index 5ee20dda02616953561297453a56767f66cd1a25..ad2f6af8ba122aeb71819655679bb65129136004 100644 (file)
@@ -979,6 +979,7 @@ static std::string getEnumNameForToken(StringRef Str) {
     case '.': Res += "_DOT_"; break;
     case '<': Res += "_LT_"; break;
     case '>': Res += "_GT_"; break;
+    case '-': Res += "_MINUS_"; break;
     default:
       if ((*it >= 'A' && *it <= 'Z') ||
           (*it >= 'a' && *it <= 'z') ||
@@ -1848,6 +1849,7 @@ static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
       case MatchableInfo::ResOperand::ImmOperand: {
         int64_t Val = OpInfo.ImmVal;
         std::string Ty = "imm_" + itostr(Val);
+        Ty = getEnumNameForToken(Ty);
         Signature += "__" + Ty;
 
         std::string Name = "CVT_" + Ty;