[Mlir-commits] [mlir] [mlir] introduce transform.loop.forall_to_for (PR #65474)
Matthias Springer
llvmlistbot at llvm.org
Wed Sep 6 07:55:37 PDT 2023
================
@@ -64,6 +69,79 @@ transform::GetParentForOp::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}
+//===----------------------------------------------------------------------===//
+// ForallToForOp
+//===----------------------------------------------------------------------===//
+
+DiagnosedSilenceableFailure
+transform::ForallToForOp::apply(transform::TransformRewriter &rewriter,
+ transform::TransformResults &results,
+ transform::TransformState &state) {
+ auto payload = state.getPayloadOps(getTarget());
+ if (!llvm::hasSingleElement(payload)) {
+ return emitSilenceableError() << "expected a single payload op";
+ }
+ auto target = dyn_cast<scf::ForallOp>(*payload.begin());
+ if (!target) {
+ DiagnosedSilenceableFailure diag =
+ emitSilenceableError() << "expected the payload to be scf.forall";
+ diag.attachNote((*payload.begin())->getLoc()) << "payload op";
+ return diag;
+ }
+
+ rewriter.setInsertionPoint(target);
+
+ if (!target.getOutputs().empty()) {
+ return emitSilenceableError()
+ << "unsupported shared outputs (didn't bufferize?)";
+ }
+
+ auto materialize = [](OpBuilder &b, Location loc, OpFoldResult r) -> Value {
----------------
matthias-springer wrote:
You can use `getValueOrCreateConstantIndexOp`.
https://github.com/llvm/llvm-project/pull/65474
More information about the Mlir-commits
mailing list