LLVM 22.0.0git
llvm::LiveRegUnits Class Reference

A set of register units used to track register liveness. More...

#include "llvm/CodeGen/LiveRegUnits.h"

Public Member Functions

 LiveRegUnits ()=default
 Constructs a new empty LiveRegUnits set.
 LiveRegUnits (const TargetRegisterInfo &TRI)
 Constructs and initialize an empty LiveRegUnits set.
void init (const TargetRegisterInfo &TRI)
 Initialize and clear the set.
void clear ()
 Clears the set.
bool empty () const
 Returns true if the set is empty.
void addReg (MCRegister Reg)
 Adds register units covered by physical register Reg.
void addRegMasked (MCRegister Reg, LaneBitmask Mask)
 Adds register units covered by physical register Reg that are part of the lanemask Mask.
void removeReg (MCRegister Reg)
 Removes all register units covered by physical register Reg.
LLVM_ABI void removeRegsNotPreserved (const uint32_t *RegMask)
 Removes register units not preserved by the regmask RegMask.
LLVM_ABI void addRegsInMask (const uint32_t *RegMask)
 Adds register units not preserved by the regmask RegMask.
bool available (MCRegister Reg) const
 Returns true if no part of physical register Reg is live.
LLVM_ABI void stepBackward (const MachineInstr &MI)
 Updates liveness when stepping backwards over the instruction MI.
LLVM_ABI void accumulate (const MachineInstr &MI)
 Adds all register units used, defined or clobbered in MI.
LLVM_ABI void addLiveOuts (const MachineBasicBlock &MBB)
 Adds registers living out of block MBB.
LLVM_ABI void addLiveIns (const MachineBasicBlock &MBB)
 Adds registers living into block MBB.
void addUnits (const BitVector &RegUnits)
 Adds all register units marked in the bitvector RegUnits.
void removeUnits (const BitVector &RegUnits)
 Removes all register units marked in the bitvector RegUnits.
const BitVectorgetBitVector () const
 Return the internal bitvector representation of the set.

Static Public Member Functions

static void accumulateUsedDefed (const MachineInstr &MI, LiveRegUnits &ModifiedRegUnits, LiveRegUnits &UsedRegUnits, const TargetRegisterInfo *TRI)
 For a machine instruction MI, adds all register units used in UsedRegUnits and defined or clobbered in ModifiedRegUnits.

Detailed Description

A set of register units used to track register liveness.

Definition at line 31 of file LiveRegUnits.h.

Constructor & Destructor Documentation

◆ LiveRegUnits() [1/2]

llvm::LiveRegUnits::LiveRegUnits ( )
default

Constructs a new empty LiveRegUnits set.

Referenced by accumulateUsedDefed().

◆ LiveRegUnits() [2/2]

llvm::LiveRegUnits::LiveRegUnits ( const TargetRegisterInfo & TRI)
inline

Constructs and initialize an empty LiveRegUnits set.

Definition at line 40 of file LiveRegUnits.h.

References init().

Member Function Documentation

◆ accumulate()

void LiveRegUnits::accumulate ( const MachineInstr & MI)

Adds all register units used, defined or clobbered in MI.

This is useful when walking over a range of instruction to find registers unused over the whole range.

Definition at line 69 of file LiveRegUnits.cpp.

References addReg(), addRegsInMask(), and MI.

Referenced by canRenameUntilSecondLoad(), canRenameUpToDef(), and llvm::ARMBaseInstrInfo::isMBBSafeToOutlineFrom().

◆ accumulateUsedDefed()

void llvm::LiveRegUnits::accumulateUsedDefed ( const MachineInstr & MI,
LiveRegUnits & ModifiedRegUnits,
LiveRegUnits & UsedRegUnits,
const TargetRegisterInfo * TRI )
inlinestatic

For a machine instruction MI, adds all register units used in UsedRegUnits and defined or clobbered in ModifiedRegUnits.

This is useful when walking over a range of instructions to track registers used or defined separately.

Definition at line 48 of file LiveRegUnits.h.

References addReg(), addRegsInMask(), assert(), LiveRegUnits(), MI, and Reg.

Referenced by llvm::HexagonRegisterInfo::eliminateFrameIndex(), and INITIALIZE_PASS().

◆ addLiveIns()

void LiveRegUnits::addLiveIns ( const MachineBasicBlock & MBB)

Adds registers living into block MBB.

Definition at line 158 of file LiveRegUnits.cpp.

