[NFC][RemoveDIs] Prefer iterators over inst-pointers in InstCombine
[llvm-project.git] / llvm / test / TableGen / GlobalISelCombinerEmitter / operand-types.td
blobc871e603e4e05aa376c30b2750b48b8d2196e709
1 // RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
2 // RUN:     -gicombiner-stop-after-parse -combiners=MyCombiner %s | \
3 // RUN: FileCheck %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])
15 // CHECK-NEXT:   )
16 // CHECK-NEXT:   (ApplyPats
17 // CHECK-NEXT:     <apply_root>__InstTest0_apply_0:(CodeGenInstructionPattern G_MUL operands:[<def>i64:$x, i32:$y, i16:$w])
18 // CHECK-NEXT:   )
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
24 // CHECK-NEXT:   )
25 // CHECK-NEXT:   (OperandTable ApplyPats
26 // CHECK-NEXT:     w -> <live-in>
27 // CHECK-NEXT:     x -> __InstTest0_apply_0
28 // CHECK-NEXT:     y -> <live-in>
29 // CHECK-NEXT:   )
30 // CHECK-NEXT: )
31 def InstTest0 : GICombineRule<
32   (defs root:$x),
33   (match
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 [
43 // CHECK-NEXT:         [
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]),
46 // CHECK-NEXT:         ],
47 // CHECK-NEXT:         [
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]),
50 // CHECK-NEXT:         ],
51 // CHECK-NEXT:       ])
52 // CHECK-NEXT:     )
53 // CHECK-NEXT:   )
54 // CHECK-NEXT:   (MatchPats
55 // CHECK-NEXT:     <match_root>__PatFragTest0_match_0:(PatFragPattern FooPF operands:[<def>$dst])
56 // CHECK-NEXT:   )
57 // CHECK-NEXT:   (ApplyPats
58 // CHECK-NEXT:     <apply_root>__PatFragTest0_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, (i32 0)])
59 // CHECK-NEXT:   )
60 // CHECK-NEXT:   (OperandTable MatchPats
61 // CHECK-NEXT:     dst -> __PatFragTest0_match_0
62 // CHECK-NEXT:   )
63 // CHECK-NEXT:   (OperandTable ApplyPats
64 // CHECK-NEXT:     dst -> __PatFragTest0_apply_0
65 // CHECK-NEXT:   )
66 // CHECK-NEXT:   (PermutationsToEmit
67 // CHECK-NEXT:     [__PatFragTest0_match_0[0]],
68 // CHECK-NEXT:     [__PatFragTest0_match_0[1]],
69 // CHECK-NEXT:   )
70 // CHECK-NEXT: )
71 def FooPF: GICombinePatFrag<
72     (outs root:$cst),(ins),
73     [
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)),
76     ]>;
77 def PatFragTest0 : GICombineRule<
78   (defs root:$dst),
79   (match (FooPF $dst)),
80   (apply (COPY $dst, (i32 0)))>;
82 def MyCombiner: GICombiner<"GenMyCombiner", [
83   InstTest0,
84   PatFragTest0
85 ]>;