Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions mlir/tools/mlir-tblgen/PassGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class {0}Base : public {1} {
}
::llvm::StringRef getArgument() const override { return "{2}"; }

::llvm::StringRef getDescription() const override { return "{3}"; }
::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }

/// Returns the derived pass name.
static constexpr ::llvm::StringLiteral getPassName() {
Expand Down Expand Up @@ -271,9 +271,9 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
os.indent(2) << "::mlir::Pass::"
<< (opt.isListOption() ? "ListOption" : "Option");

os << formatv(R"(<{0}> {1}{{*this, "{2}", ::llvm::cl::desc("{3}"))",
os << formatv(R"(<{0}> {1}{{*this, "{2}", ::llvm::cl::desc(R"PO({3})PO"))",
opt.getType(), opt.getCppVariableName(), opt.getArgument(),
opt.getDescription());
opt.getDescription().trim());
if (std::optional<StringRef> defaultVal = opt.getDefaultValue())
os << ", ::llvm::cl::init(" << defaultVal << ")";
if (std::optional<StringRef> additionalFlags = opt.getAdditionalFlags())
Expand All @@ -285,9 +285,10 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
/// Emit the declarations for each of the pass statistics.
static void emitPassStatisticDecls(const Pass &pass, raw_ostream &os) {
for (const PassStatistic &stat : pass.getStatistics()) {
os << formatv(" ::mlir::Pass::Statistic {0}{{this, \"{1}\", \"{2}\"};\n",
stat.getCppVariableName(), stat.getName(),
stat.getDescription());
os << formatv(
" ::mlir::Pass::Statistic {0}{{this, \"{1}\", R\"PS({2})PS\"};\n",
stat.getCppVariableName(), stat.getName(),
stat.getDescription().trim());
}
}

Expand Down Expand Up @@ -320,7 +321,7 @@ static void emitPassDefs(const Pass &pass, raw_ostream &os) {

os << "namespace impl {\n";
os << formatv(baseClassBegin, passName, pass.getBaseClass(),
pass.getArgument(), pass.getSummary(),
pass.getArgument(), pass.getSummary().trim(),
dependentDialectRegistrations);

if (ArrayRef<PassOption> options = pass.getOptions(); !options.empty()) {
Expand Down Expand Up @@ -393,7 +394,7 @@ class {0}Base : public {1} {
}
::llvm::StringRef getArgument() const override { return "{2}"; }

::llvm::StringRef getDescription() const override { return "{3}"; }
::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }

/// Returns the derived pass name.
static constexpr ::llvm::StringLiteral getPassName() {
Expand Down Expand Up @@ -439,7 +440,7 @@ static void emitOldPassDecl(const Pass &pass, raw_ostream &os) {
"\n ");
}
os << formatv(oldPassDeclBegin, defName, pass.getBaseClass(),
pass.getArgument(), pass.getSummary(),
pass.getArgument(), pass.getSummary().trim(),
dependentDialectRegistrations);
emitPassOptionDecls(pass, os);
emitPassStatisticDecls(pass, os);
Expand Down
7 changes: 5 additions & 2 deletions mlir/unittests/TableGen/passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ def TestPassWithOptions : Pass<"test"> {

let options = [
Option<"testOption", "testOption", "int", "0", "Test option">,
ListOption<"testListOption", "test-list-option", "int64_t",
"Test list option">
// Testing the output of multi-line description. This would fail compilation
// if not properly handled.
ListOption<"testListOption", "test-list-option", "int64_t", [{
Test
list option}]>
];
}

Expand Down