LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::DataLayout Class Reference

A parsed version of the target data layout string in and methods for querying it. More...

#include "llvm/IR/DataLayout.h"

Classes

struct  PointerSpec
 Pointer type specification. More...
 
struct  PrimitiveSpec
 Primitive type specification. More...
 

Public Types

enum class  FunctionPtrAlignType { Independent , MultipleOfFunctionAlign }
 

Public Member Functions

 DataLayout ()
 Constructs a DataLayout with default values.
 
 DataLayout (StringRef LayoutString)
 Constructs a DataLayout from a specification string.
 
 DataLayout (const DataLayout &DL)
 
 ~DataLayout ()
 
DataLayoutoperator= (const DataLayout &Other)
 
bool operator== (const DataLayout &Other) const
 
bool operator!= (const DataLayout &Other) const
 
bool isLittleEndian () const
 Layout endianness...
 
bool isBigEndian () const
 
const std::string & getStringRepresentation () const
 Returns the string representation of the DataLayout.
 
bool isDefault () const
 Test if the DataLayout was constructed from an empty string.
 
bool isLegalInteger (uint64_t Width) const
 Returns true if the specified type is known to be a native integer type supported by the CPU.
 
bool isIllegalInteger (uint64_t Width) const
 
bool exceedsNaturalStackAlignment (Align Alignment) const
 Returns true if the given alignment exceeds the natural stack alignment.
 
Align getStackAlignment () const
 
unsigned getAllocaAddrSpace () const
 
PointerTypegetAllocaPtrType (LLVMContext &Ctx) const
 
MaybeAlign getFunctionPtrAlign () const
 Returns the alignment of function pointers, which may or may not be related to the alignment of functions.
 
FunctionPtrAlignType getFunctionPtrAlignType () const
 Return the type of function pointer alignment.
 
unsigned getProgramAddressSpace () const
 
unsigned getDefaultGlobalsAddressSpace () const
 
bool hasMicrosoftFastStdCallMangling () const
 
bool doNotMangleLeadingQuestionMark () const
 Returns true if symbols with leading question marks should not receive IR mangling.
 
bool hasLinkerPrivateGlobalPrefix () const
 
StringRef getLinkerPrivateGlobalPrefix () const
 
char getGlobalPrefix () const
 
StringRef getPrivateGlobalPrefix () const
 
bool fitsInLegalInteger (unsigned Width) const
 Returns true if the specified type fits in a native integer type supported by the CPU.
 
Align getPointerABIAlignment (unsigned AS) const
 Layout pointer alignment.
 
Align getPointerPrefAlignment (unsigned AS=0) const
 Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of the backends/clients are updated.
 
unsigned getPointerSize (unsigned AS=0) const
 Layout pointer size in bytes, rounded up to a whole number of bytes.
 
unsigned getMaxIndexSize () const
 Returns the maximum index size over all address spaces.
 
unsigned getIndexSize (unsigned AS) const
 rounded up to a whole number of bytes.
 
ArrayRef< unsignedgetNonIntegralAddressSpaces () const
 Return the address spaces containing non-integral pointers.
 
bool isNonIntegralAddressSpace (unsigned AddrSpace) const
 
bool isNonIntegralPointerType (PointerType *PT) const
 
bool isNonIntegralPointerType (Type *Ty) 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 are updated.
 
unsigned getMaxIndexSizeInBits () const
 Returns the maximum index size over all address spaces.
 
unsigned getIndexSizeInBits (unsigned AS) const
 Size in bits of index used for address calculation in getelementptr.
 
unsigned getPointerTypeSizeInBits (Type *) const
 Layout pointer size, in bits, based on the type.
 
unsigned getIndexTypeSizeInBits (Type *Ty) const
 Layout size of the index used in GEP calculation.
 
unsigned getPointerTypeSize (Type *Ty) const
 
TypeSize getTypeSizeInBits (Type *Ty) const
 Size examples:
 
TypeSize getTypeStoreSize (Type *Ty) const
 Returns the maximum number of bytes that may be overwritten by storing the specified type.
 
