1// RUN: not llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \ 2// RUN: -combiners=MyCombiner %s 2>&1 | \ 3// RUN: FileCheck -implicit-check-not=error %s 4 5include "llvm/Target/Target.td" 6include "llvm/Target/GlobalISel/Combine.td" 7 8def MyTargetISA : InstrInfo; 9def MyTarget : Target { let InstructionSet = MyTargetISA; } 10 11def dummy; 12 13def R0 : Register<"r0"> { let Namespace = "MyTarget"; } 14def GPR32 : RegisterClass<"MyTarget", [i32], 32, (add R0)>; 15class I<dag OOps, dag IOps, list<dag> Pat> 16 : Instruction { 17 let Namespace = "MyTarget"; 18 let OutOperandList = OOps; 19 let InOperandList = IOps; 20 let Pattern = Pat; 21} 22def MOV : I<(outs GPR32:$dst), (ins GPR32:$src1), []>; 23 24def missing_match_node : GICombineRule< 25 (defs root:$a), 26 (dummy), 27 (dummy)>; 28// CHECK: :[[@LINE-4]]:{{[0-9]+}}: error: Expected match operator 29// CHECK-NEXT: def missing_match_node : GICombineRule< 30// CHECK: :[[@LINE-6]]:{{[0-9]+}}: error: Failed to parse rule 31 32def null_matcher : GICombineRule< 33 (defs root:$a), 34 (match), 35 (dummy)>; 36// CHECK: :[[@LINE-4]]:{{[0-9]+}}: error: Matcher is empty 37// CHECK-NEXT: def null_matcher : GICombineRule< 38// CHECK: :[[@LINE-6]]:{{[0-9]+}}: error: Failed to parse rule 39 40def unknown_kind1 : GICombineRule< 41 (defs root:$a), 42 (match 0), 43 (dummy)>; 44// CHECK: :[[@LINE-4]]:{{[0-9]+}}: error: Expected a subclass of GIMatchKind or a sub-dag whose operator is either of a GIMatchKindWithArgs or Instruction 45// CHECK-NEXT: def unknown_kind1 : GICombineRule< 46// CHECK: :[[@LINE-6]]:{{[0-9]+}}: error: Failed to parse rule 47 48def unknown_kind2 : GICombineRule< 49 (defs root:$a), 50 (match (dummy)), 51 (dummy)>; 52// CHECK: :[[@LINE-4]]:{{[0-9]+}}: error: Expected a subclass of GIMatchKind or a sub-dag whose operator is either of a GIMatchKindWithArgs or Instruction 53// CHECK-NEXT: def unknown_kind2 : GICombineRule< 54// CHECK: :[[@LINE-6]]:{{[0-9]+}}: error: Failed to parse rule 55 56def multidef : GICombineRule< 57 (defs root:$a), 58 (match (MOV $a, $b), 59 (MOV $a, $b)), 60 (dummy)>; 61// CHECK: :[[@LINE-5]]:{{[0-9]+}}: error: Two different MachineInstrs cannot def the same vreg 62// CHECK-NEXT: def multidef : GICombineRule< 63// CHECK: :[[@LINE-7]]:{{[0-9]+}}: error: Failed to parse rule 64 65def multidef_but_not_an_error: GICombineRule< 66 (defs root:$a), 67 (match (MOV $a, $b), 68 (MOV $a, $b)), 69 (dummy)>; 70// CHECK-NOT: :[[@LINE-5]]:{{[0-9]+}}: error: 71 72def MyCombiner: GICombinerHelper<"GenMyCombiner", [ 73// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: Failed to parse one or more rules 74 missing_match_node, 75 null_matcher, 76 unknown_kind1, 77 unknown_kind2, 78 multidef 79 // Rules omitted from a matcher can be as broken as you like. They will not be read. 80 // multidef_but_not_an_error 81]>; 82