File: pattern-parsing.td

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (434 lines) | stat: -rw-r--r-- 17,027 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
// RUN: llvm-tblgen -I %S/Inputs -I %p/../../../include -gen-global-isel-combiner \
// RUN:     -gicombiner-stop-after-parse -combiners=MyCombiner %s | \
// RUN: FileCheck %s

include "llvm/Target/Target.td"
include "llvm/Target/GlobalISel/Combine.td"

include "test-intrinsics.td"

def MyTargetISA : InstrInfo;
def MyTarget : Target { let InstructionSet = MyTargetISA; }

def dummy;

def HasAnswerToEverything : Predicate<"Subtarget->getAnswerToUniverse() == 42 && Subtarget->getAnswerToLife() == 42">;
def reg_matchinfo : GIDefMatchData<"Register">;

// CHECK:      (CombineRule name:WipOpcodeTest0 id:0 root:d
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>d:(AnyOpcodePattern [G_TRUNC])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __WipOpcodeTest0_apply_0:(CXXPattern apply code:"APPLY")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats <empty>)
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def WipOpcodeTest0 : GICombineRule<
  (defs root:$d),
  (match (wip_match_opcode G_TRUNC):$d),
  (apply [{ APPLY }])>;

// CHECK:     (CombineRule name:WipOpcodeTest1 id:1 root:d
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>d:(AnyOpcodePattern [G_TRUNC, G_SEXT])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __WipOpcodeTest1_apply_0:(CXXPattern apply code:"APPLY")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats <empty>)
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def WipOpcodeTest1 : GICombineRule<
  (defs root:$d),
  (match (wip_match_opcode G_TRUNC, G_SEXT):$d),
  (apply [{ APPLY }])>;

// CHECK:     (CombineRule name:InstTest0 id:2 root:d
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>d:(CodeGenInstructionPattern COPY operands:[<def>$a, $b])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __InstTest0_apply_0:(CXXPattern apply code:"APPLY")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> d
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def InstTest0 : GICombineRule<
  (defs root:$d),
  (match (COPY $a, $b):$d),
  (apply [{ APPLY }])>;

// CHECK:      (CombineRule name:InstTest1 id:3 root:d
// CHECK-NEXT:   (MatchDatas
// CHECK-NEXT:      (MatchDataDef symbol:r0 type:Register)
// CHECK-NEXT:   )
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>d:(CodeGenInstructionPattern COPY operands:[<def>$a, i32:$b])
// CHECK-NEXT:     __InstTest1_match_1:(CodeGenInstructionPattern G_ZEXT operands:[<def>$x, 0])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __InstTest1_apply_0:(CXXPattern apply code:"APPLY")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> d
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:     x -> __InstTest1_match_1
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
let Predicates = [HasAnswerToEverything] in
def InstTest1 : GICombineRule<
  (defs root:$d, reg_matchinfo:$r0),
  (match (COPY $a, i32:$b):$d,
         (G_ZEXT $x, 0)),
  (apply [{ APPLY }])>;

// CHECK:      (CombineRule name:InstTest2 id:4 root:d
// CHECK-NEXT:   (MatchDatas
// CHECK-NEXT:     (MatchDataDef symbol:r0 type:Register)
// CHECK-NEXT:   )
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__InstTest2_match_0:(CodeGenInstructionPattern COPY operands:[<def>$d, (i32 0):$x])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __InstTest2_apply_0:(CXXPattern apply code:"APPLY")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     d -> __InstTest2_match_0
// CHECK-NEXT:     x -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def InstTest2 : GICombineRule<
  (defs root:$d, reg_matchinfo:$r0),
  (match (COPY $d, (i32 0):$x)),
  (apply [{ APPLY }])>;

// CHECK:      (CombineRule name:InOutInstTest0 id:5 root:dst
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__InOutInstTest0_match_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, $tmp])
// CHECK-NEXT:     __InOutInstTest0_match_1:(CodeGenInstructionPattern G_ZEXT operands:[<def>$tmp, $src])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__InOutInstTest0_apply_0:(CodeGenInstructionPattern G_TRUNC operands:[<def>$dst, $src])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     dst -> __InOutInstTest0_match_0
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:     tmp -> __InOutInstTest0_match_1
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __InOutInstTest0_apply_0
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT: )
def InOutInstTest0 : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $tmp),
         (G_ZEXT $tmp, $src)),
  (apply (G_TRUNC $dst, $src))>;

