[flang][openacc] Allow acc routine at the top level (#69936)
Some compilers allow the `$acc routine(<name>)` to be placed at the
program unit level. To be compatible, this patch enables the use of acc
routine at this level. These acc routine directives must have a name.
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index c3afd91..ff31625 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -316,6 +316,7 @@
globalOmpRequiresSymbol = b.symTab.symbol();
},
[&](Fortran::lower::pft::CompilerDirectiveUnit &d) {},
+ [&](Fortran::lower::pft::OpenACCDirectiveUnit &d) {},
},
u);
}
@@ -328,6 +329,14 @@
[&](Fortran::lower::pft::ModuleLikeUnit &m) { lowerMod(m); },
[&](Fortran::lower::pft::BlockDataUnit &b) {},
[&](Fortran::lower::pft::CompilerDirectiveUnit &d) {},
+ [&](Fortran::lower::pft::OpenACCDirectiveUnit &d) {
+ builder = new fir::FirOpBuilder(bridge.getModule(),
+ bridge.getKindMap());
+ Fortran::lower::genOpenACCRoutineConstruct(
+ *this, bridge.getSemanticsContext(), bridge.getModule(),
+ d.routine, accRoutineInfos);
+ builder = nullptr;
+ },
},
u);
}
@@ -2362,6 +2371,10 @@
genFIR(e);
}
+ void genFIR(const Fortran::parser::OpenACCRoutineConstruct &acc) {
+ // Handled by genFIR(const Fortran::parser::OpenACCDeclarativeConstruct &)
+ }
+
void genFIR(const Fortran::parser::OpenMPConstruct &omp) {
mlir::OpBuilder::InsertPoint insertPt = builder->saveInsertionPoint();
localSymbols.pushScope();