TypeSize getTypeStoreSizeInBits (Type *Ty) const
 Returns the maximum number of bits that may be overwritten by storing the specified type; always a multiple of 8.
 
bool typeSizeEqualsStoreSize (Type *Ty) const
 Returns true if no extra padding bits are needed when storing the specified type.
 
TypeSize getTypeAllocSize (Type *Ty) const
 Returns the offset in bytes between successive objects of the specified type, including alignment padding.
 
TypeSize getTypeAllocSizeInBits (Type *Ty) const
 Returns the offset in bits between successive objects of the specified type, including alignment padding; always a multiple of 8.
 
Align getABITypeAlign (Type *Ty) const
 Returns the minimum ABI-required alignment for the specified type.
 
Align getValueOrABITypeAlignment (MaybeAlign Alignment, Type *Ty) const
 Helper function to return Alignment if it's set or the result of getABITypeAlign(Ty), in any case the result is a valid alignment.
 
Align getABIIntegerTypeAlignment (unsigned BitWidth) const
 Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
 
Align getPrefTypeAlign (Type *Ty) const
 Returns the preferred stack/global alignment for the specified type.
 
IntegerTypegetIntPtrType (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.
 
TypegetIntPtrType (Type *) const
 Returns an integer (vector of integer) type with size at least as big as that of a pointer of the given pointer (vector of pointer) type.
 
TypegetSmallestLegalIntType (LLVMContext &C, unsigned Width=0) const
 Returns the smallest integer type with size at least as big as Width bits.
 
TypegetLargestLegalIntType (LLVMContext &C) const
 Returns the largest legal integer type, or null if none are set.
 
unsigned getLargestLegalIntTypeSizeInBits () const
 Returns the size of largest legal integer type size, or 0 if none are set.
 
IntegerTypegetIndexType (LLVMContext &C, unsigned AddressSpace) const
 Returns the type of a GEP index in AddressSpace.
 
TypegetIndexType (Type *PtrTy) const
 Returns the type of a GEP index.
 
int64_t getIndexedOffsetInType (Type *ElemTy, ArrayRef< Value * > Indices) const
 Returns the offset from the beginning of the type for the specified indices.
 
SmallVector< APIntgetGEPIndicesForOffset (Type *&ElemTy, APInt &Offset) const
 Get GEP indices to access Offset inside ElemTy.
 
std::optional< APIntgetGEPIndexForOffset (Type *&ElemTy, APInt &Offset) const
 Get single GEP index to access Offset inside ElemTy.
 
const StructLayoutgetStructLayout (StructType *Ty) const
 Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of its fields.
 
Align getPreferredAlign (const GlobalVariable *GV) const
 Returns the preferred alignment of the specified global.
 

Static Public Member Functions

static Expected< DataLayoutparse (StringRef LayoutString)
 Parse a data layout string and return the layout.
 
static const chargetManglingComponent (const Triple &T)
 

Detailed Description

A parsed version of the target data layout string in and methods for querying it.

The target data layout string is specified by the target - a frontend generating LLVM IR is required to generate the right target data for the target being codegen'd to.

Definition at line 63 of file DataLayout.h.

Member Enumeration Documentation

◆ FunctionPtrAlignType

Enumerator
Independent 

The function pointer alignment is independent of the function alignment.

MultipleOfFunctionAlign 

The function pointer alignment is a multiple of the function alignment.

Definition at line 85 of file DataLayout.h.

Constructor & Destructor Documentation

◆ DataLayout() [1/3]

DataLayout::DataLayout ( )

Constructs a DataLayout with default values.

Definition at line 212 of file DataLayout.cpp.

◆ DataLayout() [2/3]

DataLayout::DataLayout ( StringRef  LayoutString)
explicit

Constructs a DataLayout from a specification string.

WARNING: Aborts execution if the string is malformed. Use parse() instead.

Definition at line 218 of file DataLayout.cpp.

References llvm::report_fatal_error().

◆ DataLayout() [3/3]

llvm::DataLayout::DataLayout ( const DataLayout DL)
inline

Definition at line 182 of file DataLayout.h.

References DL.

◆ ~DataLayout()

DataLayout::~DataLayout ( )

Definition at line 716 of file DataLayout.cpp.

Member Function Documentation

◆ doNotMangleLeadingQuestionMark()

bool llvm::DataLayout::doNotMangleLeadingQuestionMark ( ) const
inline

Returns true if symbols with leading question marks should not receive IR mangling.

True for Windows mangling modes.

Definition at line 262 of file DataLayout.h.

◆ exceedsNaturalStackAlignment()

bool llvm::DataLayout::exceedsNaturalStackAlignment ( Align  Alignment) const
inline

Returns true if the given alignment exceeds the natural stack alignment.

Definition at line 225 of file DataLayout.h.

◆ fitsInLegalInteger()

bool llvm::DataLayout::fitsInLegalInteger ( unsigned  Width) const
inline

Returns true if the specified type fits in a native integer type supported by the CPU.

For example, if the CPU only supports i32 as a native integer type, then i27 fits in a legal integer type but i45 does not.

Definition at line 317 of file DataLayout.h.

◆ getABIIntegerTypeAlignment()

Align llvm::DataLayout::getABIIntegerTypeAlignment ( unsigned  BitWidth) const
inline

Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.

Definition at line 491 of file DataLayout.h.

References llvm::BitWidth.

Referenced by llvm::OpenMPIRBuilder::emitOffloadingArrays(), and llvm::MachineJumpTableInfo::getEntryAlignment().

◆ getABITypeAlign()

Align DataLayout::getABITypeAlign ( Type Ty) const

◆ getAllocaAddrSpace()

unsigned llvm::DataLayout::getAllocaAddrSpace ( ) const
inline

◆ getAllocaPtrType()

PointerType * llvm::DataLayout::getAllocaPtrType ( LLVMContext Ctx) const
inline

Definition at line 236 of file DataLayout.h.

References llvm::PointerType::get().

◆ getDefaultGlobalsAddressSpace()

unsigned llvm::DataLayout::getDefaultGlobalsAddressSpace ( ) const
inline

◆ getFunctionPtrAlign()

MaybeAlign llvm::DataLayout::getFunctionPtrAlign ( ) const
inline

Returns the alignment of function pointers, which may or may not be related to the alignment of functions.

See also
getFunctionPtrAlignType

Definition at line 243 of file DataLayout.h.

◆ getFunctionPtrAlignType()

FunctionPtrAlignType llvm::DataLayout::getFunctionPtrAlignType ( ) const
inline

Return the type of function pointer alignment.

See also
getFunctionPtrAlign

Definition at line 247 of file DataLayout.h.

◆ getGEPIndexForOffset()

std::optional< APInt > DataLayout::getGEPIndexForOffset ( Type *&  ElemTy,
APInt Offset 
) const

Get single GEP index to access Offset inside ElemTy.

Returns std::nullopt if index cannot be computed, e.g. because the type is not an aggregate. ElemTy is updated to be the result element type and Offset to be the residual offset.

Definition at line 959 of file DataLayout.cpp.

References llvm::StructLayout::getElementContainingOffset(), getElementIndex(), llvm::StructLayout::getElementOffset(), llvm::StructLayout::getSizeInBytes(), getStructLayout(), getTypeAllocSize(), and llvm::Offset.

Referenced by getGEPIndicesForOffset().

◆ getGEPIndicesForOffset()

SmallVector< APInt > DataLayout::getGEPIndicesForOffset ( Type *&  ElemTy,
APInt Offset 
) const

Get GEP indices to access Offset inside ElemTy.

ElemTy is updated to be the result element type and Offset to be the residual offset.

Definition at line 989 of file DataLayout.cpp.

References assert(), getElementIndex(), getGEPIndexForOffset(), getTypeAllocSize(), llvm::Type::isSized(), llvm::Offset, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by llvm::InstCombinerImpl::visitGEPOfGEP().

◆ getGlobalPrefix()

char llvm::DataLayout::getGlobalPrefix ( ) const
inline

Definition at line 274 of file DataLayout.h.

References llvm_unreachable.

Referenced by llvm::emitLinkerFlagsForGlobalCOFF().

◆ getIndexedOffsetInType()

int64_t DataLayout::getIndexedOffsetInType ( Type ElemTy,
ArrayRef< Value * >  Indices 
) const

Returns the offset from the beginning of the type for the specified indices.

Note that this takes the element type, not the pointer type. This is used to implement getelementptr.

Definition at line 911 of file DataLayout.cpp.

References assert(), llvm::gep_type_begin(), llvm::gep_type_end(), llvm::StructLayout::getElementOffset(), llvm::generic_gep_type_iterator< ItTy >::getOperand(), llvm::generic_gep_type_iterator< ItTy >::getSequentialElementStride(), getStructLayout(), llvm::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), and Idx.

