diff options
author | Peter Klausler <pklausler@nvidia.com> | 2023-05-06 15:03:39 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2023-05-31 09:48:59 -0700 |
commit | 4ad7279392653c0bcf564799ffb3f7e20ed4ef00 (patch) | |
tree | 229d523e46e3b4d297b9d6692bb8b3171d384e9e /flang/lib/Common | |
parent | 5a0108947c470a19b5cef25b084677b0dda8d8c3 (diff) | |
download | llvm-4ad7279392653c0bcf564799ffb3f7e20ed4ef00.zip llvm-4ad7279392653c0bcf564799ffb3f7e20ed4ef00.tar.gz llvm-4ad7279392653c0bcf564799ffb3f7e20ed4ef00.tar.bz2 |
[flang] CUDA Fortran - part 1/5: parsing
Begin upstreaming of CUDA Fortran support in LLVM Flang.
This first patch implements parsing for CUDA Fortran syntax,
including:
- a new LanguageFeature enum value for CUDA Fortran
- driver change to enable that feature for *.cuf and *.CUF source files
- parse tree representation of CUDA Fortran syntax
- dumping and unparsing of the parse tree
- the actual parsers for CUDA Fortran syntax
- prescanning support for !@CUF and !$CUF
- basic sanity testing via unparsing and parse tree dumps
... along with any minimized changes elsewhere to make these
work, mostly no-op cases in common::visitors instances in
semantics and lowering to allow them to compile in the face
of new types in variant<> instances in the parse tree.
Because CUDA Fortran allows the kernel launch chevron syntax
("call foo<<<blocks, threads>>>()") only on CALL statements and
not on function references, the parse tree nodes for CallStmt,
FunctionReference, and their shared Call were rearranged a bit;
this caused a fair amount of one-line changes in many files.
More patches will follow that implement CUDA Fortran in the symbol
table and name resolution, and then semantic checking.
Differential Revision: https://reviews.llvm.org/D150159
Diffstat (limited to 'flang/lib/Common')
-rw-r--r-- | flang/lib/Common/Fortran.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/flang/lib/Common/Fortran.cpp b/flang/lib/Common/Fortran.cpp index e8d8fef..27ff31e 100644 --- a/flang/lib/Common/Fortran.cpp +++ b/flang/lib/Common/Fortran.cpp @@ -97,4 +97,23 @@ std::string AsFortran(IgnoreTKRSet tkr) { return result; } +bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x, + std::optional<CUDADataAttr> y, IgnoreTKRSet ignoreTKR) { + if (!x && !y) { + return true; + } else if (x && y && *x == *y) { + return true; + } else if (ignoreTKR.test(IgnoreTKR::Device) && + x.value_or(CUDADataAttr::Device) == CUDADataAttr::Device && + y.value_or(CUDADataAttr::Device) == CUDADataAttr::Device) { + return true; + } else if (ignoreTKR.test(IgnoreTKR::Managed) && + x.value_or(CUDADataAttr::Managed) == CUDADataAttr::Managed && + y.value_or(CUDADataAttr::Managed) == CUDADataAttr::Managed) { + return true; + } else { + return false; + } +} + } // namespace Fortran::common |