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
|
// RUN: not llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
// RUN: -combiners=MyCombiner %s 2>&1| \
// RUN: FileCheck %s -implicit-check-not=error:
include "llvm/Target/Target.td"
include "llvm/Target/GlobalISel/Combine.td"
def MyTargetISA : InstrInfo;
def MyTarget : Target { let InstructionSet = MyTargetISA; }
def dummy;
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: :[[@LINE+2]]:{{[0-9]+}}: error: cannot emit rule 'too_many_perms'; 27 permutations would be emitted, but the max is 16
let MaxPermutations = 16 in
def too_many_perms : 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)), "APPLY ${src}")>;
def DummyCXXPF: GICombinePatFrag<
(outs),
(ins gi_mo:$in),
[
(pattern "return foo()"),
]>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: operand 'foo' (for parameter 'in' of 'DummyCXXPF') cannot be unbound
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: one or more alternatives of 'DummyCXXPF' do not bind 'in' to an instruction operand; either use a bound operand or ensure 'DummyCXXPF' binds 'in' in all alternatives
def undef_livein : GICombineRule<
(defs root:$dst),
(match (G_ZEXT $dst, $bar),
(DummyCXXPF $foo)
),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: GICombinePatFrag must have one root in its 'out' operands
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'OutMustBeRoot'
def OutMustBeRoot: GICombinePatFrag<
(outs $foo, $bar),
(ins),
[
(pattern (G_ZEXT $foo, $bar), (G_FPEXT $bar, $y)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(OutMustBeRoot ?:$bar, ?:$foo)'
def out_must_be_root : GICombineRule<
(defs root:$dst),
(match (G_ZEXT $dst, $bar),
(OutMustBeRoot $bar, $foo)
),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: output parameter 'bar' must be 'root' or 'gi_mo'
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'BadOutType'
def BadOutType: GICombinePatFrag<
(outs root:$foo, gi_imm:$bar),
(ins),
[
(pattern (G_ZEXT $foo, $bar), (G_FPEXT $bar, $y)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(BadOutType ?:$bar, ?:$foo)'
def bad_out_type : GICombineRule<
(defs root:$dst),
(match (G_ZEXT $dst, $bar),
(BadOutType $bar, $foo)
),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: pattern 'dbg' ('G_FPEXT') is unreachable from the pattern root!
def UnreachablePat: GICombinePatFrag<
(outs root:$foo, $bar),
(ins),
[
(pattern (G_ZEXT $foo, $x), (G_FPEXT $bar, $y):$dbg),
]>;
def unreachable_pat : GICombineRule<
(defs root:$dst),
(match (G_ZEXT $dst, $bar),
(UnreachablePat $bar, $foo)
),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: wip_match_opcode cannot be used in GICombinePatFrag
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'WipMatchOpcodePatFrag'
def WipMatchOpcodePatFrag: GICombinePatFrag<
(outs),
(ins),
[
(pattern (wip_match_opcode G_ZEXT)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(WipMatchOpcodePatFrag)'
def wip_match_opcode_patfrag : GICombineRule<
(defs root:$dst),
(match (WipMatchOpcodePatFrag)),
(apply (COPY $dst, (i32 0)))>;
def DummyPF: GICombinePatFrag<(outs),(ins),[]>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: nested GICombinePatFrag are not supported
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'NestingPatFrag'
def NestingPatFrag: GICombinePatFrag<
(outs),
(ins),
[
(pattern (DummyPF)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(NestingPatFrag)'
def nest_pat_frag : GICombineRule<
(defs root:$dst),
(match (NestingPatFrag)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: input parameter 'k' cannot be redefined!
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'DupParamIn'
def DupParamIn: GICombinePatFrag<
(outs),
(ins gi_mo:$k, gi_mo:$k),
[
(pattern (G_ZEXT $k, $x)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(DupParamIn ?:$dst, ?:$bar)'
def dup_params_in : GICombineRule<
(defs root:$dst),
(match (DupParamIn $dst, $bar)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: duplicate parameter 'k'
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'DupParamOut'
def DupParamOut: GICombinePatFrag<
(outs root:$k, root:$k),
(ins),
[
(pattern (G_ZEXT $k, $x)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(DupParamOut ?:$dst, ?:$bar)'
def dup_params_out : GICombineRule<
(defs root:$dst),
(match (DupParamOut $dst, $bar)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: input parameter 'k' cannot be redefined!
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'DupParamInOut'
def DupParamInOut: GICombinePatFrag<
(outs root:$k),
(ins gi_mo:$k),
[
(pattern (G_ZEXT $k, $x)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(DupParamInOut ?:$dst, ?:$bar)'
def dup_params_inout : GICombineRule<
(defs root:$dst),
(match (DupParamInOut $dst, $bar)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: output parameter 'k' must be defined by all alternative patterns in 'DefByAllAlts'
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'DefByAllAlts'
def DefByAllAlts: GICombinePatFrag<
(outs root:$k),
(ins),
[
(pattern (G_ZEXT $k, $x)),
(pattern (G_FPEXT $z, $k))
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(DefByAllAlts ?:$dst)'
def def_by_all_alts : GICombineRule<
(defs root:$dst),
(match (DefByAllAlts $dst)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: Operand 'x' is defined multiple times in patterns of alternative #1
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'MultiDefInPat'
def MultiDefInPat: GICombinePatFrag<
(outs root:$k),
(ins),
[
(pattern (G_ZEXT $k, $a)),
(pattern (G_ZEXT $k, $x), (G_ZEXT $x, $foo), (G_FPEXT $x, $foo)),
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(MultiDefInPat ?:$dst)'
def multi_def_in_pat : GICombineRule<
(defs root:$dst),
(match (MultiDefInPat $dst)),
(apply (COPY $dst, (i32 0)))>;
def ExpectedImm: GICombinePatFrag<
(outs root:$k),
(ins gi_imm:$i),
[
(pattern (G_ZEXT $k, $i)),
]>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'ExpectedImm' to be an immediate; got MachineOperand $z
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(ExpectedImm ?:$dst, ?:$z)'
def expected_imm : GICombineRule<
(defs root:$dst),
(match (ExpectedImm $dst, $z)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: operand 1 of 'ExpectedImm' cannot be a named immediate
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(ExpectedImm ?:$dst, (i32 0):$z)'
def expected_imm_namedimm : GICombineRule<
(defs root:$dst),
(match (ExpectedImm $dst, (i32 0):$z)),
(apply (COPY $dst, (i32 0)))>;
def ExpectedMO: GICombinePatFrag<
(outs root:$k),
(ins gi_mo:$i),
[
(pattern (G_ZEXT $k, $i)),
]>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'ExpectedMO' to be a MachineOperand; got imm 0
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(ExpectedMO ?:$dst, (i32 0))'
def expected_mo : GICombineRule<
(defs root:$dst),
(match (ExpectedMO $dst, (i32 0))),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'ExpectedMO' to be a MachineOperand; got imm 0:$z
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(ExpectedMO ?:$dst, (i32 0):$z)'
def expected_mo_namedimm : GICombineRule<
(defs root:$dst),
(match (ExpectedMO $dst, (i32 0):$z)),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'dum': using GICombinePatFrag is not supported in apply patterns
def patfrag_in_apply : GICombineRule<
(defs root:$dst),
(match (COPY $dst, (i32 0))),
(apply (DummyPF):$dum)>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: cannot use 'DummyPF as match root
def patfrag_cannot_be_root : GICombineRule<
(defs root:$root),
(match (DummyPF):$root),
(apply (COPY $dst, (i32 0)):$root)>;
def TypedParams: GICombinePatFrag<
(outs root:$k),
(ins gi_mo:$i),
[
(pattern (G_ZEXT $k, i32:$i)),
]>;
// CHECK: :[[@LINE+3]]:{{[0-9]+}}: warning: impossible type constraints: operand 1 of 'broken' has type 'i64', but 'TypedParams' constrains it to 'i32'
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: note: operand 1 of 'broken' is 'k'
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: argument 1 of 'TypedParams' is 'i'
def inconsistent_arg_type : GICombineRule<
(defs root:$dst),
(match (TypedParams $dst, i64:$k):$broken),
(apply (COPY $dst, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: all instructions that define root 'foo' in 'RootDefHasMultiDefs' can only have a single output operand
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'RootDefHasMultiDefs'
def RootDefHasMultiDefs: GICombinePatFrag<
(outs root:$foo),
(ins gi_imm:$cst),
[
(pattern (G_UNMERGE_VALUES $foo, $z, $y))
]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(RootDefHasMultiDefs ?:$root, (i32 10))'
def root_def_has_multi_defs : GICombineRule<
(defs root:$root),
(match (RootDefHasMultiDefs $root, (i32 10))),
(apply (COPY $root, (i32 0)))>;
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: matching/writing MIFlags is only allowed on CodeGenInstruction patterns
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(DummyCXXPF ?:$x, (MIFlags FmArcp))'
def miflags_in_pf : GICombineRule<
(defs root:$x),
(match (COPY $x, $y), (DummyCXXPF $x, (MIFlags FmArcp))),
(apply (COPY $x, $y))>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: '$pf' does not refer to a CodeGenInstruction in MIFlags of '__badtype_for_flagref_in_apply_apply_0'
def badtype_for_flagref_in_apply : GICombineRule<
(defs root:$dst),
(match (G_ZEXT $dst, $src), (DummyCXXPF $src):$pf),
(apply (G_MUL $dst, $src, $src, (MIFlags $pf)))>;
// CHECK: error: Failed to parse one or more rules
def MyCombiner: GICombiner<"GenMyCombiner", [
too_many_perms,
undef_livein,
out_must_be_root,
bad_out_type,
unreachable_pat,
wip_match_opcode_patfrag,
nest_pat_frag,
dup_params_in,
dup_params_out,
dup_params_inout,
def_by_all_alts,
multi_def_in_pat,
expected_imm,
expected_imm_namedimm,
expected_mo,
expected_mo_namedimm,
patfrag_in_apply,
patfrag_cannot_be_root,
inconsistent_arg_type,
root_def_has_multi_defs,
miflags_in_pf,
badtype_for_flagref_in_apply
]>;
|