aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/AddressSpaces.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
commit461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch)
tree6942083d7d56bba40ec790a453ca58ad3baf6832 /include/clang/Basic/AddressSpaces.h
parent75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff)
Vendor import of clang trunk r321017:vendor/clang/clang-trunk-r321017
Notes
Notes: svn path=/vendor/clang/dist/; revision=326941 svn path=/vendor/clang/clang-trunk-r321017/; revision=326942; tag=vendor/clang/clang-trunk-r321017
Diffstat (limited to 'include/clang/Basic/AddressSpaces.h')
-rw-r--r--include/clang/Basic/AddressSpaces.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/include/clang/Basic/AddressSpaces.h b/include/clang/Basic/AddressSpaces.h
index 95b9b9c7d0b3..6b0090813e9b 100644
--- a/include/clang/Basic/AddressSpaces.h
+++ b/include/clang/Basic/AddressSpaces.h
@@ -16,25 +16,26 @@
#ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
#define LLVM_CLANG_BASIC_ADDRESSSPACES_H
-namespace clang {
+#include <assert.h>
-namespace LangAS {
+namespace clang {
/// \brief Defines the address space values used by the address space qualifier
/// of QualType.
///
-enum ID {
+enum class LangAS : unsigned {
// The default value 0 is the value used in QualType for the the situation
- // where there is no address space qualifier. For most languages, this also
- // corresponds to the situation where there is no address space qualifier in
- // the source code, except for OpenCL, where the address space value 0 in
- // QualType represents private address space in OpenCL source code.
+ // where there is no address space qualifier.
Default = 0,
// OpenCL specific address spaces.
+ // In OpenCL each l-value must have certain non-default address space, each
+ // r-value must have no address space (i.e. the default address space). The
+ // pointee of a pointer must have non-default address space.
opencl_global,
opencl_local,
opencl_constant,
+ opencl_private,
opencl_generic,
// CUDA specific address spaces.
@@ -50,9 +51,24 @@ enum ID {
/// The type of a lookup table which maps from language-specific address spaces
/// to target-specific ones.
-typedef unsigned Map[FirstTargetAddressSpace];
+typedef unsigned LangASMap[(unsigned)LangAS::FirstTargetAddressSpace];
+
+/// \return whether \p AS is a target-specific address space rather than a
+/// clang AST address space
+inline bool isTargetAddressSpace(LangAS AS) {
+ return (unsigned)AS >= (unsigned)LangAS::FirstTargetAddressSpace;
}
+inline unsigned toTargetAddressSpace(LangAS AS) {
+ assert(isTargetAddressSpace(AS));
+ return (unsigned)AS - (unsigned)LangAS::FirstTargetAddressSpace;
}
+inline LangAS getLangASFromTargetAS(unsigned TargetAS) {
+ return static_cast<LangAS>((TargetAS) +
+ (unsigned)LangAS::FirstTargetAddressSpace);
+}
+
+} // namespace clang
+
#endif