20 #ifndef LLVM_IR_DATALAYOUT_H
21 #define LLVM_IR_DATALAYOUT_H
28 #include "llvm/Support/DataTypes.h"
74 unsigned pref_align,
uint32_t bit_width);
107 unsigned StackNaturalAlign;
117 ManglingModeT ManglingMode;
125 std::string StringRepresentation;
132 return const_cast<DataLayout *
>(
this)->findPointerLowerBound(AddressSpace);
146 mutable void *LayoutMap;
152 void setAlignment(
AlignTypeEnum align_type,
unsigned abi_align,
153 unsigned pref_align,
uint32_t bit_width);
155 bool ABIAlign,
Type *Ty)
const;
156 void setPointerAlignment(
uint32_t AddrSpace,
unsigned ABIAlign,
157 unsigned PrefAlign,
uint32_t TypeByteWidth);
160 unsigned getAlignment(
Type *Ty,
bool abi_or_pref)
const;
167 return &align != &InvalidAlignmentElem;
175 return &align != &InvalidPointerElem;
180 void parseSpecifier(
StringRef LayoutDescription);
188 reset(LayoutDescription);
200 StringRepresentation = DL.StringRepresentation;
202 StackNaturalAlign = DL.StackNaturalAlign;
203 ManglingMode = DL.ManglingMode;
204 LegalIntWidths = DL.LegalIntWidths;
205 Alignments = DL.Alignments;
206 Pointers = DL.Pointers;
207 NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
229 return StringRepresentation;
233 bool isDefault()
const {
return StringRepresentation.empty(); }
243 for (
unsigned LegalIntWidth : LegalIntWidths)
244 if (LegalIntWidth == Width)
253 return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
259 return ManglingMode == MM_WinCOFFX86;
265 if (ManglingMode == MM_MachO)
271 switch (ManglingMode) {
285 switch (ManglingMode) {
308 for (
unsigned LegalIntWidth : LegalIntWidths)
309 if (Width <= LegalIntWidth)
332 return NonIntegralAddressSpaces;
338 NonIntegralSpaces.
end();
498 unsigned StructAlignment;
499 unsigned IsPadded : 1;
500 unsigned NumElements : 31;
501 uint64_t MemberOffsets[1];
518 assert(Idx < NumElements &&
"Invalid element idx!");
519 return MemberOffsets[Idx];
534 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
A parsed version of the target data layout string in and methods for querying it. ...
StringRef getPrivateGlobalPrefix() const
bool hasPadding() const
Returns whether the struct has padding or not between its fields.
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
bool isNonIntegralPointerType(PointerType *PT) const
uint64_t getSizeInBits() const
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
StringRef getLinkerPrivateGlobalPrefix() const
A Module instance is used to store all the information related to an LLVM module. ...
2: 32-bit floating point type
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
unsigned getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
unsigned getStackAlignment() const
unsigned getAlignment() const
4: 80-bit floating point type (X87)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
1: 16-bit floating point type
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
bool operator==(const DataLayout &Other) const
static const char * getManglingComponent(const Triple &T)
char getGlobalPrefix() const
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
unsigned getPointerTypeSize(Type *Ty) const
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
bool hasMicrosoftFastStdCallMangling() const
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
Attribute unwrap(LLVMAttributeRef Attr)
unsigned getPreferredTypeAlignmentShift(Type *Ty) const
Returns the preferred alignment for the specified type, returned as log2 of the value (a shift amount...
unsigned getPointerABIAlignment(unsigned AS=0) const
Layout pointer alignment FIXME: The defaults need to be removed once all of the backends/clients are ...
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Class to represent struct types.
DataLayout(const DataLayout &DL)
DataLayout & operator=(const DataLayout &DL)
Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const
Returns the smallest integer type with size at least as big as Width bits.
Class to represent array types.
TypeID getTypeID() const
Return the type id for the type.
bool isLittleEndian() const
Layout endianness...
Type * getElementType() const
Class to represent pointers.
Layout pointer alignment element.
uint64_t getElementOffset(unsigned Idx) const
uint64_t getElementOffsetInBits(unsigned Idx) const
11: Arbitrary bit width integers
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
bool isIllegalInteger(uint64_t Width) const
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
unsigned getIntegerBitWidth() const
Class to represent integer types.
Type * getLargestLegalIntType(LLVMContext &C) const
Returns the largest legal integer type, or null if none are set.
bool operator==(const LayoutAlignElem &rhs) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getPreferredAlignment(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
bool operator!=(const DataLayout &Other) const
Triple - Helper class for working with autoconf configuration names.
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global, returned in log form.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU...
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
16: SIMD 'packed' format, or other vector type
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool isNonIntegralPointerType(Type *Ty) const
uint64_t getSizeInBytes() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getElementContainingOffset(uint64_t Offset) const
Given a valid byte offset into the structure, returns the structure index that contains it...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class to represent vector types.
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
bool operator==(const PointerAlignElem &rhs) const
LLVMAttributeRef wrap(Attribute Attr)
bool hasLinkerPrivateGlobalPrefix() const
Layout alignment element.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned AlignType
Alignment type from AlignTypeEnum.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
3: 64-bit floating point type
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
StringRef - Represent a constant reference to a string, i.e.
unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
9: MMX vectors (64 bits, X86 specific)
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
void init(const Module *M)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
5: 128-bit floating point type (112-bit mantissa)