1 // RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
2 // RUN: -gicombiner-stop-after-parse -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 // CHECK: (CombineRule name:InstTest0 id:0 root:x
12 // CHECK-NEXT: (MatchPats
13 // CHECK-NEXT: __InstTest0_match_0:(CodeGenInstructionPattern G_BUILD_VECTOR operands:[<def>i64:$z, i32:$y, i16:$w])
14 // CHECK-NEXT: <match_root>__InstTest0_match_1:(CodeGenInstructionPattern G_BUILD_VECTOR operands:[<def>i64:$x, i32:$y, i64:$z])
16 // CHECK-NEXT: (ApplyPats
17 // CHECK-NEXT: <apply_root>__InstTest0_apply_0:(CodeGenInstructionPattern G_MUL operands:[<def>i64:$x, i32:$y, i16:$w])
19 // CHECK-NEXT: (OperandTable MatchPats
20 // CHECK-NEXT: w -> <live-in>
21 // CHECK-NEXT: x -> __InstTest0_match_1
22 // CHECK-NEXT: y -> <live-in>
23 // CHECK-NEXT: z -> __InstTest0_match_0
25 // CHECK-NEXT: (OperandTable ApplyPats
26 // CHECK-NEXT: w -> <live-in>
27 // CHECK-NEXT: x -> __InstTest0_apply_0
28 // CHECK-NEXT: y -> <live-in>
31 def InstTest0 : GICombineRule<
34 (G_BUILD_VECTOR i64:$z, $y, $w),
35 (G_BUILD_VECTOR $x, i32:$y, $z)),
36 (apply (G_MUL i64:$x, $y, i16:$w))>;
38 // CHECK: (CombineRule name:PatFragTest0 id:1 root:dst
39 // CHECK-NEXT: (PatFrags
40 // CHECK-NEXT: (PatFrag name:FooPF
41 // CHECK-NEXT: (outs [cst:root])
42 // CHECK-NEXT: (alternatives [
44 // CHECK-NEXT: (CodeGenInstructionPattern name:__FooPF_alt0_pattern_0 G_BUILD_VECTOR operands:[<def>i64:$cst, i8:$y, $x]),
45 // CHECK-NEXT: (CodeGenInstructionPattern name:__FooPF_alt0_pattern_1 G_BUILD_VECTOR operands:[<def>$x, i8:$y, $w]),
48 // CHECK-NEXT: (CodeGenInstructionPattern name:__FooPF_alt1_pattern_0 G_BUILD_VECTOR operands:[<def>i32:$cst, i32:$y, i16:$x]),
49 // CHECK-NEXT: (CodeGenInstructionPattern name:__FooPF_alt1_pattern_1 G_BUILD_VECTOR operands:[<def>i16:$x, i32:$y, $w]),
54 // CHECK-NEXT: (MatchPats
55 // CHECK-NEXT: <match_root>__PatFragTest0_match_0:(PatFragPattern FooPF operands:[<def>$dst])
57 // CHECK-NEXT: (ApplyPats
58 // CHECK-NEXT: <apply_root>__PatFragTest0_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, (i32 0)])
60 // CHECK-NEXT: (OperandTable MatchPats
61 // CHECK-NEXT: dst -> __PatFragTest0_match_0
63 // CHECK-NEXT: (OperandTable ApplyPats
64 // CHECK-NEXT: dst -> __PatFragTest0_apply_0
66 // CHECK-NEXT: (PermutationsToEmit
67 // CHECK-NEXT: [__PatFragTest0_match_0[0]],
68 // CHECK-NEXT: [__PatFragTest0_match_0[1]],
71 def FooPF: GICombinePatFrag<
72 (outs root:$cst),(ins),
74 (pattern (G_BUILD_VECTOR i64:$cst, $y, $x), (G_BUILD_VECTOR $x, i8:$y, $w)),
75 (pattern (G_BUILD_VECTOR i32:$cst, $y, i16:$x), (G_BUILD_VECTOR $x, i32:$y, $w)),
77 def PatFragTest0 : GICombineRule<
80 (apply (COPY $dst, (i32 0)))>;
82 def MyCombiner: GICombiner<"GenMyCombiner", [