clang: lib/AST/ByteCode/PrimType.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_AST_INTERP_TYPE_H
14#define LLVM_CLANG_AST_INTERP_TYPE_H
15
16#include "llvm/Support/raw_ostream.h"
17#include
18#include
19#include
20
22namespace interp {
23
26class Floating;
27class FunctionPointer;
28class MemberPointer;
29class FixedPoint;
30template class IntegralAP;
31template <unsigned Bits, bool Signed> class Integral;
32
33
51};
52
55}
56
60};
61inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
63 switch (CK) {
65 OS << "reinterpret_cast";
66 break;
68 OS << "atomic";
69 break;
70 }
71 return OS;
72}
73
75
76
80};
83};
86};
89};
92};
95};
98};
101};
104};
107};
110};
113};
116};
119};
122};
125};
126
127
129
130
131constexpr size_t align(size_t Size) {
132 return ((Size + alignof(void *) - 1) / alignof(void *)) * alignof(void *);
133}
134
136static_assert(aligned(sizeof(void *)));
137
138static inline bool aligned(const void *P) {
140}
141
142}
143}
144
145
146
147#define TYPE_SWITCH_CASE(Name, B) \
148 case Name: { \
149 using T = PrimConv::T; \
150 B; \
151 break; \
152 }
153#define TYPE_SWITCH(Expr, B) \
154 do { \
155 switch (Expr) { \
156 TYPE_SWITCH_CASE(PT_Sint8, B) \
157 TYPE_SWITCH_CASE(PT_Uint8, B) \
158 TYPE_SWITCH_CASE(PT_Sint16, B) \
159 TYPE_SWITCH_CASE(PT_Uint16, B) \
160 TYPE_SWITCH_CASE(PT_Sint32, B) \
161 TYPE_SWITCH_CASE(PT_Uint32, B) \
162 TYPE_SWITCH_CASE(PT_Sint64, B) \
163 TYPE_SWITCH_CASE(PT_Uint64, B) \
164 TYPE_SWITCH_CASE(PT_IntAP, B) \
165 TYPE_SWITCH_CASE(PT_IntAPS, B) \
166 TYPE_SWITCH_CASE(PT_Float, B) \
167 TYPE_SWITCH_CASE(PT_Bool, B) \
168 TYPE_SWITCH_CASE(PT_Ptr, B) \
169 TYPE_SWITCH_CASE(PT_FnPtr, B) \
170 TYPE_SWITCH_CASE(PT_MemberPtr, B) \
171 TYPE_SWITCH_CASE(PT_FixedPoint, B) \
172 } \
173 } while (0)
174
175#define INT_TYPE_SWITCH(Expr, B) \
176 do { \
177 switch (Expr) { \
178 TYPE_SWITCH_CASE(PT_Sint8, B) \
179 TYPE_SWITCH_CASE(PT_Uint8, B) \
180 TYPE_SWITCH_CASE(PT_Sint16, B) \
181 TYPE_SWITCH_CASE(PT_Uint16, B) \
182 TYPE_SWITCH_CASE(PT_Sint32, B) \
183 TYPE_SWITCH_CASE(PT_Uint32, B) \
184 TYPE_SWITCH_CASE(PT_Sint64, B) \
185 TYPE_SWITCH_CASE(PT_Uint64, B) \
186 TYPE_SWITCH_CASE(PT_IntAP, B) \
187 TYPE_SWITCH_CASE(PT_IntAPS, B) \
188 TYPE_SWITCH_CASE(PT_Bool, B) \
189 default: \
190 llvm_unreachable("Not an integer value"); \
191 } \
192 } while (0)
193
194#define INT_TYPE_SWITCH_NO_BOOL(Expr, B) \
195 do { \
196 switch (Expr) { \
197 TYPE_SWITCH_CASE(PT_Sint8, B) \
198 TYPE_SWITCH_CASE(PT_Uint8, B) \
199 TYPE_SWITCH_CASE(PT_Sint16, B) \
200 TYPE_SWITCH_CASE(PT_Uint16, B) \
201 TYPE_SWITCH_CASE(PT_Sint32, B) \
202 TYPE_SWITCH_CASE(PT_Uint32, B) \
203 TYPE_SWITCH_CASE(PT_Sint64, B) \
204 TYPE_SWITCH_CASE(PT_Uint64, B) \
205 TYPE_SWITCH_CASE(PT_IntAP, B) \
206 TYPE_SWITCH_CASE(PT_IntAPS, B) \
207 default: \
208 llvm_unreachable("Not an integer value"); \
209 } \
210 } while (0)
211
212#define COMPOSITE_TYPE_SWITCH(Expr, B, D) \
213 do { \
214 switch (Expr) { \
215 TYPE_SWITCH_CASE(PT_Ptr, B) \
216 default: { \
217 D; \
218 break; \
219 } \
220 } \
221 } while (0)
222#endif
The base class of the type hierarchy.
Wrapper around boolean types.
Wrapper around fixed point types.
Wrapper around numeric types.
A pointer to a memory block, live or dead.
constexpr bool aligned(uintptr_t Value)
constexpr bool isPtrType(PrimType T)
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
PrimType
Enumeration of the primitive types of the VM.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
constexpr bool isIntegralType(PrimType T)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Mapping from primitive types to their representation.