34 unsigned StackAddr = getStackAddress(Size, Offset, MPO);
35 assignValueToAddress(vreg, StackAddr, Size, MPO);
52 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg)
override;
54 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
57 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t Size,
60 virtual void markPhysRegUsed(
unsigned PhysReg) {
64 void buildLoad(
unsigned Val,
unsigned Addr, uint64_t Size,
unsigned Alignment,
72 class CallReturnHandler :
public IncomingValueHandler {
76 : IncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
79 void markPhysRegUsed(
unsigned PhysReg)
override {
88 void IncomingValueHandler::assignValueToReg(
unsigned ValVReg,
90 MIRBuilder.buildCopy(ValVReg, PhysReg);
91 markPhysRegUsed(PhysReg);
94 unsigned IncomingValueHandler::getStackAddress(uint64_t
Size, int64_t
Offset,
101 unsigned AddrReg =
MRI.createGenericVirtualRegister(
LLT::pointer(0, 32));
102 MIRBuilder.buildFrameIndex(AddrReg, FI);
107 void IncomingValueHandler::assignValueToAddress(
unsigned ValVReg,
unsigned Addr,
111 buildLoad(ValVReg, Addr,
Size, 0, MPO);
116 for (
unsigned i = 0, ArgsSize = Args.
size(); i < ArgsSize; ++i) {
117 if (!assign(ArgLocs[i], Args[i].
Reg))
134 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg)
override;
136 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
139 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t Size,
146 void OutgoingValueHandler::assignValueToReg(
unsigned ValVReg,
148 MIRBuilder.buildCopy(PhysReg, ValVReg);
152 unsigned OutgoingValueHandler::getStackAddress(uint64_t
Size, int64_t
Offset,
156 unsigned SPReg =
MRI.createGenericVirtualRegister(p0);
157 MIRBuilder.buildCopy(SPReg, Mips::SP);
159 unsigned OffsetReg =
MRI.createGenericVirtualRegister(s32);
160 MIRBuilder.buildConstant(OffsetReg,
Offset);
162 unsigned AddrReg =
MRI.createGenericVirtualRegister(p0);
163 MIRBuilder.buildGEP(AddrReg, SPReg, OffsetReg);
169 void OutgoingValueHandler::assignValueToAddress(
unsigned ValVReg,
unsigned Addr,
174 MIRBuilder.buildStore(ValVReg, Addr, *MMO);
179 for (
unsigned i = 0; i < Args.
size(); ++i) {
180 if (!assign(ArgLocs[i], Args[i].
Reg))
195 const Value *Val,
unsigned VReg)
const {
199 if (Val !=
nullptr) {
213 splitToValueTypes(ArgRetInfo, 0, RetInfos, OrigArgIndices);
216 subTargetRegTypeForCallingConv(
217 MIRBuilder, RetInfos, OrigArgIndices,
219 unsigned origIdx,
unsigned partOffs) {
220 Outs.
emplace_back(flags, vt, argvt, used, origIdx, partOffs);
228 OutgoingValueHandler RetHandler(MIRBuilder, MF.
getRegInfo(),
Ret);
229 if (!RetHandler.handle(ArgLocs, RetInfos)) {
264 splitToValueTypes(AInfo, i, ArgInfos, OrigArgIndices);
269 subTargetRegTypeForCallingConv(
270 MIRBuilder, ArgInfos, OrigArgIndices,
273 Ins.
emplace_back(flags, vt, argvt, used, origIdx, partOffs);
287 IncomingValueHandler Handler(MIRBuilder, MF.
getRegInfo());
288 if (!Handler.handle(ArgLocs, ArgInfos))
303 for (
auto &
Arg : OrigArgs) {
306 if (
Arg.Flags.isByVal() ||
Arg.Flags.isSRet())
320 MIRBuilder.
buildInstr(Mips::ADJCALLSTACKDOWN);
334 FuncOrigArgs.reserve(OrigArgs.size());
339 for (
auto &
Arg : OrigArgs) {
343 FuncOrigArgs.push_back(Entry);
345 splitToValueTypes(
Arg, i, ArgInfos, OrigArgIndices);
350 subTargetRegTypeForCallingConv(
351 MIRBuilder, ArgInfos, OrigArgIndices,
354 Outs.
emplace_back(flags, vt, argvt, used, origIdx, partOffs);
365 OutgoingValueHandler RetHandler(MIRBuilder, MF.
getRegInfo(), MIB);
366 if (!RetHandler.handle(ArgLocs, ArgInfos)) {
370 unsigned NextStackOffset = CCInfo.getNextStackOffset();
373 NextStackOffset =
alignTo(NextStackOffset, StackAlignment);
383 splitToValueTypes(OrigRet, 0, ArgInfos, OrigRetIndices);
386 subTargetRegTypeForCallingConv(
387 MIRBuilder, ArgInfos, OrigRetIndices,
389 unsigned origIdx,
unsigned partOffs) {
390 Ins.
emplace_back(flags, vt, argvt, used, origIdx, partOffs);
399 CallReturnHandler Handler(MIRBuilder, MF.
getRegInfo(), MIB);
400 if (!Handler.handle(ArgLocs, ArgInfos))
409 void MipsCallLowering::subTargetRegTypeForCallingConv(
418 for (
auto &
Arg : Args) {
427 PushBack(Flags, RegisterVT, VT,
true, OrigArgIndices[ArgNo], 0);
433 void MipsCallLowering::splitToValueTypes(
434 const ArgInfo &OrigArg,
unsigned OriginalIndex,
441 SplitArgsOrigIndices.
push_back(OriginalIndex);
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void push_back(const T &Elt)
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
C - The default llvm calling convention, compatible with C.
Compute iterated dominance frontiers using a linear time algorithm.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static const MCPhysReg VRegs[32]
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...
A description of a memory reference used in the backend.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
CCAssignFn * CCAssignFnForCall() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isIntegerTy() const
True if this is an instance of IntegerType.
unsigned GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const
Obtain the size of the area allocated by the callee for arguments.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Return the register type for a given MVT, ensuring vectors are treated as a series of gpr sized integ...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
const char * getSymbolName() const
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.
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
unsigned getSizeInBits() const
Type * getType() const
All values are typed, get the type of this value.
unsigned getABIAlignmentForCallingConv(Type *ArgTy, DataLayout DL) const override
Return the correct alignment for the current calling convention.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn, const Type *RetTy, const char *Func)
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MipsCallLowering(const MipsTargetLowering &TLI)
void setOrigAlign(unsigned A)
amdgpu Simplify well known AMD library false Value * Callee
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function...
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...
size_t size() const
size - Get the array size.
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...
bool isPointerTy() const
True if this is an instance of PointerType.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
std::vector< ArgListEntry > ArgListTy
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class contains a discriminated union of information about pointers in memory operands...
bool assign(const CCValAssign &VA, unsigned vreg)
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
The memory access writes data.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
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.
Information about stack frame layout on the target.
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.
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
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.
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
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.
unsigned getLocMemOffset() const
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
virtual const TargetFrameLowering * getFrameLowering() const
MachineFunction & getMF()
Getter for the function we currently build.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
This file describes how to lower LLVM calls to machine code calls.
bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val, unsigned VReg) const override
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static bool isSupportedType(Type *T)
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).
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...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
CCAssignFn * CCAssignFnForReturn() const
MachineInstrBuilder buildInstr(unsigned Opc, DstTy &&Ty, UseArgsTy &&... Args)
DAG like Generic method for building arbitrary instructions as above.
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
unsigned getLocReg() const
unsigned AllocateStack(unsigned Size, unsigned Align)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
iterator_range< arg_iterator > args()