95 lines · plain
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 5include "llvm/Target/Target.td"6include "llvm/Target/GlobalISel/Combine.td"7 8def MyTargetISA : InstrInfo;9def MyTarget : Target { let InstructionSet = MyTargetISA; }10 11// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'GIReplaceReg' to be a name12// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0))'13def 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 name19// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0):$k)'20def 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' pattern27def 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 133// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIEraseRoot ?:$dst)'34def 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' pattern40def 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 operand46// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: 'COPY' has 1 output operands47def eraseroot_root_has_def: GICombineRule<48 (defs root:$dst),49 (match (COPY $dst, $src)),50 (apply (GIEraseRoot))>;51 52def 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 Intrinsic57def 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' pattern63def 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 169// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst)'70def 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 root76def 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 rules82 83def 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_nonroot94]>;95