LLVM  13.0.0git
Public Member Functions | Static Public Member Functions | List of all members
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. More...
 
 LiveRegUnits (const TargetRegisterInfo &TRI)
 Constructs and initialize an empty LiveRegUnits set. More...
 
void init (const TargetRegisterInfo &TRI)
 Initialize and clear the set. More...
 
void clear ()
 Clears the set. More...
 
bool empty () const
 Returns true if the set is empty. More...
 
void addReg (MCPhysReg Reg)
 Adds register units covered by physical register Reg. More...
 
void addRegMasked (MCPhysReg Reg, LaneBitmask Mask)
 Adds register units covered by physical register Reg that are part of the lanemask Mask. More...
 
void removeReg (MCPhysReg Reg)
 Removes all register units covered by physical register Reg. More...
 
void removeRegsNotPreserved (const uint32_t *RegMask)
 Removes register units not preserved by the regmask RegMask. More...
 
void addRegsInMask (const uint32_t *RegMask)
 Adds register units not preserved by the regmask RegMask. More...
 
bool available (MCPhysReg Reg) const
 Returns true if no part of physical register Reg is live. More...
 
void stepBackward (const MachineInstr &MI)
 Updates liveness when stepping backwards over the instruction MI. More...
 
void accumulate (const MachineInstr &MI)
 Adds all register units used, defined or clobbered in MI. More...
 
void addLiveOuts (const MachineBasicBlock &MBB)
 Adds registers living out of block MBB. More...
 
void addLiveIns (const MachineBasicBlock &MBB)
 Adds registers living into block MBB. More...
 
void addUnits (const BitVector &RegUnits)
 Adds all register units marked in the bitvector RegUnits. More...
 
void removeUnits (const BitVector &RegUnits)
 Removes all register units marked in the bitvector RegUnits. More...
 
const BitVectorgetBitVector () const
 Return the internal bitvector representation of the set. More...
 

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

Detailed Description

A set of register units used to track register liveness.

Definition at line 30 of file LiveRegUnits.h.

Constructor & Destructor Documentation

◆ LiveRegUnits() [1/2]

llvm::LiveRegUnits::LiveRegUnits ( )
default

Constructs a new empty LiveRegUnits set.

◆ LiveRegUnits() [2/2]

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

Constructs and initialize an empty LiveRegUnits set.

Definition at line 39 of file LiveRegUnits.h.

References init(), and TRI.

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 60 of file LiveRegUnits.cpp.

References addReg(), addRegsInMask(), MI, and llvm::phys_regs_and_masks().

Referenced by canRenameUpToDef(), findSurvivorBackwards(), and llvm::outliner::Candidate::initLRU().

◆ accumulateUsedDefed()

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

Definition at line 47 of file LiveRegUnits.h.

References addReg(), addRegsInMask(), assert(), MI, llvm::RISCVFenceField::O, Reg, and TRI.

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

◆ addLiveIns()

void LiveRegUnits::addLiveIns ( const MachineBasicBlock MBB)

Adds registers living into block MBB.

Definition at line 141 of file LiveRegUnits.cpp.

References addBlockLiveIns(), llvm::MachineBasicBlock::getParent(), and MBB.

Referenced by llvm::RegScavenger::enterBasicBlock().

◆ 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 124 of file LiveRegUnits.cpp.

References addBlockLiveIns(), addCalleeSavedRegs(), llvm::MachineFunction::getFrameInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFrameInfo::isCalleeSavedInfoValid(), llvm::MachineBasicBlock::isReturnBlock(), MBB, and llvm::MachineBasicBlock::successors().

Referenced by llvm::RegScavenger::enterBasicBlockEnd(), llvm::outliner::Candidate::initLRU(), llvm::AArch64InstrInfo::isMBBSafeToOutlineFrom(), and llvm::ARMBaseInstrInfo::isMBBSafeToOutlineFrom().

◆ addReg()

void llvm::LiveRegUnits::addReg ( MCPhysReg  Reg)
inline

◆ addRegMasked()

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

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

Definition at line 93 of file LiveRegUnits.h.

References llvm::MCRegUnitMaskIterator::isValid(), llvm::BitmaskEnumDetail::Mask(), llvm::LaneBitmask::none(), Reg, llvm::BitVector::set(), and TRI.

Referenced by addBlockLiveIns(), and llvm::RegScavenger::setRegUsed().

◆ 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 31 of file LiveRegUnits.cpp.

References llvm::MachineOperand::clobbersPhysReg(), E, llvm::MCRegisterInfo::getNumRegUnits(), llvm::MCRegUnitRootIterator::isValid(), and llvm::BitVector::set().

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 144 of file LiveRegUnits.h.

◆ available()

bool llvm::LiveRegUnits::available ( MCPhysReg  Reg) const
inline

◆ clear()

void llvm::LiveRegUnits::clear ( )
inline

Clears the set.

Definition at line 80 of file LiveRegUnits.h.

References llvm::BitVector::reset().

Referenced by INITIALIZE_PASS().

◆ empty()

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

Returns true if the set is empty.

Definition at line 83 of file LiveRegUnits.h.

References llvm::BitVector::none().

◆ getBitVector()

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

Return the internal bitvector representation of the set.

Definition at line 152 of file LiveRegUnits.h.

◆ init()

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

Initialize and clear the set.

Definition at line 73 of file LiveRegUnits.h.

References llvm::BitVector::reset(), llvm::BitVector::resize(), and TRI.

Referenced by llvm::outliner::Candidate::initLRU(), and LiveRegUnits().

◆ removeReg()

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

Removes all register units covered by physical register Reg.

Definition at line 102 of file LiveRegUnits.h.

References llvm::MCRegisterInfo::DiffListIterator::isValid(), Reg, llvm::BitVector::reset(), and TRI.

Referenced by llvm::RegScavenger::scavengeRegisterBackwards(), 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(), E, llvm::MCRegisterInfo::getNumRegUnits(), llvm::MCRegUnitRootIterator::isValid(), and llvm::BitVector::reset().

Referenced by stepBackward().

◆ removeUnits()

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

Removes all register units marked in the bitvector RegUnits.

Definition at line 148 of file LiveRegUnits.h.

References llvm::BitVector::reset().

◆ 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 40 of file LiveRegUnits.cpp.

References addReg(), MI, llvm::phys_regs_and_masks(), removeReg(), and removeRegsNotPreserved().

Referenced by llvm::RegScavenger::backward(), and llvm::outliner::Candidate::initLRU().


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