;
24static void ctorTy(
Block*, std::byte *Ptr,
bool,
bool,
bool,
bool,
31 reinterpret_cast<T*
>(Ptr)->~
T();
37 auto*SrcPtr =
reinterpret_cast<T*
>(Src);
38 auto*DstPtr =
reinterpret_cast<T*
>(Dst);
39 new(DstPtr)
T(std::move(*SrcPtr));
48 for(
unsignedI = 0,
NE=
D->getNumElems(); I <
NE; ++I) {
49 new(&
reinterpret_cast<T*
>(Ptr)[I])
T();
60 for(
unsignedI = 0,
NE=
D->getNumElems(); I <
NE; ++I) {
61 reinterpret_cast<T*
>(Ptr)[I].~
T();
72SrcIMP = std::nullopt;
76 for(
unsignedI = 0,
NE=
D->getNumElems(); I <
NE; ++I) {
77 auto*SrcPtr = &
reinterpret_cast<T*
>(Src)[I];
78 auto*DstPtr = &
reinterpret_cast<T*
>(Dst)[I];
79 new(DstPtr)
T(std::move(*SrcPtr));
84 boolIsMutable,
boolIsActive,
boolInUnion,
86 const unsignedNumElems =
D->getNumElems();
87 const unsignedElemSize =
90 unsignedElemOffset = 0;
91 for(
unsignedI = 0; I < NumElems; ++I, ElemOffset += ElemSize) {
92 auto*ElemPtr = Ptr + ElemOffset;
94 auto*ElemLoc =
reinterpret_cast<std::byte *
>(Desc + 1);
95 auto*SD =
D->ElemDesc;
99Desc->IsInitialized =
true;
100Desc->IsBase =
false;
101Desc->IsActive = IsActive;
102Desc->IsConst = IsConst ||
D->IsConst;
103Desc->IsFieldMutable = IsMutable ||
D->IsMutable;
104Desc->InUnion = InUnion;
105Desc->IsArrayElement =
true;
107 if(
auto Fn=
D->ElemDesc->CtorFn)
108 Fn(B, ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsActive,
109Desc->InUnion || SD->isUnion(),
D->ElemDesc);
114 const unsignedNumElems =
D->getNumElems();
115 const unsignedElemSize =
118 unsignedElemOffset = 0;
119 for(
unsignedI = 0; I < NumElems; ++I, ElemOffset += ElemSize) {
120 auto*ElemPtr = Ptr + ElemOffset;
122 auto*ElemLoc =
reinterpret_cast<std::byte *
>(Desc + 1);
123 if(
auto Fn=
D->ElemDesc->DtorFn)
124 Fn(B, ElemLoc,
D->ElemDesc);
130 const unsignedNumElems =
D->getNumElems();
131 const unsignedElemSize =
134 unsignedElemOffset = 0;
135 for(
unsignedI = 0; I < NumElems; ++I, ElemOffset += ElemSize) {
136 auto*SrcPtr = Src + ElemOffset;
137 auto*DstPtr = Dst + ElemOffset;
140 auto*SrcElemLoc =
reinterpret_cast<std::byte *
>(SrcDesc + 1);
142 auto*DstElemLoc =
reinterpret_cast<std::byte *
>(DstDesc + 1);
145 if(
auto Fn=
D->ElemDesc->MoveFn)
146 Fn(B, SrcElemLoc, DstElemLoc,
D->ElemDesc);
151 boolIsActive,
boolIsUnionField,
boolInUnion,
154Desc->
Offset= FieldOffset;
156Desc->IsInitialized =
D->IsArray;
157Desc->IsBase =
false;
158Desc->IsActive = IsActive && !IsUnionField;
159Desc->InUnion = InUnion;
160Desc->IsConst = IsConst ||
D->IsConst;
161Desc->IsFieldMutable = IsMutable ||
D->IsMutable;
163 if(
auto Fn=
D->CtorFn)
164 Fn(B, Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable,
165Desc->IsActive, InUnion ||
D->isUnion(),
D);
168static void initBase(
Block*B, std::byte *Ptr,
boolIsConst,
boolIsMutable,
169 boolIsActive,
boolInUnion,
const Descriptor*
D,
170 unsignedFieldOffset,
boolIsVirtualBase) {
172assert(
D->ElemRecord);
173assert(!
D->ElemRecord->isUnion());
176Desc->
Offset= FieldOffset;
178Desc->IsInitialized =
D->IsArray;
179Desc->IsBase =
true;
180Desc->IsVirtualBase = IsVirtualBase;
181Desc->IsActive = IsActive && !InUnion;
182Desc->IsConst = IsConst ||
D->IsConst;
183Desc->IsFieldMutable = IsMutable ||
D->IsMutable;
184Desc->InUnion = InUnion;
186 for(
const auto&
V:
D->ElemRecord->bases())
187 initBase(B, Ptr + FieldOffset, IsConst, IsMutable, IsActive, InUnion,
188 V.Desc,
V.Offset,
false);
189 for(
const auto&F :
D->ElemRecord->fields())
190 initField(B, Ptr + FieldOffset, IsConst, IsMutable, IsActive, InUnion,
191InUnion, F.Desc, F.Offset);
195 boolIsActive,
boolInUnion,
const Descriptor*
D) {
196 for(
const auto&
V:
D->ElemRecord->bases())
197 initBase(B, Ptr, IsConst, IsMutable, IsActive, InUnion,
V.Desc,
V.Offset,
199 for(
const auto&F :
D->ElemRecord->fields()) {
200 boolIsUnionField =
D->isUnion();
201 initField(B, Ptr, IsConst, IsMutable, IsActive, IsUnionField,
202InUnion || IsUnionField, F.Desc, F.Offset);
204 for(
const auto&
V:
D->ElemRecord->virtual_bases())
205 initBase(B, Ptr, IsConst, IsMutable, IsActive, InUnion,
V.Desc,
V.Offset,
210 unsignedFieldOffset) {
211 if(
auto Fn=
D->DtorFn)
212 Fn(B, Ptr + FieldOffset,
D);
216 unsignedFieldOffset) {
218assert(
D->ElemRecord);
220 for(
const auto&
V:
D->ElemRecord->bases())
222 for(
const auto&F :
D->ElemRecord->fields())
227 for(
const auto&F :
D->ElemRecord->bases())
229 for(
const auto&F :
D->ElemRecord->fields())
231 for(
const auto&F :
D->ElemRecord->virtual_bases())
238assert(
D->ElemRecord);
242 for(
const auto&F :
D->ElemRecord->fields()) {
243 autoFieldOffset = F.Offset;
244 const auto*SrcDesc =
250 if(
auto Fn= F.Desc->MoveFn)
251 Fn(B, Src + FieldOffset, Dst + FieldOffset, F.Desc);
259 returnctorTy<PrimConv<PT_Float>::T>;
261 returnctorTy<PrimConv<PT_IntAP>::T>;
263 returnctorTy<PrimConv<PT_IntAPS>::T>;
265 returnctorTy<PrimConv<PT_MemberPtr>::T>;
274 returndtorTy<PrimConv<PT_Float>::T>;
276 returndtorTy<PrimConv<PT_IntAP>::T>;
278 returndtorTy<PrimConv<PT_IntAPS>::T>;
280 returndtorTy<PrimConv<PT_MemberPtr>::T>;
287 returnmoveTy<PrimConv<PT_Float>::T>;
289 returnmoveTy<PrimConv<PT_IntAP>::T>;
291 returnmoveTy<PrimConv<PT_IntAPS>::T>;
293 returnmoveTy<PrimConv<PT_MemberPtr>::T>;
299llvm_unreachable(
"unknown Expr");
304llvm_unreachable(
"unknown Expr");
309llvm_unreachable(
"unknown Expr");
314 boolIsConst,
boolIsTemporary,
boolIsMutable)
316MDSize(MD.value_or(0)), AllocSize(
align(Size + MDSize)), PrimT(
Type),
317IsConst(IsConst), IsMutable(IsMutable), IsTemporary(IsTemporary),
320assert(AllocSize >= Size);
321assert(Source &&
"Missing source");
326 size_tNumElems,
boolIsConst,
boolIsTemporary,
328: Source(
D), ElemSize(
primSize(
Type)), Size(ElemSize * NumElems),
329MDSize(MD.value_or(0)),
331IsConst(IsConst), IsMutable(IsMutable), IsTemporary(IsTemporary),
334assert(Source &&
"Missing source");
341: Source(
D), ElemSize(
primSize(
Type)), Size(UnknownSizeMark),
342MDSize(MD.value_or(0)),
343AllocSize(MDSize + sizeof(
InitMapPtr) + alignof(void *)), IsConst(
true),
344IsMutable(
false), IsTemporary(IsTemporary), IsArray(
true),
347assert(Source &&
"Missing source");
352 unsignedNumElems,
boolIsConst,
boolIsTemporary,
355Size(ElemSize * NumElems), MDSize(MD.value_or(0)),
356AllocSize(
std::
max<
size_t>(alignof(void *), Size) + MDSize),
357ElemDesc(Elem), IsConst(IsConst), IsMutable(IsMutable),
360assert(Source &&
"Missing source");
367Size(UnknownSizeMark), MDSize(MD.value_or(0)),
368AllocSize(MDSize + alignof(void *)), ElemDesc(Elem), IsConst(
true),
369IsMutable(
false), IsTemporary(IsTemporary), IsArray(
true),
371assert(Source &&
"Missing source");
376 boolIsConst,
boolIsTemporary,
boolIsMutable)
377: Source(
D), ElemSize(
std::
max<
size_t>(alignof(void *), R->getFullSize())),
378Size(ElemSize), MDSize(MD.value_or(0)), AllocSize(Size + MDSize),
379ElemRecord(R), IsConst(IsConst), IsMutable(IsMutable),
382assert(Source &&
"Missing source");
387: Source(
D), ElemSize(1), Size(1), MDSize(0), AllocSize(MDSize),
388ElemRecord(nullptr), IsConst(
true), IsMutable(
false), IsTemporary(
false),
390assert(Source &&
"Missing source");
395 return D->getType();
396 if(
const auto*
T= dyn_cast_if_present<TypeDecl>(
asDecl()))
397 return QualType(
T->getTypeForDecl(), 0);
403 if(
const auto*
E=
asExpr())
405llvm_unreachable(
"Invalid descriptor type");
422 returnAT->getElementType();
425 returnCT->getElementType();
427 returnCT->getElementType();
433 if(
auto*
D= dyn_cast<const Decl *>(Source))
435 if(
auto*
E= dyn_cast<const Expr *>(Source))
437llvm_unreachable(
"Invalid descriptor type");
441 if(
const auto*
D= dyn_cast<const Decl *>(Source))
443 if(
const auto*
E= dyn_cast<const Expr *>(Source))
445llvm_unreachable(
"Invalid descriptor type");
451: UninitFields(N),
Data(
std::make_unique<T[]>(numFields(N))) {
452std::fill_n(data(), numFields(N), 0);
455boolInitMap::initializeElement(
unsignedI) {
456 unsignedBucket = I / PER_FIELD;
457T Mask = T(1) << (I % PER_FIELD);
458 if(!(data()[Bucket] & Mask)) {
459data()[Bucket] |= Mask;
462 returnUninitFields == 0;
465boolInitMap::isElementInitialized(
unsignedI)
const{
466 unsignedBucket = I / PER_FIELD;
467 returndata()[Bucket] & (T(1) << (I % PER_FIELD));
static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst, const Descriptor *D)
static void dtorTy(Block *, std::byte *Ptr, const Descriptor *)
static BlockCtorFn getCtorArrayPrim(PrimType Type)
static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsActive, bool IsUnionField, bool InUnion, const Descriptor *D, unsigned FieldOffset)
static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsActive, bool InUnion, const Descriptor *D, unsigned FieldOffset, bool IsVirtualBase)
static BlockMoveFn getMoveArrayPrim(PrimType Type)
static void destroyField(Block *B, std::byte *Ptr, const Descriptor *D, unsigned FieldOffset)
static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D)
static BlockMoveFn getMovePrim(PrimType Type)
static void moveRecord(Block *B, std::byte *Src, std::byte *Dst, const Descriptor *D)
static void moveTy(Block *, std::byte *Src, std::byte *Dst, const Descriptor *)
static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, const Descriptor *D)
static void destroyBase(Block *B, std::byte *Ptr, const Descriptor *D, unsigned FieldOffset)
static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D)
static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, const Descriptor *)
static BlockDtorFn getDtorPrim(PrimType Type)
static BlockCtorFn getCtorPrim(PrimType Type)
static BlockDtorFn getDtorArrayPrim(PrimType Type)
static void moveArrayDesc(Block *B, std::byte *Src, std::byte *Dst, const Descriptor *D)
static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D)
static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsActive, bool InUnion, const Descriptor *D)
static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsActive, bool InUnion, const Descriptor *D)
#define COMPOSITE_TYPE_SWITCH(Expr, B, D)
#define TYPE_SWITCH(Expr, B)
__DEVICE__ int max(int __a, int __b)
QualType getElementType() const
Complex values, per C99 6.2.5p11.
SourceLocation getLocation() const
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
A (possibly-)qualified type.
Encodes a location in the source.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isPointerOrReferenceType() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a GCC generic vector type.
A memory block, either on the stack or in the heap.
Structure/Class descriptor.
const RecordDecl * getDecl() const
Returns the underlying declaration.
bool isUnion() const
Checks if the record is a union.
Describes the statement/declaration an opcode was generated from.
std::optional< std::pair< bool, std::shared_ptr< InitMap > > > InitMapPtr
void(*)(Block *Storage, std::byte *FieldPtr, bool IsConst, bool IsMutable, bool IsActive, bool InUnion, const Descriptor *FieldDesc) BlockCtorFn
Invoked whenever a block is created.
bool NE(InterpState &S, CodePtr OpPC)
void(*)(Block *Storage, std::byte *FieldPtr, const Descriptor *FieldDesc) BlockDtorFn
Invoked when a block is destroyed.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
PrimType
Enumeration of the primitive types of the VM.
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
void(*)(Block *Storage, std::byte *SrcFieldPtr, std::byte *DstFieldPtr, const Descriptor *FieldDesc) BlockMoveFn
Invoked when a block with pointers referencing it goes out of scope.
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Token to denote structures of unknown size.
Describes a memory block created by an allocation site.
QualType getElemQualType() const
const ValueDecl * asValueDecl() const
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
const Decl * asDecl() const
SourceInfo getLoc() const
SourceLocation getLocation() const
std::optional< unsigned > MetadataSize
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
Descriptor(const DeclTy &D, PrimType Type, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable)
Allocates a descriptor for a primitive.
bool isRecord() const
Checks if the descriptor is of a record.
const Record *const ElemRecord
Pointer to the record, if block contains records.
bool isUnion() const
Checks if the descriptor is of a union.
const Expr * asExpr() const
bool isArray() const
Checks if the descriptor is of an array.
InitMap(unsigned N)
Initializes the map with no fields set.
Inline descriptor embedded in structures and arrays.
unsigned Offset
Offset inside the structure/array.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4