14 #ifndef LLVM_CODEGEN_CALLINGCONVLOWER_H 15 #define LLVM_CODEGEN_CALLINGCONVLOWER_H 30 class TargetRegisterInfo;
67 unsigned isCustom : 1;
80 unsigned RegNo,
MVT LocVT,
94 unsigned RegNo,
MVT LocVT,
97 Ret =
getReg(ValNo, ValVT, RegNo, LocVT, HTP);
109 Ret.isCustom =
false;
120 Ret =
getMem(ValNo, ValVT, Offset, LocVT, HTP);
128 LocInfo HTP,
unsigned ExtraInfo = 0) {
129 return getReg(ValNo, ValVT, ExtraInfo, LocVT, HTP);
169 : VReg(VReg), PReg(PReg), VT(VT) {}
195 bool AnalyzingMustTailForwardedRegs =
false;
202 Align MaxStackArgAlign;
237 ByValInfo(
unsigned B,
unsigned E,
bool IsWaste =
false) :
238 Begin(B), End(E), Waste(IsWaste) {}
255 unsigned InRegsParamsProcessed;
280 return alignTo(StackOffset, MaxStackArgAlign);
286 return UsedRegs[Reg/32] & (1 << (Reg&31));
297 AnalyzeFormalArguments(Ins, Fn);
325 AnalyzeCallOperands(Outs, Fn);
336 bool IsShadowAllocatedReg(
unsigned Reg)
const;
345 for (
unsigned i = 0; i < Regs.
size(); ++i)
346 if (!isAllocated(Regs[i]))
355 if (isAllocated(Reg))
return 0;
362 if (isAllocated(Reg))
return 0;
364 MarkAllocated(ShadowReg);
372 unsigned FirstUnalloc = getFirstUnallocated(Regs);
373 if (FirstUnalloc == Regs.
size())
377 unsigned Reg = Regs[FirstUnalloc];
386 if (RegsRequired > Regs.
size())
389 for (
unsigned StartIdx = 0; StartIdx <= Regs.
size() - RegsRequired;
391 bool BlockAvailable =
true;
393 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
394 if (isAllocated(Regs[StartIdx + BlockIdx])) {
395 BlockAvailable =
false;
399 if (BlockAvailable) {
401 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
402 MarkAllocated(Regs[StartIdx + BlockIdx]);
404 return Regs[StartIdx];
413 unsigned FirstUnalloc = getFirstUnallocated(Regs);
414 if (FirstUnalloc == Regs.
size())
418 unsigned Reg = Regs[FirstUnalloc], ShadowReg = ShadowRegs[FirstUnalloc];
420 MarkAllocated(ShadowReg);
427 const Align CheckedAlignment(Alignment);
428 StackOffset =
alignTo(StackOffset, CheckedAlignment);
429 unsigned Result = StackOffset;
431 MaxStackArgAlign =
std::max(CheckedAlignment, MaxStackArgAlign);
432 ensureMaxAlignment(CheckedAlignment);
437 if (!AnalyzingMustTailForwardedRegs)
443 MarkAllocated(ShadowReg);
444 return AllocateStack(Size, Align);
451 for (
unsigned i = 0; i < ShadowRegs.
size(); ++i)
452 MarkAllocated(ShadowRegs[i]);
453 return AllocateStack(Size, Align);
459 void HandleByVal(
unsigned ValNo,
MVT ValVT,
473 unsigned& BeginReg,
unsigned& EndReg)
const {
474 assert(InRegsParamRecordIndex < ByValRegs.
size() &&
475 "Wrong ByVal parameter index");
477 const ByValInfo&
info = ByValRegs[InRegsParamRecordIndex];
478 BeginReg = info.Begin;
484 ByValRegs.
push_back(ByValInfo(RegBegin, RegEnd));
491 unsigned e = ByValRegs.
size();
492 if (InRegsParamsProcessed < e)
493 ++InRegsParamsProcessed;
494 return InRegsParamsProcessed <
e;
499 InRegsParamsProcessed = 0;
505 InRegsParamsProcessed = 0;
515 return PendingArgFlags;
527 void analyzeMustTailForwardedRegisters(
545 unsigned NumFirstPassLocs = Locs.
size();
551 for (
auto Arg : Args) {
552 Arg.Flags.setSecArgPass();
561 TmpArgLocs.
swap(Locs);
562 auto B = TmpArgLocs.
begin(),
E = TmpArgLocs.
end();
563 std::merge(
B,
B + NumFirstPassLocs,
B + NumFirstPassLocs,
E,
564 std::back_inserter(Locs),
572 void MarkAllocated(
unsigned Reg);
577 #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.
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)
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
This class represents lattice values for constants.
Register getLocReg() const
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...
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
unsigned getValNo() const
unsigned const TargetRegisterInfo * TRI
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.
void ensureMaxAlignment(Align Alignment)
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)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags()
uint64_t value() const
This is a hole in the type system and should not be abused.
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.
void swap(SmallVectorImpl &RHS)
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")
LLVMContext & getContext() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
unsigned getInRegsParamsProcessed() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
Align max(MaybeAlign Lhs, Align Rhs)
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
unsigned AllocateStack(unsigned Size, unsigned Align, unsigned ShadowReg)
Version of AllocateStack with extra register to be shadowed.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned AllocateStack(unsigned Size, unsigned Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
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 AllocateReg(unsigned Reg)
AllocateReg - Attempt to allocate one register.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void convertToReg(unsigned RegNo)
Wrapper class representing virtual and physical registers.