Go to the documentation of this file.
19 #ifndef LLVM_IR_DATALAYOUT_H
20 #define LLVM_IR_DATALAYOUT_H
125 unsigned AllocaAddrSpace;
127 unsigned ProgramAddrSpace;
128 unsigned DefaultGlobalsAddrSpace;
143 ManglingModeT ManglingMode;
145 SmallVector<unsigned char, 8> LegalIntWidths;
149 using AlignmentsTy = SmallVector<LayoutAlignElem, 16>;
150 AlignmentsTy Alignments;
154 return const_cast<DataLayout *
>(
this)->findAlignmentLowerBound(AlignType,
162 std::string StringRepresentation;
164 using PointersTy = SmallVector<PointerAlignElem, 8>;
170 mutable void *LayoutMap =
nullptr;
174 SmallVector<unsigned, 8> NonIntegralAddressSpaces;
191 Align getAlignment(Type *Ty,
bool abi_or_pref)
const;
195 Error parseSpecifier(StringRef Desc);
203 reset(LayoutDescription);
215 StringRepresentation =
DL.StringRepresentation;
216 BigEndian =
DL.isBigEndian();
217 AllocaAddrSpace =
DL.AllocaAddrSpace;
218 StackNaturalAlign =
DL.StackNaturalAlign;
219 FunctionPtrAlign =
DL.FunctionPtrAlign;
220 TheFunctionPtrAlignType =
DL.TheFunctionPtrAlignType;
221 ProgramAddrSpace =
DL.ProgramAddrSpace;
222 DefaultGlobalsAddrSpace =
DL.DefaultGlobalsAddrSpace;
223 ManglingMode =
DL.ManglingMode;
224 LegalIntWidths =
DL.LegalIntWidths;
225 Alignments =
DL.Alignments;
226 Pointers =
DL.Pointers;
227 NonIntegralAddressSpaces =
DL.NonIntegralAddressSpaces;
253 return StringRepresentation;
257 bool isDefault()
const {
return StringRepresentation.empty(); }
274 return StackNaturalAlign && (Alignment > *StackNaturalAlign);
278 assert(StackNaturalAlign &&
"StackNaturalAlign must be defined");
279 return *StackNaturalAlign;
292 return TheFunctionPtrAlignType;
297 return DefaultGlobalsAddrSpace;
301 return ManglingMode == MM_WinCOFFX86;
307 return ManglingMode == MM_WinCOFF || ManglingMode == MM_WinCOFFX86;
313 if (ManglingMode == MM_MachO)
319 switch (ManglingMode) {
335 switch (ManglingMode) {
362 for (
unsigned LegalIntWidth : LegalIntWidths)
363 if (
Width <= LegalIntWidth)
392 return NonIntegralAddressSpaces;
405 auto *PTy = dyn_cast<PointerType>(Ty);
540 return getIntegerAlignment(
BitWidth,
true);
624 Align StructAlignment;
625 unsigned IsPadded : 1;
626 unsigned NumElements : 31;
653 assert(Idx < NumElements &&
"Invalid element idx!");
666 size_t numTrailingObjects(OverloadToken<uint64_t>)
const {
674 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
712 uint64_t MinBits = EltCnt.getKnownMinValue() *
714 return TypeSize(MinBits, EltCnt.isScalable());
723 #endif // LLVM_IR_DATALAYOUT_H
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool hasPadding() const
Returns whether the struct has padding or not between its fields.
@ FloatTyID
32-bit floating point type
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
@ DoubleTyID
64-bit floating point type
This is an optimization pass for GlobalISel generic memory operations.
bool exceedsNaturalStackAlignment(Align Alignment) const
Returns true if the given alignment exceeds the natural stack alignment.
TypeSize getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
unsigned getIndexTypeSizeInBits(Type *Ty) const
Layout size of the index used in GEP calculation.
A parsed version of the target data layout string in and methods for querying it.
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
ScalarTy getFixedSize() const
unsigned getProgramAddressSpace() const
unsigned getDefaultGlobalsAddressSpace() const
Layout pointer alignment element.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
@ Independent
The function pointer alignment is independent of the function alignment.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
MutableArrayRef< uint64_t > getMemberOffsets()
Align getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
TypeID getTypeID() const
Return the type id for the type.
Triple - Helper class for working with autoconf configuration names.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
Type * getIndexType(Type *PtrTy) const
Returns the type of a GEP index.
The instances of the Type class are immutable: once they are created, they are never changed.
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU.
static const char * getManglingComponent(const Triple &T)
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
Type * getElementType() const
Tagged union holding either a T or a Error.
Class to represent array types.
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
bool hasLinkerPrivateGlobalPrefix() const
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
@ MultipleOfFunctionAlign
The function pointer alignment is a multiple of the function alignment.
Optional< APInt > getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const
Get single GEP index to access Offset inside ElemTy.
Align getValueOrABITypeAlignment(MaybeAlign Alignment, Type *Ty) const
Helper function to return Alignment if it's set or the result of getABITypeAlignment(Ty),...
struct LLVMOpaqueTargetData * LLVMTargetDataRef
DataLayout & operator=(const DataLayout &DL)
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
uint64_t getSizeInBits() const
bool operator!=(const DataLayout &Other) const
static PointerAlignElem getInBits(uint32_t AddressSpace, Align ABIAlign, Align PrefAlign, uint32_t TypeBitWidth, uint32_t IndexBitWidth)
Initializer.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
uint64_t getNumElements() const
uint64_t getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
(vector float) vec_cmpeq(*A, *B) C
bool doNotMangleLeadingQuestionMark() const
Returns true if symbols with leading question marks should not receive IR mangling.
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
uint64_t getElementOffsetInBits(unsigned Idx) const
unsigned getPointerTypeSize(Type *Ty) const
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static TypeSize Fixed(ScalarTy MinVal)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Class to represent integer types.
Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Layout alignment element.
Attribute unwrap(LLVMAttributeRef Attr)
unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
Align getStackAlignment() const
unsigned getIndexSize(unsigned AS) const
rounded up to a whole number of bytes.
This struct is a compact representation of a valid (non-zero power of two) alignment.
@ BFloatTyID
16-bit floating point type (7-bit significand)
unsigned getIntegerBitWidth() const
void init(const Module *M)
StringRef getLinkerPrivateGlobalPrefix() const
MaybeAlign getFunctionPtrAlign() const
Returns the alignment of function pointers, which may or may not be related to the alignment of funct...
bool hasMicrosoftFastStdCallMangling() const
Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
Base class of all SIMD vector types.
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
unsigned getMaxIndexSize() const
Returns the maximum index size over all address spaces.
bool isLittleEndian() const
Layout endianness...
This is an important class for using LLVM in a threaded context.
unsigned getElementContainingOffset(uint64_t Offset) const
Given a valid byte offset into the structure, returns the structure index that contains it.
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
Class to represent pointers.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
char getGlobalPrefix() const
typename SuperClass::const_iterator const_iterator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Expected< DataLayout > parse(StringRef LayoutDescription)
Parse a data layout string and return the layout.
uint64_t getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
A Module instance is used to store all the information related to an LLVM module.
DataLayout(const DataLayout &DL)
Class for arbitrary precision integers.
unsigned getMaxIndexSizeInBits() const
Returns the maximum index size over all address spaces.
@ FP128TyID
128-bit floating point type (112-bit significand)
LLVMAttributeRef wrap(Attribute Attr)
bool isNonIntegralAddressSpace(unsigned AddrSpace) const
bool isNonIntegralPointerType(Type *Ty) const
Class to represent struct types.
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
StringRef - Represent a constant reference to a string, i.e.
uint64_t getSizeInBytes() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isNonIntegralPointerType(PointerType *PT) const
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Machine Check Debug Module
FunctionPtrAlignType getFunctionPtrAlignType() const
Return the type of function pointer alignment.
unsigned getAllocaAddrSpace() const
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU.
Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const
Returns the smallest integer type with size at least as big as Width bits.
@ IntegerTyID
Arbitrary bit width integers.
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.
bool typeSizeEqualsStoreSize(Type *Ty) const
Returns true if no extra padding bits are needed when storing the specified type.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool operator==(const LayoutAlignElem &rhs) const
uint64_t getElementOffset(unsigned Idx) const
StringRef getPrivateGlobalPrefix() const
@ FixedVectorTyID
Fixed width SIMD vector type.
bool operator==(const PointerAlignElem &rhs) const
constexpr unsigned BitWidth
bool isIllegalInteger(uint64_t Width) const
See the file comment for details on the usage of the TrailingObjects type.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Type * getLargestLegalIntType(LLVMContext &C) const
Returns the largest legal integer type, or null if none are set.
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
SmallVector< APInt > getGEPIndicesForOffset(Type *&ElemTy, APInt &Offset) const
Get GEP indices to access Offset inside ElemTy.
typename SuperClass::iterator iterator
static LayoutAlignElem get(AlignTypeEnum align_type, Align abi_align, Align pref_align, uint32_t bit_width)
bool operator==(const DataLayout &Other) const
unsigned AlignType
Alignment type from AlignTypeEnum.
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
ScalarTy getKnownMinSize() const
@ ScalableVectorTyID
Scalable SIMD vector type.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Align getAlignment() const
ArrayRef< uint64_t > getMemberOffsets() const
@ HalfTyID
16-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
Type * getElementType() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
Optional< std::vector< StOtherPiece > > Other
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...