13#ifndef LLVM_CLANG_AST_INTERP_TYPE_H
14#define LLVM_CLANG_AST_INTERP_TYPE_H
16#include "llvm/Support/raw_ostream.h"
30template <
bool Signed>
class Char;
31template <
unsigned Bits,
bool Signed>
class Integral;
74 static constexpr uint8_t None = 0xFF;
82 explicit constexpr operator bool()
const {
return V != None; }
84 assert(
operator bool());
97 return V ==
static_cast<unsigned>(PT);
103static_assert(
sizeof(OptPrimType) ==
sizeof(PrimType));
116 OS <<
"reinterpret_cast";
119 OS <<
"reinterpret_like";
132 return std::is_same_v<T, IntegralAP<false>> ||
133 std::is_same_v<T, IntegralAP<true>> || std::is_same_v<T, Floating> ||
134 std::is_same_v<T, MemberPointer>;
141 return std::is_same_v<T, Integral<16, false>> ||
142 std::is_same_v<T, Integral<16, true>> ||
143 std::is_same_v<T, Integral<32, false>> ||
144 std::is_same_v<T, Integral<32, true>> ||
145 std::is_same_v<T, Integral<64, false>> ||
146 std::is_same_v<T, Integral<64, true>>;
201constexpr size_t align(
size_t Size) {
202 return ((Size +
alignof(
void *) - 1) /
alignof(
void *)) *
alignof(
void *);
206static_assert(
aligned(
sizeof(
void *)));
217#define TYPE_SWITCH_CASE(Name, B) \
219 using T = PrimConv<Name>::T; \
223#define TYPE_SWITCH(Expr, B) \
226 TYPE_SWITCH_CASE(PT_Sint8, B) \
227 TYPE_SWITCH_CASE(PT_Uint8, B) \
228 TYPE_SWITCH_CASE(PT_Sint16, B) \
229 TYPE_SWITCH_CASE(PT_Uint16, B) \
230 TYPE_SWITCH_CASE(PT_Sint32, B) \
231 TYPE_SWITCH_CASE(PT_Uint32, B) \
232 TYPE_SWITCH_CASE(PT_Sint64, B) \
233 TYPE_SWITCH_CASE(PT_Uint64, B) \
234 TYPE_SWITCH_CASE(PT_IntAP, B) \
235 TYPE_SWITCH_CASE(PT_IntAPS, B) \
236 TYPE_SWITCH_CASE(PT_Float, B) \
237 TYPE_SWITCH_CASE(PT_Bool, B) \
238 TYPE_SWITCH_CASE(PT_Ptr, B) \
239 TYPE_SWITCH_CASE(PT_MemberPtr, B) \
240 TYPE_SWITCH_CASE(PT_FixedPoint, B) \
244#define INT_TYPE_SWITCH(Expr, B) \
247 TYPE_SWITCH_CASE(PT_Sint8, B) \
248 TYPE_SWITCH_CASE(PT_Uint8, B) \
249 TYPE_SWITCH_CASE(PT_Sint16, B) \
250 TYPE_SWITCH_CASE(PT_Uint16, B) \
251 TYPE_SWITCH_CASE(PT_Sint32, B) \
252 TYPE_SWITCH_CASE(PT_Uint32, B) \
253 TYPE_SWITCH_CASE(PT_Sint64, B) \
254 TYPE_SWITCH_CASE(PT_Uint64, B) \
255 TYPE_SWITCH_CASE(PT_IntAP, B) \
256 TYPE_SWITCH_CASE(PT_IntAPS, B) \
257 TYPE_SWITCH_CASE(PT_Bool, B) \
259 llvm_unreachable("Not an integer value"); \
263#define FIXED_SIZE_INT_TYPE_SWITCH(Expr, B) \
266 TYPE_SWITCH_CASE(PT_Sint8, B) \
267 TYPE_SWITCH_CASE(PT_Uint8, B) \
268 TYPE_SWITCH_CASE(PT_Sint16, B) \
269 TYPE_SWITCH_CASE(PT_Uint16, B) \
270 TYPE_SWITCH_CASE(PT_Sint32, B) \
271 TYPE_SWITCH_CASE(PT_Uint32, B) \
272 TYPE_SWITCH_CASE(PT_Sint64, B) \
273 TYPE_SWITCH_CASE(PT_Uint64, B) \
275 llvm_unreachable("Not an integer value"); \
279#define INT_TYPE_SWITCH_NO_BOOL(Expr, B) \
282 TYPE_SWITCH_CASE(PT_Sint8, B) \
283 TYPE_SWITCH_CASE(PT_Uint8, B) \
284 TYPE_SWITCH_CASE(PT_Sint16, B) \
285 TYPE_SWITCH_CASE(PT_Uint16, B) \
286 TYPE_SWITCH_CASE(PT_Sint32, B) \
287 TYPE_SWITCH_CASE(PT_Uint32, B) \
288 TYPE_SWITCH_CASE(PT_Sint64, B) \
289 TYPE_SWITCH_CASE(PT_Uint64, B) \
290 TYPE_SWITCH_CASE(PT_IntAP, B) \
291 TYPE_SWITCH_CASE(PT_IntAPS, B) \
293 llvm_unreachable("Not an integer value"); \
297#define TYPE_SWITCH_ALLOC(Expr, B) \
300 TYPE_SWITCH_CASE(PT_Float, B) \
301 TYPE_SWITCH_CASE(PT_IntAP, B) \
302 TYPE_SWITCH_CASE(PT_IntAPS, B) \
303 TYPE_SWITCH_CASE(PT_MemberPtr, B) \
The base class of the type hierarchy.
Wrapper around boolean types.
Wrapper around fixed point types.
If a Floating is constructed from Memory, it DOES NOT OWN THAT MEMORY.
If an IntegralAP is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Wrapper around numeric types.
OptPrimType(std::nullopt_t)
bool operator!=(PrimType PT) const
PrimType operator*() const
bool operator==(OptPrimType OPT) const
bool operator!=(OptPrimType OPT) const
PrimType value_or(PrimType PT) const
bool operator==(PrimType PT) const
A pointer to a memory block, live or dead.
constexpr bool isSignedType(PrimType T)
constexpr bool aligned(uintptr_t Value)
constexpr bool isIntegralOrPointer()
constexpr bool isPtrType(PrimType T)
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
constexpr bool isIntegerOrBoolType(PrimType T)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
PrimType
Enumeration of the primitive types of the VM.
constexpr bool needsAlloc()
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
constexpr bool isIntegerType(PrimType T)
The JSON file list parser is used to communicate input to InstallAPI.
__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.