#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>
usingnamespacellvm;
StructLayout::StructLayout(StructType *ST, const DataLayout &DL)
: … { … }
unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const { … }
namespace {
class StructLayoutMap { … };
}
bool DataLayout::PrimitiveSpec::operator==(const PrimitiveSpec &Other) const { … }
bool DataLayout::PointerSpec::operator==(const PointerSpec &Other) const { … }
namespace {
struct LessPrimitiveBitWidth { … };
struct LessPointerAddrSpace { … };
}
const char *DataLayout::getManglingComponent(const Triple &T) { … }
constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[] = …;
constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[] = …;
constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[] = …;
constexpr DataLayout::PointerSpec DefaultPointerSpecs[] = …;
DataLayout::DataLayout()
: … { … }
DataLayout::DataLayout(StringRef LayoutString) : … { … }
DataLayout &DataLayout::operator=(const DataLayout &Other) { … }
bool DataLayout::operator==(const DataLayout &Other) const { … }
Expected<DataLayout> DataLayout::parse(StringRef LayoutString) { … }
static Error createSpecFormatError(Twine Format) { … }
static Error parseAddrSpace(StringRef Str, unsigned &AddrSpace) { … }
static Error parseSize(StringRef Str, unsigned &BitWidth,
StringRef Name = "size") { … }
static Error parseAlignment(StringRef Str, Align &Alignment, StringRef Name,
bool AllowZero = false) { … }
Error DataLayout::parsePrimitiveSpec(StringRef Spec) { … }
Error DataLayout::parseAggregateSpec(StringRef Spec) { … }
Error DataLayout::parsePointerSpec(StringRef Spec) { … }
Error DataLayout::parseSpecification(StringRef Spec) { … }
Error DataLayout::parseLayoutString(StringRef LayoutString) { … }
void DataLayout::setPrimitiveSpec(char Specifier, uint32_t BitWidth,
Align ABIAlign, Align PrefAlign) { … }
const DataLayout::PointerSpec &
DataLayout::getPointerSpec(uint32_t AddrSpace) const { … }
void DataLayout::setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth,
Align ABIAlign, Align PrefAlign,
uint32_t IndexBitWidth) { … }
Align DataLayout::getIntegerAlignment(uint32_t BitWidth,
bool abi_or_pref) const { … }
DataLayout::~DataLayout() { … }
const StructLayout *DataLayout::getStructLayout(StructType *Ty) const { … }
Align DataLayout::getPointerABIAlignment(unsigned AS) const { … }
Align DataLayout::getPointerPrefAlignment(unsigned AS) const { … }
unsigned DataLayout::getPointerSize(unsigned AS) const { … }
unsigned DataLayout::getMaxIndexSize() const { … }
unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const { … }
unsigned DataLayout::getIndexSize(unsigned AS) const { … }
unsigned DataLayout::getIndexTypeSizeInBits(Type *Ty) const { … }
Align DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const { … }
Align DataLayout::getABITypeAlign(Type *Ty) const { … }
Align DataLayout::getPrefTypeAlign(Type *Ty) const { … }
IntegerType *DataLayout::getIntPtrType(LLVMContext &C,
unsigned AddressSpace) const { … }
Type *DataLayout::getIntPtrType(Type *Ty) const { … }
Type *DataLayout::getSmallestLegalIntType(LLVMContext &C, unsigned Width) const { … }
unsigned DataLayout::getLargestLegalIntTypeSizeInBits() const { … }
IntegerType *DataLayout::getIndexType(LLVMContext &C,
unsigned AddressSpace) const { … }
Type *DataLayout::getIndexType(Type *Ty) const { … }
int64_t DataLayout::getIndexedOffsetInType(Type *ElemTy,
ArrayRef<Value *> Indices) const { … }
static APInt getElementIndex(TypeSize ElemSize, APInt &Offset) { … }
std::optional<APInt> DataLayout::getGEPIndexForOffset(Type *&ElemTy,
APInt &Offset) const { … }
SmallVector<APInt> DataLayout::getGEPIndicesForOffset(Type *&ElemTy,
APInt &Offset) const { … }
Align DataLayout::getPreferredAlign(const GlobalVariable *GV) const { … }