Referenced by llvm::InstCombinerImpl::visitGEPOfGEP().

◆ getIndexSize()

unsigned DataLayout::getIndexSize ( unsigned  AS) const

rounded up to a whole number of bytes.

Definition at line 768 of file DataLayout.cpp.

References llvm::divideCeil().

◆ getIndexSizeInBits()

unsigned llvm::DataLayout::getIndexSizeInBits ( unsigned  AS) const
inline

◆ getIndexType() [1/2]

IntegerType * DataLayout::getIndexType ( LLVMContext C,
unsigned  AddressSpace 
) const

◆ getIndexType() [2/2]

Type * DataLayout::getIndexType ( Type PtrTy) const

Returns the type of a GEP index.

If it was not specified explicitly, it will be the integer type of the pointer width - IntPtrType.

Definition at line 901 of file DataLayout.cpp.

References assert(), llvm::IntegerType::get(), llvm::VectorType::get(), llvm::Type::getContext(), getIndexTypeSizeInBits(), and llvm::Type::isPtrOrPtrVectorTy().

◆ getIndexTypeSizeInBits()

unsigned DataLayout::getIndexTypeSizeInBits ( Type Ty) const

◆ getIntPtrType() [1/2]

IntegerType * DataLayout::getIntPtrType ( LLVMContext C,
unsigned  AddressSpace = 0 
) const

