LLVM 20.0.0git
Functions | Variables
DataLayout.cpp File Reference
#include "llvm/IR/DataLayout.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemAlloc.h"
#include "llvm/Support/TypeSize.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <new>
#include <utility>

Go to the source code of this file.

Functions

static Error createSpecFormatError (Twine Format)
 
static Error parseAddrSpace (StringRef Str, unsigned &AddrSpace)
 Attempts to parse an address space component of a specification.
 
static Error parseSize (StringRef Str, unsigned &BitWidth, StringRef Name="size")
 Attempts to parse a size component of a specification.
 
static Error parseAlignment (StringRef Str, Align &Alignment, StringRef Name, bool AllowZero=false)
 Attempts to parse an alignment component of a specification.
 
static APInt getElementIndex (TypeSize ElemSize, APInt &Offset)
 

Variables

constexpr DataLayout::PrimitiveSpec DefaultIntSpecs []
 
constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs []
 
constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs []
 
constexpr DataLayout::PointerSpec DefaultPointerSpecs []
 

Function Documentation

◆ createSpecFormatError()

static Error createSpecFormatError ( Twine  Format)
static

Definition at line 271 of file DataLayout.cpp.

References llvm::createStringError(), and llvm::Format.

◆ getElementIndex()

static APInt getElementIndex ( TypeSize  ElemSize,
APInt Offset 
)
static

◆ parseAddrSpace()

static Error parseAddrSpace ( StringRef  Str,
unsigned AddrSpace 
)
static

Attempts to parse an address space component of a specification.

Definition at line 277 of file DataLayout.cpp.

References llvm::createStringError(), and llvm::Error::success().

◆ parseAlignment()

static Error parseAlignment ( StringRef  Str,
Align Alignment,
StringRef  Name,
bool  AllowZero = false 
)
static

Attempts to parse an alignment component of a specification.

On success, returns the value converted to byte amount in Alignment. If the value is zero and AllowZero is true, Alignment is set to one.

Return an error in a number of cases:

  • Str is empty or contains characters other than decimal digits;
  • the value is zero and AllowZero is false;
  • the value is too large;
  • the value is not a multiple of the byte width;
  • the value converted to byte amount is not not a power of two.

Definition at line 310 of file DataLayout.cpp.

References llvm::createStringError(), llvm::isPowerOf2_32(), Name, and llvm::Error::success().

◆ parseSize()

static Error parseSize ( StringRef  Str,
unsigned BitWidth,
StringRef  Name = "size" 
)
static

Attempts to parse a size component of a specification.

Definition at line 288 of file DataLayout.cpp.

References llvm::BitWidth, llvm::createStringError(), Name, and llvm::Error::success().

Variable Documentation

◆ DefaultFloatSpecs

constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[]
constexpr
Initial value:
= {
{16, Align::Constant<2>(), Align::Constant<2>()},
{32, Align::Constant<4>(), Align::Constant<4>()},
{64, Align::Constant<8>(), Align::Constant<8>()},
{128, Align::Constant<16>(), Align::Constant<16>()},
}

Definition at line 197 of file DataLayout.cpp.

◆ DefaultIntSpecs

constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[]
constexpr
Initial value:
= {
{1, Align::Constant<1>(), Align::Constant<1>()},
{8, Align::Constant<1>(), Align::Constant<1>()},
{16, Align::Constant<2>(), Align::Constant<2>()},
{32, Align::Constant<4>(), Align::Constant<4>()},
{64, Align::Constant<4>(), Align::Constant<8>()},
}

Definition at line 190 of file DataLayout.cpp.

◆ DefaultPointerSpecs

constexpr DataLayout::PointerSpec DefaultPointerSpecs[]
constexpr
Initial value:
= {
{0, 64, Align::Constant<8>(), Align::Constant<8>(), 64, false},
}

Definition at line 209 of file DataLayout.cpp.

◆ DefaultVectorSpecs

constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[]
constexpr
Initial value:
= {
{64, Align::Constant<8>(), Align::Constant<8>()},
{128, Align::Constant<16>(), Align::Constant<16>()},
}

Definition at line 203 of file DataLayout.cpp.