@@ -320,8 +320,9 @@ bool CodeGenAction::beginSourceFileAction() {
320320 // Add OpenMP-related passes
321321 // WARNING: These passes must be run immediately after the lowering to ensure
322322 // that the FIR is correct with respect to OpenMP operations/attributes.
323- if (ci.getInvocation ().getFrontendOpts ().features .IsEnabled (
324- Fortran::common::LanguageFeature::OpenMP)) {
323+ bool isOpenMPEnabled = ci.getInvocation ().getFrontendOpts ().features .IsEnabled (
324+ Fortran::common::LanguageFeature::OpenMP);
325+ if (isOpenMPEnabled) {
325326 bool isDevice = false ;
326327 if (auto offloadMod = llvm::dyn_cast<mlir::omp::OffloadModuleInterface>(
327328 mlirModule->getOperation ()))
@@ -332,6 +333,30 @@ bool CodeGenAction::beginSourceFileAction() {
332333 fir::createOpenMPFIRPassPipeline (pm, isDevice);
333334 }
334335
336+ using DoConcurrentMappingKind =
337+ Fortran::frontend::CodeGenOptions::DoConcurrentMappingKind;
338+ DoConcurrentMappingKind selectedKind = ci.getInvocation ().getCodeGenOpts ().getDoConcurrentMapping ();
339+ if (selectedKind != DoConcurrentMappingKind::DCMK_None) {
340+ if (!isOpenMPEnabled) {
341+ unsigned diagID = ci.getDiagnostics ().getCustomDiagID (
342+ clang::DiagnosticsEngine::Warning,
343+ " lowering `do concurrent` loops to OpenMP is only supported if "
344+ " OpenMP is enabled" );
345+ ci.getDiagnostics ().Report (diagID);
346+ } else {
347+ bool mapToDevice = selectedKind == DoConcurrentMappingKind::DCMK_Device;
348+
349+ if (mapToDevice) {
350+ unsigned diagID = ci.getDiagnostics ().getCustomDiagID (
351+ clang::DiagnosticsEngine::Warning,
352+ " TODO: lowering `do concurrent` loops to OpenMP device is not "
353+ " supported yet" );
354+ ci.getDiagnostics ().Report (diagID);
355+ } else
356+ pm.addPass (fir::createDoConcurrentConversionPass ());
357+ }
358+ }
359+
335360 pm.enableVerifier (/* verifyPasses=*/ true );
336361 pm.addPass (std::make_unique<Fortran::lower::VerifierPass>());
337362
0 commit comments