[llvm-branch-commits] [mlir] [mlir][Transforms] Add 1:N `matchAndRewrite` overload (PR #116470)

Markus Böck via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Nov 16 02:05:54 PST 2024


================
@@ -1733,12 +1819,14 @@ ConversionPattern::matchAndRewrite(Operation *op,
                                              getTypeConverter());
 
   // Remap the operands of the operation.
-  SmallVector<Value, 4> operands;
+  SmallVector<SmallVector<Value>> remapped;
   if (failed(rewriterImpl.remapValues("operand", op->getLoc(), rewriter,
-                                      op->getOperands(), operands))) {
+                                      op->getOperands(), remapped))) {
     return failure();
   }
-  return matchAndRewrite(op, operands, dialectRewriter);
+  SmallVector<ValueRange> remappedAsRange = llvm::map_to_vector(
+      remapped, [](const auto &v) -> ValueRange { return v; });
----------------
zero9178 wrote:

```suggestion
  SmallVector<ValueRange> remappedAsRange = llvm::to_vector_of<ValueRange>(
      remapped);
```

https://github.com/llvm/llvm-project/pull/116470


More information about the llvm-branch-commits mailing list