[flang-commits] [flang] [llvm] [mlir] [flang][OpenMP][MLIR] Add MLIR op for loop directive (PR #113911)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Oct 31 08:26:00 PDT 2024
================
@@ -1948,6 +1948,29 @@ LogicalResult LoopWrapperInterface::verifyImpl() {
return success();
}
+//===----------------------------------------------------------------------===//
+// LoopOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult LoopOp::verify() {
+ return verifyReductionVarList(*this, getReductionSyms(), getReductionVars(),
+ getReductionByref());
+}
+
+LogicalResult LoopOp::verifyRegions() {
+ Region ®ion = getRegion();
+
+ // Minimal amount of checks to verify the only nested op is an
+ // `omp.loop_nest`. A more extensive vierfication is done by the
+ // `LoopWrapperInterface` trait but the difference is that `omp.loop` cannot
+ // have another nested `LoopWrapperInterface`.
+ if (range_size(region.getOps()) != 1 || !isa<LoopNestOp>(*region.op_begin()))
+ return emitError() << "`omp.loop` expected to have a single nested "
+ "operation which is a `omp.loop_nest`";
----------------
skatrak wrote:
Since the `LoopWrapperInterface` verifier has already checked that the operation has a single nested loop wrapper or `omp.loop_nest` child by this point, I think here we should probably make a slightly different check:
```suggestion
if (llvm::isa_and_nonnull<LoopWrapperInterface>((*this)->getParentOp()) || getNestedWrapper())
return emitError() << "`omp.loop` expected to be a standalone loop wrapper";
```
https://github.com/llvm/llvm-project/pull/113911
More information about the flang-commits
mailing list