class DataLayout

Declaration

class DataLayout { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:113

Member Variables

private bool BigEndian
Defaults to false.
private unsigned int AllocaAddrSpace
private llvm::MaybeAlign StackNaturalAlign
private unsigned int ProgramAddrSpace
private unsigned int DefaultGlobalsAddrSpace
private llvm::MaybeAlign FunctionPtrAlign
private llvm::DataLayout::FunctionPtrAlignType TheFunctionPtrAlignType
private llvm::DataLayout::ManglingModeT ManglingMode
private SmallVector<unsigned char, 8> LegalIntWidths
private llvm::DataLayout::AlignmentsTy Alignments
private std::string StringRepresentation
The string representation used to create this DataLayout
private llvm::DataLayout::PointersTy Pointers
private void* LayoutMap = nullptr
private SmallVector<unsigned int, 8> NonIntegralAddressSpaces
Pointers in these address spaces are non-integral, and don't have a well-defined bitwise representation.

Method Overview

Methods

DataLayout(llvm::StringRef LayoutDescription)

Description

Constructs a DataLayout from a specification string. See reset().

Declared at: llvm/include/llvm/IR/DataLayout.h:202

Parameters

llvm::StringRef LayoutDescription

DataLayout(const llvm::Module* M)

Description

Initialize target data from properties stored in the module.

Declared at: llvm/include/llvm/IR/DataLayout.h:207

Parameters

const llvm::Module* M

DataLayout(const llvm::DataLayout& DL)

Declared at: llvm/include/llvm/IR/DataLayout.h:209

Parameters

const llvm::DataLayout& DL

void clear()

Declared at: llvm/include/llvm/IR/DataLayout.h:198

bool doNotMangleLeadingQuestionMark() const

Description

Returns true if symbols with leading question marks should not receive IR mangling. True for Windows mangling modes.

Declared at: llvm/include/llvm/IR/DataLayout.h:306

bool exceedsNaturalStackAlignment(
    llvm::Align Alignment) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:273

Parameters

llvm::Align Alignment

AlignmentsTy::iterator findAlignmentLowerBound(
    llvm::AlignTypeEnum AlignType,
    uint32_t BitWidth)

Declared at: llvm/include/llvm/IR/DataLayout.h:159

Parameters

llvm::AlignTypeEnum AlignType
uint32_t BitWidth

AlignmentsTy::const_iterator
findAlignmentLowerBound(
    llvm::AlignTypeEnum AlignType,
    uint32_t BitWidth) const

Declared at: llvm/include/llvm/IR/DataLayout.h:153

Parameters

llvm::AlignTypeEnum AlignType
uint32_t BitWidth

bool fitsInLegalInteger(unsigned int Width) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:361

Parameters

unsigned int Width

llvm::Align getABIIntegerTypeAlignment(
    unsigned int BitWidth) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:539

Parameters

unsigned int BitWidth

llvm::Align getABITypeAlign(llvm::Type* Ty) const

Description

Returns the minimum ABI-required alignment for the specified type.

Declared at: llvm/include/llvm/IR/DataLayout.h:528

Parameters

llvm::Type* Ty

uint64_t getABITypeAlignment(llvm::Type* Ty) const

Description

Returns the minimum ABI-required alignment for the specified type. FIXME: Deprecate this function once migration to Align is over.

Declared at: llvm/include/llvm/IR/DataLayout.h:525

Parameters

llvm::Type* Ty

llvm::Align getAlignment(llvm::Type* Ty,
                         bool abi_or_pref) const

Description

Internal helper method that returns requested alignment for type.

Declared at: llvm/include/llvm/IR/DataLayout.h:191

Parameters

llvm::Type* Ty
bool abi_or_pref

unsigned int getAllocaAddrSpace() const

Declared at: llvm/include/llvm/IR/DataLayout.h:282

unsigned int getDefaultGlobalsAddressSpace() const

Declared at: llvm/include/llvm/IR/DataLayout.h:296

llvm::MaybeAlign getFunctionPtrAlign() const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:287

llvm::DataLayout::FunctionPtrAlignType
getFunctionPtrAlignType() const

Description

Return the type of function pointer alignment.

Declared at: llvm/include/llvm/IR/DataLayout.h:291

Optional<llvm::APInt> getGEPIndexForOffset(
    llvm::Type*& ElemTy,
    llvm::APInt& Offset) const

Description

Get single GEP index to access Offset inside ElemTy. Returns None 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.

Declared at: llvm/include/llvm/IR/DataLayout.h:598

Parameters

llvm::Type*& ElemTy
llvm::APInt& Offset

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

Description

Get GEP indices to access Offset inside ElemTy. ElemTy is updated to be the result element type and Offset to be the residual offset.

Declared at: llvm/include/llvm/IR/DataLayout.h:592

Parameters

llvm::Type*& ElemTy
llvm::APInt& Offset

char getGlobalPrefix() const

Declared at: llvm/include/llvm/IR/DataLayout.h:318

unsigned int getIndexSize(unsigned int AS) const

Description

rounded up to a whole number of bytes.

Declared at: llvm/include/llvm/IR/DataLayout.h:387

Parameters

unsigned int AS

unsigned int getIndexSizeInBits(
    unsigned int AS) const

Description

Size in bits of index used for address calculation in getelementptr.

Declared at: llvm/include/llvm/IR/DataLayout.h:422

Parameters

unsigned int AS

llvm::Type* getIndexType(llvm::Type* PtrTy) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:581

Parameters

llvm::Type* PtrTy

unsigned int getIndexTypeSizeInBits(
    llvm::Type* Ty) const

Description

Layout size of the index used in GEP calculation. The function should be called with pointer or vector of pointers type.

Declared at: llvm/include/llvm/IR/DataLayout.h:435

Parameters

llvm::Type* Ty

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

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:588

Parameters

llvm::Type* ElemTy
ArrayRef<llvm::Value*> Indices

llvm::IntegerType* getIntPtrType(
    llvm::LLVMContext& C,
    unsigned int AddressSpace = 0) const

Description

Returns an integer type with size at least as big as that of a pointer in the given address space.

Declared at: llvm/include/llvm/IR/DataLayout.h:558

Parameters

llvm::LLVMContext& C
unsigned int AddressSpace = 0

llvm::Type* getIntPtrType(llvm::Type*) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:562

Parameters

llvm::Type*

llvm::Align getIntegerAlignment(
    uint32_t BitWidth,
    bool abi_or_pref) const

Description

Internal helper to get alignment for integer of given bitwidth.

Declared at: llvm/include/llvm/IR/DataLayout.h:188

Parameters

uint32_t BitWidth
bool abi_or_pref

llvm::Type* getLargestLegalIntType(
    llvm::LLVMContext& C) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:569

Parameters

llvm::LLVMContext& C

unsigned int getLargestLegalIntTypeSizeInBits()
    const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:576

llvm::StringRef getLinkerPrivateGlobalPrefix()
    const

Declared at: llvm/include/llvm/IR/DataLayout.h:312

static const char* getManglingComponent(
    const llvm::Triple& T)

Declared at: llvm/include/llvm/IR/DataLayout.h:354

Parameters

const llvm::Triple& T

unsigned int getMaxIndexSize() const

Description

Returns the maximum index size over all address spaces.

Declared at: llvm/include/llvm/IR/DataLayout.h:383

unsigned int getMaxIndexSizeInBits() const

Description

Returns the maximum index size over all address spaces.

Declared at: llvm/include/llvm/IR/DataLayout.h:417

ArrayRef<unsigned int>
getNonIntegralAddressSpaces() const

Description

Return the address spaces containing non-integral pointers. Pointers in this address space don't have a well-defined bitwise representation.

Declared at: llvm/include/llvm/IR/DataLayout.h:391

llvm::Align getPointerABIAlignment(
    unsigned int AS) const

Description

Layout pointer alignment

Declared at: llvm/include/llvm/IR/DataLayout.h:369

Parameters

unsigned int AS

const llvm::PointerAlignElem& getPointerAlignElem(
    uint32_t AddressSpace) const

Declared at: llvm/include/llvm/IR/DataLayout.h:167

Parameters

uint32_t AddressSpace

llvm::Align getPointerPrefAlignment(
    unsigned int AS = 0) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:374

Parameters

unsigned int AS = 0

unsigned int getPointerSize(
    unsigned int AS = 0) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:380

Parameters

unsigned int AS = 0

unsigned int getPointerSizeInBits(
    unsigned int AS = 0) const

Description

Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients are updated.

Declared at: llvm/include/llvm/IR/DataLayout.h:412

Parameters

unsigned int AS = 0

unsigned int getPointerTypeSize(
    llvm::Type* Ty) const

Declared at: llvm/include/llvm/IR/DataLayout.h:437

Parameters

llvm::Type* Ty

unsigned int getPointerTypeSizeInBits(
    llvm::Type*) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:431

Parameters

llvm::Type*

llvm::Align getPrefTypeAlign(llvm::Type* Ty) const

Description

Returns the preferred stack/global alignment for the specified type. This is always at least as good as the ABI alignment.

Declared at: llvm/include/llvm/IR/DataLayout.h:554

Parameters

llvm::Type* Ty

uint64_t getPrefTypeAlignment(
    llvm::Type* Ty) const

Description

Returns the preferred stack/global alignment for the specified type. This is always at least as good as the ABI alignment. FIXME: Deprecate this function once migration to Align is over.

Declared at: llvm/include/llvm/IR/DataLayout.h:548

Parameters

llvm::Type* Ty

llvm::Align getPreferredAlign(
    const llvm::GlobalVariable* GV) const

Description

Returns the preferred alignment of the specified global. This includes an explicitly requested alignment (if the global has one).

Declared at: llvm/include/llvm/IR/DataLayout.h:609

Parameters

const llvm::GlobalVariable* GV

llvm::StringRef getPrivateGlobalPrefix() const

Declared at: llvm/include/llvm/IR/DataLayout.h:334

unsigned int getProgramAddressSpace() const

Declared at: llvm/include/llvm/IR/DataLayout.h:295

llvm::Type* getSmallestLegalIntType(
    llvm::LLVMContext& C,
    unsigned int Width = 0) const

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:566

Parameters

llvm::LLVMContext& C
unsigned int Width = 0

llvm::Align getStackAlignment() const

Declared at: llvm/include/llvm/IR/DataLayout.h:277

const std::string& getStringRepresentation() const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:252

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

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:604

Parameters

llvm::StructType* Ty

llvm::TypeSize getTypeAllocSize(
    llvm::Type* Ty) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:506

Parameters

llvm::Type* Ty

llvm::TypeSize getTypeAllocSizeInBits(
    llvm::Type* Ty) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:519

Parameters

llvm::Type* Ty

llvm::TypeSize getTypeSizeInBits(
    llvm::Type* Ty) const

Description

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).

