14#ifndef LLVM_ABI_FUNCTIONINFO_H
15#define LLVM_ABI_FUNCTIONINFO_H
55 const Type *CoercionType =
nullptr;
56 const Type *UnpaddedCoerceAndExpandType =
nullptr;
65 struct DirectAttrInfo {
69 struct IndirectAttrInfo {
81 bool Conservative : 1;
82 bool IndirectByVal : 1;
83 bool IndirectRealign : 1;
84 bool CanBeFlattened : 1;
85 unsigned NeededIntRegs : 3;
86 unsigned NeededSseRegs : 3;
91 NeededIntRegs(0), NeededSseRegs(0) {}
106 bool CanBeFlattened =
true) {
109 AI.Alignment =
Align;
111 AI.CanBeFlattened = CanBeFlattened;
116 assert(
T &&
"Type cannot be null");
117 assert(
T->isInteger() &&
"Unexpected type - only integers can be extended");
121 AI.Alignment = std::nullopt;
125 if (IntTy->isSigned())
135 AI.Conservative =
true;
142 bool Realign =
false) {
144 AI.Alignment =
Align;
146 AI.IndirectByVal = ByVal;
147 AI.IndirectRealign = Realign;
154 bool Realign =
false) {
156 AI.Alignment =
Align;
158 AI.IndirectRealign = Realign;
171 const Type *UnpaddedCoerceToType) {
172 assert(CoerceToType && UnpaddedCoerceToType &&
173 "coerce-and-expand types cannot be null");
175 "coerce-and-expand coerce type must be a record");
177 AI.CoercionType = CoerceToType;
178 AI.UnpaddedCoerceAndExpandType = UnpaddedCoerceToType;
183 this->SignExt = SignExtend;
185 this->ZeroExt =
false;
190 this->ZeroExt = ZeroExtend;
192 this->SignExt =
false;
199 CanBeFlattened = Flatten;
223 assert(
IntRegs <= 7 && SseRegs <= 7 &&
"Register demand does not fit");
225 NeededSseRegs = SseRegs;
235 assert(Alignment.has_value() &&
236 "Indirect arguments must have an alignment");
248 return IndirectByVal;
253 return IndirectRealign;
260 return CanBeFlattened;
275 return !SignExt && !ZeroExt;
294 return UnpaddedCoerceAndExpandType;
302 if (!AT || AT->isMatrixType())
305 return Elt && Elt->getSizeInBits().getFixedValue() == 8;
327 unsigned NumRequired;
338 assert(
N != ~0U &&
"~0U is reserved for a signature with no ellipsis");
351 const Type *ReturnType;
360 NumArgs(NumArguments),
CC(CC), Required(Required) {}
368 void operator delete(
void *p) { ::operator
delete(p); }
376 LLVM_ABI static std::unique_ptr<FunctionInfo>
387 bool isVariadic()
const {
return Required.allowsOptionalArgs(); }
402 assert(Index < NumArgs &&
"Invalid argument index");
407 assert(Index < NumArgs &&
"Invalid argument index");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static const MCPhysReg IntRegs[32]
This header defines support for implementing classes that have some trailing object (or arrays of obj...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
const T * getTrailingObjects() const
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
bool getCanBeFlattened() const
Whether a Direct record coercion may be split into one wire argument per field.
const Type * getCoerceToType() const
static ArgInfo getConservativeExtend(const Type *T)
bool isCoerceAndExpand() const
ArgInfo & setCanBeFlattened(bool Flatten)
See getCanBeFlattened.
static bool isPaddingForCoerceAndExpand(const Type *Ty)
True if Ty is an array of i8, the padding element of a coerce-and-expand type.
Align getIndirectAlign() const
const Type * getUnpaddedCoerceAndExpandType() const
DirectAttrInfo DirectAttr
ArgInfo & setZeroExt(bool ZeroExtend=true)
static ArgInfo getIgnore()
static ArgInfo getIndirectAliased(Align Align, unsigned AddrSpace, bool Realign=false)
An aliased indirect argument.
void setNeededRegs(unsigned IntRegs, unsigned SseRegs)
bool isConservative() const
Whether the extension is conservative, i.e.
unsigned getIndirectAddrSpace() const
static ArgInfo getCoerceAndExpand(const Type *CoerceToType, const Type *UnpaddedCoerceToType)
IndirectAttrInfo IndirectAttr
@ IndirectAliased
Like Indirect, but the pointer may alias an object referenced elsewhere.
@ Extend
Valid only for integer argument types.
@ CoerceAndExpand
Only valid for aggregate argument types.
@ Direct
Pass the argument directly using the normal converted LLVM type, or by coercing to another specified ...
@ Ignore
Ignore the argument (treat as void). Useful for void and empty structs.
@ Indirect
Pass the argument indirectly via a hidden pointer with the specified alignment and address space.
static ArgInfo getExtend(const Type *T)
static ArgInfo getIndirect(Align Align, bool ByVal, unsigned AddrSpace=0, bool Realign=false)
Realign: the caller couldn't guarantee sufficient alignment - the callee must copy the argument to a ...
MaybeAlign getDirectAlign() const
static ArgInfo getDirect(const Type *T=nullptr, unsigned Offset=0, MaybeAlign Align=std::nullopt, bool CanBeFlattened=true)
unsigned getNeededIntRegs() const
How many integer and vector argument registers this argument occupies.
bool getIndirectRealign() const
ArgInfo & setSignExt(bool SignExtend=true)
bool getIndirectByVal() const
unsigned getNeededSseRegs() const
bool isIndirectAliased() const
unsigned getDirectOffset() const
ArrayRef< ArgEntry > arguments() const
unsigned getNumRequiredArgs() const
const ArgInfo & getReturnInfo() const
const ArgEntry * const_arg_iterator
MutableArrayRef< ArgEntry > arguments()
CallingConv::ID getCallingConvention() const
ArgInfo & getReturnInfo()
const_arg_iterator arg_begin() const
const ArgEntry & getArgInfo(unsigned Index) const
friend class TrailingObjects
const_arg_iterator arg_end() const
unsigned arg_size() const
ArgEntry & getArgInfo(unsigned Index)
const Type * getReturnType() const
static LLVM_ABI std::unique_ptr< FunctionInfo > create(CallingConv::ID CC, const Type *ReturnType, ArrayRef< const Type * > ArgTypes, RequiredArgs Required=RequiredArgs::All)
Whether a signature accepts arguments beyond its declared parameters, and where the declared ones end...
bool allowsOptionalArgs() const
RequiredArgs(unsigned N)
A signature whose leading N arguments are declared and whose remaining arguments pass through an elli...
unsigned getNumRequiredArgs() const
RequiredArgs(All_t)
A signature with no ellipsis, where every argument is declared.
Represents the ABI-specific view of a type in LLVM.
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
ArgEntry(const Type *T, ArgInfo A)