Skip to content

Commit 794056e

Browse files
committed
[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 <[email protected]> Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D140590
1 parent f7bc8e0 commit 794056e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

mlir/test/mlir-tblgen/op-interface.td

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: mlir-tblgen -gen-op-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL
22
// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=OP_DECL
3+
// RUN: mlir-tblgen -gen-op-interface-docs -I %S/../../include %s | FileCheck %s --check-prefix=DOCS
34

45
include "mlir/IR/OpBase.td"
56

@@ -31,6 +32,13 @@ def TestOpInterface : OpInterface<"TestOpInterface"> {
3132
/*methodName=*/"foo",
3233
/*args=*/(ins "int":$input)
3334
>,
35+
InterfaceMethod<
36+
/*desc=*/[{some function comment}],
37+
/*retTy=*/"int",
38+
/*methodName=*/"body_foo",
39+
/*args=*/(ins "int":$input),
40+
/*body=*/[{ return 0; }]
41+
>,
3442
InterfaceMethod<
3543
/*desc=*/[{some function comment}],
3644
/*retTy=*/"int",
@@ -93,3 +101,17 @@ def DeclareMethodsWithDefaultOp : Op<TestDialect, "declare_methods_op",
93101
// OP_DECL-LABEL: class DeclareMethodsWithDefaultOp : public
94102
// OP_DECL: int foo(int input);
95103
// OP_DECL: int default_foo(int input);
104+
105+
// DOCS-LABEL: {{^}}## TestOpInterface (`TestOpInterface`)
106+
// DOCS: some op interface description
107+
108+
// DOCS: {{^}}### Methods:
109+
110+
// DOCS: {{^}}#### `foo`
111+
// DOCS: some function comment
112+
113+
// DOCS: {{^}}#### `body_foo`
114+
// DOCS: some function comment
115+
116+
// DOCS: {{^}}#### `default_foo`
117+
// DOCS: some function comment

mlir/tools/mlir-tblgen/OpInterfacesGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ static void emitInterfaceDoc(const llvm::Record &interfaceDef,
557557

558558
// If the body is not provided, this method must be provided by the user.
559559
if (!method.getBody())
560-
os << "\nNOTE: This method *must* be implemented by the user.\n\n";
560+
os << "\nNOTE: This method *must* be implemented by the user.";
561+
562+
os << "\n\n";
561563
}
562564
}
563565

0 commit comments

Comments
 (0)