aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/IdentifierTable.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2021-04-23 08:22:35 -0700
committerErich Keane <erich.keane@intel.com>2021-05-27 07:12:20 -0700
commiteba69b59d1a30dead07da2c279c8ecfd2b62ba9f (patch)
treedf24fabb423576b4a9a86173b65a9af0e7a4f061 /clang/lib/Basic/IdentifierTable.cpp
parentcaf86d2959d5e900ed29af5e0ae2be23e3d299c5 (diff)
downloadllvm-eba69b59d1a30dead07da2c279c8ecfd2b62ba9f.zip
llvm-eba69b59d1a30dead07da2c279c8ecfd2b62ba9f.tar.gz
llvm-eba69b59d1a30dead07da2c279c8ecfd2b62ba9f.tar.bz2
Reimplement __builtin_unique_stable_name-
The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution. This implements a builtin to provide a unique name that is stable across compilations of this TU for the purposes of implementing the library component of the unnamed kernel feature of SYCL. It does this by running the Itanium mangler with a few modifications. Because it is somewhat common to wrap non-kernel-related lambdas in macros that aren't present on the device (such as for logging), this uniquely generates an ID for all lambdas involved in the naming of a kernel. It uses the lambda-mangling number to do this, except replaces this with its own number (starting at 10000 for readabililty reasons) for lambdas used to name a kernel. Additionally, this implements itself as constexpr with a slight catch: if a name would be invalidated by the use of this lambda in a later kernel invocation, it is diagnosed as an error (see the Sema tests). Differential Revision: https://reviews.llvm.org/D103112
Diffstat (limited to 'clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r--clang/lib/Basic/IdentifierTable.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index 3c18219..dafacaf 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -107,8 +107,9 @@ namespace {
KEYCXX20 = 0x200000,
KEYOPENCLCXX = 0x400000,
KEYMSCOMPAT = 0x800000,
+ KEYSYCL = 0x1000000,
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
- KEYALL = (0xffffff & ~KEYNOMS18 &
+ KEYALL = (0xfffffff & ~KEYNOMS18 &
~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
};
@@ -155,6 +156,8 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
if (LangOpts.CPlusPlus && (Flags & KEYALLCXX)) return KS_Future;
if (LangOpts.CPlusPlus && !LangOpts.CPlusPlus20 && (Flags & CHAR8SUPPORT))
return KS_Future;
+ if (LangOpts.isSYCL() && (Flags & KEYSYCL))
+ return KS_Enabled;
return KS_Disabled;
}