From: Daniel Sanders Date: Thu, 24 Aug 2017 18:54:16 +0000 (+0000) Subject: [globalisel][tablegen] Predicates should start from GIPFP_Invalid+1 not GIPFP_Invalid X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8273d02129daf60471c6d7c0f272314b862aba5;p=llvm [globalisel][tablegen] Predicates should start from GIPFP_Invalid+1 not GIPFP_Invalid 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 --- diff --git a/test/TableGen/GlobalISelEmitter.td b/test/TableGen/GlobalISelEmitter.td index ddfb4f8744a..4364f8645b8 100644 --- a/test/TableGen/GlobalISelEmitter.td +++ b/test/TableGen/GlobalISelEmitter.td @@ -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: }; diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index 17898beb7de..3402c496c8d 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -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";