LLVM  14.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::CCState Class Reference

CCState - This class holds information needed while lowering arguments and return values. More...

#include "llvm/CodeGen/CallingConvLower.h"

Inheritance diagram for llvm::CCState:
Inheritance graph
[legend]

Public Member Functions

 CCState (CallingConv::ID CC, bool isVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &locs, LLVMContext &C)
 
void addLoc (const CCValAssign &V)
 
LLVMContextgetContext () const
 
MachineFunctiongetMachineFunction () const
 
CallingConv::ID getCallingConv () const
 
bool isVarArg () const
 
unsigned getNextStackOffset () const
 getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment requirements. More...
 
unsigned getAlignedCallFrameSize () const
 getAlignedCallFrameSize - Return the size of the call frame needed to be able to store all arguments and such that the alignment requirement of each of the arguments is satisfied. More...
 
bool isAllocated (MCRegister Reg) const
 isAllocated - Return true if the specified register (or an alias) is allocated. More...
 
void AnalyzeFormalArguments (const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
 AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals into this state. More...
 
void AnalyzeArguments (const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
 The function will invoke AnalyzeFormalArguments. More...
 
void AnalyzeReturn (const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
 AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values into this state. More...
 
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 without sret-demotion, and false otherwise. More...
 
void AnalyzeCallOperands (const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
 AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed values into this state. More...
 
void AnalyzeCallOperands (SmallVectorImpl< MVT > &ArgVTs, SmallVectorImpl< ISD::ArgFlagsTy > &Flags, CCAssignFn Fn)
 AnalyzeCallOperands - Same as above except it takes vectors of types and argument flags. More...
 
void AnalyzeArguments (const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
 The function will invoke AnalyzeCallOperands. More...
 
void AnalyzeCallResult (const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
 AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values into this state. More...
 
bool IsShadowAllocatedReg (MCRegister Reg) const
 A shadow allocated register is a register that was allocated but wasn't added to the location list (Locs). More...
 
void AnalyzeCallResult (MVT VT, CCAssignFn Fn)
 AnalyzeCallResult - Same as above except it's specialized for calls which produce a single value. More...
 
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. More...
 
void DeallocateReg (MCPhysReg Reg)
 
MCRegister AllocateReg (MCPhysReg Reg)
 AllocateReg - Attempt to allocate one register. More...
 
MCRegister AllocateReg (MCPhysReg Reg, MCPhysReg ShadowReg)
 Version of AllocateReg with extra register to be shadowed. More...
 
MCPhysReg AllocateReg (ArrayRef< MCPhysReg > Regs)
 AllocateReg - Attempt to allocate one of the specified registers. More...
 
MCPhysReg AllocateRegBlock (ArrayRef< MCPhysReg > Regs, unsigned RegsRequired)
 AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive registers. More...
 
MCRegister AllocateReg (ArrayRef< MCPhysReg > Regs, const MCPhysReg *ShadowRegs)
 Version of AllocateReg with list of registers to be shadowed. More...
 
unsigned AllocateStack (unsigned Size, Align Alignment)
 AllocateStack - Allocate a chunk of stack space with the specified size and alignment. More...
 
void ensureMaxAlignment (Align Alignment)
 
unsigned AllocateStack (unsigned Size, Align Alignment, ArrayRef< MCPhysReg > ShadowRegs)
 Version of AllocateStack with list of extra registers to be shadowed. More...
 
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. More...
 
unsigned getInRegsParamsCount () const
 
unsigned getInRegsParamsProcessed () const
 
void getInRegsParamInfo (unsigned InRegsParamRecordIndex, unsigned &BeginReg, unsigned &EndReg) const
 
void addInRegsParamInfo (unsigned RegBegin, unsigned RegEnd)
 
bool nextInRegsParam ()
 
void clearByValRegsInfo ()
 
void rewindByValRegsInfo ()
 
SmallVectorImpl< CCValAssign > & getPendingLocs ()
 
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags ()
 
void getRemainingRegParmsForType (SmallVectorImpl< MCPhysReg > &Regs, MVT VT, CCAssignFn Fn)
 Compute the remaining unused register parameters that would be used for the given value type. More...
 
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. More...
 
template<class T >
void AnalyzeArgumentsSecondPass (const SmallVectorImpl< T > &Args, CCAssignFn Fn)
 The function runs an additional analysis pass over function arguments. More...
 

Static Public Member Functions

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. More...
 

Detailed Description

CCState - This class holds information needed while lowering arguments and return values.

It captures which registers are already assigned and which stack slots are used. It provides accessors to allocate these values.

Definition at line 191 of file CallingConvLower.h.

Constructor & Destructor Documentation

◆ CCState()

CCState::CCState ( CallingConv::ID  CC,
bool  isVarArg,
MachineFunction MF,
SmallVectorImpl< CCValAssign > &  locs,
LLVMContext C 
)

Member Function Documentation

◆ addInRegsParamInfo()

void llvm::CCState::addInRegsParamInfo ( unsigned  RegBegin,
unsigned  RegEnd 
)
inline

Definition at line 472 of file CallingConvLower.h.

Referenced by llvm::MipsTargetLowering::HandleByVal().

◆ addLoc()

void llvm::CCState::addLoc ( const CCValAssign V)
inline

◆ AllocateReg() [1/4]

MCPhysReg llvm::CCState::AllocateReg ( ArrayRef< MCPhysReg Regs)
inline

AllocateReg - Attempt to allocate one of the specified registers.

If none are available, return zero. Otherwise, return the first one available, marking it and any aliases as allocated.

Definition at line 370 of file CallingConvLower.h.

References getFirstUnallocated(), Reg, and llvm::ArrayRef< T >::size().

◆ AllocateReg() [2/4]

MCRegister llvm::CCState::AllocateReg ( ArrayRef< MCPhysReg Regs,
const MCPhysReg ShadowRegs 
)
inline

Version of AllocateReg with list of registers to be shadowed.

Definition at line 411 of file CallingConvLower.h.

References getFirstUnallocated(), Reg, and llvm::ArrayRef< T >::size().

◆ AllocateReg() [3/4]

MCRegister llvm::CCState::AllocateReg ( MCPhysReg  Reg)
inline

AllocateReg - Attempt to allocate one register.

If it is not available, return zero. Otherwise, return the register, marking it and any aliases as allocated.

Definition at line 351 of file CallingConvLower.h.

References isAllocated(), and Reg.

Referenced by allocateFixedSGPRInputImpl(), allocateHSAUserSGPRs(), llvm::SITargetLowering::allocateHSAUserSGPRs(), allocateRVVReg(), allocateSGPR32InputImpl(), llvm::SITargetLowering::allocateSpecialEntryInputVGPRs(), llvm::SITargetLowering::allocateSpecialInputVGPRsFixed(), llvm::SITargetLowering::allocateSystemSGPRs(), allocateVGPR32Input(), AnalyzeArguments(), llvm::analyzeArguments(), llvm::analyzeReturnValues(), CC_AArch64_Custom_Block(), CC_AIX(), CC_ARM_AAPCS_Custom_Aggregate(), CC_MipsO32(), CC_PPC32_SPE_CustomSplitFP64(), CC_PPC32_SPE_RetF64(), CC_PPC32_SVR4_Custom_AlignArgRegs(), CC_PPC32_SVR4_Custom_AlignFPArgRegs(), CC_PPC32_SVR4_Custom_SkipLastArgRegsPPCF128(), CC_RISCV(), CC_RISCV_FastCC(), CC_RISCV_GHC(), CC_RISCVAssign2XLen(), CC_SkipOdd(), CC_Sparc_Assign_Ret_Split_64(), CC_Sparc_Assign_Split_64(), llvm::CC_SystemZ_I128Indirect(), CC_X86_32_MCUInReg(), CC_X86_32_RegCall_Assign2Regs(), CC_X86_32_VectorCall(), CC_X86_64_VectorCall(), CC_X86_VectorCallAssignRegister(), llvm::CC_XPLINK64_Allocate128BitVararg(), llvm::CC_XPLINK64_Shadow_Reg(), CustomAssignInRegList(), f64AssignAAPCS(), f64AssignAPCS(), f64RetAssign(), finishStackBlock(), llvm::MipsTargetLowering::HandleByVal(), llvm::AMDGPUCallLowering::lowerFormalArguments(), llvm::SITargetLowering::LowerFormalArguments(), llvm::AMDGPUCallLowering::passSpecialInputs(), and llvm::SITargetLowering::passSpecialInputs().

◆ AllocateReg() [4/4]

MCRegister llvm::CCState::AllocateReg ( MCPhysReg  Reg,
MCPhysReg  ShadowReg 
)
inline

Version of AllocateReg with extra register to be shadowed.

Definition at line 359 of file CallingConvLower.h.

References isAllocated(), and Reg.

◆ AllocateRegBlock()

MCPhysReg llvm::CCState::AllocateRegBlock ( ArrayRef< MCPhysReg Regs,
unsigned  RegsRequired 
)
inline

AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive registers.

If this is not possible, return zero. Otherwise, return the first register of the block that were allocated, marking the entire block as allocated.

Definition at line 384 of file CallingConvLower.h.

References isAllocated(), and llvm::ArrayRef< T >::size().

Referenced by CC_AArch64_Custom_Block(), and CC_ARM_AAPCS_Custom_Aggregate().

◆ AllocateStack() [1/2]

unsigned llvm::CCState::AllocateStack ( unsigned  Size,
Align  Alignment 
)
inline

◆ AllocateStack() [2/2]

unsigned llvm::CCState::AllocateStack ( unsigned  Size,
Align  Alignment,
ArrayRef< MCPhysReg ShadowRegs 
)
inline

Version of AllocateStack with list of extra registers to be shadowed.

Note that, unlike AllocateReg, this shadows ALL of the shadow registers.

Definition at line 438 of file CallingConvLower.h.

References AllocateStack(), i, llvm::Check::Size, and llvm::ArrayRef< T >::size().

◆ AnalyzeArguments() [1/2]

void llvm::CCState::AnalyzeArguments ( const SmallVectorImpl< ISD::InputArg > &  Ins,
CCAssignFn  Fn 
)
inline

The function will invoke AnalyzeFormalArguments.

Definition at line 287 of file CallingConvLower.h.

References AnalyzeFormalArguments(), and llvm::MipsISD::Ins.

Referenced by AnalyzeArgumentsSecondPass().

◆ AnalyzeArguments() [2/2]

void llvm::CCState::AnalyzeArguments ( const SmallVectorImpl< ISD::OutputArg > &  Outs,
CCAssignFn  Fn 
)
inline

The function will invoke AnalyzeCallOperands.

Definition at line 315 of file CallingConvLower.h.

References AnalyzeCallOperands().

◆ AnalyzeArgumentsSecondPass()

template<class T >
void llvm::CCState::AnalyzeArgumentsSecondPass ( const SmallVectorImpl< T > &  Args,
CCAssignFn  Fn 
)
inline

The function runs an additional analysis pass over function arguments.

It will mark each argument with the attribute flag SecArgPass. After running, it will sort the locs list.

Creates similar argument list to Args in which each argument is marked using SecArgPass flag.

Definition at line 532 of file CallingConvLower.h.

References AnalyzeArguments(), Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, B, E, merge(), and llvm::SmallVectorImpl< T >::swap().

◆ AnalyzeCallOperands() [1/2]

void CCState::AnalyzeCallOperands ( const SmallVectorImpl< ISD::OutputArg > &  Outs,
CCAssignFn  Fn 
)

◆ AnalyzeCallOperands() [2/2]

void CCState::AnalyzeCallOperands ( SmallVectorImpl< MVT > &  ArgVTs,
SmallVectorImpl< ISD::ArgFlagsTy > &  Flags,
CCAssignFn  Fn 
)

AnalyzeCallOperands - Same as above except it takes vectors of types and argument flags.

Same as above except it takes vectors of types and argument flags.

Definition at line 148 of file CallingConvLower.cpp.

References llvm::dbgs(), llvm::CCValAssign::Full, llvm::EVT::getEVTString(), i, and llvm_unreachable.

◆ AnalyzeCallResult() [1/2]

void CCState::AnalyzeCallResult ( const SmallVectorImpl< ISD::InputArg > &  Ins,
CCAssignFn  Fn 
)

AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values into this state.

Analyze the return values of a call, incorporating info about the passed values into this state.

Definition at line 167 of file CallingConvLower.cpp.

References llvm::dbgs(), llvm::numbers::e, llvm::CCValAssign::Full, llvm::EVT::getEVTString(), i, llvm::MipsISD::Ins, and llvm_unreachable.

Referenced by llvm::MipsCCState::AnalyzeCallResult(), AnalyzeRetResult(), llvm::VETargetLowering::LowerCall(), llvm::SystemZTargetLowering::LowerCall(), llvm::SparcTargetLowering::LowerCall_32(), llvm::SparcTargetLowering::LowerCall_64(), llvm::HexagonTargetLowering::LowerCallResult(), llvm::SITargetLowering::LowerCallResult(), and resultsCompatible().

◆ AnalyzeCallResult() [2/2]

void CCState::AnalyzeCallResult ( MVT  VT,
CCAssignFn  Fn 
)

AnalyzeCallResult - Same as above except it's specialized for calls which produce a single value.

Same as above except it's specialized for calls that produce a single value.

Definition at line 183 of file CallingConvLower.cpp.

References llvm::dbgs(), llvm::CCValAssign::Full, llvm::EVT::getEVTString(), and llvm_unreachable.

◆ AnalyzeFormalArguments()

void CCState::AnalyzeFormalArguments ( const SmallVectorImpl< ISD::InputArg > &  Ins,
CCAssignFn  Fn 
)

◆ analyzeMustTailForwardedRegisters()

void CCState::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.

Definition at line 245 of file CallingConvLower.cpp.

References llvm::MachineFunction::addLiveIn(), llvm::TargetLoweringBase::getRegClassFor(), getRemainingRegParmsForType(), llvm::MachineFunction::getSubtarget(), and llvm::TargetSubtargetInfo::getTargetLowering().

Referenced by handleMustTailForwardedRegisters().

◆ AnalyzeReturn()

void CCState::AnalyzeReturn ( const SmallVectorImpl< ISD::OutputArg > &  Outs,
CCAssignFn  Fn 
)

AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values into this state.

Analyze the returned values of a return, incorporating info about the result values into this state.

Definition at line 118 of file CallingConvLower.cpp.

References llvm::numbers::e, llvm::CCValAssign::Full, i, and llvm::report_fatal_error().

Referenced by AnalyzeRetResult(), llvm::MipsCCState::AnalyzeReturn(), llvm::VETargetLowering::LowerReturn(), llvm::HexagonTargetLowering::LowerReturn(), llvm::SITargetLowering::LowerReturn(), llvm::SystemZTargetLowering::LowerReturn(), llvm::SparcTargetLowering::LowerReturn_32(), and llvm::SparcTargetLowering::LowerReturn_64().

◆ CheckReturn()

bool CCState::CheckReturn ( const SmallVectorImpl< ISD::OutputArg > &  Outs,
CCAssignFn  Fn 
)

CheckReturn - Analyze the return values of a function, returning true if the return can be performed without sret-demotion, and false otherwise.

Analyze the return values of a function, returning true if the return can be performed without sret-demotion and false otherwise.

Definition at line 104 of file CallingConvLower.cpp.

References llvm::numbers::e, llvm::CCValAssign::Full, and i.

Referenced by llvm::VETargetLowering::CanLowerReturn(), llvm::LanaiTargetLowering::CanLowerReturn(), llvm::HexagonTargetLowering::CanLowerReturn(), llvm::SITargetLowering::CanLowerReturn(), llvm::SystemZTargetLowering::CanLowerReturn(), and llvm::MipsCCState::CheckReturn().

◆ clearByValRegsInfo()

void llvm::CCState::clearByValRegsInfo ( )
inline

Definition at line 487 of file CallingConvLower.h.

References llvm::SmallVectorImpl< T >::clear().

Referenced by CCState().

◆ DeallocateReg()

void llvm::CCState::DeallocateReg ( MCPhysReg  Reg)
inline

Definition at line 343 of file CallingConvLower.h.

References assert(), isAllocated(), and Reg.

Referenced by finishStackBlock().

◆ ensureMaxAlignment()

void CCState::ensureMaxAlignment ( Align  Alignment)

◆ getAlignedCallFrameSize()

unsigned llvm::CCState::getAlignedCallFrameSize ( ) const
inline

getAlignedCallFrameSize - Return the size of the call frame needed to be able to store all arguments and such that the alignment requirement of each of the arguments is satisfied.

Definition at line 271 of file CallingConvLower.h.

References llvm::alignTo().

◆ getCallingConv()

CallingConv::ID llvm::CCState::getCallingConv ( ) const
inline

◆ getContext()

LLVMContext& llvm::CCState::getContext ( ) const
inline

◆ getFirstUnallocated()

unsigned llvm::CCState::getFirstUnallocated ( ArrayRef< MCPhysReg Regs) const
inline

◆ getInRegsParamInfo()

void llvm::CCState::getInRegsParamInfo ( unsigned  InRegsParamRecordIndex,
unsigned &  BeginReg,
unsigned &  EndReg 
) const
inline

Definition at line 461 of file CallingConvLower.h.

References assert(), and info.

◆ getInRegsParamsCount()

unsigned llvm::CCState::getInRegsParamsCount ( ) const
inline

Definition at line 454 of file CallingConvLower.h.

◆ getInRegsParamsProcessed()

unsigned llvm::CCState::getInRegsParamsProcessed ( ) const
inline

Definition at line 457 of file CallingConvLower.h.

◆ getMachineFunction()

MachineFunction& llvm::CCState::getMachineFunction ( ) const
inline

◆ getNextStackOffset()

unsigned llvm::CCState::getNextStackOffset ( ) const
inline

◆ getPendingArgFlags()

SmallVectorImpl<ISD::ArgFlagsTy>& llvm::CCState::getPendingArgFlags ( )
inline

Definition at line 503 of file CallingConvLower.h.

Referenced by CC_RISCV().

◆ getPendingLocs()

SmallVectorImpl<CCValAssign>& llvm::CCState::getPendingLocs ( )
inline

◆ getRemainingRegParmsForType()

void CCState::getRemainingRegParmsForType ( SmallVectorImpl< MCPhysReg > &  Regs,
MVT  VT,
CCAssignFn  Fn 
)

Compute the remaining unused register parameters that would be used for the given value type.

This is useful when varargs are passed in the registers that normal prototyped parameters would be passed in, or for implementing perfect forwarding.

Definition at line 206 of file CallingConvLower.cpp.

References assert(), llvm::dbgs(), E, llvm::CCValAssign::Full, llvm::EVT::getEVTString(), I, isValueTypeInRegForCC(), llvm_unreachable, and llvm::ISD::ArgFlagsTy::setInReg().

Referenced by analyzeMustTailForwardedRegisters().

◆ HandleByVal()

void CCState::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.

The size and alignment information of the argument is encoded in its parameter attribute.

Definition at line 44 of file CallingConvLower.cpp.

References addLoc(), llvm::alignTo(), AllocateStack(), ensureMaxAlignment(), llvm::ISD::ArgFlagsTy::getByValSize(), llvm::CCValAssign::getMem(), llvm::ISD::ArgFlagsTy::getNonZeroByValAlign(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::TargetLowering::HandleByVal(), llvm::MinAlign(), Offset, and llvm::Check::Size.

Referenced by AnalyzeArguments().

◆ isAllocated()

bool llvm::CCState::isAllocated ( MCRegister  Reg) const
inline

◆ IsShadowAllocatedReg()

bool CCState::IsShadowAllocatedReg ( MCRegister  Reg) const

A shadow allocated register is a register that was allocated but wasn't added to the location list (Locs).

Returns
true if the register was allocated as shadow or false otherwise.

Definition at line 71 of file CallingConvLower.cpp.

References isAllocated(), llvm::MCRegAliasIterator::isValid(), and Reg.

Referenced by CC_X86_VectorCallAssignRegister().

◆ isVarArg()

bool llvm::CCState::isVarArg ( ) const
inline

◆ nextInRegsParam()

bool llvm::CCState::nextInRegsParam ( )
inline

Definition at line 479 of file CallingConvLower.h.

References llvm::numbers::e.

◆ resultsCompatible()

bool CCState::resultsCompatible ( CallingConv::ID  CalleeCC,
CallingConv::ID  CallerCC,
MachineFunction MF,
LLVMContext C,
const SmallVectorImpl< ISD::InputArg > &  Ins,
CCAssignFn  CalleeFn,
CCAssignFn  CallerFn 
)
static

Returns true if the results of the two calling conventions are compatible.

This is usually part of the check for tailcall eligibility.

Definition at line 266 of file CallingConvLower.cpp.

References AnalyzeCallResult(), E, llvm::CCValAssign::getExtraInfo(), llvm::CCValAssign::getLocInfo(), I, llvm::MipsISD::Ins, and llvm::CCValAssign::isRegLoc().

Referenced by llvm::SITargetLowering::isEligibleForTailCallOptimization().

◆ rewindByValRegsInfo()

void llvm::CCState::rewindByValRegsInfo ( )
inline

Definition at line 493 of file CallingConvLower.h.


The documentation for this class was generated from the following files: