clang 23.0.0git
Program.cpp
Go to the documentation of this file.
1//===--- Program.cpp - Bytecode for the constexpr VM ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "Program.h"
10#include "Context.h"
11#include "Function.h"
12#include "Integral.h"
13#include "PrimType.h"
14#include "clang/AST/Decl.h"
15#include "clang/AST/DeclCXX.h"
17
18using namespace clang;
19using namespace clang::interp;
20
21unsigned Program::getOrCreateNativePointer(const void *Ptr) {
22 auto [It, Inserted] =
23 NativePointerIndices.try_emplace(Ptr, NativePointers.size());
24 if (Inserted)
25 NativePointers.push_back(Ptr);
26
27 return It->second;
28}
29
30const void *Program::getNativePointer(unsigned Idx) const {
31 return NativePointers[Idx];
32}
33
35 const size_t CharWidth = S->getCharByteWidth();
36 const size_t BitWidth = CharWidth * Ctx.getCharBit();
37 unsigned StringLength = S->getLength();
38
39 OptPrimType CharType =
40 Ctx.classify(S->getType()->castAsArrayTypeUnsafe()->getElementType());
41 assert(CharType);
42
43 if (!Base)
44 Base = S;
45
46 // Create a descriptor for the string.
47 Descriptor *Desc = allocateDescriptor(Base, *CharType, Descriptor::GlobalMD,
48 StringLength + 1,
49 /*isConst=*/true,
50 /*isTemporary=*/false,
51 /*isMutable=*/false);
52
53 // Allocate storage for the string.
54 // The byte length does not include the null terminator.
55 unsigned GlobalIndex = Globals.size();
56 unsigned Sz = Desc->getAllocSize();
57 auto *G = new (Allocator, Sz) Global(Ctx.getEvalID(), Desc, /*isStatic=*/true,
58 /*isExtern=*/false);
59 G->block()->invokeCtor();
60
61 new (G->block()->rawData())
63 Globals.push_back(G);
64
65 const Pointer Ptr(G->block());
66 if (CharWidth == 1) {
67 std::memcpy(&Ptr.elem<char>(0), S->getString().data(), StringLength);
68 } else {
69 // Construct the string in storage.
70 for (unsigned I = 0; I <= StringLength; ++I) {
71 uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit(I);
73 Ptr.elem<T>(I) = T::from(CodePoint, BitWidth););
74 }
75 }
77
78 return GlobalIndex;
79}
80
81Pointer Program::getPtrGlobal(unsigned Idx) const {
82 assert(Idx < Globals.size());
83 return Pointer(Globals[Idx]->block());
84}
85
87 if (auto It = GlobalIndices.find(VD); It != GlobalIndices.end())
88 return It->second;
89
90 // Find any previous declarations which were already evaluated.
91 std::optional<unsigned> Index;
92 for (const Decl *P = VD->getPreviousDecl(); P; P = P->getPreviousDecl()) {
93 if (auto It = GlobalIndices.find(P); It != GlobalIndices.end()) {
94 Index = It->second;
95 break;
96 }
97 }
98
99 // Map the decl to the existing index.
100 if (Index)
101 GlobalIndices[VD] = *Index;
102
103 return std::nullopt;
104}
105
107 if (auto It = GlobalIndices.find(E); It != GlobalIndices.end())
108 return It->second;
109 return std::nullopt;
110}
111
113 const Expr *Init) {
114 if (auto Idx = getGlobal(VD))
115 return Idx;
116
117 if (auto Idx = createGlobal(VD, Init)) {
118 GlobalIndices[VD] = *Idx;
119 return Idx;
120 }
121 return std::nullopt;
122}
123
125 assert(D);
126 // Dedup blocks since they are immutable and pointers cannot be compared.
127 if (auto It = DummyVariables.find(D.getOpaqueValue());
128 It != DummyVariables.end())
129 return It->second;
130
131 QualType QT;
132 bool IsWeak = false;
133 if (const auto *E = dyn_cast<const Expr *>(D)) {
134 QT = E->getType();
135 } else {
136 const auto *VD = cast<ValueDecl>(cast<const Decl *>(D));
137 IsWeak = VD->isWeak();
138 QT = VD->getType();
139 if (QT->isPointerOrReferenceType())
140 QT = QT->getPointeeType();
141 }
142 assert(!QT.isNull());
143
144 Descriptor *Desc;
145 if (OptPrimType T = Ctx.classify(QT))
146 Desc = createDescriptor(D, *T, /*SourceTy=*/nullptr, std::nullopt,
147 /*IsConst=*/QT.isConstQualified());
148 else
149 Desc = createDescriptor(D, QT.getTypePtr(), std::nullopt,
150 /*IsConst=*/QT.isConstQualified());
151 if (!Desc)
152 Desc = allocateDescriptor(D);
153
154 assert(Desc);
155
156 // Allocate a block for storage.
157 unsigned I = Globals.size();
158
159 auto *G = new (Allocator, Desc->getAllocSize())
160 Global(Ctx.getEvalID(), getCurrentDecl(), Desc, /*IsStatic=*/true,
161 /*IsExtern=*/false, IsWeak, /*IsDummy=*/true);
162 G->block()->invokeCtor();
163 assert(G->block()->isDummy());
164
165 Globals.push_back(G);
166 DummyVariables[D.getOpaqueValue()] = I;
167 return I;
168}
169
171 bool IsStatic, IsExtern;
172 bool IsWeak = VD->isWeak();
173 if (const auto *Var = dyn_cast<VarDecl>(VD)) {
175 IsExtern = Var->hasExternalStorage();
178 IsStatic = true;
179 IsExtern = false;
180 } else {
181 IsStatic = false;
182 IsExtern = true;
183 }
184
185 // Register all previous declarations as well. For extern blocks, just replace
186 // the index with the new variable.
187 UnsignedOrNone Idx =
188 createGlobal(VD, VD->getType(), IsStatic, IsExtern, IsWeak, Init);
189 if (!Idx)
190 return std::nullopt;
191
192 Global *NewGlobal = Globals[*Idx];
193 // Note that this loop has one iteration where Redecl == VD.
194 for (const Decl *Redecl : VD->redecls()) {
195
196 // If this redecl was registered as a dummy variable, it is now a proper
197 // global variable and points to the block we just created.
198 if (auto DummyIt = DummyVariables.find(Redecl);
199 DummyIt != DummyVariables.end()) {
200 Global *Dummy = Globals[DummyIt->second];
201 Dummy->block()->movePointersTo(NewGlobal->block());
202 Globals[DummyIt->second] = NewGlobal;
203 DummyVariables.erase(DummyIt);
204 }
205 // If the redeclaration hasn't been registered yet at all, we just set its
206 // global index to Idx. If it has been registered yet, it might have
207 // pointers pointing to it and we need to transfer those pointers to the new
208 // block.
209 auto [Iter, Inserted] = GlobalIndices.try_emplace(Redecl);
210 if (Inserted) {
211 GlobalIndices[Redecl] = *Idx;
212 continue;
213 }
214
215 if (Redecl != VD) {
216 if (Block *RedeclBlock = Globals[Iter->second]->block();
217 RedeclBlock->isExtern()) {
218
219 // All pointers pointing to the previous extern decl now point to the
220 // new decl.
221 // A previous iteration might've already fixed up the pointers for this
222 // global.
223 if (RedeclBlock != NewGlobal->block())
224 RedeclBlock->movePointersTo(NewGlobal->block());
225
226 Globals[Iter->second] = NewGlobal;
227 }
228 }
229 Iter->second = *Idx;
230 }
231
232 return *Idx;
233}
234
236 if (auto Idx = getGlobal(E))
237 return Idx;
238 if (auto Idx = createGlobal(E, E->getType(), /*isStatic=*/true,
239 /*isExtern=*/false, /*IsWeak=*/false)) {
240 GlobalIndices[E] = *Idx;
241 return *Idx;
242 }
243 return std::nullopt;
244}
245
247 bool IsStatic, bool IsExtern, bool IsWeak,
248 const Expr *Init) {
249 // Create a descriptor for the global.
250 Descriptor *Desc;
251 const bool IsConst = Ty.isConstQualified();
252 const bool IsTemporary = D.dyn_cast<const Expr *>();
253 const bool IsVolatile = Ty.isVolatileQualified();
254 if (OptPrimType T = Ctx.classify(Ty))
255 Desc = createDescriptor(D, *T, nullptr, Descriptor::GlobalMD, IsConst,
256 IsTemporary, /*IsMutable=*/false, IsVolatile);
257 else
258 Desc = createDescriptor(D, Ty.getTypePtr(), Descriptor::GlobalMD, IsConst,
259 IsTemporary, /*IsMutable=*/false, IsVolatile);
260
261 if (!Desc)
262 return std::nullopt;
263
264 // Allocate a block for storage.
265 unsigned I = Globals.size();
266
267 auto *G = new (Allocator, Desc->getAllocSize()) Global(
268 Ctx.getEvalID(), getCurrentDecl(), Desc, IsStatic, IsExtern, IsWeak);
269 G->block()->invokeCtor();
270
271 // Initialize GlobalInlineDescriptor fields.
272 auto *GD = new (G->block()->rawData()) GlobalInlineDescriptor();
273 if (!Init)
274 GD->InitState = GlobalInitState::NoInitializer;
275 Globals.push_back(G);
276
277 return I;
278}
279
281 F = F->getCanonicalDecl();
282 assert(F);
283 auto It = Funcs.find(F);
284 return It == Funcs.end() ? nullptr : It->second.get();
285}
286
288 // Use the actual definition as a key.
289 RD = RD->getDefinition();
290 if (!RD)
291 return nullptr;
292
293 if (!RD->isCompleteDefinition())
294 return nullptr;
295
296 // Return an existing record if available. Otherwise, we insert nullptr now
297 // and replace that later, so recursive calls to this function with the same
298 // RecordDecl don't run into infinite recursion.
299 auto [It, Inserted] = Records.try_emplace(RD);
300 if (!Inserted)
301 return It->second;
302
303 // Number of bytes required by fields and base classes.
304 unsigned BaseSize = 0;
305 // Number of bytes required by virtual base.
306 unsigned VirtSize = 0;
307
308 // Helper to get a base descriptor.
309 auto GetBaseDesc = [this](const RecordDecl *BD,
310 const Record *BR) -> const Descriptor * {
311 if (!BR)
312 return nullptr;
313 return allocateDescriptor(BD, BR, std::nullopt, /*isConst=*/false,
314 /*isTemporary=*/false,
315 /*isMutable=*/false, /*IsVolatile=*/false);
316 };
317
318 // Reserve space for base classes.
319 Record::BaseList Bases;
320 Record::VirtualBaseList VirtBases;
321 if (const auto *CD = dyn_cast<CXXRecordDecl>(RD)) {
322 Bases.reserve(CD->getNumBases());
323 for (const CXXBaseSpecifier &Spec : CD->bases()) {
324 if (Spec.isVirtual())
325 continue;
326
327 // In error cases, the base might not be a RecordType.
328 const auto *BD = Spec.getType()->getAsCXXRecordDecl();
329 if (!BD)
330 return nullptr;
331 const Record *BR = getOrCreateRecord(BD);
332
333 const Descriptor *Desc = GetBaseDesc(BD, BR);
334 if (!Desc)
335 return nullptr;
336
337 BaseSize += align(sizeof(InlineDescriptor));
338 Bases.emplace_back(BD, Desc, BR, BaseSize);
339 BaseSize += align(BR->getSize());
340 }
341
342 for (const CXXBaseSpecifier &Spec : CD->vbases()) {
343 const auto *BD = Spec.getType()->castAsCXXRecordDecl();
344 const Record *BR = getOrCreateRecord(BD);
345
346 const Descriptor *Desc = GetBaseDesc(BD, BR);
347 if (!Desc)
348 return nullptr;
349
350 VirtSize += align(sizeof(InlineDescriptor));
351 VirtBases.emplace_back(BD, Desc, BR, VirtSize);
352 VirtSize += align(BR->getSize());
353 }
354 }
355
356 // Reserve space for fields.
357 Record::FieldList Fields;
358 Fields.reserve(RD->getNumFields());
359 bool HasPtrField = false;
360 for (const FieldDecl *FD : RD->fields()) {
361 FD = FD->getFirstDecl();
362 // Note that we DO create fields and descriptors
363 // for unnamed bitfields here, even though we later ignore
364 // them everywhere. That's so the FieldDecl's getFieldIndex() matches.
365
366 // Reserve space for the field's descriptor and the offset.
367 BaseSize += align(sizeof(InlineDescriptor));
368
369 // Classify the field and add its metadata.
370 QualType FT = FD->getType();
371 const bool IsConst = FT.isConstQualified();
372 const bool IsMutable = FD->isMutable();
373 const bool IsVolatile = FT.isVolatileQualified();
374 const Descriptor *Desc;
375 if (OptPrimType T = Ctx.classify(FT)) {
376 Desc = createDescriptor(FD, *T, nullptr, std::nullopt, IsConst,
377 /*isTemporary=*/false, IsMutable, IsVolatile);
378 HasPtrField = HasPtrField || (T == PT_Ptr);
379 } else {
380 Desc = createDescriptor(FD, FT.getTypePtr(), std::nullopt, IsConst,
381 /*isTemporary=*/false, IsMutable, IsVolatile);
382 HasPtrField = HasPtrField || (Desc && Desc->isPrimitiveArray() &&
383 Desc->getPrimType() == PT_Ptr);
384 }
385 if (!Desc)
386 return nullptr;
387 Fields.emplace_back(FD, Desc, BaseSize);
388 BaseSize += align(Desc->getAllocSize());
389 }
390
391 Record *R = new (Allocator)
392 Record(RD, std::move(Bases), std::move(Fields), std::move(VirtBases),
393 VirtSize, BaseSize, HasPtrField);
394 Records[RD] = R;
395 return R;
396}
397
400 bool IsConst, bool IsTemporary,
401 bool IsMutable, bool IsVolatile,
402 const Expr *Init) {
403
404 // Classes and structures.
405 if (const auto *RD = Ty->getAsRecordDecl()) {
406 if (const auto *Record = getOrCreateRecord(RD))
407 return allocateDescriptor(D, Record, MDSize, IsConst, IsTemporary,
408 IsMutable, IsVolatile);
409 return allocateDescriptor(D, MDSize);
410 }
411
412 // Arrays.
413 if (const auto *ArrayType = Ty->getAsArrayTypeUnsafe()) {
415 // Array of well-known bounds.
416 if (const auto *CAT = dyn_cast<ConstantArrayType>(ArrayType)) {
417 size_t NumElems = CAT->getZExtSize();
418 if (OptPrimType T = Ctx.classify(ElemTy)) {
419 // Arrays of primitives.
420 unsigned ElemSize = primSize(*T);
421 if ((Descriptor::MaxArrayElemBytes / ElemSize) < NumElems) {
422 return nullptr;
423 }
424 return allocateDescriptor(D, *T, MDSize, NumElems, IsConst, IsTemporary,
425 IsMutable);
426 }
427 // Arrays of composites. In this case, the array is a list of pointers,
428 // followed by the actual elements.
429 const Descriptor *ElemDesc = createDescriptor(
430 D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
431 if (!ElemDesc)
432 return nullptr;
433 unsigned ElemSize = ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
434 if (std::numeric_limits<unsigned>::max() / ElemSize <= NumElems)
435 return nullptr;
436 return allocateDescriptor(D, Ty, ElemDesc, MDSize, NumElems, IsConst,
437 IsTemporary, IsMutable);
438 }
439
440 // Array of unknown bounds - cannot be accessed and pointer arithmetic
441 // is forbidden on pointers to such objects.
444 if (OptPrimType T = Ctx.classify(ElemTy)) {
445 return allocateDescriptor(D, *T, MDSize, IsConst, IsTemporary,
447 }
448 const Descriptor *Desc = createDescriptor(
449 D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
450 if (!Desc)
451 return nullptr;
452 return allocateDescriptor(D, Desc, MDSize, IsTemporary,
454 }
455 }
456
457 // Atomic types.
458 if (const auto *AT = Ty->getAs<AtomicType>()) {
459 const Type *InnerTy = AT->getValueType().getTypePtr();
460 return createDescriptor(D, InnerTy, MDSize, IsConst, IsTemporary,
461 IsMutable);
462 }
463
464 // Complex types - represented as arrays of elements.
465 if (const auto *CT = Ty->getAs<ComplexType>()) {
466 OptPrimType ElemTy = Ctx.classify(CT->getElementType());
467 if (!ElemTy)
468 return nullptr;
469
470 return allocateDescriptor(D, *ElemTy, MDSize, 2, IsConst, IsTemporary,
471 IsMutable);
472 }
473
474 // Same with vector types.
475 if (const auto *VT = Ty->getAs<VectorType>()) {
476 OptPrimType ElemTy = Ctx.classify(VT->getElementType());
477 if (!ElemTy)
478 return nullptr;
479
480 return allocateDescriptor(D, *ElemTy, MDSize, VT->getNumElements(), IsConst,
481 IsTemporary, IsMutable);
482 }
483
484 return nullptr;
485}
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
Definition MachO.h:31
#define INT_TYPE_SWITCH_NO_BOOL(Expr, B)
Definition PrimType.h:252
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3730
QualType getElementType() const
Definition TypeBase.h:3742
Represents a base class of a C++ class.
Definition DeclCXX.h:146
Complex values, per C99 6.2.5p11.
Definition TypeBase.h:3283
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition DeclBase.h:1061
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition DeclBase.h:1049
This represents one expression.
Definition Expr.h:112
QualType getType() const
Definition Expr.h:144
Represents a member of a struct/union/class.
Definition Decl.h:3160
Represents a function declaration or definition.
Definition Decl.h:2000
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:3748
A global _GUID constant.
Definition DeclCXX.h:4401
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition TypeBase.h:8433
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1004
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8349
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition TypeBase.h:8422
Represents a struct/union/class.
Definition Decl.h:4327
unsigned getNumFields() const
Returns the number of fields (non-static data members) in this record.
Definition Decl.h:4543
field_range fields() const
Definition Decl.h:4530
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition Decl.h:4511
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
unsigned getLength() const
Definition Expr.h:1912
uint32_t getCodeUnit(size_t i) const
Definition Expr.h:1885
StringRef getString() const
Definition Expr.h:1870
unsigned getCharByteWidth() const
Definition Expr.h:1913
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3818
A template parameter object.
The base class of the type hierarchy.
Definition TypeBase.h:1839
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
Definition TypeBase.h:9255
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition Type.h:41
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition Type.cpp:753
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
Definition TypeBase.h:9232
bool isPointerOrReferenceType() const
Definition TypeBase.h:8590
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9179
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4458
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Definition Decl.cpp:5582
Represents a GCC generic vector type.
Definition TypeBase.h:4183
A memory block, either on the stack or in the heap.
Definition InterpBlock.h:44
bool isExtern() const
Checks if the block is extern.
Definition InterpBlock.h:77
void movePointersTo(Block *B)
Move all pointers from this block to.
static bool shouldBeGloballyIndexed(const ValueDecl *VD)
Returns whether we should create a global variable for the given ValueDecl.
Definition Context.h:146
OptPrimType classify(QualType T) const
Classifies a type.
Definition Context.cpp:404
unsigned getEvalID() const
Definition Context.h:161
Bytecode function.
Definition Function.h:99
A pointer to a memory block, live or dead.
Definition Pointer.h:93
void initializeAllElements() const
Initialize all elements of a primitive array at once.
Definition Pointer.cpp:598
T & elem(unsigned I) const
Dereferences the element at index I.
Definition Pointer.h:695
Function * getFunction(const FunctionDecl *F)
Returns a function.
Definition Program.cpp:280
Block * getGlobal(unsigned Idx)
Returns the value of a global.
Definition Program.h:71
UnsignedOrNone getOrCreateGlobal(const ValueDecl *VD, const Expr *Init=nullptr)
Returns or creates a global an creates an index to it.
Definition Program.cpp:112
unsigned getOrCreateNativePointer(const void *Ptr)
Marshals a native pointer to an ID for embedding in bytecode.
Definition Program.cpp:21
Pointer getPtrGlobal(unsigned Idx) const
Returns a pointer to a global.
Definition Program.cpp:81
unsigned getOrCreateDummy(const DeclTy &D)
Returns or creates a dummy value for unknown declarations.
Definition Program.cpp:124
const void * getNativePointer(unsigned Idx) const
Returns the value of a marshalled native pointer.
Definition Program.cpp:30
UnsignedOrNone createGlobal(const ValueDecl *VD, const Expr *Init)
Creates a global and returns its index.
Definition Program.cpp:170
Descriptor * createDescriptor(const DeclTy &D, PrimType T, const Type *SourceTy=nullptr, Descriptor::MetadataSize MDSize=std::nullopt, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false, bool IsVolatile=false)
Creates a descriptor for a primitive type.
Definition Program.h:119
unsigned createGlobalString(const StringLiteral *S, const Expr *Base=nullptr)
Emits a string literal among global data.
Definition Program.cpp:34
UnsignedOrNone getCurrentDecl() const
Returns the current declaration ID.
Definition Program.h:159
Record * getOrCreateRecord(const RecordDecl *RD)
Returns a record or creates one if it does not exist.
Definition Program.cpp:287
Structure/Class descriptor.
Definition Record.h:25
unsigned getSize() const
Returns the size of the record.
Definition Record.h:69
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition PrimType.h:190
bool Init(InterpState &S, CodePtr OpPC)
Definition Interp.h:2140
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
Definition PrimType.cpp:23
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
Definition Address.h:327
Token to denote structures of unknown size.
Definition Descriptor.h:140
Describes a memory block created by an allocation site.
Definition Descriptor.h:121
unsigned getAllocSize() const
Returns the allocated size, including metadata.
Definition Descriptor.h:246
static constexpr MetadataSize GlobalMD
Definition Descriptor.h:144
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
Definition Descriptor.h:147
std::optional< unsigned > MetadataSize
Definition Descriptor.h:142
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
Definition Descriptor.h:258
PrimType getPrimType() const
Definition Descriptor.h:240
Descriptor used for global variables.
Definition Descriptor.h:50
Inline descriptor embedded in structures and arrays.
Definition Descriptor.h:66