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

Jan Leyonberg via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 10:07:51 PDT 2026


================
@@ -30,14 +32,34 @@ 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());
+
+/// Returns the subset of \p s's clauses that are allowed on the given leaf
+/// directive.
+static llvm::SmallVector<const OMPClause *>
+getLeafClauses(CIRGenFunction &cgf, const OMPExecutableDirective &s,
+               llvm::omp::Directive leaf) {
+  unsigned version = cgf.getContext().getLangOpts().OpenMP;
+  llvm::SmallVector<const OMPClause *> result;
+  for (const OMPClause *c : s.clauses())
+    if (llvm::omp::isAllowedClauseForDirective(leaf, c->getClauseKind(),
+                                               version))
+      result.push_back(c);
+  return result;
+}
+
+template <typename DirectiveTy>
+static mlir::LogicalResult
+emitParallelOp(CIRGenFunction &cgf, const DirectiveTy &s, mlir::Location begin,
+               mlir::Location end,
+               llvm::function_ref<mlir::LogicalResult()> emitBody) {
+  CIRGenBuilderTy &builder = cgf.getBuilder();
+  CIRGenModule &cgm = cgf.getCIRGenModule();
+
+  llvm::SmallVector<const OMPClause *> clauses =
----------------
jsjodin wrote:

Okay, I split things up. It is better to do this now rather than later on when there's a lot more code.

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


More information about the cfe-commits mailing list