summaryrefslogtreecommitdiff
path: root/mlir/lib/IR
diff options
context:
space:
mode:
authorMatthias Springer <springerm@google.com>2023-02-22 10:41:22 +0100
committerMatthias Springer <springerm@google.com>2023-02-22 10:41:57 +0100
commitbafc4dfc764587de577a354e459ea351b43fdb43 (patch)
tree1777d15b835492574e3fba8704238b06e8c41194 /mlir/lib/IR
parent93d640f3922b2a15501101b229f8be40e8528a63 (diff)
downloadllvm-bafc4dfc764587de577a354e459ea351b43fdb43.tar.gz
[mlir] RewriterBase::Listener: Add notifyOperationModified callback
This callback is triggered by `finalizeRootUpdate`. This allows listeners to listen for in-place op modifications without creating a new RewriterBase subclass. Differential Revision: https://reviews.llvm.org/D143380
Diffstat (limited to 'mlir/lib/IR')
-rw-r--r--mlir/lib/IR/PatternMatch.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 10baea61d9a4..958d82ae5bcb 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -294,6 +294,12 @@ void RewriterBase::eraseBlock(Block *block) {
block->erase();
}
+void RewriterBase::finalizeRootUpdate(Operation *op) {
+ // Notify the listener that the operation was modified.
+ if (auto *rewriteListener = dyn_cast_if_present<Listener>(listener))
+ rewriteListener->notifyOperationModified(op);
+}
+
/// Merge the operations of block 'source' into the end of block 'dest'.
/// 'source's predecessors must be empty or only contain 'dest`.
/// 'argValues' is used to replace the block arguments of 'source' after