aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/mod-file.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2023-05-06 15:03:39 -0700
committerPeter Klausler <pklausler@nvidia.com>2023-05-31 10:19:32 -0700
commit27f71807dadbf4da1b6981c653f960b3f18d94e0 (patch)
treeeb7423336bd03eb33a7b5ca973400f18c7b6e99a /flang/lib/Semantics/mod-file.cpp
parentf3b39ceaf535af142f392720b86952bcefe9f314 (diff)
downloadllvm-27f71807dadbf4da1b6981c653f960b3f18d94e0.zip
llvm-27f71807dadbf4da1b6981c653f960b3f18d94e0.tar.gz
llvm-27f71807dadbf4da1b6981c653f960b3f18d94e0.tar.bz2
[flang] CUDA Fortran - part 2/5: symbols & scopes
Add representations of CUDA Fortran data and subprogram attributes to the symbol table and scopes of semantics. Set them in name resolution, and emit them to module files. Depends on https://reviews.llvm.org/D150159. Differential Revision: https://reviews.llvm.org/D150161
Diffstat (limited to 'flang/lib/Semantics/mod-file.cpp')
-rw-r--r--flang/lib/Semantics/mod-file.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 8ff4469..1ed4e2e 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -457,6 +457,31 @@ void ModFileWriter::PutSubprogram(const Symbol &symbol) {
os << (isAbstract ? "abstract " : "") << "interface\n";
}
PutAttrs(os, prefixAttrs, nullptr, false, ""s, " "s);
+ if (auto attrs{details.cudaSubprogramAttrs()}) {
+ if (*attrs == common::CUDASubprogramAttrs::HostDevice) {
+ os << "attributes(host,device) ";
+ } else {
+ PutLower(os << "attributes(", common::EnumToString(*attrs)) << ") ";
+ }
+ if (!details.cudaLaunchBounds().empty()) {
+ os << "launch_bounds";
+ char sep{'('};
+ for (auto x : details.cudaLaunchBounds()) {
+ os << sep << x;
+ sep = ',';
+ }
+ os << ") ";
+ }
+ if (!details.cudaClusterDims().empty()) {
+ os << "cluster_dims";
+ char sep{'('};
+ for (auto x : details.cudaClusterDims()) {
+ os << sep << x;
+ sep = ',';
+ }
+ os << ") ";
+ }
+ }
os << (details.isFunction() ? "function " : "subroutine ");
os << symbol.name() << '(';
int n = 0;
@@ -710,6 +735,10 @@ void ModFileWriter::PutObjectEntity(
});
os << ") " << symbol.name() << '\n';
}
+ if (auto attr{details.cudaDataAttr()}) {
+ PutLower(os << "attributes(", common::EnumToString(*attr))
+ << ") " << symbol.name() << '\n';
+ }
}
void ModFileWriter::PutProcEntity(llvm::raw_ostream &os, const Symbol &symbol) {
@@ -990,6 +1019,7 @@ Scope *ModFileReader::Read(const SourceName &name,
options.isModuleFile = true;
options.features.Enable(common::LanguageFeature::BackslashEscapes);
options.features.Enable(common::LanguageFeature::OpenMP);
+ options.features.Enable(common::LanguageFeature::CUDA);
if (!isIntrinsic.value_or(false) && !notAModule) {
// The search for this module file will scan non-intrinsic module
// directories. If a directory is in both the intrinsic and non-intrinsic