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/Parser/preprocessor.cpp | |
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/Parser/preprocessor.cpp')
-rw-r--r-- | flang/lib/Parser/preprocessor.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp index 6dea129..1efe21a 100644 --- a/flang/lib/Parser/preprocessor.cpp +++ b/flang/lib/Parser/preprocessor.cpp @@ -622,11 +622,12 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner &prescanner) { TokenSequence braced{dir, j + 1, k - j - 1}; include = braced.ToString(); j = k; - } else if ((include = dir.TokenAt(j).ToString()).substr(0, 1) == "\"" && - include.substr(include.size() - 1, 1) == "\"") { // #include "foo" + } else if (((include = dir.TokenAt(j).ToString()).substr(0, 1) == "\"" || + include.substr(0, 1) == "'") && + include.substr(include.size() - 1, 1) == include.substr(0, 1)) { + // #include "foo" and #include 'foo' include = include.substr(1, include.size() - 2); - // #include "foo" starts search in directory of file containing - // the directive + // Start search in directory of file containing the directive auto prov{dir.GetTokenProvenanceRange(dirOffset).start()}; if (const auto *currentFile{allSources_.GetSourceFile(prov)}) { prependPath = DirectoryName(currentFile->path()); |