[llvm] 6886f09 - [TableGen] Add `countRendererFns` to `InstructionOperandMatcher`

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 00:26:40 PDT 2022


Author: Pierre van Houtryve
Date: 2022-09-30T07:26:30Z
New Revision: 6886f094e8af1a4db31c22678f431f0c45dac781

URL: https://github.com/llvm/llvm-project/commit/6886f094e8af1a4db31c22678f431f0c45dac781
DIFF: https://github.com/llvm/llvm-project/commit/6886f094e8af1a4db31c22678f431f0c45dac781.diff

LOG: [TableGen] Add `countRendererFns` to `InstructionOperandMatcher`

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/TableGen/GlobalISelEmitter.td b/llvm/test/TableGen/GlobalISelEmitter.td
index ef5c25ac4b5f1..2878718457e80 100644
--- a/llvm/test/TableGen/GlobalISelEmitter.td
+++ b/llvm/test/TableGen/GlobalISelEmitter.td
@@ -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
 

diff  --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 71ea14d0f5453..9910284c93a62 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2522,6 +2522,12 @@ class InstructionOperandMatcher : public OperandPredicateMatcher {
         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() {


        


More information about the llvm-commits mailing list