]> granicus.if.org Git - llvm/commitdiff
[globalisel][tablegen] Predicates should start from GIPFP_Invalid+1 not GIPFP_Invalid
authorDaniel Sanders <daniel_l_sanders@apple.com>
Thu, 24 Aug 2017 18:54:16 +0000 (18:54 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Thu, 24 Aug 2017 18:54:16 +0000 (18:54 +0000)
This fixes a warning when there are zero defined predicates and also fixes an
unnoticed bug where the first predicate in the table was unusable.

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

test/TableGen/GlobalISelEmitter.td
utils/TableGen/GlobalISelEmitter.cpp

index ddfb4f8744ac21756ff830274a253281a333ac90..4364f8645b888d2746a89dcc08758fe61da2d058 100644 (file)
@@ -111,10 +111,11 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; }
 
 // CHECK-LABEL: // PatFrag predicates.
 // CHECK-NEXT:  enum {
-// CHECK-NEXT:    GIPFP_Predicate_simm8 = GIPFP_Invalid,
+// CHECK-NEXT:    GIPFP_Predicate_simm8 = GIPFP_Invalid + 1,
 // CHECK-NEXT:  };
 // CHECK-NEXT:  static bool Predicate_simm8(int64_t Imm) { return isInt<8>(Imm);   }
 // CHECK-NEXT:  static InstructionSelector::ImmediatePredicateFn ImmPredicateFns[] = {
+// CHECK-NEXT:    nullptr,
 // CHECK-NEXT:    Predicate_simm8,
 // CHECK-NEXT:  };
 
index 17898beb7de404c0c7f0b30455860d9df3af36a6..3402c496c8dda7f381561d52e093ebe2b324dc8b 100644 (file)
@@ -2731,7 +2731,7 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
   {
     OS << "// PatFrag predicates.\n"
        << "enum {\n";
-    StringRef EnumeratorSeparator = " = GIPFP_Invalid,\n";
+    StringRef EnumeratorSeparator = " = GIPFP_Invalid + 1,\n";
     for (const auto *Record : RK.getAllDerivedDefinitions("PatFrag")) {
       if (!Record->getValueAsString("ImmediateCode").empty()) {
         OS << "  GIPFP_Predicate_" << Record->getName() << EnumeratorSeparator;
@@ -2744,7 +2744,9 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
     if (!Record->getValueAsString("ImmediateCode").empty())
       OS << "  static bool Predicate_" << Record->getName() << "(int64_t Imm) {"
          << Record->getValueAsString("ImmediateCode") << "  }\n";
-  OS << "static InstructionSelector::ImmediatePredicateFn ImmPredicateFns[] = {\n";
+  OS << "static InstructionSelector::ImmediatePredicateFn ImmPredicateFns[] = "
+        "{\n"
+     << "  nullptr,\n";
   for (const auto *Record : RK.getAllDerivedDefinitions("PatFrag"))
     if (!Record->getValueAsString("ImmediateCode").empty())
       OS << "  Predicate_" << Record->getName() << ",\n";