[llvm] r311684 - [globalisel][tablegen] Predicates should start from GIPFP_Invalid+1 not GIPFP_Invalid
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 11:54:16 PDT 2017
Author: dsanders
Date: Thu Aug 24 11:54:16 2017
New Revision: 311684
URL: http://llvm.org/viewvc/llvm-project?rev=311684&view=rev
Log:
[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.
Modified:
llvm/trunk/test/TableGen/GlobalISelEmitter.td
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/test/TableGen/GlobalISelEmitter.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/GlobalISelEmitter.td?rev=311684&r1=311683&r2=311684&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/GlobalISelEmitter.td (original)
+++ llvm/trunk/test/TableGen/GlobalISelEmitter.td Thu Aug 24 11:54:16 2017
@@ -111,10 +111,11 @@ def HasC : Predicate<"Subtarget->hasC()"
// 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: };
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=311684&r1=311683&r2=311684&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Thu Aug 24 11:54:16 2017
@@ -2731,7 +2731,7 @@ void GlobalISelEmitter::run(raw_ostream
{
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
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";
More information about the llvm-commits
mailing list