[Mlir-commits] [mlir] 9067f54 - [mlir][IR][NFC] Make `replaceAllUsesWith` non-templatized (#84722)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 1 19:03:15 PDT 2024
Author: Matthias Springer
Date: 2024-04-02T11:03:12+09:00
New Revision: 9067f5470573454ad33f2d1786cdfa77f7f9329c
URL: https://github.com/llvm/llvm-project/commit/9067f5470573454ad33f2d1786cdfa77f7f9329c
DIFF: https://github.com/llvm/llvm-project/commit/9067f5470573454ad33f2d1786cdfa77f7f9329c.diff
LOG: [mlir][IR][NFC] Make `replaceAllUsesWith` non-templatized (#84722)
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`.
Added:
Modified:
mlir/include/mlir/IR/PatternMatch.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index ac2b0d5a38375a..15b1c38929485e 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -635,11 +635,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