[llvm] [GlobalISel][TableGen] MIR Pattern Variadics (PR #100563)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 00:02:25 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),
----------------
Pierre-vh wrote:
There is no reason, I just forgot that those tests were changed to use regexes and I generally update them by copy-pasting the output of tblgen. I will make a patch to fix it.
https://github.com/llvm/llvm-project/pull/100563
More information about the llvm-commits
mailing list