15 #ifndef LLVM_CODEGEN_CALLINGCONVLOWER_H 16 #define LLVM_CODEGEN_CALLINGCONVLOWER_H 30 class TargetRegisterInfo;
66 unsigned isCustom : 1;
79 unsigned RegNo,
MVT LocVT,
93 unsigned RegNo,
MVT LocVT,
96 Ret =
getReg(ValNo, ValVT, RegNo, LocVT, HTP);
108 Ret.isCustom =
false;
119 Ret =
getMem(ValNo, ValVT, Offset, LocVT, HTP);
127 LocInfo HTP,
unsigned ExtraInfo = 0) {
128 return getReg(ValNo, ValVT, ExtraInfo, LocVT, HTP);
168 : VReg(VReg), PReg(PReg), VT(VT) {}
194 bool AnalyzingMustTailForwardedRegs =
false;
200 unsigned StackOffset;
201 unsigned MaxStackArgAlign;
236 ByValInfo(
unsigned B,
unsigned E,
bool IsWaste =
false) :
237 Begin(B), End(E), Waste(IsWaste) {}
254 unsigned InRegsParamsProcessed;
279 return alignTo(StackOffset, MaxStackArgAlign);
285 return UsedRegs[Reg/32] & (1 << (Reg&31));
296 AnalyzeFormalArguments(Ins, Fn);
324 AnalyzeCallOperands(Outs, Fn);
335 bool IsShadowAllocatedReg(
unsigned Reg)
const;
344 for (
unsigned i = 0; i < Regs.
size(); ++i)
345 if (!isAllocated(Regs[i]))
354 if (isAllocated(Reg))
return 0;
361 if (isAllocated(Reg))
return 0;
363 MarkAllocated(ShadowReg);
371 unsigned FirstUnalloc = getFirstUnallocated(Regs);
372 if (FirstUnalloc == Regs.
size())
376 unsigned Reg = Regs[FirstUnalloc];
385 if (RegsRequired > Regs.
size())
388 for (
unsigned StartIdx = 0; StartIdx <= Regs.
size() - RegsRequired;
390 bool BlockAvailable =
true;
392 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
393 if (isAllocated(Regs[StartIdx + BlockIdx])) {
394 BlockAvailable =
false;
398 if (BlockAvailable) {
400 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
401 MarkAllocated(Regs[StartIdx + BlockIdx]);
403 return Regs[StartIdx];
412 unsigned FirstUnalloc = getFirstUnallocated(Regs);
413 if (FirstUnalloc == Regs.
size())
417 unsigned Reg = Regs[FirstUnalloc], ShadowReg = ShadowRegs[FirstUnalloc];
419 MarkAllocated(ShadowReg);
426 assert(Align && ((Align - 1) & Align) == 0);
427 StackOffset =
alignTo(StackOffset, Align);
428 unsigned Result = StackOffset;
430 MaxStackArgAlign =
std::max(Align, MaxStackArgAlign);
431 ensureMaxAlignment(Align);
436 if (!AnalyzingMustTailForwardedRegs)
442 MarkAllocated(ShadowReg);
443 return AllocateStack(Size, Align);
450 for (
unsigned i = 0; i < ShadowRegs.
size(); ++i)
451 MarkAllocated(ShadowRegs[i]);
452 return AllocateStack(Size, Align);
458 void HandleByVal(
unsigned ValNo,
MVT ValVT,
472 unsigned& BeginReg,
unsigned& EndReg)
const {
473 assert(InRegsParamRecordIndex < ByValRegs.
size() &&
474 "Wrong ByVal parameter index");
476 const ByValInfo&
info = ByValRegs[InRegsParamRecordIndex];
477 BeginReg = info.Begin;
483 ByValRegs.
push_back(ByValInfo(RegBegin, RegEnd));
490 unsigned e = ByValRegs.
size();
491 if (InRegsParamsProcessed < e)
492 ++InRegsParamsProcessed;
493 return InRegsParamsProcessed < e;
498 InRegsParamsProcessed = 0;
504 InRegsParamsProcessed = 0;
514 return PendingArgFlags;
526 void analyzeMustTailForwardedRegisters(
544 unsigned NumFirstPassLocs = Locs.
size();
550 for (
auto Arg : Args) {
551 Arg.Flags.setSecArgPass();
561 auto B = TmpArgLocs.
begin(),
E = TmpArgLocs.
end();
562 std::merge(
B,
B + NumFirstPassLocs,
B + NumFirstPassLocs,
E,
563 std::back_inserter(Locs),
571 void MarkAllocated(
unsigned Reg);
576 #endif // LLVM_CODEGEN_CALLINGCONVLOWER_H
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set, or Regs.size() if they are all allocated.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
unsigned getExtraInfo() const
Describes a register that needs to be forwarded from the prologue to a musttail call.
bool isAllocated(unsigned Reg) const
isAllocated - Return true if the specified register (or an alias) is allocated.
void push_back(const T &Elt)
void AnalyzeArgumentsSecondPass(const SmallVectorImpl< T > &Args, CCAssignFn Fn)
The function runs an additional analysis pass over function arguments.
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...
unsigned getValNo() const
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...
MachineFunction & getMachineFunction() const
bool isUpperBitsInLoc() const
void convertToMem(unsigned Offset)
unsigned AllocateReg(unsigned Reg, unsigned ShadowReg)
Version of AllocateReg with extra register to be shadowed.
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 ...
unsigned AllocateReg(ArrayRef< MCPhysReg > Regs)
AllocateReg - Attempt to allocate one of the specified registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void addLoc(const CCValAssign &V)
LocInfo getLocInfo() const
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
SmallVectorImpl< CCValAssign > & getPendingLocs()
void addInRegsParamInfo(unsigned RegBegin, unsigned RegEnd)
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags()
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned AllocateReg(ArrayRef< MCPhysReg > Regs, const MCPhysReg *ShadowRegs)
Version of AllocateReg with list of registers to be shadowed.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
ForwardedRegister(unsigned VReg, MCPhysReg PReg, MVT VT)
This is an important class for using LLVM in a threaded context.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
LLVMContext & getContext() const
unsigned getInRegsParamsProcessed() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
CCState - This class holds information needed while lowering arguments and return values...
void AnalyzeArguments(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
The function will invoke AnalyzeCallOperands.
unsigned AllocateRegBlock(ArrayRef< MCPhysReg > Regs, unsigned RegsRequired)
AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive registers.
CCValAssign - Represent assignment of one arg/retval to a location.
CallingConv::ID getCallingConv() const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned AllocateStack(unsigned Size, unsigned Align, unsigned ShadowReg)
Version of AllocateStack with extra register to be shadowed.
amdgpu Simplify well known AMD library false Value Value * Arg
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
unsigned getLocMemOffset() const
unsigned AllocateStack(unsigned Size, unsigned Align, ArrayRef< MCPhysReg > ShadowRegs)
Version of AllocateStack with list of extra registers to be shadowed.
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
static void AnalyzeArguments(CCState &State, SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< ArgT > &Args)
Analyze incoming and outgoing function arguments.
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
void AnalyzeArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
The function will invoke AnalyzeFormalArguments.
unsigned getInRegsParamsCount() const
unsigned getAlignedCallFrameSize() const
getAlignedCallFrameSize - Return the size of the call frame needed to be able to store all arguments ...
void clearByValRegsInfo()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void getInRegsParamInfo(unsigned InRegsParamRecordIndex, unsigned &BeginReg, unsigned &EndReg) const
void rewindByValRegsInfo()
unsigned getLocReg() const
unsigned AllocateReg(unsigned Reg)
AllocateReg - Attempt to allocate one register.
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.
void convertToReg(unsigned RegNo)
void ensureMaxAlignment(unsigned Align)