1 // RUN: mlir-tblgen -gen-rewriters -I %S/../../include %s | FileCheck %s
3 include "mlir/IR/OpBase.td"
4 include "mlir/IR/PatternBase.td"
6 def Test_Dialect : Dialect {
9 class NS_Op<string mnemonic, list<Trait> traits> :
10 Op<Test_Dialect, mnemonic, traits>;
12 def AOp : NS_Op<"a_op", []> {
14 AnyInteger:$any_integer
17 let results = (outs AnyInteger);
20 def BOp : NS_Op<"b_op", []> {
26 let results = (outs AnyInteger);
29 def COp : NS_Op<"c_op", []> {
35 let results = (outs AnyInteger);
38 def DOp : NS_Op<"d_op", []> {
40 Variadic<AnyInteger>:$any_integer
43 let results = (outs AnyInteger);
46 def Foo : NativeCodeCall<"foo($_builder, $0)">;
48 // Test static matcher for duplicate DagNode
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]]
59 // CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
60 def : Pat<(AOp (BOp I32Attr:$attr, I32:$int)),
63 // CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
64 def : Pat<(COp $_, (BOp I32Attr:$attr, I32:$int)),
67 // CHECK: auto [[$VAR:.*]] = foo(
68 // CHECK: ::llvm::SmallVector<::mlir::Value, 4> [[$ARR:tblgen_variadic_values_.*]];
69 // CHECK: [[$ARR]].push_back([[$VAR]]);
70 def : Pat<(AOp $x), (DOp (variadic (Foo $x)))>;