20 #ifndef LLVM_IR_DATALAYOUT_H
21 #define LLVM_IR_DATALAYOUT_H
79 unsigned pref_align,
uint32_t bit_width);
114 unsigned AllocaAddrSpace;
115 unsigned StackNaturalAlign;
125 ManglingModeT ManglingMode;
136 return const_cast<DataLayout *
>(
this)->findAlignmentLowerBound(AlignType,
144 std::string StringRepresentation;
151 return const_cast<DataLayout *
>(
this)->findPointerLowerBound(AddressSpace);
157 mutable void *LayoutMap =
nullptr;
163 void setAlignment(
AlignTypeEnum align_type,
unsigned abi_align,
164 unsigned pref_align,
uint32_t bit_width);
166 bool ABIAlign,
Type *Ty)
const;
167 void setPointerAlignment(
uint32_t AddrSpace,
unsigned ABIAlign,
168 unsigned PrefAlign,
uint32_t TypeByteWidth);
171 unsigned getAlignment(
Type *Ty,
bool abi_or_pref)
const;
175 void parseSpecifier(
StringRef LayoutDescription);
183 reset(LayoutDescription);
195 StringRepresentation = DL.StringRepresentation;
197 AllocaAddrSpace = DL.AllocaAddrSpace;
198 StackNaturalAlign = DL.StackNaturalAlign;
199 ManglingMode = DL.ManglingMode;
200 LegalIntWidths = DL.LegalIntWidths;
201 Alignments = DL.Alignments;
202 Pointers = DL.Pointers;
203 NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
225 return StringRepresentation;
229 bool isDefault()
const {
return StringRepresentation.empty(); }
239 for (
unsigned LegalIntWidth : LegalIntWidths)
240 if (LegalIntWidth == Width)
249 return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
256 return ManglingMode == MM_WinCOFFX86;
262 if (ManglingMode == MM_MachO)
268 switch (ManglingMode) {
282 switch (ManglingMode) {
305 for (
unsigned LegalIntWidth : LegalIntWidths)
306 if (Width <= LegalIntWidth)
329 return NonIntegralAddressSpaces;
335 NonIntegralSpaces.
end();
495 unsigned StructAlignment;
496 unsigned IsPadded : 1;
497 unsigned NumElements : 31;
498 uint64_t MemberOffsets[1];
516 assert(Idx < NumElements &&
"Invalid element idx!");
517 return MemberOffsets[Idx];
533 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
574 #endif // LLVM_IR_DATALAYOUT_H
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
typename SuperClass::const_iterator const_iterator
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
struct LLVMOpaqueTargetData * LLVMTargetDataRef
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
unsigned getAllocaAddrSpace() 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
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...
Class to represent vector types.
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
typename SuperClass::iterator iterator
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
bool operator==(const PointerAlignElem &rhs) const
llvm_unreachable("Unknown RegBank!")
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 ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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)
5: 128-bit floating point type (112-bit mantissa)