19#ifndef LLVM_IR_DATALAYOUT_H
20#define LLVM_IR_DATALAYOUT_H
126 unsigned AllocaAddrSpace;
128 unsigned ProgramAddrSpace;
129 unsigned DefaultGlobalsAddrSpace;
144 ManglingModeT ManglingMode;
146 SmallVector<unsigned char, 8> LegalIntWidths;
150 using AlignmentsTy = SmallVector<LayoutAlignElem, 16>;
151 AlignmentsTy Alignments;
155 return const_cast<DataLayout *
>(
this)->findAlignmentLowerBound(AlignType,
163 std::string StringRepresentation;
165 using PointersTy = SmallVector<PointerAlignElem, 8>;
171 mutable void *LayoutMap =
nullptr;
175 SmallVector<unsigned, 8> NonIntegralAddressSpaces;
184 Error setPointerAlignmentInBits(
uint32_t AddrSpace, Align ABIAlign,
185 Align PrefAlign,
uint32_t TypeBitWidth,
192 Align getAlignment(Type *Ty,
bool abi_or_pref)
const;
196 Error parseSpecifier(StringRef Desc);
204 reset(LayoutDescription);
216 StringRepresentation =
DL.StringRepresentation;
217 BigEndian =
DL.isBigEndian();
218 AllocaAddrSpace =
DL.AllocaAddrSpace;
219 StackNaturalAlign =
DL.StackNaturalAlign;
220 FunctionPtrAlign =
DL.FunctionPtrAlign;
221 TheFunctionPtrAlignType =
DL.TheFunctionPtrAlignType;
222 ProgramAddrSpace =
DL.ProgramAddrSpace;
223 DefaultGlobalsAddrSpace =
DL.DefaultGlobalsAddrSpace;
224 ManglingMode =
DL.ManglingMode;
225 LegalIntWidths =
DL.LegalIntWidths;
226 Alignments =
DL.Alignments;
227 Pointers =
DL.Pointers;
228 NonIntegralAddressSpaces =
DL.NonIntegralAddressSpaces;
254 return StringRepresentation;
258 bool isDefault()
const {
return StringRepresentation.empty(); }
275 return StackNaturalAlign && (Alignment > *StackNaturalAlign);
279 assert(StackNaturalAlign &&
"StackNaturalAlign must be defined");
280 return *StackNaturalAlign;
293 return TheFunctionPtrAlignType;
298 return DefaultGlobalsAddrSpace;
302 return ManglingMode == MM_WinCOFFX86;
308 return ManglingMode == MM_WinCOFF || ManglingMode == MM_WinCOFFX86;
314 if (ManglingMode == MM_MachO)
320 switch (ManglingMode) {
336 switch (ManglingMode) {
363 for (
unsigned LegalIntWidth : LegalIntWidths)
364 if (Width <= LegalIntWidth)
393 return NonIntegralAddressSpaces;
406 auto *PTy = dyn_cast<PointerType>(Ty);
542 return getIntegerAlignment(
BitWidth,
true);
627 Align StructAlignment;
628 unsigned IsPadded : 1;
629 unsigned NumElements : 31;
652 return llvm::ArrayRef(getTrailingObjects<uint64_t>(), NumElements);
656 assert(
Idx < NumElements &&
"Invalid element idx!");
669 size_t numTrailingObjects(OverloadToken<uint64_t>)
const {
677 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
715 uint64_t MinBits = EltCnt.getKnownMinValue() *
717 return TypeSize(MinBits, EltCnt.isScalable());
720 Type *LayoutTy = cast<TargetExtType>(Ty)->getLayoutType();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file implements a class to represent arbitrary precision integral constant values and operations...
#define LLVM_DEPRECATED(MSG, FIX)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This header defines support for implementing classes that have some trailing object (or arrays of obj...
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent array types.
uint64_t getNumElements() const
Type * getElementType() const
A parsed version of the target data layout string in and methods for querying it.
unsigned getProgramAddressSpace() const
bool typeSizeEqualsStoreSize(Type *Ty) const
Returns true if no extra padding bits are needed when storing the specified type.
uint64_t getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
bool hasLinkerPrivateGlobalPrefix() const
static const char * getManglingComponent(const Triple &T)
StringRef getLinkerPrivateGlobalPrefix() const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned getMaxIndexSize() const
Returns the maximum index size over all address spaces.
bool isNonIntegralPointerType(Type *Ty) const
@ MultipleOfFunctionAlign
The function pointer alignment is a multiple of the function alignment.
@ Independent
The function pointer alignment is independent of the function alignment.
SmallVector< APInt > getGEPIndicesForOffset(Type *&ElemTy, APInt &Offset) const
Get GEP indices to access Offset inside ElemTy.
bool isLittleEndian() const
Layout endianness...
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
unsigned getMaxIndexSizeInBits() const
Returns the maximum index size over all address spaces.
TypeSize getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
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.
unsigned getDefaultGlobalsAddressSpace() const
FunctionPtrAlignType getFunctionPtrAlignType() const
Return the type of function pointer alignment.
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
bool doNotMangleLeadingQuestionMark() const
Returns true if symbols with leading question marks should not receive IR mangling.
void init(const Module *M)
unsigned getIndexSize(unsigned AS) const
rounded up to a whole number of bytes.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
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 getPointerTypeSize(Type *Ty) const
Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
bool isNonIntegralAddressSpace(unsigned AddrSpace) const
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
bool isIllegalInteger(uint64_t Width) const
unsigned getIndexTypeSizeInBits(Type *Ty) const
Layout size of the index used in GEP calculation.
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
bool exceedsNaturalStackAlignment(Align Alignment) const
Returns true if the given alignment exceeds the natural stack alignment.
Align getStackAlignment() const
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
uint64_t getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
unsigned getAllocaAddrSpace() const
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
std::optional< APInt > getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const
Get single GEP index to access Offset inside ElemTy.
Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const
Returns the smallest integer type with size at least as big as Width bits.
Type * getIndexType(Type *PtrTy) const
Returns the type of a GEP index.
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU.
bool hasMicrosoftFastStdCallMangling() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
bool isNonIntegralPointerType(PointerType *PT) const
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 getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
Type * getLargestLegalIntType(LLVMContext &C) const
Returns the largest legal integer type, or null if none are set.
StringRef getPrivateGlobalPrefix() const
MaybeAlign getFunctionPtrAlign() const
Returns the alignment of function pointers, which may or may not be related to the alignment of funct...
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
bool operator!=(const DataLayout &Other) const
DataLayout(const DataLayout &DL)
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
char getGlobalPrefix() const
bool operator==(const DataLayout &Other) const
int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Align getValueOrABITypeAlignment(MaybeAlign Alignment, Type *Ty) const
Helper function to return Alignment if it's set or the result of getABITypeAlignment(Ty),...
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
DataLayout & operator=(const DataLayout &DL)
Tagged union holding either a T or a Error.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
bool hasPadding() const
Returns whether the struct has padding or not between its fields.
ArrayRef< uint64_t > getMemberOffsets() const
uint64_t getElementOffsetInBits(unsigned Idx) const
uint64_t getSizeInBits() const
MutableArrayRef< uint64_t > getMemberOffsets()
uint64_t getSizeInBytes() const
uint64_t getElementOffset(unsigned Idx) const
Align getAlignment() const
unsigned getElementContainingOffset(uint64_t Offset) const
Given a valid byte offset into the structure, returns the structure index that contains it.
Class to represent struct types.
See the file comment for details on the usage of the TrailingObjects type.
Triple - Helper class for working with autoconf configuration names.
static constexpr TypeSize Fixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getIntegerBitWidth() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
TypeID getTypeID() const
Return the type id for the type.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Type * getElementType() const
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
struct LLVMOpaqueTargetData * LLVMTargetDataRef
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
Attribute unwrap(LLVMAttributeRef Attr)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr unsigned BitWidth
LLVMAttributeRef wrap(Attribute Attr)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Layout alignment element.
static LayoutAlignElem get(AlignTypeEnum align_type, Align abi_align, Align pref_align, uint32_t bit_width)
bool operator==(const LayoutAlignElem &rhs) const
unsigned AlignType
Alignment type from AlignTypeEnum.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Layout pointer alignment element.
bool operator==(const PointerAlignElem &rhs) const
static PointerAlignElem getInBits(uint32_t AddressSpace, Align ABIAlign, Align PrefAlign, uint32_t TypeBitWidth, uint32_t IndexBitWidth)
Initializer.