[Mlir-commits] [mlir] [mlir][Transform] Extend transform.foreach to take multiple arguments (PR #93705)
Rolf Morel
llvmlistbot at llvm.org
Fri Jun 7 03:41:14 PDT 2024
================
@@ -1474,14 +1511,27 @@ transform::YieldOp transform::ForeachOp::getYieldOp() {
}
LogicalResult transform::ForeachOp::verify() {
- auto yieldOp = getYieldOp();
- if (getNumResults() != yieldOp.getNumOperands())
- return emitOpError() << "expects the same number of results as the "
- "terminator has operands";
- for (Value v : yieldOp.getOperands())
- if (!llvm::isa<TransformHandleTypeInterface>(v.getType()))
- return yieldOp->emitOpError("expects operands to have types implementing "
- "TransformHandleTypeInterface");
+ for (auto [targetOpt, bodyArgOpt] :
+ llvm::zip_longest(getTargets(), getBody().front().getArguments())) {
+ if (!targetOpt || !bodyArgOpt)
+ return emitOpError() << "expects the same number of targets as the body "
+ "has block arguments";
+ if (targetOpt.value().getType() != bodyArgOpt.value().getType())
+ return emitOpError(
+ "expects co-indexed targets and the body's "
+ "block arguments to have the same op/value/param type");
+ }
+
+ for (auto [resultOpt, yieldOperandOpt] :
+ llvm::zip_longest(getResults(), getYieldOp().getOperands())) {
+ if (!resultOpt || !yieldOperandOpt)
+ return emitOpError() << "expects the same number of results as the "
+ "yield terminator has operands";
+ if (resultOpt.value().getType() != yieldOperandOpt.value().getType())
+ return emitOpError("expects co-indexed results and yield "
+ "operands to have the same op/value/param type");
+ }
----------------
rolfmorel wrote:
Done.
https://github.com/llvm/llvm-project/pull/93705
More information about the Mlir-commits
mailing list