Skip to content

Commit 67dfe9c

Browse files
Vladislav Vinogradovjoker-eph
authored andcommitted
[mlir] Return new Operation from Rewriter::replaceOpWithNewOp
It will allow to perform additional manipulation with the newly created Operation. For example, custom attributes propagation/changes. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D95525
1 parent 39047f6 commit 67dfe9c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/include/mlir/IR/PatternMatch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,10 @@ class PatternRewriter : public OpBuilder, public OpBuilder::Listener {
480480
/// Replaces the result op with a new op that is created without verification.
481481
/// The result values of the two ops must be the same types.
482482
template <typename OpTy, typename... Args>
483-
void replaceOpWithNewOp(Operation *op, Args &&... args) {
483+
OpTy replaceOpWithNewOp(Operation *op, Args &&... args) {
484484
auto newOp = create<OpTy>(op->getLoc(), std::forward<Args>(args)...);
485485
replaceOpWithResultsOfAnotherOp(op, newOp.getOperation());
486+
return newOp;
486487
}
487488

488489
/// This method erases an operation that is known to have no uses.

0 commit comments

Comments
 (0)