2021-09-21 06:59:56 +08:00
|
|
|
// RUN: mlir-tblgen -gen-rewriters -I %S/../../include %s | FileCheck %s
|
|
|
|
|
|
|
|
include "mlir/IR/OpBase.td"
|
2022-01-28 13:58:31 +08:00
|
|
|
include "mlir/IR/PatternBase.td"
|
2021-09-21 06:59:56 +08:00
|
|
|
|
|
|
|
def Test_Dialect : Dialect {
|
|
|
|
let name = "test";
|
|
|
|
}
|
2022-01-30 06:30:57 +08:00
|
|
|
class NS_Op<string mnemonic, list<Trait> traits> :
|
2021-09-21 06:59:56 +08:00
|
|
|
Op<Test_Dialect, mnemonic, traits>;
|
|
|
|
|
|
|
|
def AOp : NS_Op<"a_op", []> {
|
|
|
|
let arguments = (ins
|
|
|
|
AnyInteger:$any_integer
|
|
|
|
);
|
|
|
|
|
|
|
|
let results = (outs AnyInteger);
|
|
|
|
}
|
|
|
|
|
|
|
|
def BOp : NS_Op<"b_op", []> {
|
|
|
|
let arguments = (ins
|
|
|
|
AnyAttr: $any_attr,
|
|
|
|
AnyInteger
|
|
|
|
);
|
|
|
|
|
|
|
|
let results = (outs AnyInteger);
|
|
|
|
}
|
|
|
|
|
|
|
|
def COp : NS_Op<"c_op", []> {
|
|
|
|
let arguments = (ins
|
|
|
|
AnyAttr: $any_attr,
|
|
|
|
AnyInteger
|
|
|
|
);
|
|
|
|
|
|
|
|
let results = (outs AnyInteger);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test static matcher for duplicate DagNode
|
|
|
|
// ---
|
|
|
|
|
2021-11-12 06:08:54 +08:00
|
|
|
// CHECK: static ::mlir::LogicalResult [[$TYPE_CONSTRAINT:__mlir_ods_local_type_constraint.*]](
|
|
|
|
// CHECK-NEXT: {{.*::mlir::Type type}}
|
|
|
|
// CHECK: static ::mlir::LogicalResult [[$ATTR_CONSTRAINT:__mlir_ods_local_attr_constraint.*]](
|
|
|
|
// CHECK-NEXT: {{.*::mlir::Attribute attr}}
|
|
|
|
// CHECK: static ::mlir::LogicalResult [[$DAG_MATCHER:static_dag_matcher.*]](
|
2022-02-02 18:57:16 +08:00
|
|
|
// CHECK: if(::mlir::failed([[$ATTR_CONSTRAINT]]
|
|
|
|
// CHECK: if(::mlir::failed([[$TYPE_CONSTRAINT]]
|
2021-09-21 06:59:56 +08:00
|
|
|
|
2022-02-02 18:57:16 +08:00
|
|
|
// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
|
2021-09-21 06:59:56 +08:00
|
|
|
def : Pat<(AOp (BOp I32Attr:$attr, I32:$int)),
|
|
|
|
(AOp $int)>;
|
|
|
|
|
2022-02-02 18:57:16 +08:00
|
|
|
// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
|
2021-09-21 06:59:56 +08:00
|
|
|
def : Pat<(COp $_, (BOp I32Attr:$attr, I32:$int)),
|
|
|
|
(COp $attr, $int)>;
|