Skip to content

Commit e70c754

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 7b93ec3 commit e70c754

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
@@ -615,11 +615,13 @@ class RewriterBase : public OpBuilder {
615615
/// Find uses of `from` and replace them with `to`. Also notify the listener
616616
/// about every in-place op modification (for every use that was replaced).
617617
void replaceAllUsesWith(Value from, Value to) {
618-
return replaceAllUsesWith(from.getImpl(), to);
618+
for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {
619+
Operation *op = operand.getOwner();
620+
modifyOpInPlace(op, [&]() { operand.set(to); });
621+
}
619622
}
620-
template <typename OperandType, typename ValueT>
621-
void replaceAllUsesWith(IRObjectWithUseList<OperandType> *from, ValueT &&to) {
622-
for (OperandType &operand : llvm::make_early_inc_range(from->getUses())) {
623+
void replaceAllUsesWith(Block *from, Block *to) {
624+
for (BlockOperand &operand : llvm::make_early_inc_range(from->getUses())) {
623625
Operation *op = operand.getOwner();
624626
modifyOpInPlace(op, [&]() { operand.set(to); });
625627
}

0 commit comments

Comments
 (0)