Go to the documentation of this file.
14 #ifndef LLVM_CODEGEN_CALLINGCONVLOWER_H
15 #define LLVM_CODEGEN_CALLINGCONVLOWER_H
26 class MachineFunction;
28 class TargetRegisterInfo;
65 unsigned isCustom : 1;
78 unsigned RegNo,
MVT LocVT,
92 unsigned RegNo,
MVT LocVT,
95 Ret =
getReg(ValNo, ValVT, RegNo, LocVT, HTP);
101 unsigned Offset,
MVT LocVT,
107 Ret.isCustom =
false;
115 unsigned Offset,
MVT LocVT,
118 Ret =
getMem(ValNo, ValVT, Offset, LocVT, HTP);
126 LocInfo HTP,
unsigned ExtraInfo = 0) {
127 return getReg(ValNo, ValVT, ExtraInfo, LocVT, HTP);
193 bool AnalyzingMustTailForwardedRegs =
false;
200 Align MaxStackArgAlign;
233 ByValInfo(
unsigned B,
unsigned E) : Begin(
B), End(
E) {}
245 unsigned InRegsParamsProcessed;
276 return UsedRegs[
Reg / 32] & (1 << (
Reg & 31));
335 for (
unsigned i = 0;
i < Regs.
size(); ++
i)
343 MarkUnallocated(
Reg);
361 MarkAllocated(ShadowReg);
370 if (FirstUnalloc == Regs.
size())
383 if (RegsRequired > Regs.
size())
386 for (
unsigned StartIdx = 0; StartIdx <= Regs.
size() - RegsRequired;
388 bool BlockAvailable =
true;
390 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
392 BlockAvailable =
false;
396 if (BlockAvailable) {
398 for (
unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
399 MarkAllocated(Regs[StartIdx + BlockIdx]);
401 return Regs[StartIdx];
411 if (FirstUnalloc == Regs.
size())
415 MCRegister Reg = Regs[FirstUnalloc], ShadowReg = ShadowRegs[FirstUnalloc];
417 MarkAllocated(ShadowReg);
427 MaxStackArgAlign =
std::max(Alignment, MaxStackArgAlign);
438 for (
unsigned i = 0;
i < ShadowRegs.
size(); ++
i)
439 MarkAllocated(ShadowRegs[
i]);
460 unsigned& BeginReg,
unsigned& EndReg)
const {
461 assert(InRegsParamRecordIndex < ByValRegs.size() &&
462 "Wrong ByVal parameter index");
464 const ByValInfo&
info = ByValRegs[InRegsParamRecordIndex];
465 BeginReg =
info.Begin;
471 ByValRegs.push_back(ByValInfo(RegBegin, RegEnd));
478 unsigned e = ByValRegs.size();
479 if (InRegsParamsProcessed <
e)
480 ++InRegsParamsProcessed;
481 return InRegsParamsProcessed <
e;
486 InRegsParamsProcessed = 0;
492 InRegsParamsProcessed = 0;
502 return PendingArgFlags;
532 unsigned NumFirstPassLocs = Locs.size();
539 Arg.Flags.setSecArgPass();
540 SecPassArg.push_back(
Arg);
548 TmpArgLocs.
swap(Locs);
549 auto B = TmpArgLocs.begin(),
E = TmpArgLocs.end();
551 std::back_inserter(Locs),
553 return A.getValNo() <
B.getValNo();
566 #endif // LLVM_CODEGEN_CALLINGCONVLOWER_H
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
This is an optimization pass for GlobalISel generic memory operations.
ForwardedRegister(Register VReg, MCPhysReg PReg, MVT VT)
bool isUpperBitsInLoc() const
unsigned getExtraInfo() const
CCState - This class holds information needed while lowering arguments and return values.
void addLoc(const CCValAssign &V)
Reg
All possible values of the reg field in the ModR/M byte.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
MachineFunction & getMachineFunction() const
void AnalyzeArgumentsSecondPass(const SmallVectorImpl< T > &Args, CCAssignFn Fn)
The function runs an additional analysis pass over function arguments.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
MCPhysReg AllocateRegBlock(ArrayRef< MCPhysReg > Regs, unsigned RegsRequired)
AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive registers.
MCRegister AllocateReg(ArrayRef< MCPhysReg > Regs, const MCPhysReg *ShadowRegs)
Version of AllocateReg with list of registers to be shadowed.
void clearByValRegsInfo()
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
void addInRegsParamInfo(unsigned RegBegin, unsigned RegEnd)
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.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
CCValAssign - Represent assignment of one arg/retval to a location.
bool IsShadowAllocatedReg(MCRegister Reg) const
A shadow allocated register is a register that was allocated but wasn't added to the location list (L...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Register getLocReg() const
(vector float) vec_cmpeq(*A, *B) C
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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 ...
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
LLVMContext & getContext() const
LocInfo getLocInfo() const
unsigned getLocMemOffset() const
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void ensureMaxAlignment(Align Alignment)
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.
MCPhysReg AllocateReg(ArrayRef< MCPhysReg > Regs)
AllocateReg - Attempt to allocate one of the specified registers.
unsigned getAlignedCallFrameSize() const
getAlignedCallFrameSize - Return the size of the call frame needed to be able to store all arguments ...
void getInRegsParamInfo(unsigned InRegsParamRecordIndex, unsigned &BeginReg, unsigned &EndReg) const
void AnalyzeArguments(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
The function will invoke AnalyzeCallOperands.
Describes a register that needs to be forwarded from the prologue to a musttail call.
CCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &locs, LLVMContext &C)
This is an important class for using LLVM in a threaded context.
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
void convertToReg(unsigned RegNo)
CallingConv::ID getCallingConv() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getInRegsParamsCount() const
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
unsigned AllocateStack(unsigned Size, Align Alignment, ArrayRef< MCPhysReg > ShadowRegs)
Version of AllocateStack with list of extra registers to be shadowed.
SmallVectorImpl< CCValAssign > & getPendingLocs()
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.
unsigned getValNo() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
MCRegister AllocateReg(MCPhysReg Reg, MCPhysReg ShadowReg)
Version of AllocateReg with extra register to be shadowed.
void convertToMem(unsigned Offset)
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
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 ...
void rewindByValRegsInfo()
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags()
Wrapper class representing virtual and physical registers.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
void swap(SmallVectorImpl &RHS)
void DeallocateReg(MCPhysReg Reg)
unsigned AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
void getRemainingRegParmsForType(SmallVectorImpl< MCPhysReg > &Regs, MVT VT, CCAssignFn Fn)
Compute the remaining unused register parameters that would be used for the given value type.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
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.
void AnalyzeArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
The function will invoke AnalyzeFormalArguments.
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
size_t size() const
size - Get the array size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned getInRegsParamsProcessed() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool isAllocated(MCRegister Reg) const
isAllocated - Return true if the specified register (or an alias) is allocated.
Wrapper class representing physical registers. Should be passed by value.