diff --git a/mlir/test/mlir-tblgen/op-interface.td b/mlir/test/mlir-tblgen/op-interface.td --- a/mlir/test/mlir-tblgen/op-interface.td +++ b/mlir/test/mlir-tblgen/op-interface.td @@ -1,5 +1,6 @@ // RUN: mlir-tblgen -gen-op-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL // RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=OP_DECL +// RUN: mlir-tblgen -gen-op-interface-docs -I %S/../../include %s | FileCheck %s --check-prefix=DOCS include "mlir/IR/OpBase.td" @@ -31,6 +32,13 @@ /*methodName=*/"foo", /*args=*/(ins "int":$input) >, + InterfaceMethod< + /*desc=*/[{some function comment}], + /*retTy=*/"int", + /*methodName=*/"body_foo", + /*args=*/(ins "int":$input), + /*body=*/[{ return 0; }] + >, InterfaceMethod< /*desc=*/[{some function comment}], /*retTy=*/"int", @@ -93,3 +101,17 @@ // OP_DECL-LABEL: class DeclareMethodsWithDefaultOp : public // OP_DECL: int foo(int input); // OP_DECL: int default_foo(int input); + +// DOCS-LABEL: {{^}}## TestOpInterface (`TestOpInterface`) +// DOCS: some op interface description + +// DOCS: {{^}}### Methods: + +// DOCS: {{^}}#### `foo` +// DOCS: some function comment + +// DOCS: {{^}}#### `body_foo` +// DOCS: some function comment + +// DOCS: {{^}}#### `default_foo` +// DOCS: some function comment diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp --- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp +++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp @@ -557,7 +557,9 @@ // If the body is not provided, this method must be provided by the user. if (!method.getBody()) - os << "\nNOTE: This method *must* be implemented by the user.\n\n"; + os << "\nNOTE: This method *must* be implemented by the user."; + + os << "\n\n"; } }