[Mlir-commits] [mlir] [mlir][IR][NFC] Make `replaceAllUsesWith` non-templatized (PR #84722)
Matthias Springer
llvmlistbot at llvm.org
Mon Apr 1 18:55:48 PDT 2024
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/84722
>From 48279f39fbc039baaeee8de96e4e7713c845bf47 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Tue, 2 Apr 2024 01:54:46 +0000
Subject: [PATCH] [mlir][IR][NFC] Make `replaceAllUsesWith` non-templatized
Turn `RewriterBase::replaceAllUsesWith` into a non-templatized implementation, so that it can be made virtual and be overridden in the `ConversionPatternRewriter` in a subsequent change.
This change is in preparation of adding dialect conversion support for `replaceAllUsesWith`.
---
mlir/include/mlir/IR/PatternMatch.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 070e6ed702f86a..137408d08092a9 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -634,11 +634,13 @@ class RewriterBase : public OpBuilder {
/// Find uses of `from` and replace them with `to`. Also notify the listener
/// about every in-place op modification (for every use that was replaced).
void replaceAllUsesWith(Value from, Value to) {
- return replaceAllUsesWith(from.getImpl(), to);
+ for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {
+ Operation *op = operand.getOwner();
+ modifyOpInPlace(op, [&]() { operand.set(to); });
+ }
}
- template <typename OperandType, typename ValueT>
- void replaceAllUsesWith(IRObjectWithUseList<OperandType> *from, ValueT &&to) {
- for (OperandType &operand : llvm::make_early_inc_range(from->getUses())) {
+ void replaceAllUsesWith(Block *from, Block *to) {
+ for (BlockOperand &operand : llvm::make_early_inc_range(from->getUses())) {
Operation *op = operand.getOwner();
modifyOpInPlace(op, [&]() { operand.set(to); });
}
More information about the Mlir-commits
mailing list