Skip to content

Commit 48279f3

Browse files
[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`.
1 parent d7a43a0 commit 48279f3

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
@@ -634,11 +634,13 @@ class RewriterBase : public OpBuilder {
634634
/// Find uses of `from` and replace them with `to`. Also notify the listener
635635
/// about every in-place op modification (for every use that was replaced).
636636
void replaceAllUsesWith(Value from, Value to) {
637-
return replaceAllUsesWith(from.getImpl(), to);
637+
for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {
638+
Operation *op = operand.getOwner();
639+
modifyOpInPlace(op, [&]() { operand.set(to); });
640+
}
638641
}
639-
template <typename OperandType, typename ValueT>
640-
void replaceAllUsesWith(IRObjectWithUseList<OperandType> *from, ValueT &&to) {
641-
for (OperandType &operand : llvm::make_early_inc_range(from->getUses())) {
642+
void replaceAllUsesWith(Block *from, Block *to) {
643+
for (BlockOperand &operand : llvm::make_early_inc_range(from->getUses())) {
642644
Operation *op = operand.getOwner();
643645
modifyOpInPlace(op, [&]() { operand.set(to); });
644646
}

0 commit comments

Comments
 (0)