14#ifndef LLVM_CODEGEN_CALLINGCONVLOWER_H
15#define LLVM_CODEGEN_CALLINGCONVLOWER_H
28class TargetRegisterInfo;
60 std::variant<Register, int64_t, unsigned> Data;
66 unsigned isCustom : 1;
78 : ValNo(ValNo), isCustom(IsCustom), HTP(HTP), ValVT(ValVT), LocVT(LocVT) {
83 MVT LocVT,
LocInfo HTP,
bool IsCustom =
false) {
84 CCValAssign Ret(HTP, ValNo, ValVT, LocVT, IsCustom);
91 return getReg(ValNo, ValVT, RegNo, LocVT, HTP,
true);
95 MVT LocVT,
LocInfo HTP,
bool IsCustom =
false) {
96 CCValAssign Ret(HTP, ValNo, ValVT, LocVT, IsCustom);
107 LocInfo HTP,
unsigned ExtraInfo = 0) {
109 Ret.Data = ExtraInfo;
120 bool isRegLoc()
const {
return std::holds_alternative<Register>(
Data); }
121 bool isMemLoc()
const {
return std::holds_alternative<int64_t>(
Data); }
172 bool AnalyzingMustTailForwardedRegs =
false;
178 bool NegativeOffsets;
181 Align MaxStackArgAlign;
214 ByValInfo(
unsigned B,
unsigned E) : Begin(
B),
End(
E) {}
226 unsigned InRegsParamsProcessed;
231 bool NegativeOffsets =
false);
249 return alignTo(StackSize, MaxStackArgAlign);
255 return UsedRegs[
Reg / 32] & (1 << (
Reg & 31));
314 for (
unsigned i = 0; i < Regs.
size(); ++i)
322 MarkUnallocated(
Reg);
340 MarkAllocated(ShadowReg);
349 if (FirstUnalloc == Regs.
size())
362 if (RegsRequired > Regs.
size())
365 for (
unsigned StartIdx = 0; StartIdx <= Regs.
size() - RegsRequired;
367 bool BlockAvailable =
true;
369 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
371 BlockAvailable =
false;
375 if (BlockAvailable) {
377 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
378 MarkAllocated(Regs[StartIdx + BlockIdx]);
380 return Regs[StartIdx];
390 if (FirstUnalloc == Regs.
size())
394 MCRegister Reg = Regs[FirstUnalloc], ShadowReg = ShadowRegs[FirstUnalloc];
396 MarkAllocated(ShadowReg);
404 if (NegativeOffsets) {
411 MaxStackArgAlign = std::max(Alignment, MaxStackArgAlign);
444 unsigned& BeginReg,
unsigned& EndReg)
const {
445 assert(InRegsParamRecordIndex < ByValRegs.
size() &&
446 "Wrong ByVal parameter index");
448 const ByValInfo&
info = ByValRegs[InRegsParamRecordIndex];
449 BeginReg =
info.Begin;
455 ByValRegs.
push_back(ByValInfo(RegBegin, RegEnd));
462 unsigned e = ByValRegs.
size();
463 if (InRegsParamsProcessed < e)
464 ++InRegsParamsProcessed;
465 return InRegsParamsProcessed < e;
470 InRegsParamsProcessed = 0;
476 InRegsParamsProcessed = 0;
486 return PendingArgFlags;
516 unsigned NumFirstPassLocs = Locs.
size();
522 for (
auto Arg : Args) {
523 Arg.Flags.setSecArgPass();
532 TmpArgLocs.
swap(Locs);
533 auto B = TmpArgLocs.
begin(),
E = TmpArgLocs.
end();
534 std::merge(
B,
B + NumFirstPassLocs,
B + NumFirstPassLocs,
E,
535 std::back_inserter(Locs),
537 return A.getValNo() <
B.getValNo();
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
CCState - This class holds information needed while lowering arguments and return values.
void getInRegsParamInfo(unsigned InRegsParamRecordIndex, unsigned &BeginReg, unsigned &EndReg) const
void HandleByVal(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, int MinSize, Align MinAlign, ISD::ArgFlagsTy ArgFlags)
Allocate space on the stack large enough to pass an argument by value.
MachineFunction & getMachineFunction() const
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
void AnalyzeArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
The function will invoke AnalyzeFormalArguments.
void analyzeMustTailForwardedRegisters(SmallVectorImpl< ForwardedRegister > &Forwards, ArrayRef< MVT > RegParmTypes, CCAssignFn Fn)
Compute the set of registers that need to be preserved and forwarded to any musttail calls.
int64_t AllocateStack(unsigned Size, Align Alignment, ArrayRef< MCPhysReg > ShadowRegs)
Version of AllocateStack with list of extra registers to be shadowed.
void AnalyzeArgumentsSecondPass(const SmallVectorImpl< T > &Args, CCAssignFn Fn)
The function runs an additional analysis pass over function arguments.
static bool resultsCompatible(CallingConv::ID CalleeCC, CallingConv::ID CallerCC, MachineFunction &MF, LLVMContext &C, const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn CalleeFn, CCAssignFn CallerFn)
Returns true if the results of the two calling conventions are compatible.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
bool IsShadowAllocatedReg(MCRegister Reg) const
A shadow allocated register is a register that was allocated but wasn't added to the location list (L...
void AnalyzeArguments(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
The function will invoke AnalyzeCallOperands.
CallingConv::ID getCallingConv() const
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags()
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
MCPhysReg AllocateRegBlock(ArrayRef< MCPhysReg > Regs, unsigned RegsRequired)
AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive registers.
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
LLVMContext & getContext() const
int64_t AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
void rewindByValRegsInfo()
void getRemainingRegParmsForType(SmallVectorImpl< MCPhysReg > &Regs, MVT VT, CCAssignFn Fn)
Compute the remaining unused register parameters that would be used for the given value type.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
unsigned getInRegsParamsProcessed() const
void ensureMaxAlignment(Align Alignment)
void DeallocateReg(MCPhysReg Reg)
MCPhysReg AllocateReg(ArrayRef< MCPhysReg > Regs)
AllocateReg - Attempt to allocate one of the specified registers.
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
MCRegister AllocateReg(ArrayRef< MCPhysReg > Regs, const MCPhysReg *ShadowRegs)
Version of AllocateReg with list of registers to be shadowed.
SmallVectorImpl< CCValAssign > & getPendingLocs()
uint64_t getAlignedCallFrameSize() const
getAlignedCallFrameSize - Return the size of the call frame needed to be able to store all arguments ...
bool isAllocated(MCRegister Reg) const
isAllocated - Return true if the specified register (or an alias) is allocated.
void addInRegsParamInfo(unsigned RegBegin, unsigned RegEnd)
MCRegister AllocateReg(MCPhysReg Reg, MCPhysReg ShadowReg)
Version of AllocateReg with extra register to be shadowed.
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
void addLoc(const CCValAssign &V)
unsigned getInRegsParamsCount() const
void clearByValRegsInfo()
CCValAssign - Represent assignment of one arg/retval to a location.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
Register getLocReg() const
bool isPendingLoc() const
LocInfo getLocInfo() const
bool isUpperBitsInLoc() const
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
void convertToReg(unsigned RegNo)
unsigned getExtraInfo() const
int64_t getLocMemOffset() const
unsigned getValNo() const
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
void convertToMem(int64_t Offset)
This is an important class for using LLVM in a threaded context.
Wrapper class representing physical registers. Should be passed by value.
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void swap(SmallVectorImpl &RHS)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool CCCustomFn(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
CCCustomFn - This function assigns a location for Val, possibly updating all args to reflect changes ...
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Describes a register that needs to be forwarded from the prologue to a musttail call.
ForwardedRegister(Register VReg, MCPhysReg PReg, MVT VT)