Skip to content

Commit 33550b4

Browse files
authored
[mlir] Add operator<< for printing Block (#92550)
Turns out it was already in Analysis/CFGLoopInfo, so just move it to IR/AsmPrinter.
1 parent 4b62afc commit 33550b4

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

mlir/include/mlir/Analysis/CFGLoopInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ class CFGLoopInfo : public llvm::LoopInfoBase<mlir::Block, mlir::CFGLoop> {
4949
CFGLoopInfo(const llvm::DominatorTreeBase<mlir::Block, false> &domTree);
5050
};
5151

52-
raw_ostream &operator<<(raw_ostream &os, mlir::Block &block);
53-
5452
} // namespace mlir
5553

5654
#endif // MLIR_ANALYSIS_LOOPINFO_H

mlir/include/mlir/IR/Block.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace llvm {
2020
class BitVector;
21+
class raw_ostream;
2122
} // namespace llvm
2223

2324
namespace mlir {
@@ -401,6 +402,8 @@ class Block : public IRObjectWithUseList<BlockOperand>,
401402

402403
friend struct llvm::ilist_traits<Block>;
403404
};
405+
406+
raw_ostream &operator<<(raw_ostream &, Block &);
404407
} // namespace mlir
405408

406409
#endif // MLIR_IR_BLOCK_H

mlir/lib/Analysis/CFGLoopInfo.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ CFGLoopInfo::CFGLoopInfo(
2323
const llvm::DominatorTreeBase<mlir::Block, false> &domTree) {
2424
analyze(domTree);
2525
}
26-
27-
raw_ostream &mlir::operator<<(raw_ostream &os, mlir::Block &block) {
28-
block.print(os);
29-
return os;
30-
}

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3984,6 +3984,11 @@ void Block::printAsOperand(raw_ostream &os, AsmState &state) {
39843984
printer.printBlockName(this);
39853985
}
39863986

3987+
raw_ostream &mlir::operator<<(raw_ostream &os, Block &block) {
3988+
block.print(os);
3989+
return os;
3990+
}
3991+
39873992
//===--------------------------------------------------------------------===//
39883993
// Custom printers
39893994
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)