[Mlir-commits] [mlir] 33550b4 - [mlir] Add operator<< for printing `Block` (#92550)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat May 18 06:03:23 PDT 2024
Author: Krzysztof Parzyszek
Date: 2024-05-18T08:03:19-05:00
New Revision: 33550b43f49a4e5b20e748936278e55f67e4b929
URL: https://github.com/llvm/llvm-project/commit/33550b43f49a4e5b20e748936278e55f67e4b929
DIFF: https://github.com/llvm/llvm-project/commit/33550b43f49a4e5b20e748936278e55f67e4b929.diff
LOG: [mlir] Add operator<< for printing `Block` (#92550)
Turns out it was already in Analysis/CFGLoopInfo, so just move it
to IR/AsmPrinter.
Added:
Modified:
mlir/include/mlir/Analysis/CFGLoopInfo.h
mlir/include/mlir/IR/Block.h
mlir/lib/Analysis/CFGLoopInfo.cpp
mlir/lib/IR/AsmPrinter.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/CFGLoopInfo.h b/mlir/include/mlir/Analysis/CFGLoopInfo.h
index 41e75021942c6..15ac0d71cb94d 100644
--- a/mlir/include/mlir/Analysis/CFGLoopInfo.h
+++ b/mlir/include/mlir/Analysis/CFGLoopInfo.h
@@ -49,8 +49,6 @@ class CFGLoopInfo : public llvm::LoopInfoBase<mlir::Block, mlir::CFGLoop> {
CFGLoopInfo(const llvm::DominatorTreeBase<mlir::Block, false> &domTree);
};
-raw_ostream &operator<<(raw_ostream &os, mlir::Block &block);
-
} // namespace mlir
#endif // MLIR_ANALYSIS_LOOPINFO_H
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index c14e9aad8f6d1..e4fddfcb7608e 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -18,6 +18,7 @@
namespace llvm {
class BitVector;
+class raw_ostream;
} // namespace llvm
namespace mlir {
@@ -401,6 +402,8 @@ class Block : public IRObjectWithUseList<BlockOperand>,
friend struct llvm::ilist_traits<Block>;
};
+
+raw_ostream &operator<<(raw_ostream &, Block &);
} // namespace mlir
#endif // MLIR_IR_BLOCK_H
diff --git a/mlir/lib/Analysis/CFGLoopInfo.cpp b/mlir/lib/Analysis/CFGLoopInfo.cpp
index 785f6c05d76e6..9fe220344dcea 100644
--- a/mlir/lib/Analysis/CFGLoopInfo.cpp
+++ b/mlir/lib/Analysis/CFGLoopInfo.cpp
@@ -23,8 +23,3 @@ CFGLoopInfo::CFGLoopInfo(
const llvm::DominatorTreeBase<mlir::Block, false> &domTree) {
analyze(domTree);
}
-
-raw_ostream &mlir::operator<<(raw_ostream &os, mlir::Block &block) {
- block.print(os);
- return os;
-}
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 9a5c51ba738f9..29e36210f1270 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -3984,6 +3984,11 @@ void Block::printAsOperand(raw_ostream &os, AsmState &state) {
printer.printBlockName(this);
}
+raw_ostream &mlir::operator<<(raw_ostream &os, Block &block) {
+ block.print(os);
+ return os;
+}
+
//===--------------------------------------------------------------------===//
// Custom printers
//===--------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list