14#ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
15#define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
48 virtual void anchor();
90 "only void types should have no register");
132 std::optional<PtrAuthInfo>
PAI;
177 IsIncomingArgumentHandler(IsIncoming) {
190 return IsIncomingArgumentHandler;
200 if (
getAssignFn(State.isVarArg())(ValNo, ValVT, LocVT, LocInfo, Flags,
224 const bool IsIncomingArgumentHandler;
225 virtual void anchor();
307 std::function<
void()> *Thunk =
nullptr) {
324 unsigned MaxSizeBits = 0);
357 template <
class XXXTargetLowering>
358 const XXXTargetLowering *
getTLI()
const {
359 return static_cast<const XXXTargetLowering *
>(TLI);
365 unsigned ArgIdx)
const;
373 const AttributeList &Attrs,
374 unsigned OpIdx)
const;
376 template <
typename FuncInfoTy>
378 const FuncInfoTy &FuncInfo)
const;
386 void splitToValueTypes(
const ArgInfo &OrigArgInfo,
402 bool determineAssignments(ValueAssigner &Assigner,
411 determineAndHandleAssignments(ValueHandler &Handler, ValueAssigner &Assigner,
420 bool handleAssignments(ValueHandler &Handler, SmallVectorImpl<ArgInfo> &Args,
422 SmallVectorImpl<CCValAssign> &ArgLocs,
423 MachineIRBuilder &MIRBuilder,
424 ArrayRef<Register> ThisReturnRegs = {})
const;
429 bool parametersInCSRMatch(
const MachineRegisterInfo &
MRI,
430 const uint32_t *CallerPreservedMask,
431 const SmallVectorImpl<CCValAssign> &ArgLocs,
432 const SmallVectorImpl<ArgInfo> &OutVals)
const;
444 bool resultsCompatible(CallLoweringInfo &
Info, MachineFunction &MF,
445 SmallVectorImpl<ArgInfo> &InArgs,
446 ValueAssigner &CalleeAssigner,
447 ValueAssigner &CallerAssigner)
const;
475 void insertSRetIncomingArgument(
const Function &
F,
484 CallLoweringInfo &
Info)
const;
507 bool IsVarArg)
const {
525 assert(SwiftErrorVReg == 0 &&
"attempt to use unsupported swifterror");
597 std::optional<PtrAuthInfo> PAI,
Register ConvergenceCtrlToken,
598 std::function<
Register()> GetCalleeReg)
const;
611 const DataLayout &
DL,
612 const Function &FuncInfo)
const;
616 const DataLayout &
DL,
617 const CallBase &FuncInfo)
const;
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Implement a low-level type suitable for MachineInstr level instruction selection.
Promote Memory to Register
MachineInstr unsigned OpIdx
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
CCState - This class holds information needed while lowering arguments and return values.
CCValAssign - Represent assignment of one arg/retval to a location.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
virtual ~CallLowering()=default
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 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...
virtual bool isTypeIsValidForThisReturn(EVT Ty) const
For targets which support the "returned" parameter attribute, returns true if the given type is a val...
virtual bool enableBigEndian() const
For targets which want to use big-endian can enable it with enableBigEndian() hook.
virtual bool supportSwiftError() const
CallLowering(const TargetLowering *TLI)
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 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...
const TargetLowering * getTLI() const
Getter for generic TargetLowering class.
const XXXTargetLowering * getTLI() const
Getter for target specific TargetLowering class.
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
virtual bool fallBackToDAGISel(const MachineFunction &MF) const
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Helper class to build MachineInstr.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateImm(int64_t Val)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Helper struct shared between Function Specialization and SCCP Solver.
const Value * OrigValue
Optionally track the original IR value for the argument.
SmallVector< Register, 4 > Regs
SmallVector< Register, 2 > OrigRegs
unsigned OrigArgIndex
Index original Function's argument.
ArgInfo(ArrayRef< Register > Regs, Type *Ty, unsigned OrigIndex, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), const Value *OrigValue=nullptr)
ArgInfo(ArrayRef< Register > Regs, const Value &OrigValue, unsigned OrigIndex, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >())
static const unsigned NoArgIndex
Sentinel value for implicit machine-level input arguments.
SmallVector< ISD::ArgFlagsTy, 4 > Flags
BaseArgInfo(Type *Ty, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >())
bool IsVarArg
True if the call is to a vararg function.
bool IsMustTailCall
True if the call must be tail call optimized.
bool IsTailCall
True if the call passes all target-independent checks for tail call optimization.
MachineOperand Callee
Destination of the call.
bool CanLowerReturn
True if the function's return value can be lowered to registers.
ArgInfo OrigRet
Descriptor for the return type of the function.
const ConstantInt * CFIType
Expected type identifier for indirect calls with a CFI check.
CallingConv::ID CallConv
Calling convention to be used for the call.
Register ConvergenceCtrlToken
Valid if the call is a controlled convergent operation.
const CallBase * CB
Original IR callsite corresponding to this call, if available.
Register DemoteRegister
VReg to hold the hidden sret parameter.
bool IsConvergent
True if this call results in convergent operations.
std::optional< PtrAuthInfo > PAI
The auth-call information in the "ptrauth" bundle, if present.
int DemoteStackIndex
The stack index for sret demotion.
Register SwiftErrorVReg
Valid if the call has a swifterror inout parameter, and contains the vreg that the swifterror should ...
SmallVector< ArgInfo, 32 > OrigArgs
List of descriptors of the arguments passed to the function.
bool LoweredTailCall
True if the call was lowered as a tail call.
IncomingValueAssigner(CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
OutgoingValueAssigner(CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
CCAssignFn * getAssignFn(bool IsVarArg) const
Select the appropriate assignment function depending on whether this is a variadic call.
CCAssignFn * AssignFn
Assignment function to use for a general call.
bool isIncomingArgumentHandler() const
Returns true if the handler is dealing with incoming arguments, i.e.
ValueAssigner(bool IsIncoming, CCAssignFn *AssignFn_, CCAssignFn *AssignFnVarArg_=nullptr)
CCAssignFn * AssignFnVarArg
Assignment function to use for a variadic call.
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).
uint64_t StackSize
The size of the currently allocated portion of the stack.
virtual ~ValueAssigner()=default
MachineIRBuilder & MIRBuilder
virtual ~ValueHandler()=default
MachineRegisterInfo & MRI
const bool IsIncomingArgumentHandler
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 void assignValueToAddress(const ArgInfo &Arg, unsigned ValRegIndex, Register Addr, LLT MemTy, const MachinePointerInfo &MPO, const CCValAssign &VA)
An overload which takes an ArgInfo if additional information about the arg is needed.
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.
bool isIncomingArgumentHandler() const
Returns true if the handler is dealing with incoming arguments, i.e.
virtual void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy, const MachinePointerInfo &MPO, const CCValAssign &VA)=0
The specified value has been assigned to a stack location.
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.
virtual void assignValueToReg(Register ValVReg, Register PhysReg, const CCValAssign &VA)=0
The specified value has been assigned to a physical register, handle the appropriate COPY (either to ...
ValueHandler(bool IsIncoming, MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
This class contains a discriminated union of information about pointers in memory operands,...