[Mlir-commits] [mlir] [mlir][Transform] Extend transform.foreach to take multiple arguments (PR #93705)
Rolf Morel
llvmlistbot at llvm.org
Thu May 30 09:45:52 PDT 2024
================
@@ -1474,14 +1538,33 @@ 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";
+ auto target = targetOpt.value();
+ if (target.getType() != bodyArgOpt.value().getType() ||
+ !isa<TransformHandleTypeInterface, TransformValueHandleTypeInterface,
+ TransformParamTypeInterface>(target.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";
+ auto result = resultOpt.value();
+ if (result.getType() != yieldOperandOpt.value().getType() ||
+ !isa<TransformHandleTypeInterface, TransformValueHandleTypeInterface,
----------------
rolfmorel wrote:
Same as above.
https://github.com/llvm/llvm-project/pull/93705
More information about the Mlir-commits
mailing list