def MatchICst: GICombinePatFrag<
    (outs),
    (ins gi_mo:$foo, gi_imm:$cst),
    [(pattern "return matchIConstant(${foo}, ${cst})")]>;

// CHECK:      (CombineRule name:PatFragTest0 id:6 root:dst
// CHECK-NEXT:   (PatFrags
// CHECK-NEXT:     (PatFrag name:MatchICst
// CHECK-NEXT:       (ins [foo:machine_operand, cst:imm])
// CHECK-NEXT:       (alternatives [
// CHECK-NEXT:         [
// CHECK-NEXT:           (CXXPattern name:__MatchICst_alt0_pattern_0 match code:"return matchIConstant(${foo}, ${cst})"),
// CHECK-NEXT:         ],
// CHECK-NEXT:       ])
// CHECK-NEXT:     )
// CHECK-NEXT:   )
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__PatFragTest0_match_0:(CodeGenInstructionPattern G_ZEXT operands:[<def>$dst, $cst])
// CHECK-NEXT:     __PatFragTest0_match_1:(PatFragPattern MatchICst operands:[$cst, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__PatFragTest0_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     cst -> <live-in>
// CHECK-NEXT:     dst -> __PatFragTest0_match_0
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __PatFragTest0_apply_0
// CHECK-NEXT:   )
// CHECK-NEXT: )
def PatFragTest0 : GICombineRule<
  (defs root:$dst),
  (match (G_ZEXT $dst, $cst), (MatchICst $cst, (i32 0))),
  (apply (COPY $dst, (i32 0)))>;

def MatchFooPerms: GICombinePatFrag<
    (outs),
    (ins gi_mo:$foo, gi_imm:$cst),
    [
      (pattern "return foo(${foo}, ${cst})"),
      (pattern "return bar(${foo}, ${cst})"),
      (pattern "return bux(${foo}, ${cst})"),
    ]>;

// CHECK:      (CombineRule name:PatFragTest1 id:7 root:dst
// CHECK-NEXT:   (PatFrags
// CHECK-NEXT:     (PatFrag name:MatchFooPerms
// CHECK-NEXT:       (ins [foo:machine_operand, cst:imm])
// CHECK-NEXT:       (alternatives [
// CHECK-NEXT:         [
// CHECK-NEXT:           (CXXPattern name:__MatchFooPerms_alt0_pattern_0 match code:"return foo(${foo}, ${cst})"),
// CHECK-NEXT:         ],
// CHECK-NEXT:         [
// CHECK-NEXT:           (CXXPattern name:__MatchFooPerms_alt1_pattern_0 match code:"return bar(${foo}, ${cst})"),
// CHECK-NEXT:         ],
// CHECK-NEXT:         [
// CHECK-NEXT:           (CXXPattern name:__MatchFooPerms_alt2_pattern_0 match code:"return bux(${foo}, ${cst})"),
// CHECK-NEXT:         ],
// CHECK-NEXT:       ])
// CHECK-NEXT:     )
// CHECK-NEXT:   )
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__PatFragTest1_match_0:(CodeGenInstructionPattern G_ZEXT operands:[<def>$dst, $cst])
// CHECK-NEXT:     a:(PatFragPattern MatchFooPerms operands:[$cst, (i32 0)])
// CHECK-NEXT:     b:(PatFragPattern MatchFooPerms operands:[$cst, (i32 0)])
// CHECK-NEXT:     c:(PatFragPattern MatchFooPerms operands:[$cst, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__PatFragTest1_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     cst -> <live-in>
// CHECK-NEXT:     dst -> __PatFragTest1_match_0
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __PatFragTest1_apply_0
// CHECK-NEXT:   )
// CHECK-NEXT:   (PermutationsToEmit
// CHECK-NEXT:     [a[0], b[0], c[0]],
// CHECK-NEXT:     [a[0], b[0], c[1]],
// CHECK-NEXT:     [a[0], b[0], c[2]],
// CHECK-NEXT:     [a[0], b[1], c[0]],
// CHECK-NEXT:     [a[0], b[1], c[1]],
// CHECK-NEXT:     [a[0], b[1], c[2]],
// CHECK-NEXT:     [a[0], b[2], c[0]],
// CHECK-NEXT:     [a[0], b[2], c[1]],
// CHECK-NEXT:     [a[0], b[2], c[2]],
// CHECK-NEXT:     [a[1], b[0], c[0]],
// CHECK-NEXT:     [a[1], b[0], c[1]],
// CHECK-NEXT:     [a[1], b[0], c[2]],
// CHECK-NEXT:     [a[1], b[1], c[0]],
// CHECK-NEXT:     [a[1], b[1], c[1]],
// CHECK-NEXT:     [a[1], b[1], c[2]],
// CHECK-NEXT:     [a[1], b[2], c[0]],
// CHECK-NEXT:     [a[1], b[2], c[1]],
// CHECK-NEXT:     [a[1], b[2], c[2]],
// CHECK-NEXT:     [a[2], b[0], c[0]],
// CHECK-NEXT:     [a[2], b[0], c[1]],
// CHECK-NEXT:     [a[2], b[0], c[2]],
// CHECK-NEXT:     [a[2], b[1], c[0]],
// CHECK-NEXT:     [a[2], b[1], c[1]],
// CHECK-NEXT:     [a[2], b[1], c[2]],
// CHECK-NEXT:     [a[2], b[2], c[0]],
// CHECK-NEXT:     [a[2], b[2], c[1]],
// CHECK-NEXT:     [a[2], b[2], c[2]],
// CHECK-NEXT:   )
// CHECK-NEXT: )
let MaxPermutations = -1 in
def PatFragTest1 : GICombineRule<
  (defs root:$dst),
  (match (G_ZEXT $dst, $cst),
         (MatchFooPerms $cst, (i32 0)):$a,
         (MatchFooPerms $cst, (i32 0)):$b,
         (MatchFooPerms $cst, (i32 0)):$c
  ),
  (apply (COPY $dst, (i32 0)))>;

