46 lines · plain
1// RUN: mlir-tblgen --gen-type-interface-decls -I %S/../../include %s | FileCheck %s2 3include "mlir/IR/OpBase.td"4 5def TestEmptyMethodBodyTypeInterface : TypeInterface<"TestEmptyMethodBodyTypeInterface"> {6 let cppNamespace = "::TestEmptyMethodBodyTypeInterface";7 let description = [{8 Treat method body with only spaces as empty.9 }];10 let methods = [11 InterfaceMethod<12 /*desc=*/ [{ Trim spaces of method body and default implementation }],13 /*returnType=*/ "StringRef",14 /*methodName=*/ "trimSpaces",15 /*args=*/ (ins),16 // CHECK-LABEL: StringRef detail::TestEmptyMethodBodyTypeInterfaceInterfaceTraits::Model<ConcreteType>::trimSpaces17 // CHECK-SAME: {18 // CHECK-NEXT: return (::llvm::cast<ConcreteType>(tablegen_opaque_val)).trimSpaces();19 // CHECK-NEXT: }20 /*methodBody=*/ [{ }],21 /*defaultImpl=*/ [{ return StringRef(); }]22 >23 ];24}25 26def TestEmptyDefaultImplTypeInterface : TypeInterface<"TestEmptyDefaultImplTypeInterface"> {27 let cppNamespace = "::TestEmptyDefaultImplTypeInterface";28 let description = [{29 Treat default implementation with only spaces as empty.30 }];31 32 let methods = [33 InterfaceMethod<34 /*desc=*/ [{ Trim spaces of default implementation }],35 /*returnType=*/ "StringRef",36 /*methodName=*/ "trimSpaces",37 /*args=*/ (ins),38 /*methodBody=*/ [{ return StringRef(); }],39 // COM: Don't generate default implementation40 // CHECK-NOT: StringRef detail::TestEmptyDefaultImplTypeInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteType>::trimSpaces41 /*defaultImpl=*/ [{42 }]43 >44 ];45}46