[clang] [OpenMP][CIR] Implement basic 'parallel' lowering + some clause infra (PR #172308)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 16 10:57:29 PST 2025


================
@@ -30,8 +30,35 @@ CIRGenFunction::emitOMPErrorDirective(const OMPErrorDirective &s) {
 }
 mlir::LogicalResult
 CIRGenFunction::emitOMPParallelDirective(const OMPParallelDirective &s) {
-  getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPParallelDirective");
-  return mlir::failure();
+  mlir::LogicalResult res = mlir::success();
+  llvm::SmallVector<mlir::Type> retTy;
+  llvm::SmallVector<mlir::Value> operands;
+  mlir::Location begin = getLoc(s.getBeginLoc());
+  mlir::Location end = getLoc(s.getEndLoc());
+
+  auto parallelOp =
+      mlir::omp::ParallelOp::create(builder, begin, retTy, operands);
+  emitOpenMPClauses(parallelOp, s.clauses());
+
+  {
+    mlir::Block &block = parallelOp.getRegion().emplaceBlock();
+    mlir::OpBuilder::InsertionGuard guardCase(builder);
+    builder.setInsertionPointToEnd(&block);
+
+    LexicalScope ls{*this, begin, builder.getInsertionBlock()};
+
+    if (s.hasCancel())
----------------
erichkeane wrote:

TBH, I didn't even know how to SPELL cancel here, as I'm unfamiliar with OpenMP beyond the very basics.  I just wanted to make sure there was an NYI here to make sure the next person along would know something needed to be done.

However, this note is great for whoever comes along and implements this, so thank you for responding!

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


More information about the cfe-commits mailing list