90 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+1]]:{{[0-9]+}}: error: 'G_BUILD_VECTOR': GIVariadic can only be used on the last operand12def VariadicNotLastInList : GICombineRule<13 (defs root:$dst),14 (match (G_BUILD_VECTOR $dst, $a, GIVariadic<>:$b, $c)),15 (apply (G_ANYEXT $dst, $a))>;16 17// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'G_IMPLICIT_DEF': GIVariadic cannot be used on defs18def VariadicAsDef : GICombineRule<19 (defs root:$dst),20 (match (G_IMPLICIT_DEF GIVariadic<1>:$dst)),21 (apply [{ APPLY }])>;22 23// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: conflicting types for operand 'args': 'GIVariadic<2,4>' vs 'GIVariadic<3,6>'24def ConflictingInference : GICombineRule<25 (defs root:$dst),26 (match (G_BUILD_VECTOR $dst, GIVariadic<2, 4>:$args)),27 (apply (G_MERGE_VALUES $dst, GIVariadic<3, 6>:$args))>;28 29// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: cannot parse operand type: minimum number of arguments must be greater than zero in GIVariadic30// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(G_BUILD_VECTOR ?:$dst, anonymous_{{[0-9]+}}:$a)'31def InvalidBounds0 : GICombineRule<32 (defs root:$dst),33 (match (G_BUILD_VECTOR $dst, GIVariadic<0>:$a)),34 (apply [{ APPLY }])>;35 36// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: cannot parse operand type: maximum number of arguments (1) must be zero, or greater than the minimum number of arguments (1) in GIVariadic37// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(G_BUILD_VECTOR ?:$dst, anonymous_{{[0-9]+}}:$a)'38def InvalidBounds1 : GICombineRule<39 (defs root:$dst),40 (match (G_BUILD_VECTOR $dst, GIVariadic<1,1>:$a)),41 (apply [{ APPLY }])>;42 43// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: each instance of a GIVariadic operand must have a unique name within the match patterns44// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: 'c' is used multiple times45def VariadicTypeTestEqOp : GICombineRule<46 (defs root:$a),47 (match (G_MERGE_VALUES $b, $c),48 (G_BUILD_VECTOR $a, $b, GIVariadic<2, 4>:$c)),49 (apply (G_MERGE_VALUES $a, $c))>;50 51// TODO: We could support this if needed52 53// CHECK: :[[@LINE+3]]:{{[0-9]+}}: error: GISpecialType is not supported in GICombinePatFrag54// CHECK: :[[@LINE+2]]:{{[0-9]+}}: note: operand 1 of '__PFWithVariadic_alt0_pattern_0' has type 'GIVariadic<1,055// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'PFWithVariadic'56def PFWithVariadic: GICombinePatFrag<57 (outs $dst), (ins),58 [(pattern (G_ANYEXT $dst, GIVariadic<>:$b))]>;59 60// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(PFWithVariadic ?:$dst)'61def UseInPF: GICombineRule<62 (defs root:$dst),63 (match (PFWithVariadic $dst)),64 (apply (G_ANYEXT $dst, (i32 0)))>;65 66// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: cannot use a GIVariadic operand on non-variadic instruction 'G_MUL'67def NotVariadicInstMatch : GICombineRule<68 (defs root:$a),69 (match (G_MUL $a, $c, GIVariadic<2, 4>:$b)),70 (apply (G_MERGE_VALUES $a, $b, $c))>;71 72// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: cannot use a GIVariadic operand on non-variadic instruction 'G_MUL'73def NotVariadicInstApply : GICombineRule<74 (defs root:$a),75 (match (G_BUILD_VECTOR $a, GIVariadic<2, 4>:$b)),76 (apply (G_MUL $a, $b, $c))>;77 78// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse one or more rules79def MyCombiner: GICombiner<"GenMyCombiner", [80 VariadicNotLastInList,81 VariadicAsDef,82 ConflictingInference,83 InvalidBounds0,84 InvalidBounds1,85 VariadicTypeTestEqOp,86 UseInPF,87 NotVariadicInstMatch,88 NotVariadicInstApply89]>;90