[Mlir-commits] [mlir] [OpenMP][MLIR] Add num_teams clause with dims modifier support (PR #169883)

Michael Klemm llvmlistbot at llvm.org
Fri Nov 28 08:18:10 PST 2025


================
@@ -4453,6 +4454,68 @@ LogicalResult WorkdistributeOp::verify() {
   return success();
 }
 
+//===----------------------------------------------------------------------===//
+// Parser and printer for NumTeamsMultiDim Clause (with dims modifier)
+//===----------------------------------------------------------------------===//
+// num_teams_multi_dim(dims(3): %v0, %v1, %v2 : i32, i32, i32) Or:
+// num_teams_multi_dim(%v : i32)
+static ParseResult parseNumTeamsMultiDimClause(
+    OpAsmParser &parser, IntegerAttr &dimsAttr,
+    SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
+    SmallVectorImpl<Type> &types) {
+  std::optional<int64_t> dims;
+  // Try to parse optional dims modifier: dims(N):
+  if (succeeded(parser.parseOptionalKeyword("dims"))) {
+    int64_t dimsValue;
+    if (parser.parseLParen() || parser.parseInteger(dimsValue) ||
+        parser.parseRParen() || parser.parseColon()) {
+      return failure();
+    }
+    dims = dimsValue;
+  }
+  // Parse the operand list
+  if (parser.parseOperandList(values))
+    return failure();
+  // Parse colon and types
+  if (parser.parseColon() || parser.parseTypeList(types))
+    return failure();
+
+  // Verify dims matches number of values if specified
+  if (dims.has_value() && values.size() != static_cast<size_t>(*dims)) {
+    return parser.emitError(parser.getCurrentLocation())
+           << "dims(" << *dims << ") specified but " << values.size()
+           << " values provided";
+  }
+
+  // If dims not specified but we have values, it's implicitly unidimensional
+  if (!dims.has_value() && values.size() != 1) {
+    return parser.emitError(parser.getCurrentLocation())
+           << "expected 1 value without dims modifier, got " << values.size();
----------------
mjklemm wrote:

```suggestion
           << "expected 1 value without dims modifier, but got " << values.size() << " values";
```

https://github.com/llvm/llvm-project/pull/169883


More information about the Mlir-commits mailing list