[llvm] [GlobalISel][TableGen] MIR Pattern Variadics (PR #100563)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 09:51:50 PDT 2024
================
@@ -28,19 +28,48 @@ def InstTest3 : GICombineRule<
(match (G_UNMERGE_VALUES $a, $b, $c, $d)),
(apply [{ APPLY }])>;
+def VariadicTypeTestCxx : GICombineRule<
+ (defs root:$a),
+ (match (G_BUILD_VECTOR $a, GIVariadic<2, 4>:$b)),
+ (apply [{ ${b} }])>;
+
+def VariadicTypeTestReuse : GICombineRule<
+ (defs root:$a),
+ (match (G_BUILD_VECTOR $a, $c, GIVariadic<2, 4>:$b)),
+ (apply (G_MERGE_VALUES $a, $b, $c))>;
+
def MyCombiner: GICombiner<"GenMyCombiner", [
InstTest0,
InstTest1,
InstTest2,
- InstTest3
+ InstTest3,
+ VariadicTypeTestCxx,
+ VariadicTypeTestReuse
]>;
+// CHECK: bool GenMyCombiner::runCustomAction(unsigned ApplyID, const MatcherState &State, NewMIVector &OutMIs) const {
+// CHECK-NEXT: Helper.getBuilder().setInstrAndDebugLoc(*State.MIs[0]);
+// CHECK-NEXT: switch(ApplyID) {
+// CHECK-NEXT: case GICXXCustomAction_GICombiner0:{
+// CHECK-NEXT: // Apply Patterns
+// CHECK-NEXT: APPLY
+// CHECK-NEXT: return true;
+// CHECK-NEXT: }
+// CHECK-NEXT: case GICXXCustomAction_GICombiner1:{
+// CHECK-NEXT: // Apply Patterns
+// CHECK-NEXT: getRemainingOperands(*State.MIs[0], 1)
+// CHECK-NEXT: return true;
+// CHECK-NEXT: }
+// CHECK-NEXT: }
+// CHECK-NEXT: llvm_unreachable("Unknown Apply Action");
+// CHECK-NEXT: }
+
// CHECK: const uint8_t *GenMyCombiner::getMatchTable() const {
// CHECK-NEXT: constexpr static uint8_t MatchTable0[] = {
-// CHECK-NEXT: GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2([[#LOWER:]]), GIMT_Encode2([[#UPPER:]]), /*)*//*default:*//*Label 2*/ GIMT_Encode4([[#DEFAULT:]]),
+// CHECK-NEXT: GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(70), GIMT_Encode2(74), /*)*//*default:*//*Label 2*/ GIMT_Encode4(127),
----------------
dyung wrote:
This change from using a "regex" to hard coding the numbers is causing the test to fail in our downstream repo. Is there a reason why we cannot update the previous test variables instead of just hard coding values in here for this test?
https://github.com/llvm/llvm-project/pull/100563
More information about the llvm-commits
mailing list