[TableGen] Add `countRendererFns` to `InstructionOperandMatcher`
authorPierre van Houtryve <pierre.vanhoutryve@amd.com>
Thu, 29 Sep 2022 08:11:09 +0000 (08:11 +0000)
committerPierre van Houtryve <pierre.vanhoutryve@amd.com>
Fri, 30 Sep 2022 07:26:30 +0000 (07:26 +0000)
Without it, the count of renderer functions is inaccurate and, in some
edge cases (like the patterns added in D134354), we can actually
go out of bounds (run out of pre-allocated renderer function spaces
in the GISel state)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D134861

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

index ef5c25a..2878718 100644 (file)
@@ -84,7 +84,7 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; }
 // CHECK-NEXT:  #endif // ifdef GET_GLOBALISEL_TEMPORARIES_DECL
 
 // CHECK-LABEL: #ifdef GET_GLOBALISEL_TEMPORARIES_INIT
-// CHECK-NEXT:    , State(2),
+// CHECK-NEXT:    , State(3),
 // CHECK-NEXT:    ISelInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers)
 // CHECK-NEXT:  #endif // ifdef GET_GLOBALISEL_TEMPORARIES_INIT
 
index 71ea14d..9910284 100644 (file)
@@ -2522,6 +2522,12 @@ public:
         return true;
     return false;
   }
+
+  /// Report the maximum number of temporary operands needed by the predicate
+  /// matcher.
+  unsigned countRendererFns() const override {
+    return InsnMatcher->countRendererFns();
+  }
 };
 
 void InstructionMatcher::optimize() {