;
21 autoIt = NativePointerIndices.find(Ptr);
22 if(It != NativePointerIndices.end())
25 unsignedIdx = NativePointers.size();
26NativePointers.push_back(Ptr);
27NativePointerIndices[Ptr] = Idx;
32 returnNativePointers[Idx];
36 const size_tCharWidth = S->getCharByteWidth();
37 const size_tBitWidth = CharWidth * Ctx.
getCharBit();
38 unsignedStringLength = S->getLength();
52llvm_unreachable(
"unsupported character width");
67 unsignedGlobalIndex = Globals.size();
71G->block()->invokeCtor();
78 for(
unsignedI = 0; I <= StringLength; ++I) {
80 constuint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit(I);
84Field.deref<
T>() = T::from(CodePoint, BitWidth);
89Field.deref<
T>() = T::from(CodePoint, BitWidth);
94Field.deref<
T>() = T::from(CodePoint, BitWidth);
98llvm_unreachable(
"unsupported character type");
107assert(Idx < Globals.size());
108 return Pointer(Globals[Idx]->block());
112 if(
autoIt = GlobalIndices.find(VD); It != GlobalIndices.end())
116std::optional<unsigned> Index;
118 if(
autoIt = GlobalIndices.find(
P); It != GlobalIndices.end()) {
126GlobalIndices[VD] = *Index;
132 if(
autoIt = GlobalIndices.find(
E); It != GlobalIndices.end())
143GlobalIndices[VD] = *Idx;
152 if(
autoIt = DummyVariables.find(
D.getOpaqueValue());
153It != DummyVariables.end())
157 boolIsWeak =
false;
158 if(
const auto*
E= dyn_cast<const Expr *>(
D)) {
161 const ValueDecl*VD = cast<ValueDecl>(cast<const Decl *>(
D));
170 if(std::optional<PrimType>
T= Ctx.
classify(QT))
177Desc = allocateDescriptor(
D);
185 unsignedI = Globals.size();
190G->block()->invokeCtor();
192Globals.push_back(G);
193DummyVariables[
D.getOpaqueValue()] = I;
200 boolIsWeak = VD->
isWeak();
201 if(
const auto*Var = dyn_cast<VarDecl>(VD)) {
203IsExtern = Var->hasExternalStorage();
217 for(
const Decl*
P= VD;
P;
P=
P->getPreviousDecl()) {
219 unsignedPIdx = GlobalIndices[
P];
220 if(Globals[PIdx]->block()->isExtern())
221Globals[PIdx] = Globals[*Idx];
223GlobalIndices[
P] = *Idx;
235GlobalIndices[
E] = *Idx;
247 const boolIsTemporary =
D.dyn_cast<
const Expr*>();
248 if(std::optional<PrimType>
T= Ctx.
classify(Ty))
258 unsignedI = Globals.size();
262G->block()->invokeCtor();
268Globals.push_back(G);
276 autoIt = Funcs.find(F);
277 returnIt == Funcs.end() ? nullptr : It->second.get();
292 auto[It, Inserted] =
Records.try_emplace(RD);
297 unsignedBaseSize = 0;
299 unsignedVirtSize = 0;
302 autoGetBaseDesc = [
this](
const RecordDecl*BD,
306 returnallocateDescriptor(BD, BR, std::nullopt,
false,
312Record::BaseList Bases;
313Record::VirtualBaseList VirtBases;
314 if(
const auto*CD = dyn_cast<CXXRecordDecl>(RD)) {
316 if(Spec.isVirtual())
320 const auto*RT = Spec.getType()->getAs<
RecordType>();
331Bases.push_back({BD, BaseSize, Desc, BR});
336 const auto*RT = Spec.getType()->getAs<
RecordType>();
348VirtBases.push_back({BD, VirtSize, Desc, BR});
354Record::FieldList Fields;
356FD = FD->getFirstDecl();
367 const boolIsMutable = FD->isMutable();
369 if(std::optional<PrimType>
T= Ctx.
classify(FT)) {
378Fields.push_back({FD, BaseSize, Desc});
382 Record*R =
new(Allocator)
Record(RD, std::move(Bases), std::move(Fields),
383std::move(VirtBases), VirtSize, BaseSize);
390 boolIsConst,
boolIsTemporary,
391 boolIsMutable,
const Expr*
Init) {
396 returnallocateDescriptor(
D,
Record, MDSize, IsConst, IsTemporary,
404 if(
const auto*CAT = dyn_cast<ConstantArrayType>(
ArrayType)) {
405 size_tNumElems = CAT->getZExtSize();
406 if(std::optional<PrimType>
T= Ctx.
classify(ElemTy)) {
409 if(std::numeric_limits<unsigned>::max() / ElemSize <= NumElems) {
412 returnallocateDescriptor(
D, *
T, MDSize, NumElems, IsConst, IsTemporary,
418 D, ElemTy.
getTypePtr(), std::nullopt, IsConst, IsTemporary);
422 if(std::numeric_limits<unsigned>::max() / ElemSize <= NumElems)
424 returnallocateDescriptor(
D, ElemDesc, MDSize, NumElems, IsConst,
425IsTemporary, IsMutable);
431 if(isa<IncompleteArrayType>(
ArrayType) ||
433 if(std::optional<PrimType>
T= Ctx.
classify(ElemTy)) {
434 returnallocateDescriptor(
D, *
T, MDSize, IsTemporary,
438MDSize, IsConst, IsTemporary);
441 returnallocateDescriptor(
D, Desc, MDSize, IsTemporary,
449 const Type*InnerTy = AT->getValueType().getTypePtr();
456std::optional<PrimType> ElemTy = Ctx.
classify(CT->getElementType());
460 returnallocateDescriptor(
D, *ElemTy, MDSize, 2, IsConst, IsTemporary,
466std::optional<PrimType> ElemTy = Ctx.
classify(VT->getElementType());
470 returnallocateDescriptor(
D, *ElemTy, MDSize, VT->getNumElements(), IsConst,
471IsTemporary, IsMutable);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
llvm::MachO::Records Records
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Represents a base class of a C++ class.
Complex values, per C99 6.2.5p11.
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
This represents one expression.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool isConstQualified() const
Determine whether this type is const-qualified.
Represents a struct/union/class.
field_range fields() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Base for LValueReferenceType and RValueReferenceType.
StringLiteral - This represents a string literal expression, e.g.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
A template parameter object.
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.
const T * getAs() const
Member-template getAs<specific type>'.
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Represents a GCC generic vector type.
unsigned getCharBit() const
Returns CHAR_BIT.
static bool shouldBeGloballyIndexed(const ValueDecl *VD)
Returns whether we should create a global variable for the given ValueDecl.
std::optional< PrimType > classify(QualType T) const
Classifies a type.
unsigned getEvalID() const
A pointer to a memory block, live or dead.
Pointer atIndex(uint64_t Idx) const
Offsets a pointer inside an array.
void initialize() const
Initializes a field.
std::optional< unsigned > getOrCreateGlobal(const ValueDecl *VD, const Expr *Init=nullptr)
Returns or creates a global an creates an index to it.
Function * getFunction(const FunctionDecl *F)
Returns a function.
Block * getGlobal(unsigned Idx)
Returns the value of a global.
std::optional< unsigned > createGlobal(const ValueDecl *VD, const Expr *Init)
Creates a global and returns its index.
const void * getNativePointer(unsigned Idx)
Returns the value of a marshalled native pointer.
Descriptor * createDescriptor(const DeclTy &D, PrimType Type, Descriptor::MetadataSize MDSize=std::nullopt, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false)
Creates a descriptor for a primitive type.
unsigned getOrCreateNativePointer(const void *Ptr)
Marshals a native pointer to an ID for embedding in bytecode.
Pointer getPtrGlobal(unsigned Idx) const
Returns a pointer to a global.
unsigned getOrCreateDummy(const DeclTy &D)
Returns or creates a dummy value for unknown declarations.
std::optional< unsigned > getCurrentDecl() const
Returns the current declaration ID.
unsigned createGlobalString(const StringLiteral *S, const Expr *Base=nullptr)
Emits a string literal among global data.
Record * getOrCreateRecord(const RecordDecl *RD)
Returns a record or creates one if it does not exist.
Structure/Class descriptor.
unsigned getSize() const
Returns the size of the record.
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.
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
const FunctionProtoType * T
Token to denote structures of unknown size.
Describes a memory block created by an allocation site.
unsigned getAllocSize() const
Returns the allocated size, including metadata.
void makeDummy()
Make this descriptor a dummy descriptor.
static constexpr MetadataSize GlobalMD
bool isDummy() const
Checks if this is a dummy descriptor.
std::optional< unsigned > MetadataSize
Descriptor used for global variables.
GlobalInitState InitState
Inline descriptor embedded in structures and arrays.
Mapping from primitive types to their representation.
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