20 #ifndef LLVM_IR_DATALAYOUT_H 21 #define LLVM_IR_DATALAYOUT_H 79 unsigned pref_align,
uint32_t bit_width);
116 unsigned AllocaAddrSpace;
117 unsigned StackNaturalAlign;
118 unsigned ProgramAddrSpace;
128 ManglingModeT ManglingMode;
139 return const_cast<DataLayout *
>(
this)->findAlignmentLowerBound(AlignType,
147 std::string StringRepresentation;
154 return const_cast<DataLayout *
>(
this)->findPointerLowerBound(AddressSpace);
160 mutable void *LayoutMap =
nullptr;
166 void setAlignment(
AlignTypeEnum align_type,
unsigned abi_align,
167 unsigned pref_align,
uint32_t bit_width);
170 void setPointerAlignment(
uint32_t AddrSpace,
unsigned ABIAlign,
179 void parseSpecifier(
StringRef LayoutDescription);
187 reset(LayoutDescription);
199 StringRepresentation = DL.StringRepresentation;
201 AllocaAddrSpace = DL.AllocaAddrSpace;
202 StackNaturalAlign = DL.StackNaturalAlign;
203 ProgramAddrSpace = DL.ProgramAddrSpace;
204 ManglingMode = DL.ManglingMode;
205 LegalIntWidths = DL.LegalIntWidths;
206 Alignments = DL.Alignments;
207 Pointers = DL.Pointers;
208 NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
230 return StringRepresentation;
234 bool isDefault()
const {
return StringRepresentation.empty(); }
244 for (
unsigned LegalIntWidth : LegalIntWidths)
245 if (LegalIntWidth == Width)
254 return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
263 return ManglingMode == MM_WinCOFFX86;
269 return ManglingMode == MM_WinCOFF || ManglingMode == MM_WinCOFFX86;
275 if (ManglingMode == MM_MachO)
281 switch (ManglingMode) {
295 switch (ManglingMode) {
310 static const char *getManglingComponent(
const Triple &
T);
318 for (
unsigned LegalIntWidth : LegalIntWidths)
319 if (Width <= LegalIntWidth)
325 unsigned getPointerABIAlignment(
unsigned AS)
const;
330 unsigned getPointerPrefAlignment(
unsigned AS = 0)
const;
341 unsigned getIndexSize(
unsigned AS)
const;
346 return NonIntegralAddressSpaces;
352 NonIntegralSpaces.
end();
357 return PTy && isNonIntegralPointerType(PTy);
374 return getIndexSize(AS) * 8;
382 unsigned getPointerTypeSizeInBits(
Type *)
const;
386 unsigned getIndexTypeSizeInBits(
Type *Ty)
const;
389 return getPointerTypeSizeInBits(Ty) / 8;
413 uint64_t getTypeSizeInBits(
Type *Ty)
const;
420 return (getTypeSizeInBits(Ty) + 7) / 8;
428 return 8 * getTypeStoreSize(Ty);
438 return alignTo(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
447 return 8 * getTypeAllocSize(Ty);
451 unsigned getABITypeAlignment(
Type *Ty)
const;
455 unsigned getABIIntegerTypeAlignment(
unsigned BitWidth)
const;
461 unsigned getPrefTypeAlignment(
Type *Ty)
const;
465 unsigned getPreferredTypeAlignmentShift(
Type *Ty)
const;
477 Type *getSmallestLegalIntType(
LLVMContext &C,
unsigned Width = 0)
const;
481 unsigned LargestSize = getLargestLegalIntTypeSizeInBits();
487 unsigned getLargestLegalIntTypeSizeInBits()
const;
492 Type *getIndexType(
Type *PtrTy)
const;
516 unsigned getPreferredAlignmentLog(
const GlobalVariable *GV)
const;
531 unsigned StructAlignment;
532 unsigned IsPadded : 1;
533 unsigned NumElements : 31;
534 uint64_t MemberOffsets[1];
549 unsigned getElementContainingOffset(uint64_t
Offset)
const;
552 assert(Idx < NumElements &&
"Invalid element idx!");
553 return MemberOffsets[Idx];
557 return getElementOffset(Idx) * 8;
569 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
572 return getPointerSizeInBits(0);
582 return getStructLayout(cast<StructType>(Ty))->getSizeInBits();
610 #endif // LLVM_IR_DATALAYOUT_H
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
typename SuperClass::const_iterator const_iterator
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
This class represents lattice values for constants.
StringRef getPrivateGlobalPrefix() const
A Module instance is used to store all the information related to an LLVM module. ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
2: 32-bit floating point type
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
bool operator!=(const DataLayout &Other) const
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
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 getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
char getGlobalPrefix() const
1: 16-bit floating point type
StringRef getLinkerPrivateGlobalPrefix() const
unsigned getAllocaAddrSpace() const
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
static uint32_t getAlignment(const MCSectionCOFF &Sec)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Attribute unwrap(LLVMAttributeRef Attr)
TypeID getTypeID() const
Return the type id for the type.
unsigned getPointerTypeSize(Type *Ty) const
Class to represent struct types.
uint64_t getElementOffsetInBits(unsigned Idx) const
DataLayout(const DataLayout &DL)
DataLayout & operator=(const DataLayout &DL)
uint64_t getNumElements() const
uint64_t getSizeInBits() const
Class to represent array types.
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
bool isLittleEndian() const
Layout endianness...
bool isNonIntegralPointerType(Type *Ty) const
unsigned getStackAlignment() const
Class to represent pointers.
Layout pointer alignment element.
unsigned getMaxPointerSizeInBits() const
Returns the maximum pointer size over all address spaces.
11: Arbitrary bit width integers
initializer< Ty > init(const Ty &Val)
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.
Type * getLargestLegalIntType(LLVMContext &C) const
Returns the largest legal integer type, or null if none are set.
6: 128-bit floating point type (two 64-bits, PowerPC)
unsigned getAddressSpace() const
Return the address space of the Pointer type.
bool hasLinkerPrivateGlobalPrefix() const
Class to represent integer types.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
16: SIMD 'packed' format, or other vector type
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
uint64_t getSizeInBytes() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool hasMicrosoftFastStdCallMangling() const
unsigned getProgramAddressSpace() const
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
Class to represent vector types.
typename SuperClass::iterator iterator
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
static void clear(coro::Shape &Shape)
bool isNonIntegralPointerType(PointerType *PT) const
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LLVMAttributeRef wrap(Attribute Attr)
uint64_t getElementOffset(unsigned Idx) const
unsigned getIntegerBitWidth() const
Layout alignment element.
bool hasPadding() const
Returns whether the struct has padding or not between its fields.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
unsigned AlignType
Alignment type from AlignTypeEnum.
3: 64-bit floating point type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
unsigned getAlignment() const
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
Type * getElementType() const
StringRef - Represent a constant reference to a string, i.e.
static unsigned getMaxPointerSize(const DataLayout &DL)
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU...
bool isIllegalInteger(uint64_t Width) const
bool operator==(const LayoutAlignElem &rhs) const
9: MMX vectors (64 bits, X86 specific)
bool doNotMangleLeadingQuestionMark() const
Returns true if symbols with leading question marks should not receive IR mangling.
5: 128-bit floating point type (112-bit mantissa)