References addBlockLiveIns(), and MBB.

Referenced by llvm::SIFrameLowering::emitPrologue(), and initLiveUnits().

◆ addLiveOuts()

void LiveRegUnits::addLiveOuts ( const MachineBasicBlock & MBB)

Adds registers living out of block MBB.

Live out registers are the union of the live-in registers of the successor blocks and pristine registers. Live out registers of the end block are the callee saved registers.

Definition at line 145 of file LiveRegUnits.cpp.

References addBlockLiveOuts(), addCalleeSavedRegs(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::isCalleeSavedInfoValid(), and MBB.

Referenced by llvm::Thumb1InstrInfo::copyPhysReg(), expandSMEPPRToZPRSpillPseudos(), llvm::X86RegisterInfo::findDeadCallerSavedReg(), initLiveUnits(), and llvm::ARMBaseInstrInfo::isMBBSafeToOutlineFrom().

◆ addReg()

◆ addRegMasked()

void llvm::LiveRegUnits::addRegMasked ( MCRegister Reg,
LaneBitmask Mask )
inline

Adds register units covered by physical register Reg that are part of the lanemask Mask.

Definition at line 94 of file LiveRegUnits.h.

References llvm::MCRegUnitMaskIterator::isValid(), and Reg.

Referenced by addBlockLiveIns(), and addBlockLiveOuts().

◆ addRegsInMask()

void LiveRegUnits::addRegsInMask ( const uint32_t * RegMask)

Adds register units not preserved by the regmask RegMask.

The regmask has the same format as the one in the RegMask machine operand.

Definition at line 33 of file LiveRegUnits.cpp.

References llvm::MachineOperand::clobbersPhysReg(), and llvm::MCRegUnitRootIterator::isValid().

Referenced by accumulate(), and accumulateUsedDefed().

◆ addUnits()

void llvm::LiveRegUnits::addUnits ( const BitVector & RegUnits)
inline

Adds all register units marked in the bitvector RegUnits.

Definition at line 145 of file LiveRegUnits.h.

◆ available()

◆ clear()

void llvm::LiveRegUnits::clear ( )
inline

Clears the set.

Definition at line 81 of file LiveRegUnits.h.

◆ empty()

bool llvm::LiveRegUnits::empty ( ) const
inline

Returns true if the set is empty.

Definition at line 84 of file LiveRegUnits.h.

Referenced by llvm::SIFrameLowering::emitCSRSpillStores(), llvm::SIFrameLowering::emitPrologue(), and initLiveUnits().

◆ getBitVector()

const BitVector & llvm::LiveRegUnits::getBitVector ( ) const
inline

Return the internal bitvector representation of the set.

Definition at line 153 of file LiveRegUnits.h.

◆ init()

void llvm::LiveRegUnits::init ( const TargetRegisterInfo & TRI)
inline

◆ removeReg()

void llvm::LiveRegUnits::removeReg ( MCRegister Reg)
inline

Removes all register units covered by physical register Reg.

Definition at line 103 of file LiveRegUnits.h.

References Reg.

Referenced by buildPrologSpill(), llvm::SIFrameLowering::emitPrologue(), stepBackward(), and updateDefinedRegisters().

◆ removeRegsNotPreserved()

void LiveRegUnits::removeRegsNotPreserved ( const uint32_t * RegMask)

Removes register units not preserved by the regmask RegMask.

The regmask has the same format as the one in the RegMask machine operand.

Definition at line 22 of file LiveRegUnits.cpp.

References llvm::MachineOperand::clobbersPhysReg(), and llvm::MCRegUnitRootIterator::isValid().

Referenced by stepBackward().

◆ removeUnits()

void llvm::LiveRegUnits::removeUnits ( const BitVector & RegUnits)
inline

Removes all register units marked in the bitvector RegUnits.

Definition at line 149 of file LiveRegUnits.h.

◆ stepBackward()

void LiveRegUnits::stepBackward ( const MachineInstr & MI)

Updates liveness when stepping backwards over the instruction MI.

This removes all register units defined or clobbered in MI and then adds the units used (as in use operands) in MI.

Definition at line 44 of file LiveRegUnits.cpp.

References addReg(), MI, removeReg(), and removeRegsNotPreserved().

Referenced by llvm::Thumb1InstrInfo::copyPhysReg(), expandSMEPPRToZPRSpillPseudos(), llvm::X86RegisterInfo::findDeadCallerSavedReg(), and initLiveUnits().


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