[mlir] Add support for ops with regions in 'gpu-async-region' rewriter.

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D101757
This commit is contained in:
Christian Sigg 2021-05-05 20:06:37 +02:00
parent 0fdce16efb
commit a0d019fc89
1 changed files with 6 additions and 3 deletions

View File

@ -78,8 +78,6 @@ private:
if (asyncOp.getAsyncToken())
// TODO: Support ops that are already async.
return op->emitOpError("is already async");
if (op->getNumRegions() > 0)
return op->emitOpError("regions are not supported");
auto tokenType = builder.getType<gpu::AsyncTokenType>();
@ -96,7 +94,12 @@ private:
resultTypes.push_back(tokenType);
auto *newOp = Operation::create(op->getLoc(), op->getName(), resultTypes,
op->getOperands(), op->getAttrDictionary(),
op->getSuccessors());
op->getSuccessors(), op->getNumRegions());
// Clone regions into new op.
BlockAndValueMapping mapping;
for (auto pair : llvm::zip_first(op->getRegions(), newOp->getRegions()))
std::get<0>(pair).cloneInto(&std::get<1>(pair), mapping);
// Replace the op with the async clone.
auto results = newOp->getResults();