|
LLVM
5.0.0
|
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 = SparseSet< unsigned >::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 | |
| LivePhysRegs & | operator= (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 (unsigned Reg) |
| Adds a physical register and all its sub-registers to the set. More... | |
| void | removeReg (unsigned 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< unsigned, const MachineOperand * >> *Clobbers=nullptr) |
Removes physical registers clobbered by the regmask operand MO. More... | |
| bool | contains (unsigned Reg) const |
Returns true if register Reg is contained in the set. More... | |
| bool | available (const MachineRegisterInfo &MRI, unsigned Reg) const |
Returns true if register Reg and no aliasing register is in 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< unsigned, 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... | |
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.
Definition at line 140 of file LivePhysRegs.h.
|
default |
Constructs an unitialized set. init() needs to be called to initialize it.
|
inline |
Constructs and initializes an empty set.
Definition at line 58 of file LivePhysRegs.h.
References llvm::MCRegisterInfo::getNumRegs(), and llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::setUniverse().
|
delete |
| 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 213 of file LivePhysRegs.cpp.
References addPristines(), and llvm::MachineBasicBlock::getParent().
Referenced by findScratchNonCalleeSaveRegister().
| 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 200 of file LivePhysRegs.cpp.
References addCalleeSavedRegs(), addLiveOutsNoPristines(), addPristines(), llvm::MachineFunction::getFrameInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFrameInfo::isCalleeSavedInfoValid(), llvm::MachineBasicBlock::isReturnBlock(), and llvm::MachineBasicBlock::succ_empty().
Referenced by llvm::X86InstrInfo::copyPhysReg(), getLiveRegsAt(), and llvm::X86InstrInfo::replaceBranchWithTailCall().
| void LivePhysRegs::addLiveOutsNoPristines | ( | const MachineBasicBlock & | MBB | ) |
Adds all live-out registers of basic block MBB but skips pristine registers.
Definition at line 182 of file LivePhysRegs.cpp.
References addReg(), llvm::MachineFrameInfo::getCalleeSavedInfo(), llvm::MachineFunction::getFrameInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFrameInfo::isCalleeSavedInfoValid(), llvm::MachineBasicBlock::isReturnBlock(), llvm::MachineBasicBlock::succ_empty(), and llvm::MachineBasicBlock::successors().
Referenced by addLiveOuts(), and llvm::computeLiveIns().
|
inline |
Adds a physical register and all its sub-registers to the set.
Definition at line 79 of file LivePhysRegs.h.
References assert(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::insert(), and llvm::MCRegisterInfo::DiffListIterator::isValid().
Referenced by addCalleeSavedRegs(), addLiveOutsNoPristines(), findScratchNonCalleeSaveRegister(), stepBackward(), stepForward(), and toggleKills().
| bool LivePhysRegs::available | ( | const MachineRegisterInfo & | MRI, |
| unsigned | Reg | ||
| ) | const |
Returns true if register Reg and no aliasing register is in the set.
Definition at line 129 of file LivePhysRegs.cpp.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::count(), llvm::MachineRegisterInfo::isReserved(), and llvm::MCRegAliasIterator::isValid().
Referenced by llvm::HexagonInstrInfo::expandPostRAPseudo(), findScratchNonCalleeSaveRegister(), and toggleKills().
|
inline |
Definition at line 142 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::begin().
Referenced by print().
|
inline |
Clears the set.
Definition at line 73 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::clear().
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 106 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::count().
Referenced by llvm::X86InstrInfo::copyPhysReg(), and RemoveKills().
| LLVM_DUMP_METHOD void LivePhysRegs::dump | ( | ) | const |
Dumps the currently live registers to the debug output.
Definition at line 124 of file LivePhysRegs.cpp.
References llvm::dbgs().
|
inline |
Returns true if the set is empty.
Definition at line 76 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::empty().
Referenced by print().
|
inline |
Definition at line 143 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::end().
Referenced by print().
|
inline |
(re-)initializes and clears the set.
Definition at line 66 of file LivePhysRegs.h.
References llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::clear(), llvm::MCRegisterInfo::getNumRegs(), and llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::setUniverse().
Referenced by llvm::computeLiveIns().
|
delete |
| void LivePhysRegs::print | ( | raw_ostream & | OS | ) | const |
Prints the currently live registers to OS.
Prin the currently live registers to OS.
Definition at line 106 of file LivePhysRegs.cpp.
References begin(), E, empty(), end(), I, and llvm::PrintReg().
Referenced by llvm::operator<<().
|
inline |
Removes a physical register, all its sub-registers, and all its super-registers from the set.
Definition at line 89 of file LivePhysRegs.h.
References assert(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::erase(), and llvm::MCRegAliasIterator::isValid().
Referenced by addPristines(), stepBackward(), and stepForward().
| void LivePhysRegs::removeRegsInMask | ( | const MachineOperand & | MO, |
| SmallVectorImpl< std::pair< unsigned, 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 30 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 stepBackward(), and stepForward().
| 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 45 of file LivePhysRegs.cpp.
References addReg(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperandIteratorBase::isValid(), removeReg(), and removeRegsInMask().
Referenced by llvm::computeLiveIns(), llvm::X86InstrInfo::copyPhysReg(), and getLiveRegsAt().
| void LivePhysRegs::stepForward | ( | const MachineInstr & | MI, |
| SmallVectorImpl< std::pair< unsigned, 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 74 of file LivePhysRegs.cpp.
References addReg(), assert(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperandIteratorBase::isValid(), removeReg(), and removeRegsInMask().
Referenced by llvm::X86InstrInfo::replaceBranchWithTailCall().
1.8.6