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 IntegralAP;
31template <
unsigned Bits,
bool Signed>
class Integral;
54 static constexpr uint8_t None = 0xFF;
62 explicit constexpr operator bool()
const {
return V != None; }
64 assert(
operator bool());
77 return V ==
static_cast<unsigned>(PT);
83static_assert(
sizeof(OptPrimType) ==
sizeof(
PrimType));
112 OS <<
"reinterpret_cast";
126 return std::is_same_v<T, IntegralAP<false>> ||
127 std::is_same_v<T, IntegralAP<true>> || std::is_same_v<T, Floating>;
185constexpr size_t align(
size_t Size) {
186 return ((Size +
alignof(
void *) - 1) /
alignof(
void *)) *
alignof(
void *);
190static_assert(
aligned(
sizeof(
void *)));
201#define TYPE_SWITCH_CASE(Name, B) \
203 using T = PrimConv<Name>::T; \
207#define TYPE_SWITCH(Expr, B) \
210 TYPE_SWITCH_CASE(PT_Sint8, B) \
211 TYPE_SWITCH_CASE(PT_Uint8, B) \
212 TYPE_SWITCH_CASE(PT_Sint16, B) \
213 TYPE_SWITCH_CASE(PT_Uint16, B) \
214 TYPE_SWITCH_CASE(PT_Sint32, B) \
215 TYPE_SWITCH_CASE(PT_Uint32, B) \
216 TYPE_SWITCH_CASE(PT_Sint64, B) \
217 TYPE_SWITCH_CASE(PT_Uint64, B) \
218 TYPE_SWITCH_CASE(PT_IntAP, B) \
219 TYPE_SWITCH_CASE(PT_IntAPS, B) \
220 TYPE_SWITCH_CASE(PT_Float, B) \
221 TYPE_SWITCH_CASE(PT_Bool, B) \
222 TYPE_SWITCH_CASE(PT_Ptr, B) \
223 TYPE_SWITCH_CASE(PT_MemberPtr, B) \
224 TYPE_SWITCH_CASE(PT_FixedPoint, B) \
228#define INT_TYPE_SWITCH(Expr, B) \
231 TYPE_SWITCH_CASE(PT_Sint8, B) \
232 TYPE_SWITCH_CASE(PT_Uint8, B) \
233 TYPE_SWITCH_CASE(PT_Sint16, B) \
234 TYPE_SWITCH_CASE(PT_Uint16, B) \
235 TYPE_SWITCH_CASE(PT_Sint32, B) \
236 TYPE_SWITCH_CASE(PT_Uint32, B) \
237 TYPE_SWITCH_CASE(PT_Sint64, B) \
238 TYPE_SWITCH_CASE(PT_Uint64, B) \
239 TYPE_SWITCH_CASE(PT_IntAP, B) \
240 TYPE_SWITCH_CASE(PT_IntAPS, B) \
241 TYPE_SWITCH_CASE(PT_Bool, B) \
243 llvm_unreachable("Not an integer value"); \
247#define INT_TYPE_SWITCH_NO_BOOL(Expr, B) \
250 TYPE_SWITCH_CASE(PT_Sint8, B) \
251 TYPE_SWITCH_CASE(PT_Uint8, B) \
252 TYPE_SWITCH_CASE(PT_Sint16, B) \
253 TYPE_SWITCH_CASE(PT_Uint16, B) \
254 TYPE_SWITCH_CASE(PT_Sint32, B) \
255 TYPE_SWITCH_CASE(PT_Uint32, B) \
256 TYPE_SWITCH_CASE(PT_Sint64, B) \
257 TYPE_SWITCH_CASE(PT_Uint64, B) \
258 TYPE_SWITCH_CASE(PT_IntAP, B) \
259 TYPE_SWITCH_CASE(PT_IntAPS, B) \
261 llvm_unreachable("Not an integer value"); \
265#define TYPE_SWITCH_ALLOC(Expr, B) \
268 TYPE_SWITCH_CASE(PT_Float, B) \
269 TYPE_SWITCH_CASE(PT_IntAP, B) \
270 TYPE_SWITCH_CASE(PT_IntAPS, 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.
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 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.