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

Krzysztof Parzyszek llvmlistbot at llvm.org
Fri May 17 07:01:12 PDT 2024


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

None

>From db8ac496f9c08e6405a33436ed237c9568c85673 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Fri, 17 May 2024 08:55:38 -0500
Subject: [PATCH] [mlir] Add operator<< for printing `Block`

---
 mlir/include/mlir/IR/Block.h | 3 +++
 mlir/lib/IR/AsmPrinter.cpp   | 5 +++++
 2 files changed, 8 insertions(+)

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



More information about the Mlir-commits mailing list