Skip to content

Commit 68f3610

Browse files
committed
[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
1 parent 4f85136 commit 68f3610

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Diff for: flang/lib/Semantics/mod-file.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ void ModFileWriter::PutSymbol(
331331
[&](const auto &) {
332332
PutEntity(decls_, symbol);
333333
PutDirective(decls_, symbol);
334-
if (symbol.test(Symbol::Flag::OmpThreadprivate)) {
335-
decls_ << "!$omp threadprivate(" << symbol.name() << ")\n";
336-
}
337334
},
338335
},
339336
symbol.details());
@@ -875,7 +872,7 @@ llvm::raw_ostream &PutLower(llvm::raw_ostream &os, std::string_view str) {
875872
return os;
876873
}
877874

878-
void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
875+
void PutOpenACCDirective(llvm::raw_ostream &os, const Symbol &symbol) {
879876
if (symbol.test(Symbol::Flag::AccDeclare)) {
880877
os << "!$acc declare ";
881878
if (symbol.test(Symbol::Flag::AccCopy)) {
@@ -899,6 +896,17 @@ void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
899896
}
900897
}
901898

899+
void PutOpenMPDirective(llvm::raw_ostream &os, const Symbol &symbol) {
900+
if (symbol.test(Symbol::Flag::OmpThreadprivate)) {
901+
os << "!$omp threadprivate(" << symbol.name() << ")\n";
902+
}
903+
}
904+
905+
void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) {
906+
PutOpenACCDirective(os, symbol);
907+
PutOpenMPDirective(os, symbol);
908+
}
909+
902910
struct Temp {
903911
Temp(int fd, std::string path) : fd{fd}, path{path} {}
904912
Temp(Temp &&t) : fd{std::exchange(t.fd, -1)}, path{std::move(t.path)} {}

0 commit comments

Comments
 (0)