// CHECK:      (CombineRule name:VariadicsInTest id:8 root:dst
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__VariadicsInTest_match_0:(CodeGenInstructionPattern G_BUILD_VECTOR operands:[<def>$dst, $a, $b])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__VariadicsInTest_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> <live-in>
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:     dst -> __VariadicsInTest_match_0
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __VariadicsInTest_apply_0
// CHECK-NEXT:   )
// CHECK-NEXT: )
def VariadicsInTest : GICombineRule<
  (defs root:$dst),
  (match (G_BUILD_VECTOR $dst, $a, $b)),
  (apply (COPY $dst, (i32 0)))>;

// CHECK:      (CombineRule name:VariadicsOutTest id:9 root:a
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__VariadicsOutTest_match_0:(CodeGenInstructionPattern G_UNMERGE_VALUES operands:[<def>$a, <def>$b, $src])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__VariadicsOutTest_apply_0:(CodeGenInstructionPattern COPY operands:[<def>$a, (i32 0)])
// CHECK-NEXT:     <apply_root>__VariadicsOutTest_apply_1:(CodeGenInstructionPattern COPY operands:[<def>$b, (i32 0)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> __VariadicsOutTest_match_0
// CHECK-NEXT:     b -> __VariadicsOutTest_match_0
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     a -> __VariadicsOutTest_apply_0
// CHECK-NEXT:     b -> __VariadicsOutTest_apply_1
// CHECK-NEXT:   )
// CHECK-NEXT: )
def VariadicsOutTest : GICombineRule<
  (defs root:$a),
  (match (G_UNMERGE_VALUES $a, $b, $src)),
  (apply (COPY $a, (i32 0)),
         (COPY $b, (i32 0)))>;

// CHECK:      (CombineRule name:TypeOfTest id:10 root:dst
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__TypeOfTest_match_0:(CodeGenInstructionPattern COPY operands:[<def>$dst, $tmp])
// CHECK-NEXT:     __TypeOfTest_match_1:(CodeGenInstructionPattern G_ZEXT operands:[<def>$tmp, $src])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__TypeOfTest_apply_0:(CodeGenInstructionPattern G_MUL operands:[<def>$dst, (GITypeOf<$src> 0), (GITypeOf<$dst> -1)])
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     dst -> __TypeOfTest_match_0
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:     tmp -> __TypeOfTest_match_1
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __TypeOfTest_apply_0
// CHECK-NEXT:   )
// CHECK-NEXT: )
def TypeOfTest : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $tmp),
         (G_ZEXT $tmp, $src)),
  (apply (G_MUL $dst, (GITypeOf<"$src"> 0), (GITypeOf<"$dst"> -1)))>;


// CHECK:      (CombineRule name:MIFlagsTest id:11 root:dst
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>mi:(CodeGenInstructionPattern G_ZEXT operands:[<def>$dst, $src] (MIFlags (set MachineInstr::FmReassoc) (unset MachineInstr::FmNoNans, MachineInstr::FmArcp)))
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__MIFlagsTest_apply_0:(CodeGenInstructionPattern G_MUL operands:[<def>$dst, $src, $src] (MIFlags (set MachineInstr::FmReassoc) (unset MachineInstr::FmNsz, MachineInstr::FmArcp) (copy mi)))
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     dst -> mi
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     dst -> __MIFlagsTest_apply_0
// CHECK-NEXT:     src -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT: )
def MIFlagsTest : GICombineRule<
  (defs root:$dst),
  (match (G_ZEXT $dst, $src, (MIFlags FmReassoc, (not FmNoNans, FmArcp))):$mi),
  (apply (G_MUL $dst, $src, $src, (MIFlags $mi, FmReassoc, (not FmNsz, FmArcp))))>;

// CHECK-NEXT: (CombineRule name:IntrinTest0 id:12 root:a
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__IntrinTest0_match_0:(CodeGenInstructionPattern G_INTRINSIC operands:[<def>$a, $b] intrinsic(@llvm.1in.1out))
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__IntrinTest0_apply_0:(CodeGenInstructionPattern G_INTRINSIC_W_SIDE_EFFECTS operands:[<def>$a, $b] intrinsic(@llvm.sideeffects.1in.1out))
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> __IntrinTest0_match_0
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     a -> __IntrinTest0_apply_0
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT: )
def IntrinTest0 : GICombineRule<
  (defs root:$a),
  (match (int_1in_1out $a, $b)),
  (apply (int_sideeffects_1in_1out $a, $b))>;

// CHECK:      (CombineRule name:IntrinTest1 id:13 root:a
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__IntrinTest1_match_0:(CodeGenInstructionPattern G_INTRINSIC_CONVERGENT operands:[<def>$a, $b] intrinsic(@llvm.convergent.1in.1out))
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     <apply_root>__IntrinTest1_apply_0:(CodeGenInstructionPattern G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS operands:[<def>$a, $b] intrinsic(@llvm.convergent.sideeffects.1in.1out))
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> __IntrinTest1_match_0
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats
// CHECK-NEXT:     a -> __IntrinTest1_apply_0
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT: )
def IntrinTest1 : GICombineRule<
  (defs root:$a),
  (match (int_convergent_1in_1out $a, $b)),
  (apply (int_convergent_sideeffects_1in_1out $a, $b))>;

// CHECK:      (CombineRule name:CombineOperator0 id:14 root:d
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>d:(AnyOpcodePattern [G_TRUNC])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __CombineOperator0_combine_1:(CXXPattern apply code:"return APPLY;")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats <empty>)
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def CombineOperator0 : GICombineRule<
  (defs root:$d),
  (combine (wip_match_opcode G_TRUNC):$d, "return APPLY;")>;

// CHECK:      (CombineRule name:CombineOperator1 id:15 root:a
// CHECK-NEXT:   (MatchPats
// CHECK-NEXT:     <match_root>__CombineOperator1_combine_0:(CodeGenInstructionPattern G_TRUNC operands:[<def>$a, $b])
// CHECK-NEXT:   )
// CHECK-NEXT:   (ApplyPats
// CHECK-NEXT:     __CombineOperator1_combine_1:(CXXPattern apply code:"return APPLY ${a} ${b};")
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable MatchPats
// CHECK-NEXT:     a -> __CombineOperator1_combine_0
// CHECK-NEXT:     b -> <live-in>
// CHECK-NEXT:   )
// CHECK-NEXT:   (OperandTable ApplyPats <empty>)
// CHECK-NEXT: )
def CombineOperator1 : GICombineRule<
  (defs root:$a),
  (combine (G_TRUNC $a, $b), "return APPLY ${a} ${b};")>;

def MyCombiner: GICombiner<"GenMyCombiner", [
  WipOpcodeTest0,
  WipOpcodeTest1,
  InstTest0,
  InstTest1,
  InstTest2,
  InOutInstTest0,
  PatFragTest0,
  PatFragTest1,
  VariadicsInTest,
  VariadicsOutTest,
  TypeOfTest,
  MIFlagsTest,
  IntrinTest0,
  IntrinTest1,
  CombineOperator0,
  CombineOperator1
]>;