◆ getIntPtrType() [2/2]

Type * DataLayout::getIntPtrType ( Type Ty) const

Returns an integer (vector of integer) type with size at least as big as that of a pointer of the given pointer (vector of pointer) type.

Definition at line 874 of file DataLayout.cpp.

References assert(), llvm::IntegerType::get(), llvm::VectorType::get(), llvm::Type::getContext(), getPointerTypeSizeInBits(), and llvm::Type::isPtrOrPtrVectorTy().

◆ getLargestLegalIntType()

Type * llvm::DataLayout::getLargestLegalIntType ( LLVMContext C) const
inline

Returns the largest legal integer type, or null if none are set.

Definition at line 514 of file DataLayout.h.

References llvm::CallingConv::C, llvm::Type::getIntNTy(), and getLargestLegalIntTypeSizeInBits().

◆ getLargestLegalIntTypeSizeInBits()

unsigned DataLayout::getLargestLegalIntTypeSizeInBits ( ) const

Returns the size of largest legal integer type size, or 0 if none are set.

Definition at line 891 of file DataLayout.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::end(), and llvm::max_element().

Referenced by getLargestLegalIntType().

◆ getLinkerPrivateGlobalPrefix()

StringRef llvm::DataLayout::getLinkerPrivateGlobalPrefix ( ) const
inline

Definition at line 268 of file DataLayout.h.

◆ getManglingComponent()

const char * DataLayout::getManglingComponent ( const Triple T)
static

Definition at line 175 of file DataLayout.cpp.

References llvm::Triple::x86.

Referenced by computeDataLayout(), and getDataLayoutString().

◆ getMaxIndexSize()

unsigned DataLayout::getMaxIndexSize ( ) const

Returns the maximum index size over all address spaces.

Definition at line 752 of file DataLayout.cpp.

References llvm::divideCeil().

Referenced by getMaxIndexSizeInBits().

