1// RUN: mlir-tblgen -gen-op-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL 2// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=OP_DECL 3 4include "mlir/IR/OpBase.td" 5 6def TestOpInterface : OpInterface<"TestOpInterface"> { 7 let description = [{some op interface description}]; 8 9 let methods = [ 10 InterfaceMethod< 11 /*desc=*/[{some function comment}], 12 /*retTy=*/"int", 13 /*methodName=*/"foo", 14 /*args=*/(ins "int":$input) 15 >, 16 InterfaceMethod< 17 /*desc=*/[{some function comment}], 18 /*retTy=*/"int", 19 /*methodName=*/"default_foo", 20 /*args=*/(ins "int":$input), 21 /*body=*/[{}], 22 /*defaultBody=*/[{ return 0; }] 23 >, 24 ]; 25} 26 27// Define Ops with TestOpInterface and 28// DeclareOpInterfaceMethods<TestOpInterface> traits to check that there 29// are not duplicated C++ classes generated. 30def TestDialect : Dialect { 31 let name = "test"; 32} 33 34def OpInterfaceOp : Op<TestDialect, "op_interface_op", [TestOpInterface]>; 35 36def DeclareMethodsOp : Op<TestDialect, "declare_methods_op", 37 [DeclareOpInterfaceMethods<TestOpInterface>]>; 38 39def DeclareMethodsWithDefaultOp : Op<TestDialect, "declare_methods_op", 40 [DeclareOpInterfaceMethods<TestOpInterface, ["default_foo"]>]>; 41 42// DECL-LABEL: TestOpInterfaceInterfaceTraits 43// DECL: class TestOpInterface : public ::mlir::OpInterface<TestOpInterface, detail::TestOpInterfaceInterfaceTraits> 44 45// DECL: int foo(int input); 46 47// DECL: template<typename ConcreteOp> 48// DECL: int detail::TestOpInterfaceInterfaceTraits::Model<ConcreteOp>::foo 49 50// OP_DECL-LABEL: class DeclareMethodsOp : public 51// OP_DECL: int foo(int input); 52// OP_DECL-NOT: int default_foo(int input); 53 54// OP_DECL-LABEL: class DeclareMethodsWithDefaultOp : public 55// OP_DECL: int foo(int input); 56// OP_DECL: int default_foo(int input); 57