1 // RUN: llvm-tblgen -I %p/../../../../include -gen-global-isel-combiner \
2 // RUN: -combiners=MyCombiner %s | \
5 include "llvm/Target/Target.td"
6 include "llvm/Target/GlobalISel/Combine.td"
8 def MyTargetISA : InstrInfo;
9 def MyTarget : Target { let InstructionSet = MyTargetISA; }
11 def ReplaceMatched : GICombineRule<
13 (match (G_FNEG $tmp, $src),
15 (apply (GIReplaceReg $dst, $src))>;
17 def ReplaceTemp : GICombineRule<
19 (match (G_BUILD_VECTOR $tmp, $x, $y),
20 (G_UNMERGE_VALUES $a, $b, $tmp)),
21 (apply (G_UNMERGE_VALUES $a, i32:$new, $y),
22 (GIReplaceReg $b, $new))>;
24 def MyCombiner: GICombiner<"GenMyCombiner", [
29 // CHECK: const int64_t *GenMyCombiner::getMatchTable() const {
30 // CHECK-NEXT: constexpr static int64_t MatchTable0[] = {
31 // CHECK-NEXT: GIM_SwitchOpcode, /*MI*/0, /*[*/65, 180, /*)*//*default:*//*Label 2*/ 192,
32 // CHECK-NEXT: /*TargetOpcode::G_UNMERGE_VALUES*//*Label 0*/ 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 // CHECK-NEXT: /*TargetOpcode::G_FNEG*//*Label 1*/ 165,
34 // CHECK-NEXT: // Label 0: @120
35 // CHECK-NEXT: GIM_Try, /*On fail goto*//*Label 3*/ 164, // Rule ID 1 //
36 // CHECK-NEXT: GIM_CheckSimplePredicate, GICXXPred_Simple_IsRule1Enabled,
37 // CHECK-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/3,
38 // CHECK-NEXT: // MIs[0] a
39 // CHECK-NEXT: // No operand predicates
40 // CHECK-NEXT: // MIs[0] b
41 // CHECK-NEXT: // No operand predicates
42 // CHECK-NEXT: // MIs[0] tmp
43 // CHECK-NEXT: GIM_RecordInsnIgnoreCopies, /*DefineMI*/1, /*MI*/0, /*OpIdx*/2, // MIs[1]
44 // CHECK-NEXT: GIM_CheckOpcode, /*MI*/1, TargetOpcode::G_BUILD_VECTOR,
45 // CHECK-NEXT: GIM_CheckNumOperands, /*MI*/1, /*Expected*/3,
46 // CHECK-NEXT: // MIs[1] x
47 // CHECK-NEXT: // No operand predicates
48 // CHECK-NEXT: // MIs[1] y
49 // CHECK-NEXT: // No operand predicates
50 // CHECK-NEXT: GIM_CheckIsSafeToFold, /*InsnID*/1,
51 // CHECK-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,
52 // CHECK-NEXT: // Combiner Rule #1: ReplaceTemp
53 // CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/TargetOpcode::G_UNMERGE_VALUES,
54 // CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/0, // a
55 // CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/0, /*TempRegID*/0, /*TempRegFlags*/0,
56 // CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/2, // y
57 // CHECK-NEXT: GIR_EraseFromParent, /*InsnID*/0,
58 // CHECK-NEXT: GIR_ReplaceRegWithTempReg, /*OldInsnID*/0, /*OldOpIdx*/1, /*TempRegID*/0,
59 // CHECK-NEXT: GIR_Done,
60 // CHECK-NEXT: // Label 3: @164
61 // CHECK-NEXT: GIM_Reject,
62 // CHECK-NEXT: // Label 1: @165
63 // CHECK-NEXT: GIM_Try, /*On fail goto*//*Label 4*/ 191, // Rule ID 0 //
64 // CHECK-NEXT: GIM_CheckSimplePredicate, GICXXPred_Simple_IsRule0Enabled,
65 // CHECK-NEXT: // MIs[0] dst
66 // CHECK-NEXT: // No operand predicates
67 // CHECK-NEXT: // MIs[0] tmp
68 // CHECK-NEXT: GIM_RecordInsnIgnoreCopies, /*DefineMI*/1, /*MI*/0, /*OpIdx*/1, // MIs[1]
69 // CHECK-NEXT: GIM_CheckOpcode, /*MI*/1, TargetOpcode::G_FNEG,
70 // CHECK-NEXT: // MIs[1] src
71 // CHECK-NEXT: // No operand predicates
72 // CHECK-NEXT: GIM_CheckCanReplaceReg, /*OldInsnID*/0, /*OldOpIdx*/0, /*NewInsnId*/1, /*NewOpIdx*/1,
73 // CHECK-NEXT: GIM_CheckIsSafeToFold, /*InsnID*/1,
74 // CHECK-NEXT: // Combiner Rule #0: ReplaceMatched
75 // CHECK-NEXT: GIR_ReplaceReg, /*OldInsnID*/0, /*OldOpIdx*/0, /*NewInsnId*/1, /*NewOpIdx*/1,
76 // CHECK-NEXT: GIR_EraseFromParent, /*InsnID*/0,
77 // CHECK-NEXT: GIR_Done,
78 // CHECK-NEXT: // Label 4: @191
79 // CHECK-NEXT: GIM_Reject,
80 // CHECK-NEXT: // Label 2: @192
81 // CHECK-NEXT: GIM_Reject,
83 // CHECK-NEXT: return MatchTable0;