Declared at: llvm/include/llvm/IR/DataLayout.h:465

Parameters

llvm::Type* Ty

llvm::TypeSize getTypeStoreSize(
    llvm::Type* Ty) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:474

Parameters

llvm::Type* Ty

llvm::TypeSize getTypeStoreSizeInBits(
    llvm::Type* Ty) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:486

Parameters

llvm::Type* Ty

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

Description

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

Declared at: llvm/include/llvm/IR/DataLayout.h:532

Parameters

llvm::MaybeAlign Alignment
llvm::Type* Ty

bool hasLinkerPrivateGlobalPrefix() const

Declared at: llvm/include/llvm/IR/DataLayout.h:310

bool hasMicrosoftFastStdCallMangling() const

Declared at: llvm/include/llvm/IR/DataLayout.h:300

void init(const llvm::Module* M)

Declared at: llvm/include/llvm/IR/DataLayout.h:234

Parameters

const llvm::Module* M

bool isBigEndian() const

Declared at: llvm/include/llvm/IR/DataLayout.h:245

bool isDefault() const

Description

Test if the DataLayout was constructed from an empty string.

Declared at: llvm/include/llvm/IR/DataLayout.h:257

bool isIllegalInteger(uint64_t Width) const

Declared at: llvm/include/llvm/IR/DataLayout.h:270

