Skip to content

Commit 8604bf6

Browse files
committed
Pretty print on -dump-pass-pipeline
1 parent 4ad230b commit 8604bf6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

mlir/lib/Pass/Pass.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "mlir/IR/Threading.h"
1919
#include "mlir/IR/Verifier.h"
2020
#include "mlir/Support/FileUtilities.h"
21+
#include "mlir/Support/IndentedOstream.h"
2122
#include "llvm/ADT/Hashing.h"
2223
#include "llvm/ADT/STLExtras.h"
2324
#include "llvm/ADT/ScopeExit.h"
@@ -392,18 +393,28 @@ StringRef OpPassManager::getOpAnchorName() const {
392393
/// Prints out the passes of the pass manager as the textual representation
393394
/// of pipelines.
394395
void printAsTextualPipeline(
395-
raw_ostream &os, StringRef anchorName,
396+
raw_indented_ostream &os, StringRef anchorName,
396397
const llvm::iterator_range<OpPassManager::pass_iterator> &passes) {
397-
os << anchorName << "(";
398+
os << anchorName << "(\n";
399+
os.indent();
398400
llvm::interleave(
399401
passes, [&](mlir::Pass &pass) { pass.printAsTextualPipeline(os); },
400-
[&]() { os << ","; });
402+
[&]() { os << ",\n"; });
403+
os << "\n";
404+
os.unindent();
401405
os << ")";
402406
}
407+
void printAsTextualPipeline(
408+
raw_ostream &os, StringRef anchorName,
409+
const llvm::iterator_range<OpPassManager::pass_iterator> &passes) {
410+
raw_indented_ostream indentedOS(os);
411+
printAsTextualPipeline(indentedOS, anchorName, passes);
412+
}
403413
void OpPassManager::printAsTextualPipeline(raw_ostream &os) const {
404414
StringRef anchorName = getOpAnchorName();
415+
raw_indented_ostream indentedOS(os);
405416
::printAsTextualPipeline(
406-
os, anchorName,
417+
indentedOS, anchorName,
407418
{MutableArrayRef<std::unique_ptr<Pass>>{impl->passes}.begin(),
408419
MutableArrayRef<std::unique_ptr<Pass>>{impl->passes}.end()});
409420
}

0 commit comments

Comments
 (0)