llvm/llvm/lib/IR/DataLayout.cpp

//===- DataLayout.cpp - Data size & alignment routines ---------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines layout properties related to datatype size/offset/alignment
// information.
//
// This structure should be created once, filled in if the defaults are not
// correct and then passed around by const&.  None of the members functions
// require modification to the object.
//
//===----------------------------------------------------------------------===//

#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;

//===----------------------------------------------------------------------===//
// Support for StructLayout
//===----------------------------------------------------------------------===//

StructLayout::StructLayout(StructType *ST, const DataLayout &DL)
    :{}

/// getElementContainingOffset - Given a valid offset into the structure,
/// return the structure index that contains it.
unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const {}

namespace {

class StructLayoutMap {};

} // end anonymous namespace

//===----------------------------------------------------------------------===//
//                       DataLayout Class Implementation
//===----------------------------------------------------------------------===//

bool DataLayout::PrimitiveSpec::operator==(const PrimitiveSpec &Other) const {}

bool DataLayout::PointerSpec::operator==(const PointerSpec &Other) const {}

namespace {
/// Predicate to sort primitive specs by bit width.
struct LessPrimitiveBitWidth {};

/// Predicate to sort pointer specs by address space number.
struct LessPointerAddrSpace {};
} // namespace

const char *DataLayout::getManglingComponent(const Triple &T) {}

// Default primitive type specifications.
// NOTE: These arrays must be sorted by type bit width.
constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[] =;
constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[] =;
constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[] =;

// Default pointer type specifications.
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) {}

/// Attempts to parse an address space component of a specification.
static Error parseAddrSpace(StringRef Str, unsigned &AddrSpace) {}

/// Attempts to parse a size component of a specification.
static Error parseSize(StringRef Str, unsigned &BitWidth,
                       StringRef Name = "size") {}

/// Attempts to parse an alignment component of a specification.
///
/// On success, returns the value converted to byte amount in \p Alignment.
/// If the value is zero and \p AllowZero is true, \p Alignment is set to one.
///
/// Return an error in a number of cases:
/// - \p Str is empty or contains characters other than decimal digits;
/// - the value is zero and \p 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.
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 {}

/*!
  \param abi_or_pref Flag that determines which alignment is returned. true
  returns the ABI alignment, false returns the preferred alignment.
  \param Ty The underlying type for which alignment is determined.

  Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref
  == false) for the requested type \a Ty.
 */
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 {}

/// getPreferredAlign - Return the preferred alignment of the specified global.
/// This includes an explicitly requested alignment (if the global has one).
Align DataLayout::getPreferredAlign(const GlobalVariable *GV) const {}