◆ getMaxIndexSizeInBits()

unsigned llvm::DataLayout::getMaxIndexSizeInBits ( ) const
inline

Returns the maximum index size over all address spaces.

Definition at line 373 of file DataLayout.h.

References getMaxIndexSize().

◆ getNonIntegralAddressSpaces()

ArrayRef< unsigned > llvm::DataLayout::getNonIntegralAddressSpaces ( ) const
inline

Return the address spaces containing non-integral pointers.

Pointers in this address space don't have a well-defined bitwise representation.

Definition at line 347 of file DataLayout.h.

Referenced by isNonIntegralAddressSpace().

◆ getPointerABIAlignment()

Align DataLayout::getPointerABIAlignment ( unsigned  AS) const

Layout pointer alignment.

Definition at line 740 of file DataLayout.cpp.

References llvm::DataLayout::PointerSpec::ABIAlign.

Referenced by llvm::MachineJumpTableInfo::getEntryAlignment().

◆ getPointerPrefAlignment()

Align DataLayout::getPointerPrefAlignment ( unsigned  AS = 0) const

Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of the backends/clients are updated.

Definition at line 744 of file DataLayout.cpp.

References llvm::DataLayout::PointerSpec::PrefAlign.

◆ getPointerSize()

unsigned DataLayout::getPointerSize ( unsigned  AS = 0) const

Layout pointer size in bytes, rounded up to a whole number of bytes.

FIXME: The defaults need to be removed once all of the backends/clients are updated.

Definition at line 748 of file DataLayout.cpp.

References llvm::BitWidth, and llvm::divideCeil().

Referenced by llvm::TargetLoweringBase::emitPatchPoint(), llvm::TargetMachine::getAllocaPointerSize(), llvm::MachineJumpTableInfo::getEntrySize(), llvm::TargetMachine::getPointerSize(), llvm::TargetMachine::getProgramPointerSize(), isTargetNullPtr(), and llvm::OpenMPIRBuilder::registerTargetGlobalVariable().

◆ getPointerSizeInBits()

unsigned llvm::DataLayout::getPointerSizeInBits ( unsigned  AS = 0) const
inline

◆ getPointerTypeSize()

unsigned llvm::DataLayout::getPointerTypeSize ( Type Ty) const
inline

Definition at line 393 of file DataLayout.h.

References getPointerTypeSizeInBits().

◆ getPointerTypeSizeInBits()

unsigned DataLayout::getPointerTypeSizeInBits ( Type Ty) const

Layout pointer size, in bits, based on the type.

If this function is called with a pointer type, then the type size of the pointer is returned. If this function is called with a vector of pointers, then the type size of the pointer is returned. This should only be called with a pointer or vector of pointers.

Definition at line 761 of file DataLayout.cpp.

References assert(), getPointerSizeInBits(), llvm::Type::getScalarType(), and llvm::Type::isPtrOrPtrVectorTy().

