LLVM  8.0.1
Public Types | Public Member Functions | List of all members
llvm::LivePhysRegs Class Reference

A set of physical registers with utility functions to track liveness when walking backward/forward through a basic block. More...

#include "llvm/CodeGen/LivePhysRegs.h"

Public Types

using const_iterator = RegisterSet::const_iterator
 

Public Member Functions

 LivePhysRegs ()=default
 Constructs an unitialized set. init() needs to be called to initialize it. More...
 
 LivePhysRegs (const TargetRegisterInfo &TRI)
 Constructs and initializes an empty set. More...
 
 LivePhysRegs (const LivePhysRegs &)=delete
 
LivePhysRegsoperator= (const LivePhysRegs &)=delete
 
void init (const TargetRegisterInfo &TRI)
 (re-)initializes and clears 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 a physical register and all its sub-registers to the set. More...
 
void removeReg (MCPhysReg Reg)
 Removes a physical register, all its sub-registers, and all its super-registers from the set. More...
 
void removeRegsInMask (const MachineOperand &MO, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> *Clobbers=nullptr)
 Removes physical registers clobbered by the regmask operand MO. More...
 
bool contains (MCPhysReg Reg) const
 Returns true if register Reg is contained in the set. More...
 
bool available (const MachineRegisterInfo &MRI, MCPhysReg Reg) const
 Returns true if register Reg and no aliasing register is in the set. More...
 
void removeDefs (const MachineInstr &MI)
 Remove defined registers and regmask kills from the set. More...
 
void addUses (const MachineInstr &MI)
 Add uses to the set. More...
 
void stepBackward (const MachineInstr &MI)
 Simulates liveness when stepping backwards over an instruction(bundle). More...
 
void stepForward (const MachineInstr &MI, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> &Clobbers)
 Simulates liveness when stepping forward over an instruction(bundle). More...
 
void addLiveIns (const MachineBasicBlock &MBB)
 Adds all live-in registers of basic block MBB. More...
 
void addLiveOuts (const MachineBasicBlock &MBB)
 Adds all live-out registers of basic block MBB. More...
 
void addLiveOutsNoPristines (const MachineBasicBlock &MBB)
 Adds all live-out registers of basic block MBB but skips pristine registers. More...
 
const_iterator begin () const
 
const_iterator end () const
 
void print (raw_ostream &OS) const
 Prints the currently live registers to OS. More...
 
void dump () const
 Dumps the currently live registers to the debug output. More...
 

Detailed Description

A set of physical registers with utility functions to track liveness when walking backward/forward through a basic block.

Definition at line 49 of file LivePhysRegs.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 147 of file LivePhysRegs.h.

Constructor & Destructor Documentation

◆ LivePhysRegs() [1/3]

llvm::LivePhysRegs::LivePhysRegs ( )
default

Constructs an unitialized set. init() needs to be called to initialize it.

Referenced by LivePhysRegs().

◆ LivePhysRegs() [2/3]

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

Constructs and initializes an empty set.

Definition at line 59 of file LivePhysRegs.h.

References llvm::MCRegisterInfo::getNumRegs(), LivePhysRegs(), operator=(), and llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::setUniverse().

◆ LivePhysRegs() [3/3]

llvm::LivePhysRegs::LivePhysRegs ( const LivePhysRegs )
delete

Member Function Documentation

◆ addLiveIns()

void LivePhysRegs::addLiveIns ( const MachineBasicBlock MBB)

Adds all live-in registers of basic block MBB.

Live in registers are the registers in the blocks live-in list and the pristine registers.

Definition at line 241 of file LivePhysRegs.cpp.

References llvm::MachineBasicBlock::getParent().

Referenced by llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), llvm::computeAndAddLiveIns(), contains(), findScratchNonCalleeSaveRegister(), llvm::operator<<(), and UpdatePredRedefs().

◆ addLiveOuts()

void LivePhysRegs::addLiveOuts ( const MachineBasicBlock MBB)

Adds all live-out registers of basic 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 235 of file LivePhysRegs.cpp.

References addLiveOutsNoPristines(), and llvm::MachineBasicBlock::getParent().

Referenced by ComputeCommonTailLength(), contains(), findTemporariesForLR(), llvm::ScheduleDAGInstrs::fixupKills(), getLiveRegsAt(), INITIALIZE_PASS(), mergeOperations(), and llvm::X86InstrInfo::replaceBranchWithTailCall().

◆ addLiveOutsNoPristines()

void LivePhysRegs::addLiveOutsNoPristines ( const MachineBasicBlock MBB)

◆ addReg()

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

◆ addUses()

void LivePhysRegs::addUses ( const MachineInstr MI)

◆ available()

bool LivePhysRegs::available ( const MachineRegisterInfo MRI,
MCPhysReg  Reg 
) const

◆ begin()

const_iterator llvm::LivePhysRegs::begin ( ) const
inline

Definition at line 149 of file LivePhysRegs.h.

