[Mlir-commits] [mlir] 67dfe9c - [mlir] Return new Operation from `Rewriter::replaceOpWithNewOp`

Mehdi Amini llvmlistbot at llvm.org
Tue Feb 2 10:33:23 PST 2021


Author: Vladislav Vinogradov
Date: 2021-02-02T18:33:13Z
New Revision: 67dfe9c8d70c1242c1e91e3bafc710781ac2a585

URL: https://github.com/llvm/llvm-project/commit/67dfe9c8d70c1242c1e91e3bafc710781ac2a585
DIFF: https://github.com/llvm/llvm-project/commit/67dfe9c8d70c1242c1e91e3bafc710781ac2a585.diff

LOG: [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

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 1a306e6ba58c..04904dad32ef 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -480,9 +480,10 @@ class PatternRewriter : public OpBuilder, public OpBuilder::Listener {
   /// Replaces the result op with a new op that is created without verification.
   /// The result values of the two ops must be the same types.
   template <typename OpTy, typename... Args>
-  void replaceOpWithNewOp(Operation *op, Args &&... args) {
+  OpTy replaceOpWithNewOp(Operation *op, Args &&... args) {
     auto newOp = create<OpTy>(op->getLoc(), std::forward<Args>(args)...);
     replaceOpWithResultsOfAnotherOp(op, newOp.getOperation());
+    return newOp;
   }
 
   /// This method erases an operation that is known to have no uses.


        


More information about the Mlir-commits mailing list