clang  6.0.0svn
AddressSpaces.h
Go to the documentation of this file.
1 //===--- AddressSpaces.h - Language-specific address spaces -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Provides definitions for the various language-specific address
12 /// spaces.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
17 #define LLVM_CLANG_BASIC_ADDRESSSPACES_H
18 
19 #include <assert.h>
20 
21 namespace clang {
22 
23 /// \brief Defines the address space values used by the address space qualifier
24 /// of QualType.
25 ///
26 enum class LangAS : unsigned {
27  // The default value 0 is the value used in QualType for the the situation
28  // where there is no address space qualifier.
29  Default = 0,
30 
31  // OpenCL specific address spaces.
32  // In OpenCL each l-value must have certain non-default address space, each
33  // r-value must have no address space (i.e. the default address space). The
34  // pointee of a pointer must have non-default address space.
40 
41  // CUDA specific address spaces.
45 
46  // This denotes the count of language-specific address spaces and also
47  // the offset added to the target-specific address spaces, which are usually
48  // specified by address space attributes __attribute__(address_space(n))).
50 };
51 
52 /// The type of a lookup table which maps from language-specific address spaces
53 /// to target-specific ones.
54 typedef unsigned LangASMap[(unsigned)LangAS::FirstTargetAddressSpace];
55 
56 /// \return whether \p AS is a target-specific address space rather than a
57 /// clang AST address space
58 inline bool isTargetAddressSpace(LangAS AS) {
59  return (unsigned)AS >= (unsigned)LangAS::FirstTargetAddressSpace;
60 }
61 
62 inline unsigned toTargetAddressSpace(LangAS AS) {
63  assert(isTargetAddressSpace(AS));
64  return (unsigned)AS - (unsigned)LangAS::FirstTargetAddressSpace;
65 }
66 
67 inline LangAS getLangASFromTargetAS(unsigned TargetAS) {
68  return static_cast<LangAS>((TargetAS) +
70 }
71 
72 } // namespace clang
73 
74 #endif
LangAS getLangASFromTargetAS(unsigned TargetAS)
Definition: AddressSpaces.h:67
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:26
unsigned toTargetAddressSpace(LangAS AS)
Definition: AddressSpaces.h:62
unsigned LangASMap[(unsigned) LangAS::FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
Definition: AddressSpaces.h:54
bool isTargetAddressSpace(LangAS AS)
Definition: AddressSpaces.h:58
Dataflow Directional Tag Classes.