References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::begin().

Referenced by print().

◆ clear()

void llvm::LivePhysRegs::clear ( )
inline

Clears the set.

Definition at line 74 of file LivePhysRegs.h.

References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::clear().

Referenced by ComputeCommonTailLength(), and mergeOperations().

◆ contains()

bool llvm::LivePhysRegs::contains ( MCPhysReg  Reg) const
inline

Returns true if register Reg is contained in the set.

This also works if only the super register of Reg has been defined, because addReg() always adds all sub-registers to the set as well. Note: Returns false if just some sub registers are live, use available() when searching a free register.

Definition at line 107 of file LivePhysRegs.h.

References addLiveIns(), addLiveOuts(), addLiveOutsNoPristines(), addUses(), available(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::count(), MI, MRI, Reg, removeDefs(), stepBackward(), and stepForward().

Referenced by llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), and findTemporariesForLR().

◆ dump()

LLVM_DUMP_METHOD void LivePhysRegs::dump ( ) const

Dumps the currently live registers to the debug output.

Definition at line 139 of file LivePhysRegs.cpp.

References llvm::dbgs().

Referenced by end().

◆ empty()

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

Returns true if the set is empty.

Definition at line 77 of file LivePhysRegs.h.

References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::empty().

Referenced by addCalleeSavedRegs(), and print().

◆ end()

const_iterator llvm::LivePhysRegs::end ( ) const
inline

Definition at line 150 of file LivePhysRegs.h.

References dump(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::end(), and print().

Referenced by print().

◆ init()

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

◆ operator=()

LivePhysRegs& llvm::LivePhysRegs::operator= ( const LivePhysRegs )
delete

Referenced by LivePhysRegs().

◆ print()

void LivePhysRegs::print ( raw_ostream OS) const

Prints the currently live registers to OS.

Prin the currently live registers to OS.

Definition at line 121 of file LivePhysRegs.cpp.

References begin(), E, empty(), end(), I, and llvm::printReg().

Referenced by end(), and llvm::operator<<().

◆ removeDefs()

void LivePhysRegs::removeDefs ( const MachineInstr MI)

Remove defined registers and regmask kills from the set.

Definition at line 45 of file LivePhysRegs.cpp.

References llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::RISCVFenceField::O, Reg, removeReg(), and removeRegsInMask().

Referenced by contains(), llvm::recomputeLivenessFlags(), and stepBackward().

◆ removeReg()

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

Removes a physical register, all its sub-registers, and all its super-registers from the set.

Definition at line 90 of file LivePhysRegs.h.

References assert(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::erase(), and removeRegsInMask().

Referenced by addCalleeSavedRegs(), llvm::ScheduleDAGInstrs::fixupKills(), removeDefs(), and stepForward().

◆ removeRegsInMask()

void LivePhysRegs::removeRegsInMask ( const MachineOperand MO,
SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> *  Clobbers = nullptr 
)

Removes physical registers clobbered by the regmask operand MO.

Remove all registers from the set that get clobbered by the register mask.

The clobbers set will be the list of live registers clobbered by the regmask.

Definition at line 31 of file LivePhysRegs.cpp.

References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::begin(), llvm::MachineOperand::clobbersPhysReg(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::end(), and llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::erase().

Referenced by llvm::ScheduleDAGInstrs::fixupKills(), removeDefs(), removeReg(), and stepForward().

◆ stepBackward()

void LivePhysRegs::stepBackward ( const MachineInstr MI)

Simulates liveness when stepping backwards over an instruction(bundle).

Simulates liveness when stepping backwards over an instruction(bundle): Remove Defs, add uses.

Remove Defs, add uses. This is the recommended way of calculating liveness.

This is the recommended way of calculating liveness.

Definition at line 73 of file LivePhysRegs.cpp.

References addUses(), and removeDefs().

Referenced by ComputeCommonTailLength(), llvm::computeLiveIns(), contains(), findTemporariesForLR(), and getLiveRegsAt().

◆ stepForward()

void LivePhysRegs::stepForward ( const MachineInstr MI,
SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> &  Clobbers 
)

Simulates liveness when stepping forward over an instruction(bundle).

Simulates liveness when stepping forward over an instruction(bundle): Remove killed-uses, add defs.

Remove killed-uses, add defs. This is the not recommended way, because it depends on accurate kill flags. If possible use stepBackward() instead of this function. The clobbers set will be the list of registers either defined or clobbered by a regmask. The operand will identify whether this is a regmask or register operand.

This is the not recommended way, because it depends on accurate kill flags. If possible use stepBackward() instead of this function.

Definition at line 85 of file LivePhysRegs.cpp.

References addReg(), assert(), llvm::MachineOperand::clobbersPhysReg(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::RISCVFenceField::O, Reg, removeReg(), and removeRegsInMask().

Referenced by llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), contains(), llvm::X86InstrInfo::replaceBranchWithTailCall(), and UpdatePredRedefs().


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