Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,11 @@ def OpenACC_LoopOp : OpenACC_Op<"loop",
/// Used to retrieve the block inside the op's region.
Block &getBody() { return getLoopRegions().front()->front(); }

/// Used to determine if this operation is merely a container for a loop
/// operation instead of being loop-like itself.
bool isLoopLike() { return !getLowerbound().empty(); }
bool isContainerLike() { return !isLoopLike(); }

/// Return true if the op has the auto attribute for the
/// mlir::acc::DeviceType::None device_type.
bool hasAuto();
Expand Down
17 changes: 17 additions & 0 deletions mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,14 @@ LogicalResult checkDeviceTypes(mlir::ArrayAttr deviceTypes) {
}

LogicalResult acc::LoopOp::verify() {
if (getUpperbound().size() != getStep().size())
return emitError() << "number of upperbounds expected to be the same as "
"number of steps";

if (getUpperbound().size() != getLowerbound().size())
return emitError() << "number of upperbounds expected to be the same as "
"number of lowerbounds";

if (!getUpperbound().empty() && getInclusiveUpperbound() &&
(getUpperbound().size() != getInclusiveUpperbound()->size()))
return emitError() << "inclusiveUpperbound size is expected to be the same"
Expand Down Expand Up @@ -2415,6 +2423,15 @@ LogicalResult acc::LoopOp::verify() {
if (getRegion().empty())
return emitError("expected non-empty body.");

// When it is container-like - it is expected to hold a loop-like operation.
// TODO: Get the collapse attribute into account.
if (isContainerLike()) {
// TODO: Ensure there is a single loop-like operation at any one level.
auto loopLikeOps = getRegion().getOps<LoopLikeOpInterface>();
if (loopLikeOps.empty())
return emitError("expected to hold a loop-like operation.");
}

return success();
}

Expand Down
Loading