LLVM 24.0.0git
llvm::abi::TargetInfo Class Referenceabstract

#include "llvm/ABI/TargetInfo.h"

Inheritance diagram for llvm::abi::TargetInfo:
[legend]

Public Member Functions

 TargetInfo (TypeBuilder &Builder)
virtual ~TargetInfo ()=default
virtual void computeInfo (FunctionInfo &FI) const =0
 Populate FI with the target's ABI-lowering decisions for each argument and return value.
virtual bool isPassByRef (const Type *Ty) const
virtual const ABICompatInfo & getABICompatInfo () const =0
 Return this target's ABI compatibility flags.
virtual unsigned getAllocaAddrSpace () const
 Address space in which indirect arguments are allocated (the target's alloca/stack space).
virtual bool hasInt128Type () const
 Whether the target has a 128-bit integer type. Default true.
virtual unsigned getLongLongWidth () const
 Width of long long in bits. Default 64.
virtual llvm::Align getMaxIntegerAlign () const
 Alignment of the widest integer the target's data layout gives an alignment to.

Protected Member Functions

LLVM_ABI RecordArgABI getRecordArgABI (const RecordType *RT) const
LLVM_ABI RecordArgABI getRecordArgABI (const Type *Ty) const
LLVM_ABI bool isPromotableInteger (const IntegerType *IT) const
unsigned getBitIntRegThreshold () const
 Bit width above which a _BitInt cannot stay in registers.
LLVM_ABI ArgInfo getNaturalAlignIndirect (const Type *Ty, unsigned AddrSpace, bool ByVal=true) const
LLVM_ABI const Type * getI8Array (uint64_t NumBytes) const
 An array of NumBytes i8 elements, the padding element of a coerce-and-expand type.
LLVM_ABI const Type * convertTypeForMem (const Type *Ty) const
 In-memory form of Ty.
LLVM_ABI const Type * getStructOfTypes (ArrayRef< const Type * > Elems, bool Packed) const
 A record with one field per element of Elems, each at offset 0.
LLVM_ABI bool isAggregateTypeForABI (const Type *Ty) const
LLVM_ABI const Type * useFirstFieldIfTransparentUnion (const Type *Ty) const
 If Ty is a transparent union, return its first field type; otherwise return Ty unchanged.
LLVM_ABI const Type * isSingleElementStruct (const Type *Ty) const
 Returns the scalar a single-element struct reduces to, else null.
LLVM_ABI bool maybeCommonClassifyReturnType (FunctionInfo &FI) const
 Apply rules for classifying return types that are common to all targets.
virtual bool isHomogeneousAggregateBaseType (const Type *Ty) const
 Return true if Ty is a valid base type for a homogeneous aggregate.
virtual bool isHomogeneousAggregateSmallEnough (const Type *Base, uint64_t Members) const
 Return true if a homogeneous aggregate with Members copies of Base is small enough to be passed in registers for this ABI.
virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate () const
 Return true if zero-length bitfields should be ignored when deciding whether an aggregate is homogeneous.
virtual bool isPermittedToBeHomogeneousAggregate (const RecordType *RT) const
 Return true if the C++ ABI permits RT to be a homogeneous aggregate.
LLVM_ABI bool isHomogeneousAggregate (const Type *Ty, const Type *&Base, uint64_t &Members) const
 Return true if Ty is an ELFv2-style homogeneous aggregate.

Protected Attributes

TypeBuilder & TB

Detailed Description

Definition at line 65 of file TargetInfo.h.

Constructor & Destructor Documentation

◆ TargetInfo()

llvm::abi::TargetInfo::TargetInfo ( TypeBuilder & Builder)
inlineexplicit

◆ ~TargetInfo()

virtual llvm::abi::TargetInfo::~TargetInfo ( )
virtualdefault

Member Function Documentation

◆ computeInfo()

virtual void llvm::abi::TargetInfo::computeInfo ( FunctionInfo & FI) const
pure virtual

Populate FI with the target's ABI-lowering decisions for each argument and return value.

Implemented in llvm::abi::AArch64TargetInfo, llvm::abi::AMDGPUTargetInfo, llvm::abi::BPFTargetInfo, and llvm::abi::DefaultTargetInfo.

◆ convertTypeForMem()

const Type * TargetInfo::convertTypeForMem ( const Type * Ty) const
protected

In-memory form of Ty.

A record becomes one field list: non-empty bases and fields in offset order. Padding is an array of i8. The result is packed when a member offset or the record size is not a multiple of the converted member alignment, and then every gap is an explicit array. Any other record has an array only where that alignment does not already produce the gap, and for the tail that alignment is capped at getMaxIntegerAlign(). A record with a virtual base has no layout here. An array is rebuilt when its element type changes. Any other type is returned unchanged.

Definition at line 102 of file TargetInfo.cpp.

References A(), llvm::alignTo(), assert(), B(), llvm::sampleprof::Base, convertTypeForMem(), llvm::abi::Default, llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), getConvertedAlign(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), getI8Array(), getMaxIntegerAlign(), llvm::abi::Type::getSizeInBits(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::Offset, llvm::abi::Packed, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Size, llvm::stable_sort(), TB, and llvm::Align::value().

Referenced by convertTypeForMem().

◆ getABICompatInfo()

virtual const ABICompatInfo & llvm::abi::TargetInfo::getABICompatInfo ( ) const
pure virtual

Return this target's ABI compatibility flags.

Targets with extra flags store a derived object and return that as an ABICompatInfo reference.

Implemented in llvm::abi::AArch64TargetInfo, llvm::abi::AMDGPUTargetInfo, llvm::abi::BPFTargetInfo, and llvm::abi::X86_64TargetInfo.

Referenced by isHomogeneousAggregate().

◆ getAllocaAddrSpace()

virtual unsigned llvm::abi::TargetInfo::getAllocaAddrSpace ( ) const
inlinevirtual

Address space in which indirect arguments are allocated (the target's alloca/stack space).

Reimplemented in llvm::abi::AMDGPUTargetInfo.

Definition at line 85 of file TargetInfo.h.

Referenced by llvm::abi::DefaultTargetInfo::classifyArgumentType(), and llvm::abi::DefaultTargetInfo::classifyReturnType().

◆ getBitIntRegThreshold()

unsigned llvm::abi::TargetInfo::getBitIntRegThreshold ( ) const
inlineprotected

Bit width above which a _BitInt cannot stay in registers.

Definition at line 104 of file TargetInfo.h.

References getLongLongWidth(), and hasInt128Type().

Referenced by llvm::abi::DefaultTargetInfo::classifyArgumentType(), and llvm::abi::DefaultTargetInfo::classifyReturnType().

◆ getI8Array()

const Type * TargetInfo::getI8Array ( uint64_t NumBytes) const
protected

An array of NumBytes i8 elements, the padding element of a coerce-and-expand type.

Definition at line 53 of file TargetInfo.cpp.

References assert(), and TB.

Referenced by convertTypeForMem().

◆ getLongLongWidth()

virtual unsigned llvm::abi::TargetInfo::getLongLongWidth ( ) const
inlinevirtual

Width of long long in bits. Default 64.

Definition at line 91 of file TargetInfo.h.

Referenced by getBitIntRegThreshold().

◆ getMaxIntegerAlign()

virtual llvm::Align llvm::abi::TargetInfo::getMaxIntegerAlign ( ) const
inlinevirtual

Alignment of the widest integer the target's data layout gives an alignment to.

An integer wider than that one is aligned to this. Default 16, the alignment of i128 on AArch64 and x86-64.

Definition at line 96 of file TargetInfo.h.

Referenced by convertTypeForMem().

◆ getNaturalAlignIndirect()

ArgInfo TargetInfo::getNaturalAlignIndirect ( const Type * Ty,
unsigned AddrSpace,
bool ByVal = true ) const
protected

◆ getRecordArgABI() [1/2]

◆ getRecordArgABI() [2/2]

RecordArgABI TargetInfo::getRecordArgABI ( const Type * Ty) const
protected

Definition at line 205 of file TargetInfo.cpp.

References llvm::dyn_cast(), getRecordArgABI(), and llvm::abi::RAA_Default.

◆ getStructOfTypes()

const Type * TargetInfo::getStructOfTypes ( llvm::ArrayRef< const Type * > Elems,
bool Packed ) const
protected

A record with one field per element of Elems, each at offset 0.

Packed selects a packed record, which has no alignment padding between fields.

Definition at line 59 of file TargetInfo.cpp.

References assert(), llvm::abi::Default, llvm::SmallVectorImpl< T >::emplace_back(), llvm::ArrayRef< T >::empty(), llvm::TypeSize::getFixed(), llvm::abi::Packed, llvm::SmallVectorImpl< T >::reserve(), llvm::ArrayRef< T >::size(), and TB.

◆ hasInt128Type()

virtual bool llvm::abi::TargetInfo::hasInt128Type ( ) const
inlinevirtual

Whether the target has a 128-bit integer type. Default true.

Definition at line 88 of file TargetInfo.h.

Referenced by getBitIntRegThreshold().

◆ isAggregateTypeForABI()

◆ isHomogeneousAggregate()

bool TargetInfo::isHomogeneousAggregate ( const Type * Ty,
const Type *& Base,
uint64_t & Members ) const
protected

◆ isHomogeneousAggregateBaseType()

virtual bool llvm::abi::TargetInfo::isHomogeneousAggregateBaseType ( const Type * Ty) const
inlineprotectedvirtual

Return true if Ty is a valid base type for a homogeneous aggregate.

Definition at line 144 of file TargetInfo.h.

Referenced by isHomogeneousAggregate().

◆ isHomogeneousAggregateSmallEnough()

virtual bool llvm::abi::TargetInfo::isHomogeneousAggregateSmallEnough ( const Type * Base,
uint64_t Members ) const
inlineprotectedvirtual

Return true if a homogeneous aggregate with Members copies of Base is small enough to be passed in registers for this ABI.

Definition at line 150 of file TargetInfo.h.

References llvm::sampleprof::Base, and uint64_t.

Referenced by isHomogeneousAggregate().

◆ isPassByRef()

virtual bool llvm::abi::TargetInfo::isPassByRef ( const Type * Ty) const
inlinevirtual

Definition at line 77 of file TargetInfo.h.

◆ isPermittedToBeHomogeneousAggregate()

virtual bool llvm::abi::TargetInfo::isPermittedToBeHomogeneousAggregate ( const RecordType * RT) const
inlineprotectedvirtual

Return true if the C++ ABI permits RT to be a homogeneous aggregate.

Definition at line 162 of file TargetInfo.h.

Referenced by isHomogeneousAggregate().

◆ isPromotableInteger()

bool TargetInfo::isPromotableInteger ( const IntegerType * IT) const
protected

◆ isSingleElementStruct()

const Type * TargetInfo::isSingleElementStruct ( const Type * Ty) const
protected

Returns the scalar a single-element struct reduces to, else null.

Definition at line 225 of file TargetInfo.cpp.

References llvm::sampleprof::Base, llvm::dyn_cast(), llvm::abi::Type::getABISizeInBits(), isAggregateTypeForABI(), and isSingleElementStruct().

Referenced by isSingleElementStruct().

◆ isZeroLengthBitfieldPermittedInHomogeneousAggregate()

virtual bool llvm::abi::TargetInfo::isZeroLengthBitfieldPermittedInHomogeneousAggregate ( ) const
inlineprotectedvirtual

Return true if zero-length bitfields should be ignored when deciding whether an aggregate is homogeneous.

Definition at line 157 of file TargetInfo.h.

Referenced by isHomogeneousAggregate().

◆ maybeCommonClassifyReturnType()

bool TargetInfo::maybeCommonClassifyReturnType ( FunctionInfo & FI) const
protected

◆ useFirstFieldIfTransparentUnion()

const Type * TargetInfo::useFirstFieldIfTransparentUnion ( const Type * Ty) const
protected

If Ty is a transparent union, return its first field type; otherwise return Ty unchanged.

Definition at line 214 of file TargetInfo.cpp.

References assert(), and llvm::dyn_cast().

Referenced by llvm::abi::DefaultTargetInfo::classifyArgumentType().

Member Data Documentation

◆ TB


The documentation for this class was generated from the following files: