Skip to content

Commit

Permalink
[flang][NFC] Reorganize directive output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
clementval committed Aug 4, 2023
1 parent 4f85136 commit 68f3610
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions flang/lib/Semantics/mod-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)) {
Expand All @@ -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)} {}
Expand Down

0 comments on commit 68f3610

Please sign in to comment.