aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/mod-file.cpp
diff options
context:
space:
mode:
authorValentin Clement <clementval@gmail.com>2023-08-04 14:42:38 -0700
committerValentin Clement <clementval@gmail.com>2023-08-04 14:42:57 -0700
commit68f36106c79c261cd3c2bf69f027e63da26034fd (patch)
tree44c687784d5dd9e482e8d2c0d104a0ec60471db7 /flang/lib/Semantics/mod-file.cpp
parent4f851361e47475817e4aa04d3bc68d30144d239d (diff)
downloadllvm-68f36106c79c261cd3c2bf69f027e63da26034fd.zip
llvm-68f36106c79c261cd3c2bf69f027e63da26034fd.tar.gz
llvm-68f36106c79c261cd3c2bf69f027e63da26034fd.tar.bz2
[flang][NFC] Reorganize directive output
OpenACC and OpenMP directive are emitted in the module file. Just reorganized the code so this is well separated and do not pollute the main Fortran part. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D157143
Diffstat (limited to 'flang/lib/Semantics/mod-file.cpp')
-rw-r--r--flang/lib/Semantics/mod-file.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 7b15ce5..4822673 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -331,9 +331,6 @@ void ModFileWriter::PutSymbol(
[&](const auto &) {
PutEntity(decls_, symbol);
PutDirective(decls_, symbol);
- if (symbol.test(Symbol::Flag::OmpThreadprivate)) {
- decls_ << "!$omp threadprivate(" << symbol.name() << ")\n";
- }
},
},
symbol.details());
@@ -875,7 +872,7 @@ llvm::raw_ostream &PutLower(llvm::raw_ostream &os, std::string_view str) {
return os;
}
-void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
+void PutOpenACCDirective(llvm::raw_ostream &os, const Symbol &symbol) {
if (symbol.test(Symbol::Flag::AccDeclare)) {
os << "!$acc declare ";
if (symbol.test(Symbol::Flag::AccCopy)) {
@@ -899,6 +896,17 @@ void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
}
}
+void PutOpenMPDirective(llvm::raw_ostream &os, const Symbol &symbol) {
+ if (symbol.test(Symbol::Flag::OmpThreadprivate)) {
+ os << "!$omp threadprivate(" << symbol.name() << ")\n";
+ }
+}
+
+void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
+ PutOpenACCDirective(os, symbol);
+ PutOpenMPDirective(os, symbol);
+}
+
struct Temp {
Temp(int fd, std::string path) : fd{fd}, path{path} {}
Temp(Temp &&t) : fd{std::exchange(t.fd, -1)}, path{std::move(t.path)} {}