[Mlir-commits] [mlir] [mlir-tblgen] Render enum keyword alternatives in generated attr/type docs (PR #203677)
Maksim Levental
llvmlistbot at llvm.org
Sat Jun 13 08:55:24 PDT 2026
================
@@ -384,6 +384,25 @@ static void emitTypeDoc(const Type &type, raw_ostream &os) {
// TypeDef Documentation
//===----------------------------------------------------------------------===//
+/// If \p param is an EnumParameter, return a string listing the enum's keyword
+/// alternatives (e.g. "`read` | `read_write`"). Otherwise return std::nullopt.
+static std::optional<std::string>
+getEnumParameterDocSyntax(const AttrOrTypeParameter ¶m) {
+ const auto *paramDef = dyn_cast<DefInit>(param.getDef());
+ if (!paramDef || !paramDef->getDef()->isSubClassOf("EnumParameter"))
+ return std::nullopt;
+ const Record *enumRec = paramDef->getDef()->getValueAsDef("enum");
+ EnumInfo enumInfo(enumRec);
+ std::vector<EnumCase> cases = enumInfo.getAllCases();
+ std::string result;
+ for (const auto &caseIt : llvm::enumerate(cases)) {
+ if (caseIt.index() > 0)
+ result += " | ";
+ result += (llvm::Twine("`") + caseIt.value().getStr() + "`").str();
+ }
----------------
makslevental wrote:
done. thanks for the suggestion!
https://github.com/llvm/llvm-project/pull/203677
More information about the Mlir-commits
mailing list