Parameters

uint64_t Width

bool isLegalInteger(uint64_t Width) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:266

Parameters

uint64_t Width

bool isLittleEndian() const

Description

Layout endianness...

Declared at: llvm/include/llvm/IR/DataLayout.h:244

bool isNonIntegralAddressSpace(
    unsigned int AddrSpace) const

Declared at: llvm/include/llvm/IR/DataLayout.h:395

Parameters

unsigned int AddrSpace

bool isNonIntegralPointerType(
    llvm::Type* Ty) const

Declared at: llvm/include/llvm/IR/DataLayout.h:404

Parameters

llvm::Type* Ty

bool isNonIntegralPointerType(
    llvm::PointerType* PT) const

Declared at: llvm/include/llvm/IR/DataLayout.h:400

Parameters

llvm::PointerType* PT

static Expected<llvm::DataLayout> parse(
    llvm::StringRef LayoutDescription)

Description

Parse a data layout string and return the layout. Return an error description on failure.

Declared at: llvm/include/llvm/IR/DataLayout.h:241

Parameters

llvm::StringRef LayoutDescription

llvm::Error parseSpecifier(llvm::StringRef Desc)

Description

Attempts to parse a target data specification string and reports an error if the string is malformed.

Declared at: llvm/include/llvm/IR/DataLayout.h:195

Parameters

llvm::StringRef Desc

void reset(llvm::StringRef LayoutDescription)

Description

Parse a data layout string (with fallback to default values).

Declared at: llvm/include/llvm/IR/DataLayout.h:237

Parameters

llvm::StringRef LayoutDescription

llvm::Error setAlignment(
    llvm::AlignTypeEnum align_type,
    llvm::Align abi_align,
    llvm::Align pref_align,
    uint32_t bit_width)

Description

Attempts to set the alignment of the given type. Returns an error description on failure.

Declared at: llvm/include/llvm/IR/DataLayout.h:178

Parameters

llvm::AlignTypeEnum align_type
llvm::Align abi_align
llvm::Align pref_align
uint32_t bit_width

llvm::Error setPointerAlignmentInBits(
    uint32_t AddrSpace,
    llvm::Align ABIAlign,
    llvm::Align PrefAlign,
    uint32_t TypeBitWidth,
    uint32_t IndexBitWidth)

Description

Attempts to set the alignment of a pointer in the given address space. Returns an error description on failure.

Declared at: llvm/include/llvm/IR/DataLayout.h:183

Parameters

uint32_t AddrSpace
llvm::Align ABIAlign
llvm::Align PrefAlign
uint32_t TypeBitWidth
uint32_t IndexBitWidth

bool typeSizeEqualsStoreSize(llvm::Type* Ty) const

Description

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.

Declared at: llvm/include/llvm/IR/DataLayout.h:494

Parameters

llvm::Type* Ty

~DataLayout()

Declared at: llvm/include/llvm/IR/DataLayout.h:211