1// RUN: mlir-tblgen -gen-rewriters -I %S/../../include %s | FileCheck %s 2 3include "mlir/IR/OpBase.td" 4include "mlir/IR/PatternBase.td" 5 6def Test_Dialect : Dialect { 7 let name = "test"; 8} 9class NS_Op<string mnemonic, list<Trait> traits> : 10 Op<Test_Dialect, mnemonic, traits>; 11 12def AOp : NS_Op<"a_op", []> { 13 let arguments = (ins 14 AnyInteger:$any_integer 15 ); 16 17 let results = (outs AnyInteger); 18} 19 20def BOp : NS_Op<"b_op", []> { 21 let arguments = (ins 22 AnyAttr: $any_attr, 23 AnyInteger 24 ); 25 26 let results = (outs AnyInteger); 27} 28 29def COp : NS_Op<"c_op", []> { 30 let arguments = (ins 31 AnyAttr: $any_attr, 32 AnyInteger 33 ); 34 35 let results = (outs AnyInteger); 36} 37 38def DOp : NS_Op<"d_op", []> { 39 let arguments = (ins 40 Variadic<AnyInteger>:$any_integer 41 ); 42 43 let results = (outs AnyInteger); 44} 45 46def Foo : NativeCodeCall<"foo($_builder, $0)">; 47 48// Test static matcher for duplicate DagNode 49// --- 50 51// CHECK: static ::llvm::LogicalResult [[$TYPE_CONSTRAINT:__mlir_ods_local_type_constraint.*]]( 52// CHECK-NEXT: {{.*::mlir::Type type}} 53// CHECK: static ::llvm::LogicalResult [[$ATTR_CONSTRAINT:__mlir_ods_local_attr_constraint.*]]( 54// CHECK-NEXT: {{.*::mlir::Attribute attr}} 55// CHECK: static ::llvm::LogicalResult [[$DAG_MATCHER:static_dag_matcher.*]]( 56// CHECK: if(::mlir::failed([[$ATTR_CONSTRAINT]] 57// CHECK: if(::mlir::failed([[$TYPE_CONSTRAINT]] 58 59// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops 60def : Pat<(AOp (BOp I32Attr:$attr, I32:$int)), 61 (AOp $int)>; 62 63// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops 64def : Pat<(COp $_, (BOp I32Attr:$attr, I32:$int)), 65 (COp $attr, $int)>; 66 67// CHECK: auto [[$VAR:.*]] = foo( 68// CHECK: ::llvm::SmallVector<::mlir::Value, 4> [[$ARR:tblgen_variadic_values_.*]]; 69// CHECK: [[$ARR]].push_back([[$VAR]]); 70def : Pat<(AOp $x), (DOp (variadic (Foo $x)))>; 71