[clang] [CIR][OpenMP] Add support for combined target parallel directives (PR #207019)

Sergio Afonso via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 07:14:15 PDT 2026


================
@@ -30,49 +33,107 @@ CIRGenFunction::emitOMPErrorDirective(const OMPErrorDirective &s) {
   getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPErrorDirective");
   return mlir::failure();
 }
-mlir::LogicalResult
-CIRGenFunction::emitOMPParallelDirective(const OMPParallelDirective &s) {
-  mlir::LogicalResult res = mlir::success();
-  mlir::Location begin = getLoc(s.getBeginLoc());
-  mlir::Location end = getLoc(s.getEndLoc());
 
-  mlir::omp::ParallelOperands clauseOps;
-  OpenMPClauseEmitter ce(*this, getCIRGenModule(), builder, begin, s.clauses());
+static llvm::SmallVector<const OMPClause *>
+getLeafClauses(CIRGenFunction &cgf, const OMPExecutableDirective &s,
+               llvm::omp::Directive leaf) {
+  unsigned version = cgf.getContext().getLangOpts().OpenMP;
+  llvm::SmallVector<omp::LeafWithClauses> leaves = omp::decompose(version, s);
+
+  llvm::SmallVector<const OMPClause *> result;
+  for (const omp::LeafWithClauses &l : leaves) {
+    if (l.id != leaf)
+      continue;
+    for (llvm::omp::Clause synth : l.synthesized)
+      cgf.getCIRGenModule().errorNYI(s.getSourceRange(),
+                                     (llvm::Twine("OpenMP synthesized '") +
+                                      llvm::omp::getOpenMPClauseName(synth) +
+                                      "' clause from construct decomposition")
+                                         .str());
+    llvm::append_range(result, l.clauses);
+  }
+  return result;
+}
+
+/// True when the op emitted for \p leaf must carry the omp.combined marker.
+static bool leafIsCombined(CIRGenFunction &cgf, const OMPExecutableDirective &s,
----------------
skatrak wrote:

As it's currently implemented, this should also be called for every `emitXyzOp` function for an operation that might be combined, not just `omp.target`.

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


More information about the cfe-commits mailing list