LLVM 22.0.0git
|
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 | |
LLVM_ABI | DataLayout () |
Constructs a DataLayout with default values. | |
LLVM_ABI | DataLayout (StringRef LayoutString) |
Constructs a DataLayout from a specification string. | |
DataLayout (const DataLayout &DL) | |
LLVM_ABI | ~DataLayout () |
LLVM_ABI DataLayout & | operator= (const DataLayout &Other) |
LLVM_ABI 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 |
MaybeAlign | getStackAlignment () const |
Returns the natural stack alignment, or MaybeAlign() if one wasn't specified. | |
unsigned | getAllocaAddrSpace () const |
PointerType * | getAllocaPtrType (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. | |
LLVM_ABI Align | getPointerABIAlignment (unsigned AS) const |
Layout pointer alignment. | |
LLVM_ABI 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. | |
LLVM_ABI unsigned | getPointerSize (unsigned AS=0) const |
The pointer representation size in bytes, rounded up to a whole number of bytes. | |
LLVM_ABI unsigned | getIndexSize (unsigned AS) const |
The index size in bytes used for address calculation, rounded up to a whole number of bytes. | |
unsigned | getAddressSize (unsigned AS) const |
The integral size of a pointer in a given address space in bytes, which is defined to be the same as getIndexSize(). | |
SmallVector< unsigned, 8 > | getNonIntegralAddressSpaces () 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 |
The size in bits of the pointer representation in a given address space. | |
unsigned | getIndexSizeInBits (unsigned AS) const |
The size in bits of indices used for address calculation in getelementptr and for addresses in the given AS. | |
unsigned | getAddressSizeInBits (unsigned AS) const |
The size in bits of an address in for the given AS. | |
LLVM_ABI unsigned | getPointerTypeSizeInBits (Type *) const |
The pointer representation size in bits for this type. | |
LLVM_ABI unsigned | getIndexTypeSizeInBits (Type *Ty) const |
The size in bits of the index used in GEP calculation for this type. | |
unsigned | getAddressSizeInBits (Type *Ty) const |
The size in bits of an address for this type. | |
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. | |
LLVM_ABI 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. | |
LLVM_ABI Align | getPrefTypeAlign (Type *Ty) const |
Returns the preferred stack/global alignment for the specified type. | |
LLVM_ABI 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. | |
LLVM_ABI Type * | getIntPtrType (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. | |
LLVM_ABI Type * | getSmallestLegalIntType (LLVMContext &C, unsigned Width=0) const |
Returns the smallest integer type with size at least as big as Width bits. | |
Type * | getLargestLegalIntType (LLVMContext &C) const |
Returns the largest legal integer type, or null if none are set. | |
LLVM_ABI unsigned | getLargestLegalIntTypeSizeInBits () const |
Returns the size of largest legal integer type size, or 0 if none are set. | |
LLVM_ABI IntegerType * | getIndexType (LLVMContext &C, unsigned AddressSpace) const |
Returns the type of a GEP index in AddressSpace . | |
IntegerType * | getAddressType (LLVMContext &C, unsigned AddressSpace) const |
Returns the type of an address in AddressSpace . | |
LLVM_ABI Type * | getIndexType (Type *PtrTy) const |
Returns the type of a GEP index. | |
Type * | getAddressType (Type *PtrTy) const |
Returns the type of an address in AddressSpace . | |
LLVM_ABI int64_t | getIndexedOffsetInType (Type *ElemTy, ArrayRef< Value * > Indices) const |
Returns the offset from the beginning of the type for the specified indices. | |
LLVM_ABI SmallVector< APInt > | getGEPIndicesForOffset (Type *&ElemTy, APInt &Offset) const |
Get GEP indices to access Offset inside ElemTy. | |
LLVM_ABI std::optional< APInt > | getGEPIndexForOffset (Type *&ElemTy, APInt &Offset) const |
Get single GEP index to access Offset inside ElemTy. | |
LLVM_ABI const StructLayout * | getStructLayout (StructType *Ty) const |
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of its fields. | |
LLVM_ABI Align | getPreferredAlign (const GlobalVariable *GV) const |
Returns the preferred alignment of the specified global. | |
Static Public Member Functions | |
static LLVM_ABI Expected< DataLayout > | parse (StringRef LayoutString) |
Parse a data layout string and return the layout. | |
static LLVM_ABI const char * | getManglingComponent (const Triple &T) |
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.
|
strong |
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 89 of file DataLayout.h.
DataLayout::DataLayout | ( | ) |
Constructs a DataLayout with default values.
Definition at line 213 of file DataLayout.cpp.
|
explicit |
Constructs a DataLayout from a specification string.
WARNING: Aborts execution if the string is malformed. Use parse() instead.
Definition at line 219 of file DataLayout.cpp.
References llvm::report_fatal_error().
|
inline |
Definition at line 184 of file DataLayout.h.
References DL.
DataLayout::~DataLayout | ( | ) |
Definition at line 706 of file DataLayout.cpp.
|
inline |
Returns true if symbols with leading question marks should not receive IR mangling.
True for Windows mangling modes.
Definition at line 258 of file DataLayout.h.
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 313 of file DataLayout.h.
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
Definition at line 533 of file DataLayout.h.
References llvm::BitWidth.
Referenced by llvm::OpenMPIRBuilder::emitOffloadingArrays(), and llvm::MachineJumpTableInfo::getEntryAlignment().
Returns the minimum ABI-required alignment for the specified type.
Definition at line 842 of file DataLayout.cpp.
Referenced by llvm::analyzeArguments(), llvm::FastISel::createMachineMemOperandFor(), llvm::SelectionDAG::getConstantPool(), llvm::SelectionDAG::getEVTAlign(), llvm::BasicTTIImplBase< T >::getIntrinsicInstrCost(), llvm::X86TTIImpl::getMemoryOpCost(), getPreferredAlign(), getTypeAllocSize(), getValueOrABITypeAlignment(), llvm::FastISel::lowerCallTo(), llvm::PPCTargetLowering::PerformDAGCombine(), llvm::SITargetLowering::ReplaceNodeResults(), and solveDIType().
The integral size of a pointer in a given address space in bytes, which is defined to be the same as getIndexSize().
This exists as a separate function to make it clearer when reading code that the size of an address is being requested. While targets exist where index size and the underlying address width are not identical (e.g. AMDGPU fat pointers with 48-bit addresses and 32-bit offsets indexing), there is currently no need to differentiate these properties in LLVM.
Definition at line 358 of file DataLayout.h.
References getIndexSize().
The size in bits of an address for this type.
This is defined to return the same value as getIndexTypeSizeInBits(), but separate functions exist for code clarity.
Definition at line 427 of file DataLayout.h.
References getIndexTypeSizeInBits().
The size in bits of an address in for the given AS.
This is defined to return the same value as getIndexSizeInBits() since there is currently no target that requires these two properties to have different values. See getIndexSize() for more information.
Definition at line 407 of file DataLayout.h.
References getIndexSizeInBits().
Referenced by llvm::TargetTransformInfoImplBase::getCastInstrCost().
|
inline |
Returns the type of an address in AddressSpace
.
Definition at line 573 of file DataLayout.h.
References llvm::CallingConv::C, and getIndexType().
Referenced by llvm::IRBuilderBase::CreatePtrToAddr().
Returns the type of an address in AddressSpace
.
Definition at line 582 of file DataLayout.h.
References getIndexType().
|
inline |
Definition at line 230 of file DataLayout.h.
Referenced by llvm::OpenMPIRBuilder::createParallel(), llvm::MachinePointerInfo::getUnknownStack(), llvm::CallLowering::handleAssignments(), and llvm::ObjectSizeOffsetEvaluator::visitAllocaInst().
|
inline |
Definition at line 232 of file DataLayout.h.
References llvm::PointerType::get().
|
inline |
Definition at line 248 of file DataLayout.h.
Referenced by llvm::OpenMPIRBuilder::createReductions(), llvm::OpenMPIRBuilder::createReductionsGPU(), and llvm::OpenMPIRBuilder::getOrCreateIdent().
|
inline |
Returns the alignment of function pointers, which may or may not be related to the alignment of functions.
Definition at line 239 of file DataLayout.h.
|
inline |
Return the type of function pointer alignment.
Definition at line 243 of file DataLayout.h.
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 940 of file DataLayout.cpp.
References llvm::StructLayout::getElementContainingOffset(), getElementIndex(), llvm::StructLayout::getElementOffset(), llvm::StructLayout::getSizeInBytes(), getStructLayout(), getTypeAllocSize(), and llvm::Offset.
Referenced by 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 970 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().
|
inline |
Definition at line 270 of file DataLayout.h.
References llvm_unreachable.
Referenced by llvm::emitLinkerFlagsForGlobalCOFF().
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 892 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().
The index size in bytes used for address calculation, rounded up to a whole number of bytes.
This not only defines the size used in getelementptr operations, but also the size of addresses in this AS
. For example, a 64-bit CHERI-enabled target has 128-bit pointers of which only 64 are used to represent the address and the remaining ones are used for metadata such as bounds and access permissions. In this case getPointerSize() returns 16, but getIndexSize() returns 8. To help with code understanding, the alias getAddressSize() can be used instead of getIndexSize() to clarify that an address width is needed.
Definition at line 749 of file DataLayout.cpp.
References llvm::divideCeil().
Referenced by getAddressSize().
The size in bits of indices used for address calculation in getelementptr and for addresses in the given AS.
See getIndexSize() for more information.
Definition at line 398 of file DataLayout.h.
References llvm::DataLayout::PointerSpec::IndexBitWidth.
Referenced by llvm::OpenMPIRBuilder::emitOffloadingArrays(), getAddressSizeInBits(), llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(), getIndexType(), getIndexTypeSizeInBits(), simplifyGEPInst(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
IntegerType * DataLayout::getIndexType | ( | LLVMContext & | C, |
unsigned | AddressSpace | ||
) | const |
Returns the type of a GEP index in AddressSpace
.
If it was not specified explicitly, it will be the integer type of the pointer width - IntPtrType.
Definition at line 877 of file DataLayout.cpp.
References llvm::CallingConv::C, llvm::IntegerType::get(), and getIndexSizeInBits().
Referenced by llvm::ObjectSizeOffsetEvaluator::compute(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), llvm::InstCombinerImpl::foldGEPICmp(), llvm::InstCombinerImpl::foldPtrToIntOfGEP(), getAddressType(), llvm::ScalarEvolution::getEffectiveSCEVType(), llvm::InstCombinerImpl::OptimizePointerDifference(), simplifyAllocaArraySize(), simplifyCastInst(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::ObjectSizeOffsetEvaluator::visitAllocaInst(), llvm::InstCombinerImpl::visitGetElementPtrInst(), and llvm::PtrUseVisitor< DerivedT >::visitPtr().
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 882 of file DataLayout.cpp.
References assert(), llvm::IntegerType::get(), llvm::VectorType::get(), llvm::Type::getContext(), getIndexTypeSizeInBits(), and llvm::Type::isPtrOrPtrVectorTy().
The size in bits of the index used in GEP calculation for this type.
The function should be called with pointer or vector of pointers type. This is defined to return the same value as getAddressSizeInBits(), but separate functions exist for code clarity.
Definition at line 753 of file DataLayout.cpp.
References assert(), getAddressSpace(), getIndexSizeInBits(), llvm::Type::getScalarType(), and llvm::Type::isPtrOrPtrVectorTy().
Referenced by computeKnownBitsFromOperator(), getAddressSizeInBits(), getIndexType(), llvm::ScalarEvolution::getTypeSizeInBits(), getUnknownStore(), isNonEqualPointersWithRecursiveGEP(), llvm::simplifyBinaryIntrinsic(), llvm::simplifyLoadInst(), llvm::InstCombinerImpl::visitGEPOfGEP(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
IntegerType * DataLayout::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.
Definition at line 850 of file DataLayout.cpp.
References llvm::CallingConv::C, llvm::IntegerType::get(), and getPointerSizeInBits().
Referenced by llvm::ARMSelectionDAGInfo::EmitSpecializedLibcall(), llvm::AArch64SelectionDAGInfo::EmitStreamingCompatibleMemLibCall(), llvm::HexagonSelectionDAGInfo::EmitTargetCodeForMemcpy(), llvm::XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(), llvm::InstCombinerImpl::foldICmpInstWithConstantNotInt(), llvm::SelectionDAG::getAtomicMemcpy(), llvm::SelectionDAG::getAtomicMemmove(), llvm::ScalarEvolution::getLosslessPtrToIntExpr(), llvm::SelectionDAG::getMemcmp(), llvm::IntrinsicLowering::LowerIntrinsicCall(), simplifyCastInst(), llvm::InstCombinerImpl::visitIntToPtr(), and llvm::InstCombinerImpl::visitPtrToInt().
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 855 of file DataLayout.cpp.
References assert(), llvm::IntegerType::get(), llvm::VectorType::get(), llvm::Type::getContext(), getPointerTypeSizeInBits(), and llvm::Type::isPtrOrPtrVectorTy().
|
inline |
Returns the largest legal integer type, or null if none are set.
Definition at line 558 of file DataLayout.h.
References llvm::CallingConv::C, llvm::Type::getIntNTy(), and getLargestLegalIntTypeSizeInBits().
unsigned DataLayout::getLargestLegalIntTypeSizeInBits | ( | ) | const |
Returns the size of largest legal integer type size, or 0 if none are set.
Definition at line 872 of file DataLayout.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::end(), and llvm::max_element().
Referenced by getLargestLegalIntType().
|
inline |
Definition at line 264 of file DataLayout.h.
Definition at line 175 of file DataLayout.cpp.
References llvm::Triple::x86.
Referenced by computeDataLayout(), and getDataLayoutString().
|
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 362 of file DataLayout.h.
References llvm::SmallVectorTemplateBase< T, bool >::push_back().
Layout pointer alignment.
Definition at line 730 of file DataLayout.cpp.
References llvm::DataLayout::PointerSpec::ABIAlign.
Referenced by llvm::MachineJumpTableInfo::getEntryAlignment().
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 734 of file DataLayout.cpp.
References llvm::DataLayout::PointerSpec::PrefAlign.
The pointer representation size in bytes, rounded up to a whole number of bytes.
The difference between this function and getAddressSize() is that this one returns the size of the entire pointer representation (including metadata bits for fat pointers) and the latter only returns the number of address bits.
Definition at line 738 of file DataLayout.cpp.
References llvm::BitWidth, and llvm::divideCeil().
Referenced by llvm::LoongArchAsmPrinter::emitJumpTableInfo(), llvm::TargetLoweringBase::emitPatchPoint(), llvm::MachineJumpTableInfo::getEntrySize(), isTargetNullPtr(), and llvm::OpenMPIRBuilder::registerTargetGlobalVariable().
The size in bits of the pointer representation in a given address space.
This is not necessarily the same as the integer address of a pointer (e.g. for fat pointers).
Definition at line 390 of file DataLayout.h.
References llvm::DataLayout::PointerSpec::BitWidth.
Referenced by llvm::GIMatchTableExecutor::executeMatchTable(), llvm::InstCombinerImpl::foldIntegerTypedPHI(), llvm::ExecutionEngine::getConstantValue(), getIntPtrType(), getPointerTypeSizeInBits(), getTypeSizeInBits(), lle_X_sprintf(), llvm::GCNTTIImpl::rewriteIntrinsicWithAddressSpace(), simplifyGEPInst(), unpackFromMemLoc(), llvm::InstCombinerImpl::visitIntToPtr(), and llvm::InstCombinerImpl::visitPtrToInt().
Definition at line 431 of file DataLayout.h.
References getPointerTypeSizeInBits().
The pointer representation size in bits for this 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 742 of file DataLayout.cpp.
References assert(), getAddressSpace(), 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().
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 987 of file DataLayout.cpp.
References getABITypeAlign(), llvm::GlobalVariable::getAlign(), getPrefTypeAlign(), getTypeSizeInBits(), llvm::GlobalValue::getValueType(), llvm::GlobalVariable::hasInitializer(), and llvm::GlobalObject::hasSection().
Referenced by getAlign(), getELFSectionNameForGlobal(), promoteToConstantPool(), and llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal().
Returns the preferred stack/global alignment for the specified type.
This is always at least as good as the ABI alignment.
Definition at line 846 of file DataLayout.cpp.
Referenced by llvm::TargetLowering::CTTZTableLookup(), llvm::OpenMPIRBuilder::emitNonContiguousDescriptor(), llvm::OpenMPIRBuilder::emitOffloadingArrays(), llvm::OpenMPIRBuilder::emitTargetKernel(), llvm::PPCInstrInfo::finalizeInsInstrs(), llvm::SelectionDAG::getConstantPool(), llvm::RISCVTTIImpl::getCostOfKeepingLiveOverCall(), getPreferredAlign(), getPrefTypeAlign(), llvm::RISCVTTIImpl::getVectorInstrCost(), llvm::X86TTIImpl::getVectorInstrCost(), lowerSTOREVector(), and solveDIType().
|
inline |
Definition at line 286 of file DataLayout.h.
References llvm_unreachable.
Referenced by llvm::TargetLoweringObjectFileMachO::getIndirectSymViaGOTPCRel(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), and llvm::MipsAsmPrinter::printOperand().
|
inline |
Definition at line 247 of file DataLayout.h.
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 865 of file DataLayout.cpp.
References llvm::CallingConv::C, and llvm::Type::getIntNTy().
Referenced by llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal().
|
inline |
Returns the natural stack alignment, or MaybeAlign() if one wasn't specified.
Definition at line 228 of file DataLayout.h.
Referenced by CC_AArch64_Custom_Block().
|
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 206 of file DataLayout.h.
Referenced by llvm::orc::LLJIT::applyDataLayout(), and llvm::orc::LLJITBuilderState::prepareForConstruction().
const StructLayout * DataLayout::getStructLayout | ( | StructType * | Ty | ) | const |
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of its fields.
Note that this information is lazily cached.
Definition at line 708 of file DataLayout.cpp.
References llvm::StructType::getNumElements(), and llvm::safe_malloc().
Referenced by computeKnownBitsFromOperator(), llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(), getGEPIndexForOffset(), getIndexedOffsetInType(), llvm::ScalarEvolution::getOffsetOfExpr(), getTypeSizeInBits(), llvm::ExecutionEngine::InitializeMemory(), isGEPKnownNonNull(), llvm::FastISel::selectGetElementPtr(), and solveDIType().
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 504 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().
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 517 of file DataLayout.h.
References getTypeAllocSize().
Referenced by getTypeSizeInBits().
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 674 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::WebAssemblyTTIImpl::getInterleavedMemoryOpCost(), llvm::ARMTTIImpl::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCost(), llvm::AArch64TTIImpl::getIntrinsicInstrCost(), llvm::RISCVTTIImpl::getIntrinsicInstrCost(), llvm::GCNTTIImpl::getMemoryOpCost(), llvm::X86TTIImpl::getMemoryOpCost(), llvm::RISCVTTIImpl::getMinMaxReductionCost(), getOrCreateRefVariable(), getPreferredAlign(), llvm::RISCVTTIImpl::getRegUsageForType(), llvm::X86TTIImpl::getReplicationShuffleCost(), llvm::GCNTTIImpl::getShuffleCost(), llvm::ScalarEvolution::getTypeSizeInBits(), getTypeSizeInBits(), getTypeStoreSizeInBits(), 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().
Returns the maximum number of bytes that may be overwritten by storing 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 5 for i36 and 10 for x86_fp80.
Definition at line 468 of file DataLayout.h.
References llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), getTypeStoreSizeInBits(), and llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable().
Referenced by llvm::OpenMPIRBuilder::createAtomicRead(), llvm::OpenMPIRBuilder::createAtomicWrite(), llvm::FastISel::createMachineMemOperandFor(), llvm::OpenMPIRBuilder::createReductionsGPU(), llvm::OpenMPIRBuilder::createTask(), emitGlobalConstantLargeInt(), llvm::OpenMPIRBuilder::emitTargetTask(), llvm::OpenMPIRBuilder::emitUserDefinedMapper(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), llvm::RISCVTTIImpl::getPointersChainCost(), llvm::X86TTIImpl::getShuffleCost(), getTypeAllocSize(), llvm::TargetTransformInfoImplBase::isLegalNTLoad(), llvm::X86TTIImpl::isLegalNTLoad(), llvm::TargetTransformInfoImplBase::isLegalNTStore(), llvm::X86TTIImpl::isLegalNTStore(), llvm::ExecutionEngine::LoadValueFromMemory(), llvm::SPIRVCallLowering::lowerCall(), llvm::promoteLoopAccessesToScalars(), and llvm::ExecutionEngine::StoreValueToMemory().
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 481 of file DataLayout.h.
References llvm::alignToPowerOf2(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), getTypeSizeInBits(), and llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable().
Referenced by llvm::RISCVTTIImpl::getMemoryOpCost(), getTypeStoreSize(), and typeSizeEqualsStoreSize().
|
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 526 of file DataLayout.h.
References getABITypeAlign().
|
inline |
Definition at line 262 of file DataLayout.h.
|
inline |
Definition at line 252 of file DataLayout.h.
|
inline |
Definition at line 199 of file DataLayout.h.
Referenced by llvm::DwarfExpression::addConstantFP(), canCombineShuffleToExtendVectorInreg(), combineShuffleToAnyExtendVectorInreg(), combineShuffleToZeroExtendVectorInReg(), combineTruncationShuffle(), createGPRPairNode(), createGPRPairNodei64(), emitGlobalConstantFP(), foldVecExtTruncToExtElt(), foldVecTruncToExtElt(), getCopyFromParts(), getCopyToParts(), getFoldedOpcode(), getPPCf128HiElementSelector(), isExtendedBUILD_VECTOR(), llvm::LegalizerHelper::lowerLoad(), LowerPredicateLoad(), LowerPredicateStore(), llvm::CombinerHelper::matchLoadOrCombine(), matchPERM(), narrowExtractedVectorLoad(), optimizeIntegerToVectorInsertions(), optimizeVectorResizeWithIntegerBitCasts(), PerformBITCASTCombine(), PerformSTORECombine(), PerformTruncatingStoreCombine(), PerformVMOVRRDCombine(), llvm::AArch64TargetLowering::ReconstructShuffle(), reduceBuildVecToShuffleWithZero(), llvm::LegalizerHelper::reduceLoadStoreWidth(), ReplaceATOMIC_LOAD_128Results(), ReplaceCMP_SWAP_128Results(), ReplaceCMP_SWAP_64Results(), llvm::LegalizerHelper::scalarizeVectorBooleanStore(), llvm::TargetLowering::scalarizeVectorLoad(), llvm::TargetLowering::scalarizeVectorStore(), SkipExtensionForVMULL(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitInsertElementInst(), and llvm::InstCombinerImpl::visitShuffleVectorInst().
|
inline |
Test if the DataLayout was constructed from an empty string.
Definition at line 211 of file DataLayout.h.
Referenced by llvm::ExecutionEngine::getMangledName().
Definition at line 224 of file DataLayout.h.
References isLegalInteger().
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 220 of file DataLayout.h.
References llvm::is_contained().
Referenced by llvm::TargetTransformInfoImplBase::getCastInstrCost(), isIllegalInteger(), llvm::InstCombinerImpl::visitBitCast(), and visitIVCast().
|
inline |
Layout endianness...
Definition at line 198 of file DataLayout.h.
Referenced by addShuffleForVecExtend(), llvm::SparcTargetLowering::bitcastConstantFPToInt(), combineBVOfVecSExt(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::DwarfDebug::emitDebugLocEntry(), llvm::TargetLowering::expandUnalignedLoad(), llvm::TargetLowering::expandUnalignedStore(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::SelectionDAG::FoldConstantBuildVector(), llvm::TargetLowering::forceExpandWideMUL(), getMemsetStringVal(), llvm::PPC::getSplatIdxForPPCMnemonics(), llvm::TargetInstrInfo::getStackSlotRange(), llvm::PPCTTIImpl::instCombineIntrinsic(), llvm::PPC::isVMRGEOShuffleMask(), llvm::PPC::isVMRGHShuffleMask(), llvm::PPC::isVMRGLShuffleMask(), llvm::PPC::isVPKUDUMShuffleMask(), llvm::PPC::isVPKUHUMShuffleMask(), llvm::PPC::isVPKUWUMShuffleMask(), llvm::PPC::isVSLDOIShuffleMask(), LowerF64Op(), LowerFNEGorFABS(), llvm::SparcTargetLowering::LowerFormalArguments_32(), LowerSTORE(), performUzpCombine(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), and llvm::TargetLowering::SimplifySetCC().
Definition at line 371 of file DataLayout.h.
References llvm::DataLayout::PointerSpec::IsNonIntegral.
Referenced by llvm::GISelValueTracking::computeKnownBitsImpl(), isNonIntegralPointerType(), and llvm::LegalizerHelper::lowerMergeValues().
|
inline |
Definition at line 375 of file DataLayout.h.
References llvm::PointerType::getAddressSpace(), and isNonIntegralAddressSpace().
Referenced by isNonIntegralPointerType().
Definition at line 379 of file DataLayout.h.
References isNonIntegralPointerType().
|
inline |
Definition at line 191 of file DataLayout.h.
References llvm::Other.
DataLayout & DataLayout::operator= | ( | const DataLayout & | Other | ) |
Definition at line 224 of file DataLayout.cpp.
References llvm::Other.
bool DataLayout::operator== | ( | const DataLayout & | Other | ) | const |
Definition at line 246 of file DataLayout.cpp.
References llvm::Other.
|
static |
Parse a data layout string and return the layout.
Return an error description on failure.
Definition at line 263 of file DataLayout.cpp.
Referenced by llvm::SPIRVTranslate().
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 492 of file DataLayout.h.
References getTypeSizeInBits(), and getTypeStoreSizeInBits().