19 #ifndef LLVM_IR_DATALAYOUT_H 20 #define LLVM_IR_DATALAYOUT_H 117 MultipleOfFunctionAlign,
123 unsigned AllocaAddrSpace;
125 unsigned ProgramAddrSpace;
138 ManglingModeT ManglingMode;
149 return const_cast<DataLayout *
>(
this)->findAlignmentLowerBound(AlignType,
157 std::string StringRepresentation;
164 return const_cast<DataLayout *
>(
this)->findPointerLowerBound(AddressSpace);
170 mutable void *LayoutMap =
nullptr;
188 void parseSpecifier(
StringRef LayoutDescription);
196 reset(LayoutDescription);
208 StringRepresentation = DL.StringRepresentation;
210 AllocaAddrSpace = DL.AllocaAddrSpace;
211 StackNaturalAlign = DL.StackNaturalAlign;
212 FunctionPtrAlign = DL.FunctionPtrAlign;
213 TheFunctionPtrAlignType = DL.TheFunctionPtrAlignType;
214 ProgramAddrSpace = DL.ProgramAddrSpace;
215 ManglingMode = DL.ManglingMode;
216 LegalIntWidths = DL.LegalIntWidths;
217 Alignments = DL.Alignments;
218 Pointers = DL.Pointers;
219 NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
241 return StringRepresentation;
245 bool isDefault()
const {
return StringRepresentation.empty(); }
255 for (
unsigned LegalIntWidth : LegalIntWidths)
256 if (LegalIntWidth == Width)
265 return StackNaturalAlign && (Alignment > StackNaturalAlign);
269 assert(StackNaturalAlign &&
"StackNaturalAlign must be defined");
270 return *StackNaturalAlign;
283 return TheFunctionPtrAlignType;
289 return ManglingMode == MM_WinCOFFX86;
295 return ManglingMode == MM_WinCOFF || ManglingMode == MM_WinCOFFX86;
301 if (ManglingMode == MM_MachO)
307 switch (ManglingMode) {
321 switch (ManglingMode) {
336 static const char *getManglingComponent(
const Triple &
T);
344 for (
unsigned LegalIntWidth : LegalIntWidths)
345 if (Width <= LegalIntWidth)
351 Align getPointerABIAlignment(
unsigned AS)
const;
356 Align getPointerPrefAlignment(
unsigned AS = 0)
const;
367 unsigned getIndexSize(
unsigned AS)
const;
372 return NonIntegralAddressSpaces;
377 return find(NonIntegralSpaces, AddrSpace) != NonIntegralSpaces.
end();
386 return PTy && isNonIntegralPointerType(PTy);
403 return getIndexSize(AS) * 8;
411 unsigned getPointerTypeSizeInBits(
Type *)
const;
415 unsigned getIndexTypeSizeInBits(
Type *Ty)
const;
418 return getPointerTypeSizeInBits(Ty) / 8;
455 TypeSize BaseSize = getTypeSizeInBits(Ty);
467 return 8 * getTypeStoreSize(Ty);
475 return getTypeSizeInBits(Ty) == getTypeStoreSizeInBits(Ty);
488 return alignTo(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
500 return 8 * getTypeAllocSize(Ty);
504 unsigned getABITypeAlignment(
Type *Ty)
const;
510 return Alignment ? *Alignment :
Align(getABITypeAlignment(Ty));
515 Align getABIIntegerTypeAlignment(
unsigned BitWidth)
const;
521 unsigned getPrefTypeAlignment(
Type *Ty)
const;
537 unsigned LargestSize = getLargestLegalIntTypeSizeInBits();
543 unsigned getLargestLegalIntTypeSizeInBits()
const;
548 Type *getIndexType(
Type *PtrTy)
const;
572 unsigned getPreferredAlignmentLog(
const GlobalVariable *GV)
const;
587 Align StructAlignment;
588 unsigned IsPadded : 1;
589 unsigned NumElements : 31;
590 uint64_t MemberOffsets[1];
605 unsigned getElementContainingOffset(uint64_t
Offset)
const;
608 assert(Idx < NumElements &&
"Invalid element idx!");
609 return MemberOffsets[Idx];
613 return getElementOffset(Idx) * 8;
625 assert(Ty->
isSized() &&
"Cannot getTypeInfo() on a type that is unsized!");
659 uint64_t MinBits = EltCnt.
Min *
661 return TypeSize(MinBits, EltCnt.Scalable);
670 #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.
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.
Align getStackAlignment() const
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 operator!=(const DataLayout &Other) const
unsigned getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
bool isNonIntegralAddressSpace(unsigned AddrSpace) 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 ...
4: 80-bit floating point type (X87)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
char getGlobalPrefix() const
1: 16-bit floating point type
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
bool exceedsNaturalStackAlignment(Align Alignment) const
Returns true if the given alignment exceeds the natural stack alignment.
bool typeSizeEqualsStoreSize(Type *Ty) const
Returns true if no extra padding bits are needed when storing the specified type. ...
StringRef getLinkerPrivateGlobalPrefix() const
TypeSize getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
FunctionPtrAlignType getFunctionPtrAlignType() const
Return the type of function pointer alignment.
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
For scalable vectors, this will return the minimum number of elements in the vector.
uint64_t getSizeInBits() const
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
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
Align getValueOrABITypeAlignment(MaybeAlign Alignment, Type *Ty) const
Helper function to return Alignment if it's set or the result of getABITypeAlignment(Ty), in any case the result is a valid alignment.
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.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Triple - Helper class for working with autoconf configuration names.
16: SIMD 'packed' format, or other vector type
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
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
static constexpr TypeSize Fixed(uint64_t Size)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
LLVMAttributeRef wrap(Attribute Attr)
uint64_t getElementOffset(unsigned Idx) const
unsigned getIntegerBitWidth() const
uint64_t getKnownMinSize() 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.
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
3: 64-bit floating point type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MaybeAlign getFunctionPtrAlign() const
Returns the alignment of function pointers, which may or may not be related to the alignment of funct...
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...
Align getAlignment() const
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)