20 #ifndef LLVM_IR_DATALAYOUT_H
21 #define LLVM_IR_DATALAYOUT_H
28 #include "llvm/Support/DataTypes.h"
76 unsigned pref_align, uint32_t bit_width);
109 unsigned StackNaturalAlign;
119 ManglingModeT ManglingMode;
127 std::string StringRepresentation;
134 return const_cast<DataLayout *
>(
this)->findPointerLowerBound(AddressSpace);
148 mutable void *LayoutMap;
150 void setAlignment(
AlignTypeEnum align_type,
unsigned abi_align,
151 unsigned pref_align, uint32_t bit_width);
152 unsigned getAlignmentInfo(
AlignTypeEnum align_type, uint32_t bit_width,
153 bool ABIAlign,
Type *Ty)
const;
154 void setPointerAlignment(uint32_t AddrSpace,
unsigned ABIAlign,
155 unsigned PrefAlign, uint32_t TypeByteWidth);
158 unsigned getAlignment(
Type *Ty,
bool abi_or_pref)
const;
165 return &align != &InvalidAlignmentElem;
173 return &align != &InvalidPointerElem;
178 void parseSpecifier(
StringRef LayoutDescription);
186 reset(LayoutDescription);
198 StringRepresentation = DL.StringRepresentation;
200 StackNaturalAlign = DL.StackNaturalAlign;
201 ManglingMode = DL.ManglingMode;
202 LegalIntWidths = DL.LegalIntWidths;
203 Alignments = DL.Alignments;
204 Pointers = DL.Pointers;
226 return StringRepresentation;
230 bool isDefault()
const {
return StringRepresentation.empty(); }
240 for (
unsigned LegalIntWidth : LegalIntWidths)
241 if (LegalIntWidth == Width)
250 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)
477 unsigned StructAlignment;
478 unsigned NumElements;
479 uint64_t MemberOffsets[1];
492 assert(Idx < NumElements &&
"Invalid element idx!");
493 return MemberOffsets[Idx];
508 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. ...
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
uint64_t getSizeInBits() const
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
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
const char * getPrivateGlobalPrefix() const
bool isIllegalInteger(unsigned Width) const
unsigned getAlignment() const
4: 80-bit floating point type (X87)
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
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
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...
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.
StructType - Class to represent struct types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
DataLayout(const DataLayout &DL)
DataLayout & operator=(const DataLayout &DL)
bool isSized(SmallPtrSetImpl< const Type * > *Visited=nullptr) const
isSized - Return true if it makes sense to take the size of this type.
uint64_t getIndexedOffset(Type *Ty, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
LLVMTargetDataRef wrap(const DataLayout *P)
Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const
Returns the smallest integer type with size at least as big as Width bits.
ArrayType - Class to represent array types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
TypeID getTypeID() const
getTypeID - Return the type id for the type.
bool isLittleEndian() const
Layout endianness...
unsigned getNumElements() const
Return the number of elements in the Vector type.
Type * getElementType() const
Layout pointer alignment element.
uint64_t getElementOffset(unsigned Idx) const
uint64_t getElementOffsetInBits(unsigned Idx) const
10: Arbitrary bit width integers
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
DataLayout * unwrap(LLVMTargetDataRef P)
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...
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
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.
unsigned getIntegerBitWidth() const
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU...
15: 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...
const char * getLinkerPrivateGlobalPrefix() 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 cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
VectorType - 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().
unsigned getLargestLegalIntTypeSize() const
Returns the size of largest legal integer type size, or 0 if none are set.
uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
bool operator==(const PointerAlignElem &rhs) const
bool hasLinkerPrivateGlobalPrefix() const
bool isLegalInteger(unsigned Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
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 ...
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
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
StringRef - Represent a constant reference to a string, i.e.
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...
void init(const Module *M)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
5: 128-bit floating point type (112-bit mantissa)