Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / TableGen / GlobalISelCombinerEmitter / operand-types.td
blob4769bed9724012592b9bc32bf675bb6176b6d68c
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)))>;
83 // CHECK:      (CombineRule name:TypeOfProp id:2 root:x
84 // CHECK-NEXT:   (MatchPats
85 // CHECK-NEXT:     <match_root>__TypeOfProp_match_0:(CodeGenInstructionPattern G_ZEXT operands:[<def>$x, $y])
86 // CHECK-NEXT:   )
87 // CHECK-NEXT:   (ApplyPats
88 // CHECK-NEXT:     <apply_root>__TypeOfProp_apply_0:(CodeGenInstructionPattern G_ANYEXT operands:[<def>$x, GITypeOf<$y>:$tmp])
89 // CHECK-NEXT:     __TypeOfProp_apply_1:(CodeGenInstructionPattern G_ANYEXT operands:[<def>GITypeOf<$y>:$tmp, $y])
90 // CHECK-NEXT:   )
91 // CHECK-NEXT:   (OperandTable MatchPats
92 // CHECK-NEXT:     x -> __TypeOfProp_match_0
93 // CHECK-NEXT:     y -> <live-in>
94 // CHECK-NEXT:   )
95 // CHECK-NEXT:   (OperandTable ApplyPats
96 // CHECK-NEXT:     tmp -> __TypeOfProp_apply_1
97 // CHECK-NEXT:     x -> __TypeOfProp_apply_0
98 // CHECK-NEXT:     y -> <live-in>
99 // CHECK-NEXT:   )
100 // CHECK-NEXT: )
101 def TypeOfProp : GICombineRule<
102   (defs root:$x),
103   (match (G_ZEXT $x, $y)),
104   (apply (G_ANYEXT $x, GITypeOf<"$y">:$tmp),
105          (G_ANYEXT $tmp, $y))>;
107 def MyCombiner: GICombiner<"GenMyCombiner", [
108   InstTest0,
109   PatFragTest0,
110   TypeOfProp