Skip to content

Commit 9067f54

Browse files
[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`.
1 parent 21f85e2 commit 9067f54

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mlir/include/mlir/IR/PatternMatch.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,13 @@ class RewriterBase : public OpBuilder {
635635
/// Find uses of `from` and replace them with `to`. Also notify the listener
636636
/// about every in-place op modification (for every use that was replaced).
637637
void replaceAllUsesWith(Value from, Value to) {
638-
return replaceAllUsesWith(from.getImpl(), to);
638+
for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {
639+
Operation *op = operand.getOwner();
640+
modifyOpInPlace(op, [&]() { operand.set(to); });
641+
}
639642
}
640-
template <typename OperandType, typename ValueT>
641-
void replaceAllUsesWith(IRObjectWithUseList<OperandType> *from, ValueT &&to) {
642-
for (OperandType &operand : llvm::make_early_inc_range(from->getUses())) {
643+
void replaceAllUsesWith(Block *from, Block *to) {
644+
for (BlockOperand &operand : llvm::make_early_inc_range(from->getUses())) {
643645
Operation *op = operand.getOwner();
644646
modifyOpInPlace(op, [&]() { operand.set(to); });
645647
}

0 commit comments

Comments
 (0)