================
@@ -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())
----------------
tblah wrote:

Cancel is fully supported by flang so for things like this you could try a 
minimal fortran code example (generative AI can do this reliably in my 
experience) with flang.

e.g. `flang -fc1 -fopenmp -emit-hlfir file.f90 -o -`.

You can find flang's tests for this sort of thing in 
`flang/test/Lower/OpenMP/*`. For example, the cancel test should make it clear 
what we generate for this 
https://github.com/llvm/llvm-project/blob/13f7b308d23bb4597e8f618a54af0114dc2d636c/flang/test/Lower/OpenMP/cancel.f90#L4

If anything is unclear, please feel free to ping me or get in touch and I'll do 
my best to explain. 

https://github.com/llvm/llvm-project/pull/172308
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to