Go to the documentation of this file.
14 #ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
15 #define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
37 class FunctionLoweringInfo;
38 class MachineIRBuilder;
39 class MachineFunction;
40 struct MachinePointerInfo;
41 class MachineRegisterInfo;
47 virtual void anchor();
91 "only void types should have no register");
162 IsIncomingArgumentHandler(IsIncoming) {
175 return IsIncomingArgumentHandler;
210 const bool IsIncomingArgumentHandler;
211 virtual void anchor();
310 unsigned MaxSizeBits = 0);
342 template <
class XXXTargetLowering>
343 const XXXTargetLowering *
getTLI()
const {
344 return static_cast<const XXXTargetLowering *
>(TLI);
350 unsigned ArgIdx)
const;
356 unsigned OpIdx)
const;
358 template <
typename FuncInfoTy>
360 const FuncInfoTy &FuncInfo)
const;
412 const uint32_t *CallerPreservedMask,
428 ValueAssigner &CalleeAssigner,
429 ValueAssigner &CallerAssigner)
const;
466 CallLoweringInfo &
Info)
const;
489 bool IsVarArg)
const {
507 assert(SwiftErrorVReg == 0 &&
"attempt to use unsupported swifterror");
592 #endif // LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
Argument handling is mostly uniform between the four places that make these decisions: function forma...
bool CanLowerReturn
True if the function's return value can be lowered to registers.
This is an optimization pass for GlobalISel generic memory operations.
virtual ~ValueHandler()=default
A parsed version of the target data layout string in and methods for querying it.
bool IsMustTailCall
True if the call must be tail call optimized.
CCState - This class holds information needed while lowering arguments and return values.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void assignValueToReg(Register ValVReg, Register PhysReg, CCValAssign VA) override
Provides a default implementation for argument handling.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Register extendRegister(Register ValReg, CCValAssign &VA, unsigned MaxSizeBits=0)
Extend a register to the location type given in VA, capped at extending to at most MaxSize bits.
bool LoweredTailCall
True if the call was lowered as a tail call.
Register SwiftErrorVReg
Valid if the call has a swifterror inout parameter, and contains the vreg that the swifterror should ...
virtual void assignValueToAddress(const ArgInfo &Arg, unsigned ValRegIndex, Register Addr, LLT MemTy, MachinePointerInfo &MPO, CCValAssign &VA)
An overload which takes an ArgInfo if additional information about the arg is needed.
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI) const
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterro...
void insertSRetOutgoingArgument(MachineIRBuilder &MIRBuilder, const CallBase &CB, CallLoweringInfo &Info) const
For the call-base described by CB, insert the hidden sret ArgInfo to the OrigArgs field of Info.
The instances of the Type class are immutable: once they are created, they are never changed.
Base class for ValueHandlers used for arguments passed to a function call, or for return values.
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
virtual bool supportSwiftError() const
void splitToValueTypes(const ArgInfo &OrigArgInfo, SmallVectorImpl< ArgInfo > &SplitArgs, const DataLayout &DL, CallingConv::ID CallConv, SmallVectorImpl< uint64_t > *Offsets=nullptr) const
Break OrigArgInfo into one or more pieces the calling convention can process, returned in SplitArgs.
Register DemoteRegister
VReg to hold the hidden sret parameter.
ArgInfo(ArrayRef< Register > Regs, Type *Ty, unsigned OrigIndex, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true, const Value *OrigValue=nullptr)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
const TargetLowering * getTLI() const
Getter for generic TargetLowering class.
bool resultsCompatible(CallLoweringInfo &Info, MachineFunction &MF, SmallVectorImpl< ArgInfo > &InArgs, ValueAssigner &CalleeAssigner, ValueAssigner &CallerAssigner) const
CCValAssign - Represent assignment of one arg/retval to a location.
bool checkReturnTypeForCallConv(MachineFunction &MF) const
Toplevel function to check the return type based on the target calling convention.
IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
static MachineOperand CreateImm(int64_t Val)
CCAssignFn * AssignFn
Assignment function to use for a general call.
virtual void assignValueToReg(Register ValVReg, Register PhysReg, CCValAssign VA)=0
The specified value has been assigned to a physical register, handle the appropriate COPY (either to ...
BaseArgInfo(Type *Ty, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
virtual bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register >> VRegs, FunctionLoweringInfo &FLI) const
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs,...
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI, Register SwiftErrorVReg) const
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
virtual LLT getStackValueStoreType(const DataLayout &DL, const CCValAssign &VA, ISD::ArgFlagsTy Flags) const
Return the in-memory size to write for the argument at VA.
int DemoteStackIndex
The stack index for sret demotion.
const CallBase * CB
Original IR callsite corresponding to this call, if available.
MachineOperand class - Representation of each machine instruction operand.
bool determineAssignments(ValueAssigner &Assigner, SmallVectorImpl< ArgInfo > &Args, CCState &CCInfo) const
Analyze the argument list in Args, using Assigner to populate CCInfo.
virtual unsigned assignCustomValue(ArgInfo &Arg, ArrayRef< CCValAssign > VAs, std::function< void()> *Thunk=nullptr)
Handle custom values, which may be passed into one or more of VAs.
Base class for ValueHandlers used for arguments coming into the current function, or for return value...
virtual ~ValueAssigner()=default
Analysis containing CSE Info
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
SmallVector< Register, 2 > OrigRegs
bool isIncomingArgumentHandler() const
Returns true if the handler is dealing with incoming arguments, i.e.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
virtual bool isTypeIsValidForThisReturn(EVT Ty) const
For targets which support the "returned" parameter attribute, returns true if the given type is a val...
static const unsigned NoArgIndex
Sentinel value for implicit machine-level input arguments.
OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
Helper class to build MachineInstr.
bool checkReturn(CCState &CCInfo, SmallVectorImpl< BaseArgInfo > &Outs, CCAssignFn *Fn) const
This class contains a discriminated union of information about pointers in memory operands,...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
print Print MemDeps of function
bool isVoidTy() const
Return true if this is 'void'.
CCAssignFn * getAssignFn(bool IsVarArg) const
Select the appropriate assignment function depending on whether this is a variadic call.
void addArgFlagsFromAttributes(ISD::ArgFlagsTy &Flags, const AttributeList &Attrs, unsigned OpIdx) const
Adds flags to Flags based off of the attributes in Attrs.
@ C
C - The default llvm calling convention, compatible with C.
void copyArgumentMemory(const ArgInfo &Arg, Register DstPtr, Register SrcPtr, const MachinePointerInfo &DstPtrInfo, Align DstAlign, const MachinePointerInfo &SrcPtrInfo, Align SrcAlign, uint64_t MemSize, CCValAssign &VA) const
Do a memory copy of MemSize bytes from SrcPtr to DstPtr.
const bool IsIncomingArgumentHandler
virtual bool enableBigEndian() const
For targets which want to use big-endian can enable it with enableBigEndian() hook.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
virtual Register getStackAddress(uint64_t MemSize, int64_t Offset, MachinePointerInfo &MPO, ISD::ArgFlagsTy Flags)=0
Materialize a VReg containing the address of the specified stack-based object.
virtual ~CallLowering()=default
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void insertSRetLoads(MachineIRBuilder &MIRBuilder, Type *RetTy, ArrayRef< Register > VRegs, Register DemoteReg, int FI) const
Load the returned value from the stack into virtual registers in VRegs.
bool IsVarArg
True if the call is to a vararg function.
const XXXTargetLowering * getTLI() const
Getter for target specific TargetLowering class.
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
IncomingValueAssigner(CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Helper struct shared between Function Specialization and SCCP Solver.
unsigned const MachineRegisterInfo * MRI
Wrapper class representing virtual and physical registers.
void insertSRetIncomingArgument(const Function &F, SmallVectorImpl< ArgInfo > &SplitArgs, Register &DemoteReg, MachineRegisterInfo &MRI, const DataLayout &DL) const
Insert the hidden sret ArgInfo to the beginning of SplitArgs.
ISD::ArgFlagsTy getAttributesForArgIdx(const CallBase &Call, unsigned ArgIdx) const
virtual bool canLowerReturn(MachineFunction &MF, CallingConv::ID CallConv, SmallVectorImpl< BaseArgInfo > &Outs, bool IsVarArg) const
This hook must be implemented to check whether the return values described by Outs can fit into the r...
void insertSRetStores(MachineIRBuilder &MIRBuilder, Type *RetTy, ArrayRef< Register > VRegs, Register DemoteReg) const
Store the return value given by VRegs into stack starting at the offset specified in DemoteReg.
MachineRegisterInfo & MRI
CallingConv::ID CallConv
Calling convention to be used for the call.
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
bool handleAssignments(ValueHandler &Handler, SmallVectorImpl< ArgInfo > &Args, CCState &CCState, SmallVectorImpl< CCValAssign > &ArgLocs, MachineIRBuilder &MIRBuilder, ArrayRef< Register > ThisReturnRegs=None) const
Use Handler to insert code to handle the argument/return values represented by Args.
SmallVector< Register, 4 > Regs
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
CCAssignFn * AssignFnVarArg
Assignment function to use for a variadic call.
virtual bool fallBackToDAGISel(const MachineFunction &MF) const
Register buildExtensionHint(CCValAssign &VA, Register SrcReg, LLT NarrowTy)
Insert G_ASSERT_ZEXT/G_ASSERT_SEXT or other hint instruction based on VA, returning the new register ...
CallLowering(const TargetLowering *TLI)
MachineIRBuilder & MIRBuilder
ValueAssigner(bool IsIncoming, CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
ValueHandler(bool IsIncoming, MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
ArgInfo(ArrayRef< Register > Regs, const Value &OrigValue, unsigned OrigIndex, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void getReturnInfo(CallingConv::ID CallConv, Type *RetTy, AttributeList Attrs, SmallVectorImpl< BaseArgInfo > &Outs, const DataLayout &DL) const
Get the type and the ArgFlags for the split components of RetTy as returned by ComputeValueVTs.
ArgInfo OrigRet
Descriptor for the return type of the function.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const Value * OrigValue
Optionally track the original IR value for the argument.
virtual bool assignArg(unsigned ValNo, EVT OrigVT, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, const ArgInfo &Info, ISD::ArgFlagsTy Flags, CCState &State)
Wrap call to (typically tablegenerated CCAssignFn).
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool IsTailCall
True if the call passes all target-independent checks for tail call optimization.
unsigned OrigArgIndex
Index original Function's argument.
SmallVector< ArgInfo, 32 > OrigArgs
List of descriptors of the arguments passed to the function.
bool parametersInCSRMatch(const MachineRegisterInfo &MRI, const uint32_t *CallerPreservedMask, const SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< ArgInfo > &OutVals) const
Check whether parameters to a call that are passed in callee saved registers are the same as from the...
LLVM Value Representation.
bool isIncomingArgumentHandler() const
Returns true if the handler is dealing with incoming arguments, i.e.
OutgoingValueAssigner(CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
bool determineAndHandleAssignments(ValueHandler &Handler, ValueAssigner &Assigner, SmallVectorImpl< ArgInfo > &Args, MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, bool IsVarArg, ArrayRef< Register > ThisReturnRegs=None) const
Invoke ValueAssigner::assignArg on each of the given Args and then use Handler to move them to the as...
virtual void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy, MachinePointerInfo &MPO, CCValAssign &VA)=0
The specified value has been assigned to a stack location.
SmallVector< ISD::ArgFlagsTy, 4 > Flags
MachineOperand Callee
Destination of the call.
virtual bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const
This hook must be implemented to lower the given call instruction, including argument and return valu...
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const