[Mlir-commits] [mlir] [MLIR][OpenMP] Add omp.simd operation (PR #79843)
Kareem Ergawy
llvmlistbot at llvm.org
Thu Feb 8 06:51:48 PST 2024
================
@@ -1329,7 +1334,34 @@ void WsLoopOp::build(OpBuilder &builder, OperationState &state,
state.addAttributes(attributes);
}
+SimdOp WsLoopOp::getNestedSimd() {
+ auto ops = this->getOps<SimdOp>();
+ assert(std::distance(ops.begin(), ops.end()) <= 1 &&
+ "There can only be a single omp.simd child at most");
+ return ops.empty() ? SimdOp() : *ops.begin();
+}
+
LogicalResult WsLoopOp::verify() {
+ // Check that, if it has an omp.simd child, it must be the only one.
+ bool hasSimd = false, hasOther = false;
+ for (auto &op : this->getOps()) {
+ if (isa<SimdOp>(op)) {
+ if (hasSimd)
+ return emitOpError() << "cannot have multiple 'omp.simd' child ops";
+ hasSimd = true;
+
+ if (hasOther)
+ break;
+ } else if (!op.hasTrait<OpTrait::IsTerminator>()) {
----------------
ergawy wrote:
Does the `omp.wsloop` support other terminators than `omp.yield`? If not, should we verify that it is indeed a `yield`?
https://github.com/llvm/llvm-project/pull/79843
More information about the Mlir-commits
mailing list