Debian Codegraph @

llvm/test/TableGen/GlobalISelCombinerEmitter/builtins/builtin-pattern-errors.td

raw
1 // RUN: not llvm-tblgen -I %p/../../../../include -gen-global-isel-combiner \
2 // RUN: -combiners=MyCombiner %s 2>&1| \
3 // RUN: FileCheck %s -implicit-check-not=error:
4
5 include "llvm/Target/Target.td"
6 include "llvm/Target/GlobalISel/Combine.td"
7
8 def MyTargetISA : InstrInfo;
9 def MyTarget : Target { let InstructionSet = MyTargetISA; }
10
11 // CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'GIReplaceReg' to be a name
12 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0))'
13 def builtinpat_immop : GICombineRule<
14 (defs root:$dst),
15 (match (COPY $dst, $src)),
16 (apply (GIReplaceReg $dst, (i32 0)))>;
17
18 // CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'GIReplaceReg' to be a name
19 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0):$k)'
20 def builtinpat_namedimmop : GICombineRule<
21 (defs root:$dst),
22 (match (COPY $dst, $src)),
23 (apply (GIReplaceReg $dst, (i32 0):$k))>;
24
25
26 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'GIEraseRoot' cannot be used in a 'match' pattern
27 def eraseroot_in_match : GICombineRule<
28 (defs root:$dst),
29 (match (GIEraseRoot):$mi),
30 (apply (COPY $dst, $src))>;
31
32 // CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: 'GIEraseRoot' expected 0 operands, got 1
33 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIEraseRoot ?:$dst)'
34 def eraseroot_ops : GICombineRule<
35 (defs root:$dst),
36 (match (COPY $dst, $src)),
37 (apply (GIEraseRoot $dst), (COPY $dst, $src))>;
38
39 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIEraseRoot must be the only 'apply' pattern
40 def eraseroot_multiapply : GICombineRule<
41 (defs root:$dst),
42 (match (COPY $dst, $src)),
43 (apply (GIEraseRoot), (COPY $dst, $src))>;
44
45 // CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: GIEraseRoot can only be used if on roots that do not have any output operand
46 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: 'COPY' has 1 output operands
47 def eraseroot_root_has_def: GICombineRule<
48 (defs root:$dst),
49 (match (COPY $dst, $src)),
50 (apply (GIEraseRoot))>;
51
52 def TestPF: GICombinePatFrag<
53 (outs root:$def),
54 (ins),
55 [(pattern (COPY $def, $src))]>;
56 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIEraseRoot can only be used if the root is a CodeGenInstruction or Intrinsic
57 def eraseroot_notinstmatch: GICombineRule<
58 (defs root:$mi),
59 (match (TestPF $dst):$mi),
60 (apply (GIEraseRoot))>;
61
62 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'GIReplaceReg' cannot be used in a 'match' pattern
63 def replacereg_in_match : GICombineRule<
64 (defs root:$dst),
65 (match (GIReplaceReg $dst, $src)),
66 (apply (COPY $dst, $src))>;
67
68 // CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: 'GIReplaceReg' expected 2 operands, got 1
69 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst)'
70 def replacereg_ops : GICombineRule<
71 (defs root:$dst),
72 (match (COPY $dst, $src)),
73 (apply (GIReplaceReg $dst))>;
74
75 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIReplaceReg cannot replace 'tmp': this builtin can only replace a register defined by the match root
76 def replacereg_nonroot : GICombineRule<
77 (defs root:$dst),
78 (match (COPY $dst, $tmp), (COPY $tmp, $src)),
79 (apply (GIReplaceReg $dst, $src), (GIReplaceReg $tmp, $src))>;
80
81 // CHECK: error: Failed to parse one or more rules
82
83 def MyCombiner: GICombiner<"GenMyCombiner", [
84 builtinpat_immop,
85 builtinpat_namedimmop,
86 eraseroot_in_match,
87 eraseroot_ops,
88 eraseroot_multiapply,
89 eraseroot_root_has_def,
90 eraseroot_notinstmatch,
91 replacereg_in_match,
92 replacereg_ops,
93 replacereg_nonroot
94 ]>;