LLVM 19.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::VirtRegAuxInfo Class Reference

Calculate auxiliary information for a virtual register such as its spill weight and allocation hint. More...

#include "llvm/CodeGen/CalcSpillWeights.h"

Public Member Functions

 VirtRegAuxInfo (MachineFunction &MF, LiveIntervals &LIS, const VirtRegMap &VRM, const MachineLoopInfo &Loops, const MachineBlockFrequencyInfo &MBFI)
 
virtual ~VirtRegAuxInfo ()=default
 
void calculateSpillWeightAndHint (LiveInterval &LI)
 (re)compute li's spill weight and allocation hint.
 
void calculateSpillWeightsAndHints ()
 Compute spill weights and allocation hints for all virtual register live intervals.
 

Static Public Member Functions

static Register copyHint (const MachineInstr *MI, unsigned Reg, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI)
 Return the preferred allocation register for reg, given a COPY instruction.
 
static bool isRematerializable (const LiveInterval &LI, const LiveIntervals &LIS, const VirtRegMap &VRM, const TargetInstrInfo &TII)
 Determine if all values in LI are rematerializable.
 

Protected Member Functions

float weightCalcHelper (LiveInterval &LI, SlotIndex *Start=nullptr, SlotIndex *End=nullptr)
 Helper function for weight calculations.
 
virtual float normalize (float UseDefFreq, unsigned Size, unsigned NumInstr)
 Weight normalization function.
 

Detailed Description

Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.

Definition at line 45 of file CalcSpillWeights.h.

Constructor & Destructor Documentation

◆ VirtRegAuxInfo()

llvm::VirtRegAuxInfo::VirtRegAuxInfo ( MachineFunction MF,
LiveIntervals LIS,
const VirtRegMap VRM,
const MachineLoopInfo Loops,
const MachineBlockFrequencyInfo MBFI 
)
inline

Definition at line 57 of file CalcSpillWeights.h.

References Loops.

◆ ~VirtRegAuxInfo()

virtual llvm::VirtRegAuxInfo::~VirtRegAuxInfo ( )
virtualdefault

Member Function Documentation

◆ calculateSpillWeightAndHint()

void VirtRegAuxInfo::calculateSpillWeightAndHint ( LiveInterval LI)

(re)compute li's spill weight and allocation hint.

Definition at line 141 of file CalcSpillWeights.cpp.

References llvm::LiveInterval::setWeight(), and weightCalcHelper().

Referenced by llvm::LiveRangeEdit::calculateRegClassAndHint(), and calculateSpillWeightsAndHints().

◆ calculateSpillWeightsAndHints()

void VirtRegAuxInfo::calculateSpillWeightsAndHints ( )

Compute spill weights and allocation hints for all virtual register live intervals.

Definition at line 33 of file CalcSpillWeights.cpp.

References calculateSpillWeightAndHint(), llvm::dbgs(), llvm::LiveIntervals::getInterval(), llvm::MachineFunction::getName(), llvm::MachineFunction::getRegInfo(), I, llvm::Register::index2VirtReg(), LLVM_DEBUG, and MRI.

◆ copyHint()

Register VirtRegAuxInfo::copyHint ( const MachineInstr MI,
unsigned  Reg,
const TargetRegisterInfo TRI,
const MachineRegisterInfo MRI 
)
static

Return the preferred allocation register for reg, given a COPY instruction.

Definition at line 47 of file CalcSpillWeights.cpp.

References llvm::Register::asMCReg(), llvm::TargetRegisterClass::contains(), llvm::Register::isVirtual(), MI, MRI, and TRI.

Referenced by weightCalcHelper().

◆ isRematerializable()

bool VirtRegAuxInfo::isRematerializable ( const LiveInterval LI,
const LiveIntervals LIS,
const VirtRegMap VRM,
const TargetInstrInfo TII 
)
static

◆ normalize()

virtual float llvm::VirtRegAuxInfo::normalize ( float  UseDefFreq,
unsigned  Size,
unsigned  NumInstr 
)
inlineprotectedvirtual

Weight normalization function.

Definition at line 100 of file CalcSpillWeights.h.

References llvm::normalizeSpillWeight(), and Size.

Referenced by weightCalcHelper().

◆ weightCalcHelper()

float VirtRegAuxInfo::weightCalcHelper ( LiveInterval LI,
SlotIndex Start = nullptr,
SlotIndex End = nullptr 
)
protected

Helper function for weight calculations.

(Re)compute LI's spill weight and allocation hint, or, for non null start and end - compute future expected spill weight of a split artifact of LI that will span between start and end slot indexes.

Parameters
LIThe live interval for which to compute the weight.
StartThe expected beginning of the split artifact. Instructions before start will not affect the weight. Relevant for weight calculation of future split artifact.
EndThe expected end of the split artifact. Instructions after end will not affect the weight. Relevant for weight calculation of future split artifact.
Returns
The spill weight. Returns negative weight for unspillable LI.

Definition at line 160 of file CalcSpillWeights.cpp.

References assert(), canMemFoldInlineAsm(), copyHint(), End, llvm::TargetSubtargetInfo::getInstrInfo(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::MachineLoopInfo::getLoopFor(), llvm::LiveIntervals::getMBBFromIndex(), llvm::VirtRegMap::getOriginal(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::LiveIntervals::getRegMaskSlots(), llvm::LiveInterval::getSize(), llvm::LiveIntervals::getSlotIndexes(), llvm::LiveIntervals::getSpillWeight(), llvm::MachineOperand::getSubReg(), llvm::MachineFunction::getSubtarget(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::SmallSet< T, N, C >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LiveRange::isLiveAtIndexes(), llvm::LiveIntervals::isLiveOutOfMBB(), llvm::LoopBase< BlockT, LoopT >::isLoopExiting(), isRematerializable(), llvm::LiveInterval::isSpillable(), llvm::Register::isVirtual(), llvm::LiveRange::isZeroLength(), llvm::LiveInterval::markNotSpillable(), MBB, MI, MRI, normalize(), llvm::operator<(), llvm::LiveInterval::reg(), Reg, TII, TRI, and Writes.

Referenced by calculateSpillWeightAndHint().


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