diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -21,6 +21,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Regex.h" @@ -31,10 +32,18 @@ #include +//===----------------------------------------------------------------------===// +// Commandline Options +//===----------------------------------------------------------------------===// +static llvm::cl::OptionCategory docCat("Options for -gen-(attrdef|typedef|op|dialect)-doc"); +llvm::cl::opt shortClassName( + "short-classname", + llvm::cl::desc("Uses the short/unqualified class names in headings"), + llvm::cl::init(false), llvm::cl::cat(docCat)); + using namespace llvm; using namespace mlir; using namespace mlir::tblgen; - using mlir::tblgen::Operator; // Emit the description by aligning the text to the left per line (e.g., @@ -156,7 +165,8 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) { os << llvm::formatv("### `{0}` ({1})\n", op.getOperationName(), - op.getQualCppClassName()); + shortClassName ? op.getCppClassName() + : op.getQualCppClassName()); // Emit the summary, syntax, and description if present. if (op.hasSummary())