LLVM 24.0.0git
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, ProfileSummaryInfo *PSI=nullptr)
virtual ~VirtRegAuxInfo ()=default
LLVM_ABI void calculateSpillWeightAndHint (LiveInterval &LI)
 (re)compute li's spill weight and allocation hint.
LLVM_ABI void calculateSpillWeightsAndHints ()
 Compute spill weights and allocation hints for all virtual register live intervals.

Static Public Member Functions

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

Protected Member Functions

LLVM_ABI float weightCalcHelper (LiveInterval &LI)
 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 47 of file CalcSpillWeights.h.

Constructor & Destructor Documentation

◆ VirtRegAuxInfo()

llvm::VirtRegAuxInfo::VirtRegAuxInfo ( MachineFunction & MF,
LiveIntervals & LIS,
const VirtRegMap & VRM,
const MachineLoopInfo & Loops,
const MachineBlockFrequencyInfo & MBFI,
ProfileSummaryInfo * PSI = nullptr )
inline

Definition at line 66 of file CalcSpillWeights.h.

◆ ~VirtRegAuxInfo()

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

References LLVM_ABI, MI, MRI, Reg, TII, and TRI.

Member Function Documentation

◆ allUsesAvailableAt()

bool VirtRegAuxInfo::allUsesAvailableAt ( const MachineInstr * MI,
SlotIndex UseIdx,
const LiveIntervals & LIS,
const MachineRegisterInfo & MRI,
const TargetInstrInfo & TII )
static

◆ calculateSpillWeightAndHint()

void VirtRegAuxInfo::calculateSpillWeightAndHint ( LiveInterval & LI)

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

Definition at line 221 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 40 of file CalcSpillWeights.cpp.

References calculateSpillWeightAndHint(), llvm::dbgs(), I, llvm::Register::index2VirtReg(), LLVM_DEBUG, and MRI.

Referenced by llvm::RABasic::runOnMachineFunction().

◆ copyHint()

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

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

Definition at line 54 of file CalcSpillWeights.cpp.

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

Referenced by weightCalcHelper().

◆ isRematerializable()

◆ normalize()

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

Weight normalization function.

Definition at line 112 of file CalcSpillWeights.h.

References llvm::normalizeSpillWeight(), and llvm::Size.

Referenced by weightCalcHelper().

◆ weightCalcHelper()

float VirtRegAuxInfo::weightCalcHelper ( LiveInterval & LI)
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.
Returns
The spill weight. Returns negative weight for unspillable LI.

Definition at line 240 of file CalcSpillWeights.cpp.

References _, canMemFoldInlineAsm(), copyHint(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::MachineOperand::getReg(), llvm::LiveInterval::getSize(), llvm::LiveIntervals::getSpillWeight(), llvm::MachineOperand::getSubReg(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LiveRange::isLiveAtIndexes(), llvm::LoopBase< BlockT, LoopT >::isLoopExiting(), isRematerializable(), llvm::LiveInterval::isSpillable(), llvm::Register::isVirtual(), llvm::LiveRange::isZeroLength(), llvm::LiveInterval::markNotSpillable(), MBB, MI, MRI, normalize(), llvm::operator<(), Reg, llvm::LiveInterval::reg(), Register, llvm::sort(), TII, and TRI.

Referenced by calculateSpillWeightAndHint().


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