Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
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:
[legend]

Public Member Functions

LLVM_ABI CCState (CallingConv::ID CC, bool IsVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &Locs, LLVMContext &Context, bool NegativeOffsets=false)
void addLoc (const CCValAssign &V)
LLVMContextgetContext () const
MachineFunctiongetMachineFunction () const
CallingConv::ID getCallingConv () const
bool isVarArg () const
uint64_t getStackSize () const
 Returns the size of the currently allocated portion of the stack.
uint64_t 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.
bool isAllocated (MCRegister Reg) const
 isAllocated - Return true if the specified register (or an alias) is allocated.
LLVM_ABI void AnalyzeFormalArguments (const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
 AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals into this state.
void AnalyzeArguments (const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
 The function will invoke AnalyzeFormalArguments.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI void AnalyzeCallOperands (SmallVectorImpl< MVT > &ArgVTs, SmallVectorImpl< ISD::ArgFlagsTy > &Flags, SmallVectorImpl< Type * > &OrigTys, CCAssignFn Fn)
 AnalyzeCallOperands - Same as above except it takes vectors of types and argument flags.
void AnalyzeArguments (const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
 The function will invoke AnalyzeCallOperands.
LLVM_ABI 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.
LLVM_ABI bool IsShadowAllocatedReg (MCRegister Reg) const
 A shadow allocated register is a register that was allocated but wasn't added to the location list (Locs).
LLVM_ABI void AnalyzeCallResult (MVT VT, Type *OrigTy, CCAssignFn Fn)
 AnalyzeCallResult - Same as above except it's specialized for calls which produce a single value.
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.
void DeallocateReg (MCPhysReg Reg)
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.
MCRegister AllocateReg (ArrayRef< MCPhysReg > Regs)
 AllocateReg - Attempt to allocate one of the specified registers.
ArrayRef< MCPhysRegAllocateRegBlock (ArrayRef< MCPhysReg > Regs, unsigned RegsRequired)
 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.
int64_t AllocateStack (unsigned Size, Align Alignment)
 AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
LLVM_ABI void ensureMaxAlignment (Align Alignment)
int64_t AllocateStack (unsigned Size, Align Alignment, ArrayRef< MCPhysReg > ShadowRegs)
 Version of AllocateStack with list of extra registers to be shadowed.
LLVM_ABI 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.
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 ()
LLVM_ABI void getRemainingRegParmsForType (SmallVectorImpl< MCRegister > &Regs, MVT VT, CCAssignFn Fn)
 Compute the remaining unused register parameters that would be used for the given value type.
LLVM_ABI 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.
template<class T>
void AnalyzeArgumentsSecondPass (const SmallVectorImpl< T > &Args, CCAssignFn Fn)
 The function runs an additional analysis pass over function arguments.

Static Public Member Functions

static LLVM_ABI 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.

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 171 of file CallingConvLower.h.

Constructor & Destructor Documentation

◆ CCState()

CCState::CCState ( CallingConv::ID CC,
bool IsVarArg,
MachineFunction & MF,
SmallVectorImpl< CCValAssign > & Locs,
LLVMContext & Context,
bool NegativeOffsets = false )

Member Function Documentation

◆ addInRegsParamInfo()

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

Definition at line 460 of file CallingConvLower.h.

◆ addLoc()

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

◆ AllocateReg() [1/4]

MCRegister 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 352 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 394 of file CallingConvLower.h.

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

◆ AllocateReg() [3/4]

◆ AllocateReg() [4/4]

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

Version of AllocateReg with extra register to be shadowed.

Definition at line 341 of file CallingConvLower.h.

References isAllocated(), and Reg.

◆ AllocateRegBlock()

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

Attempt to allocate a block of RegsRequired consecutive registers.

If this is not possible, return an empty range. Otherwise, return a range of consecutive registers, marking the entire block as allocated.

Definition at line 366 of file CallingConvLower.h.

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

◆ AllocateStack() [1/2]

◆ AllocateStack() [2/2]

int64_t 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 426 of file CallingConvLower.h.

References AllocateStack(), Reg, and Size.

◆ AnalyzeArguments() [1/2]

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

The function will invoke AnalyzeFormalArguments.

Definition at line 268 of file CallingConvLower.h.

References AnalyzeFormalArguments().

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 297 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 520 of file CallingConvLower.h.

References A(), AnalyzeArguments(), B(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), E(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorImpl< T >::swap().

◆ AnalyzeCallOperands() [1/2]

◆ AnalyzeCallOperands() [2/2]

void CCState::AnalyzeCallOperands ( SmallVectorImpl< MVT > & ArgVTs,
SmallVectorImpl< ISD::ArgFlagsTy > & Flags,
SmallVectorImpl< Type * > & OrigTys,
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 144 of file CallingConvLower.cpp.

References AbstractManglingParser< Derived, Alloc >::NumOps, llvm::dbgs(), llvm::CCValAssign::Full, llvm_unreachable, and llvm::SmallVectorTemplateCommon< T, typename >::size().

◆ 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 164 of file CallingConvLower.cpp.

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

Referenced by llvm::SystemZTargetLowering::LowerCall(), llvm::VETargetLowering::LowerCall(), llvm::XtensaTargetLowering::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,
Type * OrigTy,
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 180 of file CallingConvLower.cpp.

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

◆ AnalyzeFormalArguments()

◆ 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 243 of file CallingConvLower.cpp.

References llvm::TargetLoweringBase::getRegClassFor(), getRemainingRegParmsForType(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

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 113 of file CallingConvLower.cpp.

References llvm::CCValAssign::Full, llvm::report_fatal_error(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by llvm::HexagonTargetLowering::LowerReturn(), llvm::SITargetLowering::LowerReturn(), llvm::SystemZTargetLowering::LowerReturn(), llvm::VETargetLowering::LowerReturn(), llvm::XtensaTargetLowering::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 99 of file CallingConvLower.cpp.

References llvm::CCValAssign::Full, and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by llvm::HexagonTargetLowering::CanLowerReturn(), llvm::LanaiTargetLowering::CanLowerReturn(), llvm::SITargetLowering::CanLowerReturn(), llvm::SparcTargetLowering::CanLowerReturn(), llvm::SystemZTargetLowering::CanLowerReturn(), llvm::VETargetLowering::CanLowerReturn(), and llvm::XtensaTargetLowering::CanLowerReturn().

◆ clearByValRegsInfo()

void llvm::CCState::clearByValRegsInfo ( )
inline

Definition at line 475 of file CallingConvLower.h.

Referenced by CCState().

◆ DeallocateReg()

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

Definition at line 325 of file CallingConvLower.h.

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

◆ ensureMaxAlignment()

void CCState::ensureMaxAlignment ( Align Alignment)

Definition at line 190 of file CallingConvLower.cpp.

Referenced by AllocateStack(), and HandleByVal().

◆ getAlignedCallFrameSize()

uint64_t 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 251 of file CallingConvLower.h.

References llvm::alignTo().

◆ getCallingConv()

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

◆ getContext()

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

◆ getFirstUnallocated()

◆ getInRegsParamInfo()

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

Definition at line 449 of file CallingConvLower.h.

References assert(), and info.

◆ getInRegsParamsCount()

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

Definition at line 442 of file CallingConvLower.h.

◆ getInRegsParamsProcessed()

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

Definition at line 445 of file CallingConvLower.h.

◆ getMachineFunction()

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

◆ getPendingArgFlags()

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

Definition at line 491 of file CallingConvLower.h.

◆ getPendingLocs()

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

Definition at line 486 of file CallingConvLower.h.

◆ getRemainingRegParmsForType()

void CCState::getRemainingRegParmsForType ( SmallVectorImpl< MCRegister > & 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 203 of file CallingConvLower.cpp.

References assert(), llvm::dbgs(), llvm::CCValAssign::Full, llvm::EVT::getTypeForEVT(), I, isValueTypeInRegForCC(), llvm_unreachable, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ISD::ArgFlagsTy::setInReg().

Referenced by analyzeMustTailForwardedRegisters().

◆ getStackSize()

◆ 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 45 of file CallingConvLower.cpp.

References addLoc(), llvm::alignTo(), AllocateStack(), ensureMaxAlignment(), llvm::ISD::ArgFlagsTy::getByValSize(), llvm::CCValAssign::getMem(), llvm::ISD::ArgFlagsTy::getNonZeroByValAlign(), llvm::MinAlign(), llvm::Offset, and Size.

◆ isAllocated()

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

isAllocated - Return true if the specified register (or an alias) is allocated.

Definition at line 257 of file CallingConvLower.h.

References Reg.

Referenced by AllocateReg(), AllocateReg(), AllocateRegBlock(), llvm::SITargetLowering::CanLowerReturn(), DeallocateReg(), findFirstFreeSGPR(), getFirstUnallocated(), handleMustTailForwardedRegisters(), and IsShadowAllocatedReg().

◆ 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 72 of file CallingConvLower.cpp.

References isAllocated().

◆ isVarArg()

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

Definition at line 243 of file CallingConvLower.h.

Referenced by llvm::MipsCCState::MipsCCState().

◆ nextInRegsParam()

bool llvm::CCState::nextInRegsParam ( )
inline

Definition at line 467 of file CallingConvLower.h.

◆ resultsCompatible()

◆ rewindByValRegsInfo()

void llvm::CCState::rewindByValRegsInfo ( )
inline

Definition at line 481 of file CallingConvLower.h.


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