[Mlir-commits] [mlir] [mlir] Add operator<< for printing `Block` (PR #92550)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri May 17 07:01:46 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Krzysztof Parzyszek (kparzysz)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/92550.diff


2 Files Affected:

- (modified) mlir/include/mlir/IR/Block.h (+3) 
- (modified) mlir/lib/IR/AsmPrinter.cpp (+5) 


``````````diff
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/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
 //===--------------------------------------------------------------------===//

``````````

</details>


https://github.com/llvm/llvm-project/pull/92550


More information about the Mlir-commits mailing list