[mlir] Fix missing OpInterface docs newline

Fix incorrect markdown generated by mlir-tblgen for an InterfaceMethod
that includes a body.  Previously, this would cause the next method to
show up on the same line and produce incorrect markdown.  Newlines would
only be added if the method did _not_ provide a body.  E.g., previously
this was generating markdown like:

    some function comment#### `next method`

This change makes this generate as:

    some function comment

    #### `next method`

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D140590
This commit is contained in:
Schuyler Eldridge 2022-12-22 17:34:27 -05:00
parent f7bc8e035d
commit 794056e86a
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
2 changed files with 25 additions and 1 deletions

View File

@ -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 @@ def TestOpInterface : OpInterface<"TestOpInterface"> {
/*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 @@ def DeclareMethodsWithDefaultOp : Op<TestDialect, "declare_methods_op",
// 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

View File

@ -557,7 +557,9 @@ static void emitInterfaceDoc(const llvm::Record &interfaceDef,
// 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";
}
}