aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/LangOptions.cpp
diff options
context:
space:
mode:
authorJustas Janickas <Justas.Janickas@arm.com>2021-08-24 11:59:42 +0100
committerJustas Janickas <Justas.Janickas@arm.com>2021-08-31 10:08:38 +0100
commitf9bc1b3bee557de5735c745f9558c47ca568bd96 (patch)
treec220ebdefbf7a73d4d28782b930a44220f1457d8 /clang/lib/Basic/LangOptions.cpp
parentc1184ca6eb97e0ac5f7b6cdcc99e3905d27f9d95 (diff)
downloadllvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.zip
llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.gz
llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.bz2
[OpenCL] Defines helper function for kernel language compatible OpenCL version
This change defines a helper function getOpenCLCompatibleVersion() inside LangOptions class. The function contains mapping between C++ for OpenCL versions and their corresponding compatible OpenCL versions. This mapping function should be updated each time a new C++ for OpenCL language version is introduced. The helper function is expected to simplify conditions on OpenCL C and C++ for OpenCL versions inside compiler code. Code refactoring performed. Differential Revision: https://reviews.llvm.org/D108693
Diffstat (limited to 'clang/lib/Basic/LangOptions.cpp')
-rw-r--r--clang/lib/Basic/LangOptions.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 3e3e7fe3..b6dc73d 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -52,6 +52,16 @@ VersionTuple LangOptions::getOpenCLVersionTuple() const {
return VersionTuple(Ver / 100, (Ver % 100) / 10);
}
+unsigned LangOptions::getOpenCLCompatibleVersion() const {
+ if (!OpenCLCPlusPlus)
+ return OpenCLVersion;
+ if (OpenCLCPlusPlusVersion == 100)
+ return 200;
+ if (OpenCLCPlusPlusVersion == 202100)
+ return 300;
+ llvm_unreachable("Unknown OpenCL version");
+}
+
void LangOptions::remapPathPrefix(SmallString<256> &Path) const {
for (const auto &Entry : MacroPrefixMap)
if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))