13#ifndef LLVM_CLANG_AST_INTERP_TYPE_H
14#define LLVM_CLANG_AST_INTERP_TYPE_H
16#include "llvm/Support/raw_ostream.h"
30template <
unsigned Bits,
bool Signed>
class Integral;
73 static constexpr uint8_t None = 0xFF;
81 explicit constexpr operator bool()
const {
return V != None; }
83 assert(
operator bool());
96 return V ==
static_cast<unsigned>(PT);
102static_assert(
sizeof(OptPrimType) ==
sizeof(PrimType));
115 OS <<
"reinterpret_cast";
118 OS <<
"reinterpret_like";
131 return std::is_same_v<T, IntegralAP<false>> ||
132 std::is_same_v<T, IntegralAP<true>> || std::is_same_v<T, Floating> ||
133 std::is_same_v<T, MemberPointer>;
191constexpr size_t align(
size_t Size) {
192 return ((Size +
alignof(
void *) - 1) /
alignof(
void *)) *
alignof(
void *);
196static_assert(
aligned(
sizeof(
void *)));
207#define TYPE_SWITCH_CASE(Name, B) \
209 using T = PrimConv<Name>::T; \
213#define TYPE_SWITCH(Expr, B) \
216 TYPE_SWITCH_CASE(PT_Sint8, B) \
217 TYPE_SWITCH_CASE(PT_Uint8, B) \
218 TYPE_SWITCH_CASE(PT_Sint16, B) \
219 TYPE_SWITCH_CASE(PT_Uint16, B) \
220 TYPE_SWITCH_CASE(PT_Sint32, B) \
221 TYPE_SWITCH_CASE(PT_Uint32, B) \
222 TYPE_SWITCH_CASE(PT_Sint64, B) \
223 TYPE_SWITCH_CASE(PT_Uint64, B) \
224 TYPE_SWITCH_CASE(PT_IntAP, B) \
225 TYPE_SWITCH_CASE(PT_IntAPS, B) \
226 TYPE_SWITCH_CASE(PT_Float, B) \
227 TYPE_SWITCH_CASE(PT_Bool, B) \
228 TYPE_SWITCH_CASE(PT_Ptr, B) \
229 TYPE_SWITCH_CASE(PT_MemberPtr, B) \
230 TYPE_SWITCH_CASE(PT_FixedPoint, B) \
234#define INT_TYPE_SWITCH(Expr, B) \
237 TYPE_SWITCH_CASE(PT_Sint8, B) \
238 TYPE_SWITCH_CASE(PT_Uint8, B) \
239 TYPE_SWITCH_CASE(PT_Sint16, B) \
240 TYPE_SWITCH_CASE(PT_Uint16, B) \
241 TYPE_SWITCH_CASE(PT_Sint32, B) \
242 TYPE_SWITCH_CASE(PT_Uint32, B) \
243 TYPE_SWITCH_CASE(PT_Sint64, B) \
244 TYPE_SWITCH_CASE(PT_Uint64, B) \
245 TYPE_SWITCH_CASE(PT_IntAP, B) \
246 TYPE_SWITCH_CASE(PT_IntAPS, B) \
247 TYPE_SWITCH_CASE(PT_Bool, B) \
249 llvm_unreachable("Not an integer value"); \
253#define INT_TYPE_SWITCH_NO_BOOL(Expr, B) \
256 TYPE_SWITCH_CASE(PT_Sint8, B) \
257 TYPE_SWITCH_CASE(PT_Uint8, B) \
258 TYPE_SWITCH_CASE(PT_Sint16, B) \
259 TYPE_SWITCH_CASE(PT_Uint16, B) \
260 TYPE_SWITCH_CASE(PT_Sint32, B) \
261 TYPE_SWITCH_CASE(PT_Uint32, B) \
262 TYPE_SWITCH_CASE(PT_Sint64, B) \
263 TYPE_SWITCH_CASE(PT_Uint64, B) \
264 TYPE_SWITCH_CASE(PT_IntAP, B) \
265 TYPE_SWITCH_CASE(PT_IntAPS, B) \
267 llvm_unreachable("Not an integer value"); \
271#define TYPE_SWITCH_ALLOC(Expr, B) \
274 TYPE_SWITCH_CASE(PT_Float, B) \
275 TYPE_SWITCH_CASE(PT_IntAP, B) \
276 TYPE_SWITCH_CASE(PT_IntAPS, B) \
277 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 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.