[flang-commits] [flang] 68f3610 - [flang][NFC] Reorganize directive output

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Fri Aug 4 14:43:02 PDT 2023


Author: Valentin Clement
Date: 2023-08-04T14:42:57-07:00
New Revision: 68f36106c79c261cd3c2bf69f027e63da26034fd

URL: https://github.com/llvm/llvm-project/commit/68f36106c79c261cd3c2bf69f027e63da26034fd
DIFF: https://github.com/llvm/llvm-project/commit/68f36106c79c261cd3c2bf69f027e63da26034fd.diff

LOG: [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

Added: 
    

Modified: 
    flang/lib/Semantics/mod-file.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 7b15ce5f3bfcb9..48226738ba24d1 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)} {}


        


More information about the flang-commits mailing list