13#ifndef LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
14#define LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
33using BlockCtorFn = void (*)(std::byte *FieldPtr,
bool IsConst,
bool IsMutable,
34 bool IsVolatile,
bool IsActive,
bool InUnion,
70static_assert(
sizeof(LocalInlineDescriptor) ==
sizeof(
void *));
84 LLVM_PREFERRED_TYPE(
bool)
90 LLVM_PREFERRED_TYPE(
bool)
93 LLVM_PREFERRED_TYPE(
bool)
96 LLVM_PREFERRED_TYPE(
bool)
99 LLVM_PREFERRED_TYPE(
bool)
102 LLVM_PREFERRED_TYPE(
bool)
105 LLVM_PREFERRED_TYPE(
bool)
109 LLVM_PREFERRED_TYPE(
bool)
112 LLVM_PREFERRED_TYPE(
bool)
114 LLVM_PREFERRED_TYPE(
bool)
122 void dump(llvm::raw_ostream &OS)
const;
130 const Type *SourceType =
nullptr;
132 const unsigned ElemSize;
136 const unsigned AllocSize;
139 static constexpr unsigned UnknownSizeMark = (
unsigned)-1;
209 return dyn_cast_if_present<ValueDecl>(
asDecl());
213 return dyn_cast_if_present<VarDecl>(
asDecl());
217 return dyn_cast_if_present<FieldDecl>(
asDecl());
221 return dyn_cast_if_present<RecordDecl>(
asDecl());
224 template <
typename T>
const T *
getAs()
const {
225 return dyn_cast_if_present<T>(
asDecl());
288 void dump(llvm::raw_ostream &OS)
const;
__DEVICE__ int max(int __a, int __b)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
This is an opaque type for sizes expressed in character units.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
A (possibly-)qualified type.
Represents a struct/union/class.
Encodes a location in the source.
The base class of the type hierarchy.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Structure/Class descriptor.
Describes the statement/declaration an opcode was generated from.
void(*)(std::byte *FieldPtr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *FieldDesc) BlockCtorFn
Invoked whenever a block is created.
PrimType
Enumeration of the primitive types of the VM.
void(*)(std::byte *FieldPtr, const Descriptor *FieldDesc) BlockDtorFn
Invoked when a block is destroyed.
Top level wrappers for InstallAPI frontend operations.
DynAllocKind
Kind of source for a dynamic allocation.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
const FunctionProtoType * T
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 uint8_t
Token to denote structures of unknown size.
Describes a memory block created by an allocation site.
const bool IsConst
Flag indicating if the block is mutable.
unsigned getAllocSize() const
Returns the allocated size, including metadata.
unsigned getNumElems() const
Returns the number of elements stored in the block.
unsigned getSize() const
Returns the size of the object without metadata.
void dumpFull(unsigned Offset=0, unsigned Indent=0) const
Dump descriptor, including all valid offsets.
SourceLocation getLocation() const
bool isPrimitive() const
Checks if the descriptor is of a primitive.
QualType getElemQualType() const
const RecordDecl * asRecordDecl() const
bool hasTrivialDtor() const
Whether variables of this descriptor need their destructor called or not.
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
const OptPrimType PrimT
The primitive type this descriptor was created for, or the primitive element type in case this is a p...
const ValueDecl * asValueDecl() const
const BlockCtorFn CtorFn
Storage management methods.
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
const Decl * asDecl() const
const Descriptor *const ElemDesc
Descriptor of the array element.
SourceInfo getLoc() const
const bool IsMutable
Flag indicating if a field is mutable.
QualType getDataType(const ASTContext &Ctx) const
bool isDynAlloc() const
Checks if the descriptor is of a dynamic allocation.
bool isUnknownSizeArray() const
Checks if the descriptor is of an array of unknown size.
static DynAllocKind getDynAllocKindForExpr(const Expr *E)
Returns the kind of dynamic allocation source of this block.
unsigned getElemSize() const
returns the size of an element when the structure is viewed as an array.
const bool IsArray
Flag indicating if the block is an array.
unsigned getElemDataSize() const
Returns the element data size, i.e.
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
DynAllocKind getDynAllocKind() const
Returns the kind of dynamic allocation source of this block.
DeclOrExpr getSource() const
bool isZeroSizeArray() const
Checks if the descriptor is of an array of zero size.
const FieldDecl * asFieldDecl() const
Descriptor(DeclOrExpr D, const Type *SourceTy, PrimType Type, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
Allocates a descriptor for a primitive.
const VarDecl * asVarDecl() const
PrimType getPrimType() const
CharUnits computeAlignForDynamicAlloc(const ASTContext &Ctx) const
Compute the alignment for a dynamic allocation.
bool isRecord() const
Checks if the descriptor is of a record.
const bool IsTemporary
Flag indicating if the block is a temporary.
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.
Descriptor used for global variables.
GlobalInitState InitState
A pointer-sized struct we use to allocate into data storage.
Inline descriptor embedded in structures and arrays.
unsigned IsActive
Flag indicating if the field is the active member of a union.
unsigned IsConstInMutable
Flag indicating if this field is a const field nested in a mutable parent field.
unsigned IsBase
Flag indicating if the field is an embedded base class.
unsigned IsVirtualBase
Flag inidcating if the field is a virtual base class.
unsigned InUnion
Flag indicating if this field is in a union (even if nested).
unsigned Offset
Offset inside the structure/array.
unsigned IsInitialized
For primitive fields, it indicates if the field was initialized.
unsigned IsConst
Flag indicating if the storage is constant or not.
unsigned IsArrayElement
Flag indicating if the field is an element of a composite array.
unsigned IsFieldMutable
Flag indicating if the field is mutable (if in a record).
Lifetime getLifetime() const
void setLifetime(Lifetime L)