[flang-commits] [flang] [flang][OpenMP] Lowering for CANCEL and CANCELLATIONPOINT (PR #134248)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri Apr 4 07:16:06 PDT 2025


================
@@ -220,6 +221,38 @@ bool ClauseProcessor::processBind(mlir::omp::BindClauseOps &result) const {
   return false;
 }
 
+bool ClauseProcessor::processCancelDirectiveName(
+    mlir::omp::CancelDirectiveNameClauseOps &result) const {
+  using ConstructType = mlir::omp::ClauseCancellationConstructType;
+  mlir::MLIRContext *context = &converter.getMLIRContext();
+
+  ConstructType directive;
+  if (auto *clause = findUniqueClause<omp::CancellationConstructType>())
+    switch (clause->v) {
+    case llvm::omp::OMP_CANCELLATION_CONSTRUCT_Parallel:
+      directive = mlir::omp::ClauseCancellationConstructType::Parallel;
+      break;
+    case llvm::omp::OMP_CANCELLATION_CONSTRUCT_Loop:
+      directive = mlir::omp::ClauseCancellationConstructType::Loop;
+      break;
+    case llvm::omp::OMP_CANCELLATION_CONSTRUCT_Sections:
+      directive = mlir::omp::ClauseCancellationConstructType::Sections;
+      break;
+    case llvm::omp::OMP_CANCELLATION_CONSTRUCT_Taskgroup:
+      directive = mlir::omp::ClauseCancellationConstructType::Taskgroup;
+      break;
+    case llvm::omp::OMP_CANCELLATION_CONSTRUCT_None:
+      llvm_unreachable("OMP_CANCELLATION_CONSTRUCT_None");
+      break;
+    }
+  else
+    llvm_unreachable("cancel construct missing cancellation construct type");
+
----------------
kiranchandramohan wrote:

Nit: braces for the `if` and else`.

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


More information about the flang-commits mailing list