[clang] [Clang][OpenMP] Support multidimensional target launch codegen with dims modifier (PR #239860)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 26 15:01:31 PST 2026


================
@@ -6828,46 +6838,54 @@ const Expr *CGOpenMPRuntime::getNumTeamsExprForTargetDirective(
   llvm_unreachable("Unexpected directive kind.");
 }
 
-llvm::Value *CGOpenMPRuntime::emitNumTeamsForTargetDirective(
-    CodeGenFunction &CGF, const OMPExecutableDirective &D) {
+void CGOpenMPRuntime::emitNumTeamsForTargetDirective(
+    CodeGenFunction &CGF, const OMPExecutableDirective &D,
+    llvm::SmallVectorImpl<llvm::Value *> &NumTeamsValues) {
   assert(!CGF.getLangOpts().OpenMPIsTargetDevice &&
          "Clauses associated with the teams directive expected to be emitted "
          "only for the host!");
+  NumTeamsValues.clear();
+
   CGBuilderTy &Bld = CGF.Builder;
-  int32_t MinNT = -1, MaxNT = -1;
-  const Expr *NumTeams =
-      getNumTeamsExprForTargetDirective(CGF, D, MinNT, MaxNT);
-  if (NumTeams != nullptr) {
+  llvm::SmallVector<int32_t> MinNT, MaxNT;
+  auto Exprs = getNumTeamsExprForTargetDirective(CGF, D, MinNT, MaxNT);
+  if (!Exprs.empty()) {
     OpenMPDirectiveKind DirectiveKind = D.getDirectiveKind();
 
     switch (DirectiveKind) {
     case OMPD_target: {
       const auto *CS = D.getInnermostCapturedStmt();
       CGOpenMPInnerExprInfo CGInfo(CGF, *CS);
       CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
-      llvm::Value *NumTeamsVal = CGF.EmitScalarExpr(NumTeams,
-                                                  /*IgnoreResultAssign*/ true);
-      return Bld.CreateIntCast(NumTeamsVal, CGF.Int32Ty,
-                             /*isSigned=*/true);
+      for (const Expr *E : Exprs) {
+        llvm::Value *Val = CGF.EmitScalarExpr(E, /*IgnoreResultAssign*/ true);
+        NumTeamsValues.push_back(
+            Bld.CreateIntCast(Val, CGF.Int32Ty, /*isSigned=*/true));
----------------
alexey-bataev wrote:

All such things shall be in sema

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


More information about the cfe-commits mailing list