20 #ifndef LLVM_IR_DATALAYOUT_H
21 #define LLVM_IR_DATALAYOUT_H
28 #include "llvm/Support/DataTypes.h"
67 unsigned pref_align, uint32_t bit_width);
86 unsigned pref_align, uint32_t bit_width);
101 unsigned StackNaturalAlign;
123 mutable void *LayoutMap;
126 void setAlignment(
AlignTypeEnum align_type,
unsigned abi_align,
127 unsigned pref_align, uint32_t bit_width);
128 unsigned getAlignmentInfo(
AlignTypeEnum align_type, uint32_t bit_width,
129 bool ABIAlign,
Type *Ty)
const;
132 void setPointerAlignment(uint32_t addr_space,
unsigned abi_align,
133 unsigned pref_align, uint32_t bit_width);
136 unsigned getAlignment(
Type *Ty,
bool abi_or_pref)
const;
143 return &align != &InvalidAlignmentElem;
151 return &align != &InvalidPointerElem;
156 void parseSpecifier(
StringRef LayoutDescription);
168 init(LayoutDescription);
177 StackNaturalAlign(DL.StackNaturalAlign),
178 LegalIntWidths(DL.LegalIntWidths),
179 Alignments(DL.Alignments),
180 Pointers(DL.Pointers),
211 for (
unsigned i = 0, e = (
unsigned)LegalIntWidths.
size(); i != e; ++i)
212 if (LegalIntWidths[i] == Width)
223 return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
231 for (
unsigned i = 0, e = (
unsigned)LegalIntWidths.
size(); i != e; ++i)
232 if (Width <= LegalIntWidths[i])
242 if (val == Pointers.end()) {
243 val = Pointers.find(0);
245 return val->second.ABIAlign;
253 if (val == Pointers.end()) {
254 val = Pointers.find(0);
256 return val->second.PrefAlign;
263 if (val == Pointers.end()) {
264 val = Pointers.find(0);
266 return val->second.TypeBitWidth;
406 template <
typename UIntTy>
408 assert((Alignment & (Alignment-1)) == 0 &&
"Alignment must be power of 2!");
409 return (Val + (Alignment-1)) & ~UIntTy(Alignment-1);
420 unsigned StructAlignment;
421 unsigned NumElements;
422 uint64_t MemberOffsets[1];
434 return StructAlignment;
443 assert(Idx < NumElements &&
"Invalid element idx!");
444 return MemberOffsets[Idx];
460 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
unsigned PrefAlign
Pref. alignment for this type/bitw.
std::string getStringRepresentation() const
COFF::RelocationTypeX86 Type
unsigned getPointerPrefAlignment(unsigned AS=0) const
uint64_t getSizeInBits() const
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
unsigned TypeBitWidth
Type bit width.
The main container class for the LLVM Intermediate Representation.
2: 32-bit floating point type
unsigned getPointerSize(unsigned AS=0) const
unsigned getPointerTypeSizeInBits(Type *) const
unsigned getPrefTypeAlignment(Type *Ty) const
bool isIllegalInteger(unsigned Width) const
unsigned getAlignment() const
4: 80-bit floating point type (X87)
1: 16-bit floating point type
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
uint64_t getTypeAllocSizeInBits(Type *Ty) const
unsigned getPointerTypeSize(Type *Ty) const
unsigned getPointerABIAlignment(unsigned AS=0) const
const StructLayout * getStructLayout(StructType *Ty) const
unsigned getPreferredTypeAlignmentShift(Type *Ty) const
#define llvm_unreachable(msg)
DataLayout(const DataLayout &DL)
unsigned ABIAlign
ABI alignment for this type/bitw.
uint64_t getIndexedOffset(Type *Ty, ArrayRef< Value * > Indices) const
Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const
static UIntTy RoundUpAlignment(UIntTy Val, unsigned Alignment)
unsigned PrefAlign
Pref. alignment for this type/bitw.
bool isLittleEndian() const
Layout endianness...
bool doFinalization(Module &M)
unsigned getNumElements() const
Return the number of elements in the Vector type.
Type * getElementType() const
uint64_t getElementOffset(unsigned Idx) const
uint64_t getElementOffsetInBits(unsigned Idx) const
10: Arbitrary bit width integers
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Floating point type alignment.
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
uint32_t AddressSpace
Address space for the pointer type.
Integer representation type.
Type * getLargestLegalIntType(LLVMContext &C) const
bool operator==(const LayoutAlignElem &rhs) const
Equality predicate.
unsigned getPreferredAlignment(const GlobalVariable *GV) const
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
unsigned getABITypeAlignment(Type *Ty) const
unsigned getIntegerBitWidth() const
bool fitsInLegalInteger(unsigned Width) const
15: SIMD 'packed' format, or other vector type
uint64_t getTypeAllocSize(Type *Ty) const
uint32_t TypeBitWidth
Type bit width.
uint64_t getSizeInBytes() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getElementContainingOffset(uint64_t Offset) const
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 init().
unsigned getLargestLegalIntTypeSize() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
bool operator==(const PointerAlignElem &rhs) const
Equality predicate.
void init(StringRef LayoutDescription)
unsigned getCallFrameTypeAlignment(Type *Ty) const
unsigned ABIAlign
ABI alignment for this type/bitw.
bool isLegalInteger(unsigned Width) const
unsigned getPointerSizeInBits(unsigned AS=0) const
unsigned AlignType
Alignment type (AlignTypeEnum)
uint64_t getTypeStoreSize(Type *Ty) const
3: 64-bit floating point type
uint64_t getTypeSizeInBits(Type *Ty) const
9: MMX vectors (64 bits, X86 specific)
5: 128-bit floating point type (112-bit mantissa)