Referenced by computeKnownBits(), computeKnownBitsFromOperator(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::InstCombinerImpl::foldICmpWithCastOp(), llvm::TargetTransformInfoImplBase::getCastInstrCost(), llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(), llvm::SelectionDAG::getGlobalAddress(), getIntPtrType(), getPointerTypeSize(), llvm::SelectionDAG::InferPtrAlign(), and llvm::InstCombinerImpl::visitCallInst().

◆ getPreferredAlign()

Align DataLayout::getPreferredAlign ( const GlobalVariable GV) const

Returns the preferred alignment of the specified global.

getPreferredAlign - Return the preferred alignment of the specified global.

This includes an explicitly requested alignment (if the global has one).

Definition at line 1006 of file DataLayout.cpp.

References getABITypeAlign(), llvm::GlobalObject::getAlign(), getPrefTypeAlign(), getTypeSizeInBits(), llvm::GlobalValue::getValueType(), llvm::GlobalVariable::hasInitializer(), and llvm::GlobalObject::hasSection().

Referenced by getAlign(), getELFSectionNameForGlobal(), promoteToConstantPool(), and llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal().

◆ getPrefTypeAlign()

Align DataLayout::getPrefTypeAlign ( Type Ty) const

◆ getPrivateGlobalPrefix()

StringRef llvm::DataLayout::getPrivateGlobalPrefix ( ) const
inline

◆ getProgramAddressSpace()

unsigned llvm::DataLayout::getProgramAddressSpace ( ) const
inline

◆ getSmallestLegalIntType()

Type * DataLayout::getSmallestLegalIntType ( LLVMContext C,
unsigned  Width = 0 
) const

Returns the smallest integer type with size at least as big as Width bits.

Definition at line 884 of file DataLayout.cpp.

References llvm::CallingConv::C, and llvm::Type::getIntNTy().

Referenced by llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal().

◆ getStackAlignment()

Align llvm::DataLayout::getStackAlignment ( ) const
inline

Definition at line 229 of file DataLayout.h.

References assert().

Referenced by CC_AArch64_Custom_Block().

◆ getStringRepresentation()

const std::string & llvm::DataLayout::getStringRepresentation ( ) const
inline

Returns the string representation of the DataLayout.

This representation is in the same format accepted by the string constructor above. This should not be used to compare two DataLayout as different string can represent the same layout.

Definition at line 204 of file DataLayout.h.

Referenced by llvm::orc::LLJIT::applyDataLayout(), and llvm::orc::LLJITBuilderState::prepareForConstruction().

◆ getStructLayout()

const StructLayout * DataLayout::getStructLayout ( StructType Ty) const

◆ getTypeAllocSize()

TypeSize llvm::DataLayout::getTypeAllocSize ( Type Ty) const
inline

Returns the offset in bytes between successive objects of the specified type, including alignment padding.

If Ty is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size.

This is the amount that alloca reserves for this type. For example, returns 12 or 16 for x86_fp80, depending on alignment.

Definition at line 462 of file DataLayout.h.

References llvm::alignTo(), getABITypeAlign(), getTypeStoreSize(), and value.

Referenced by llvm::analyzeArguments(), llvm::ExecutionEngine::emitGlobalVariable(), llvm::CSKYAsmPrinter::emitMachineConstantPoolValue(), llvm::SystemZAsmPrinter::emitMachineConstantPoolValue(), llvm::ARMAsmPrinter::emitXXStructor(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), llvm::GCNTTIImpl::getCallerAllocaCost(), llvm::ARMTTIImpl::getGatherScatterOpCost(), getGEPIndexForOffset(), getGEPIndicesForOffset(), getTypeAllocSizeInBits(), llvm::dxil::CBufferDataLayout::getTypeAllocSizeInBytes(), llvm::AMDGPUTTIImpl::getUnrollingPreferences(), llvm::ExecutionEngine::InitializeMemory(), llvm::HexagonTargetObjectFile::isGlobalInSmallSection(), llvm::RISCVELFTargetObjectFile::isGlobalInSmallSection(), llvm::TargetMachine::isLargeGlobalValue(), llvm::SparcTargetLowering::LowerCall_32(), llvm::FastISel::lowerCallTo(), llvm::X86TargetLowering::markLibCallAttributes(), performGlobalAddressCombine(), promoteToConstantPool(), llvm::FunctionLoweringInfo::set(), simplifyGEPInst(), llvm::InstCombinerImpl::visitAllocaInst(), llvm::ObjectSizeOffsetVisitor::visitAllocaInst(), llvm::ObjectSizeOffsetEvaluator::visitAllocaInst(), llvm::Interpreter::visitAllocaInst(), llvm::ObjectSizeOffsetVisitor::visitArgument(), llvm::InstCombinerImpl::visitGetElementPtrInst(), and llvm::ObjectSizeOffsetVisitor::visitGlobalVariable().

◆ getTypeAllocSizeInBits()

TypeSize llvm::DataLayout::getTypeAllocSizeInBits ( Type Ty) const
inline

Returns the offset in bits between successive objects of the specified type, including alignment padding; always a multiple of 8.

If Ty is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size.

This is the amount that alloca reserves for this type. For example, returns 96 or 128 for x86_fp80, depending on alignment.

Definition at line 475 of file DataLayout.h.

References getTypeAllocSize().

Referenced by getTypeSizeInBits().

◆ getTypeSizeInBits()

TypeSize llvm::DataLayout::getTypeSizeInBits ( Type Ty) const
inline

Size examples:

Type SizeInBits StoreSizeInBits AllocSizeInBits[*]


i1 1 8 8 i8 8 8 8 i19 19 24 32 i32 32 32 32 i100 100 104 128 i128 128 128 128 Float 32 32 32 Double 64 64 64 X86_FP80 80 80 96

[*] The alloc size depends on the alignment, and thus on the target. These values are for x86-32 linux. Returns the number of bits necessary to hold the specified type.

If Ty is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size.

For example, returns 36 for i36 and 80 for x86_fp80. The type passed must have a size (Type::isSized() must return true).

Definition at line 622 of file DataLayout.h.

References llvm::Type::ArrayTyID, assert(), llvm::Type::BFloatTyID, llvm::Type::DoubleTyID, llvm::Type::FixedVectorTyID, llvm::Type::FloatTyID, llvm::Type::FP128TyID, llvm::VectorType::getElementCount(), llvm::ArrayType::getElementType(), llvm::VectorType::getElementType(), llvm::TypeSize::getFixed(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::Type::getIntegerBitWidth(), llvm::ArrayType::getNumElements(), llvm::Type::getPointerAddressSpace(), getPointerSizeInBits(), llvm::StructLayout::getSizeInBits(), getStructLayout(), getTypeAllocSizeInBits(), llvm::Type::getTypeID(), getTypeSizeInBits(), llvm::Type::HalfTyID, llvm::Type::IntegerTyID, llvm::Type::isSized(), llvm::Type::LabelTyID, llvm_unreachable, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::Type::ScalableVectorTyID, llvm::Type::StructTyID, llvm::Type::TargetExtTyID, llvm::Type::X86_AMXTyID, and llvm::Type::X86_FP80TyID.

Referenced by buildFrameDebugInfo(), llvm::FastISel::canFoldAddIntoGEP(), computeKnownBits(), computeKnownBitsForHorizontalOperation(), computeKnownBitsFromOperator(), ComputeNumSignBitsImpl(), llvm::OpenMPIRBuilder::createTask(), llvm::InstCombinerImpl::foldIntegerTypedPHI(), llvm::TargetTransformInfoImplBase::getCastInstrCost(), llvm::RISCVTTIImpl::getCastInstrCost(), llvm::ExecutionEngine::getConstantValue(), llvm::HexagonTTIImpl::getInstructionCost(), llvm::ARMTTIImpl::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getMemoryOpCost(), llvm::RISCVTTIImpl::getMinMaxReductionCost(), getPreferredAlign(), llvm::RISCVTTIImpl::getRegUsageForType(), llvm::X86TTIImpl::getReplicationShuffleCost(), llvm::GCNTTIImpl::getShuffleCost(), llvm::ScalarEvolution::getTypeSizeInBits(), getTypeSizeInBits(), getTypeStoreSize(), llvm::GCNTTIImpl::getVectorInstrCost(), llvm::R600TTIImpl::getVectorInstrCost(), isKnownNonZeroFromOperator(), llvm::PatternMatch::PtrToIntSameSize_match< Op_t >::match(), llvm::OpenMPIRBuilder::registerTargetGlobalVariable(), simplifyAMDGCNMemoryIntrinsicDemanded(), simplifyGEPInst(), simplifyICmpInst(), solveDIType(), tocDataChecks(), typeSizeEqualsStoreSize(), and llvm::InstCombinerImpl::visitShuffleVectorInst().

◆ getTypeStoreSize()

TypeSize llvm::DataLayout::getTypeStoreSize ( Type Ty) const
inline

◆ getTypeStoreSizeInBits()

TypeSize llvm::DataLayout::getTypeStoreSizeInBits ( Type Ty) const
inline

Returns the maximum number of bits that may be overwritten by storing the specified type; always a multiple of 8.

If Ty is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size.

For example, returns 40 for i36 and 80 for x86_fp80.

Definition at line 442 of file DataLayout.h.

References getTypeStoreSize().

Referenced by llvm::slpvectorizer::BoUpSLP::canMapToVector(), llvm::RISCVTTIImpl::getMemoryOpCost(), and typeSizeEqualsStoreSize().

◆ getValueOrABITypeAlignment()

Align llvm::DataLayout::getValueOrABITypeAlignment ( MaybeAlign  Alignment,
Type Ty 
) const
inline

Helper function to return Alignment if it's set or the result of getABITypeAlign(Ty), in any case the result is a valid alignment.

Definition at line 484 of file DataLayout.h.

References getABITypeAlign().

◆ hasLinkerPrivateGlobalPrefix()

bool llvm::DataLayout::hasLinkerPrivateGlobalPrefix ( ) const
inline

Definition at line 266 of file DataLayout.h.

◆ hasMicrosoftFastStdCallMangling()

bool llvm::DataLayout::hasMicrosoftFastStdCallMangling ( ) const
inline

Definition at line 256 of file DataLayout.h.

◆ isBigEndian()

bool llvm::DataLayout::isBigEndian ( ) const
inline

◆ isDefault()

bool llvm::DataLayout::isDefault ( ) const
inline

Test if the DataLayout was constructed from an empty string.

Definition at line 209 of file DataLayout.h.

Referenced by llvm::ExecutionEngine::getMangledName().

◆ isIllegalInteger()

bool llvm::DataLayout::isIllegalInteger ( uint64_t  Width) const
inline

Definition at line 222 of file DataLayout.h.

References isLegalInteger().

◆ isLegalInteger()

bool llvm::DataLayout::isLegalInteger ( uint64_t  Width) const
inline

Returns true if the specified type is known to be a native integer type supported by the CPU.

For example, i64 is not native on most 32-bit CPUs and i37 is not native on any known one. This returns false if the integer width is not legal.

The width is specified in bits.

Definition at line 218 of file DataLayout.h.

References llvm::is_contained().

Referenced by llvm::TargetTransformInfoImplBase::getCastInstrCost(), isIllegalInteger(), llvm::InstCombinerImpl::visitBitCast(), and visitIVCast().

◆ isLittleEndian()

bool llvm::DataLayout::isLittleEndian ( ) const
inline

◆ isNonIntegralAddressSpace()

bool llvm::DataLayout::isNonIntegralAddressSpace ( unsigned  AddrSpace) const
inline

◆ isNonIntegralPointerType() [1/2]

bool llvm::DataLayout::isNonIntegralPointerType ( PointerType PT) const
inline

◆ isNonIntegralPointerType() [2/2]

bool llvm::DataLayout::isNonIntegralPointerType ( Type Ty) const
inline

Definition at line 360 of file DataLayout.h.

References isNonIntegralPointerType().

◆ operator!=()

bool llvm::DataLayout::operator!= ( const DataLayout Other) const
inline

Definition at line 189 of file DataLayout.h.

References llvm::Other.

◆ operator=()

DataLayout & DataLayout::operator= ( const DataLayout Other)

Definition at line 223 of file DataLayout.cpp.

References llvm::Other.

◆ operator==()

bool DataLayout::operator== ( const DataLayout Other) const

Definition at line 246 of file DataLayout.cpp.

References llvm::Other.

◆ parse()

Expected< DataLayout > DataLayout::parse ( StringRef  LayoutString)
static

Parse a data layout string and return the layout.

Return an error description on failure.

Definition at line 264 of file DataLayout.cpp.

◆ typeSizeEqualsStoreSize()

bool llvm::DataLayout::typeSizeEqualsStoreSize ( Type Ty) const
inline

Returns true if no extra padding bits are needed when storing the specified type.

For example, returns false for i19 that has a 24-bit store size.

Definition at line 450 of file DataLayout.h.

References getTypeSizeInBits(), and getTypeStoreSizeInBits().


The documentation for this class was generated from the following files: