[Mlir-commits] [mlir] [mlir][doc] Escape effects, interfaces, and traits (PR #76297)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Dec 23 10:27:41 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Rik Huijzer (rikhuijzer)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/76270.
Thanks to @<!-- -->scottamain for the clear description.
Co-authored-by: scott@<!-- -->modular.com
---
Full diff: https://github.com/llvm/llvm-project/pull/76297.diff
2 Files Affected:
- (modified) mlir/test/mlir-tblgen/gen-dialect-doc.td (+3-3)
- (modified) mlir/tools/mlir-tblgen/OpDocGen.cpp (+9-3)
``````````diff
diff --git a/mlir/test/mlir-tblgen/gen-dialect-doc.td b/mlir/test/mlir-tblgen/gen-dialect-doc.td
index ca0b6e38edf82c..c9492eb9ac3cef 100644
--- a/mlir/test/mlir-tblgen/gen-dialect-doc.td
+++ b/mlir/test/mlir-tblgen/gen-dialect-doc.td
@@ -81,9 +81,9 @@ def TestTypeDefParams : TypeDef<Test_Dialect, "TestTypeDefParams"> {
// CHECK: Other group
// CHECK: test.b
// CHECK: test.c
-// CHECK: Traits: SingleBlock, SingleBlockImplicitTerminator<YieldOp>
-// CHECK: Interfaces: NoMemoryEffect (MemoryEffectOpInterface)
-// CHECK: Effects: MemoryEffects::Effect{}
+// CHECK: Traits: `SingleBlockImplicitTerminator<YieldOp>`, `SingleBlock`
+// CHECK: Interfaces: `NoMemoryEffect (MemoryEffectOpInterface)`
+// CHECK: Effects: `MemoryEffects::Effect{}`
// CHECK: ## Attribute constraints
// CHECK: ### attribute summary
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 877ef1089dcec0..9e7ec5b13a5cfe 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -123,6 +123,12 @@ static void emitAssemblyFormat(StringRef opName, StringRef format,
os << "```\n\n";
}
+/// Place `text` between backticks so that the Markdown processor renders it as
+/// inline code.
+static std::string backticks(const std::string &text) {
+ return '`' + text + '`';
+}
+
static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
// TODO: We should link to the trait/documentation of it. That also means we
// should add descriptions to traits that can be queried.
@@ -155,14 +161,14 @@ static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
os << effect << " on " << rec->getValueAsString("resource");
});
os << "}";
- effects.insert(os.str());
+ effects.insert(backticks(os.str()));
name.append(llvm::formatv(" ({0})", traitName).str());
}
- interfaces.insert(name);
+ interfaces.insert(backticks(name));
continue;
}
- traits.insert(name);
+ traits.insert(backticks(name));
}
if (!traits.empty()) {
llvm::interleaveComma(traits, os << "\nTraits: ");
``````````
</details>
https://github.com/llvm/llvm-project/pull/76297
More information about the Mlir-commits
mailing list