[clang] [CIR][OpenMP] Implementing part of the lowering for the 'default' clause for the 'parallel' directive (PR #235537)

Pedro da Rosa Pinheiro via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 15:24:30 PST 2026


================
@@ -190,3 +176,41 @@ bool OpenMPClauseEmitter::emitMap(
   }
   return found;
 }
+
+bool OpenMPClauseEmitter::emitNumThreads(
+    mlir::omp::NumThreadsClauseOps &result) const {
+  for (const OMPClause *clause : clauses) {
+    const auto *ntc = dyn_cast<OMPNumThreadsClause>(clause);
+    if (!ntc)
+      continue;
+
+    for (const Expr *expr : ntc->getNumThreads()) {
+      mlir::Value numThreadsValue = cgf.emitScalarExpr(expr);
+      auto intType = builder.getIntegerType(32);
+      numThreadsValue = builder.createBuiltinIntCast(numThreadsValue, intType);
----------------
pedropiin wrote:

Yess it is by the third `num_threads_parallel` case in `parallel.c`. The test checks against 
```
// CHECK-NEXT: %[[NUM_THREADS_PTR:.*]] = cir.load align(4) %[[NUM_THREADS_ADDR]]
// CHECK-NEXT: %[[NUM_THREADS_I32:.*]] = cir.builtin_int_cast %[[NUM_THREADS_PTR]]
```

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


More information about the cfe-commits mailing list