57 :
ValueHandler(MIRBuilder, MRI, AssignFn), StackUsed(0) {}
59 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
66 StackUsed =
std::max(StackUsed, Size + Offset);
70 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg,
72 markPhysRegUsed(PhysReg);
77 case CCValAssign::LocInfo::SExt:
78 case CCValAssign::LocInfo::ZExt:
79 case CCValAssign::LocInfo::AExt: {
87 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t Size,
92 MIRBuilder.
buildLoad(ValVReg, Addr, *MMO);
98 virtual void markPhysRegUsed(
unsigned PhysReg) = 0;
103 struct FormalArgHandler :
public IncomingArgHandler {
106 : IncomingArgHandler(MIRBuilder, MRI, AssignFn) {}
108 void markPhysRegUsed(
unsigned PhysReg)
override {
113 struct CallReturnHandler :
public IncomingArgHandler {
116 : IncomingArgHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}
118 void markPhysRegUsed(
unsigned PhysReg)
override {
130 AssignFnVarArg(AssignFnVarArg), StackSize(0) {}
132 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
137 MIRBuilder.
buildCopy(SPReg, AArch64::SP);
143 MIRBuilder.
buildGEP(AddrReg, SPReg, OffsetReg);
149 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg,
152 unsigned ExtReg = extendRegister(ValVReg, VA);
156 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t Size,
158 if (VA.
getLocInfo() == CCValAssign::LocInfo::AExt) {
169 bool assignArg(
unsigned ValNo,
MVT ValVT,
MVT LocVT,
175 Res = AssignFn(ValNo, ValVT, LocVT, LocInfo, Info.
Flags, State);
177 Res = AssignFnVarArg(ValNo, ValVT, LocVT, LocInfo, Info.
Flags, State);
189 void AArch64CallLowering::splitToValueTypes(
192 const SplitArgTy &PerformArgSplit)
const {
203 if (SplitVTs.
size() == 1) {
211 unsigned FirstRegIdx = SplitArgs.
size();
213 OrigArg.
Ty, CallConv,
false);
214 for (
auto SplitVT : SplitVTs) {
215 Type *SplitTy = SplitVT.getTypeForEVT(Ctx);
220 SplitArgs.
back().Flags.setInConsecutiveRegs();
223 SplitArgs.
back().Flags.setInConsecutiveRegsLast();
225 for (
unsigned i = 0; i < Offsets.
size(); ++i)
226 PerformArgSplit(SplitArgs[FirstRegIdx + i].
Reg, Offsets[i] * 8);
234 "Return value without a vreg");
237 if (!VRegs.
empty()) {
250 "For each split Type there should be exactly one VReg.");
253 for (
unsigned i = 0; i < SplitEVTs.
size(); ++i) {
255 unsigned CurVReg = VRegs[i];
262 ArgInfo CurArgInfo =
ArgInfo{CurVReg, SplitEVTs[i].getTypeForEVT(Ctx)};
264 splitToValueTypes(CurArgInfo, SplitArgs, DL, MRI, F.
getCallingConv(),
270 OutgoingArgHandler Handler(MIRBuilder, MRI, MIB, AssignFn, AssignFn);
295 unsigned Dst = VRegs[i];
297 splitToValueTypes(OrigArg, SplitArgs, DL, MRI, F.
getCallingConv(),
321 FormalArgHandler Handler(MIRBuilder, MRI, AssignFn);
333 uint64_t StackOffset =
alignTo(Handler.StackUsed, 8);
341 if (Subtarget.hasCustomCallingConv())
361 for (
auto &OrigArg : OrigArgs) {
362 splitToValueTypes(OrigArg, SplitArgs, DL, MRI, CallConv,
371 TLI.CCAssignFnForCall(CallConv,
false);
373 TLI.CCAssignFnForCall(CallConv,
true);
375 auto CallSeqStart = MIRBuilder.
buildInstr(AArch64::ADJCALLSTACKDOWN);
387 TRI->UpdateCustomCallPreservedMask(MF, &Mask);
388 MIB.addRegMask(Mask);
390 if (
TRI->isAnyArgRegReserved(MF))
391 TRI->emitReservedArgRegCallError(MF);
395 OutgoingArgHandler Handler(MIRBuilder, MRI, MIB, AssignFnFixed,
420 splitToValueTypes(OrigRet, SplitArgs, DL, MRI, F.
getCallingConv(),
426 CallReturnHandler Handler(MIRBuilder, MRI, MIB, RetAssignFn);
430 if (!RegOffsets.
empty())
434 CallSeqStart.addImm(Handler.StackSize).addImm(0);
435 MIRBuilder.
buildInstr(AArch64::ADJCALLSTACKUP)
436 .
addImm(Handler.StackSize)
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res = G_GEP Op0, Op1.
This class represents lattice values for constants.
bool hasCustomCallingConv() const
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
void setVarArgsStackIndex(int Index)
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...
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
unsigned const TargetRegisterInfo * TRI
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
MachineInstrBuilder buildExtract(unsigned Res, unsigned Src, uint64_t Index)
Build and insert `Res0, ...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
bool handleAssignments(MachineIRBuilder &MIRBuilder, ArrayRef< ArgInfo > Args, ValueHandler &Handler) const
Invoke Handler::assignArg on each of the given Args and then use Callback to move them to the assigne...
MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ANYEXT Op0.
bool isTargetDarwin() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This file contains the simple types necessary to represent the attributes associated with functions a...
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< unsigned > VRegs) const override
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
LocInfo getLocInfo() const
unsigned getSizeInBits() const
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
Type * getType() const
All values are typed, get the type of this value.
const AArch64RegisterInfo * getRegisterInfo() const override
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
virtual const TargetInstrInfo * getInstrInfo() const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
bool functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override
For some targets, an LLVM struct type must be broken down into multiple simple types, but the calling convention specifies that the entire struct must be passed in a block of consecutive registers.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Analysis containing CSE Info
bool isVoidTy() const
Return true if this is 'void'.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder buildZExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ZEXT Op.
size_t size() const
size - Get the array size.
Helper class to build MachineInstr.
CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC) const
Selects the correct CCAssignFn for a given CallingConvention value.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src, unsigned Op, unsigned Index)
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC Op.
Argument handling is mostly uniform between the four places that make these decisions: function forma...
This class contains a discriminated union of information about pointers in memory operands...
MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
The memory access writes data.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
CCState - This class holds information needed while lowering arguments and return values...
void buildSequence(unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
Build and insert instructions to put Ops together at the specified p Indices to form a larger registe...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
CCValAssign - Represent assignment of one arg/retval to a location.
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< unsigned > VRegs) const override
This hook must be implemented to lower the incoming (formal) arguments, described by Args...
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
This file declares the MachineIRBuilder class.
amdgpu Simplify well known AMD library false Value Value * Arg
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const
Selects the correct CCAssignFn for a given CallingConvention value.
void UpdateCustomCalleeSavedRegs(MachineFunction &MF) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
void emplace_back(ArgTypes &&... Args)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
The memory access always returns the same value (or traps).
This file describes how to lower LLVM calls to machine code calls.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
AArch64CallLowering(const AArch64TargetLowering &TLI)
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const MCInstrDesc &II, const MachineOperand &RegMO, unsigned OpIdx)
Try to constrain Reg so that it is usable by argument OpIdx of the provided MCInstrDesc II...
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineInstrBuilder buildUndef(const DstOp &Res)
Build and insert Res = IMPLICIT_DEF.
static void Split(std::vector< std::string > &V, StringRef S)
Splits a string of comma separated items in to a vector of strings.
const MachineOperand & getOperand(unsigned i) const
iterator_range< arg_iterator > args()
bool empty() const
empty - Check if the array is empty.