[Mlir-commits] [mlir] 794056e - [mlir] Fix missing OpInterface docs newline
Schuyler Eldridge
llvmlistbot at llvm.org
Tue Dec 27 08:52:51 PST 2022
Author: Schuyler Eldridge
Date: 2022-12-27T11:52:45-05:00
New Revision: 794056e86a53beff8e80f3a4fd8926e776a1f65e
URL: https://github.com/llvm/llvm-project/commit/794056e86a53beff8e80f3a4fd8926e776a1f65e
DIFF: https://github.com/llvm/llvm-project/commit/794056e86a53beff8e80f3a4fd8926e776a1f65e.diff
LOG: [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 at sifive.com>
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D140590
Added:
Modified:
mlir/test/mlir-tblgen/op-interface.td
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-interface.td b/mlir/test/mlir-tblgen/op-interface.td
index 8ac0d6d75572d..ab041982f0276 100644
--- 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 @@ 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
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
index 1ffed30d5cced..c832d0a9f0a6c 100644
--- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -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";
}
}
More information about the Mlir-commits
mailing list