LLVM
8.0.1
|
#include "llvm/CodeGen/RegisterScavenging.h"
Public Member Functions | |
RegScavenger ()=default | |
void | enterBasicBlock (MachineBasicBlock &MBB) |
Start tracking liveness from the begin of basic block MBB . More... | |
void | enterBasicBlockEnd (MachineBasicBlock &MBB) |
Start tracking liveness from the end of basic block MBB . More... | |
void | forward () |
Move the internal MBB iterator and update register states. More... | |
void | forward (MachineBasicBlock::iterator I) |
Move the internal MBB iterator and update register states until it has processed the specific iterator. More... | |
void | unprocess () |
Invert the behavior of forward() on the current instruction (undo the changes to the available registers made by forward()). More... | |
void | unprocess (MachineBasicBlock::iterator I) |
Unprocess instructions until you reach the provided iterator. More... | |
void | backward () |
Update internal register state and move MBB iterator backwards. More... | |
void | backward (MachineBasicBlock::iterator I) |
Call backward() as long as the internal iterator does not point to I . More... | |
void | skipTo (MachineBasicBlock::iterator I) |
Move the internal MBB iterator but do not update register states. More... | |
MachineBasicBlock::iterator | getCurrentPosition () const |
bool | isRegUsed (unsigned Reg, bool includeReserved=true) const |
Return if a specific register is currently used. More... | |
BitVector | getRegsAvailable (const TargetRegisterClass *RC) |
Return all available registers in the register class in Mask. More... | |
unsigned | FindUnusedReg (const TargetRegisterClass *RC) const |
Find an unused register of the specified register class. More... | |
void | addScavengingFrameIndex (int FI) |
Add a scavenging frame index. More... | |
bool | isScavengingFrameIndex (int FI) const |
Query whether a frame index is a scavenging frame index. More... | |
void | getScavengingFrameIndices (SmallVectorImpl< int > &A) const |
Get an array of scavenging frame indices. More... | |
unsigned | scavengeRegister (const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj) |
Make a register of the specific register class available and do the appropriate bookkeeping. More... | |
unsigned | scavengeRegister (const TargetRegisterClass *RegClass, int SPAdj) |
unsigned | scavengeRegisterBackwards (const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj) |
Make a register of the specific register class available from the current position backwards to the place before To . More... | |
void | setRegUsed (unsigned Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) |
Tell the scavenger a register is used. More... | |
Definition at line 35 of file RegisterScavenging.h.
|
default |
|
inline |
Add a scavenging frame index.
Definition at line 133 of file RegisterScavenging.h.
References llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::PPCFrameLowering::addScavengingSpillSlot(), llvm::MipsSEFrameLowering::determineCalleeSaves(), llvm::ARMFrameLowering::determineCalleeSaves(), llvm::AArch64FrameLowering::determineCalleeSaves(), llvm::HexagonFrameLowering::determineCalleeSaves(), llvm::RISCVFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SIFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SystemZFrameLowering::processFunctionBeforeFrameFinalized(), llvm::XCoreFrameLowering::processFunctionBeforeFrameFinalized(), and llvm::ARCFrameLowering::processFunctionBeforeFrameFinalized().
void RegScavenger::backward | ( | ) |
Update internal register state and move MBB iterator backwards.
Contrary to unprocess() this method gives precise results even in the absence of kill flags.
Definition at line 261 of file RegisterScavenging.cpp.
References assert(), llvm::MachineBasicBlock::begin(), I, MI, and llvm::LiveRegUnits::stepBackward().
Referenced by backward(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), scavengeFrameVirtualRegsInBlock(), and unprocess().
|
inline |
Call backward() as long as the internal iterator does not point to I
.
Definition at line 108 of file RegisterScavenging.h.
References backward().
void RegScavenger::enterBasicBlock | ( | MachineBasicBlock & | MBB | ) |
Start tracking liveness from the begin of basic block MBB
.
Definition at line 84 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addLiveIns(), and llvm::cl::init().
Referenced by llvm::SIInstrInfo::calculateLDSSpillAddress(), INITIALIZE_PASS(), llvm::Mips16InstrInfo::loadImmediate(), and llvm::PPCFrameLowering::replaceFPWithRealFP().
void RegScavenger::enterBasicBlockEnd | ( | MachineBasicBlock & | MBB | ) |
Start tracking liveness from the end of basic block MBB
.
Use backward() to move towards the beginning of the block. This is preferred to enterBasicBlock() and forward() because it does not depend on the presence of kill flags.
Definition at line 89 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addLiveOuts(), addRegUnits(), assert(), llvm::MachineBasicBlock::begin(), llvm::BitVector::clear(), llvm::MachineBasicBlock::end(), llvm::cl::init(), llvm::MachineInstr::isDebugInstr(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MCRegisterInfo::DiffListIterator::isValid(), llvm::MCRegUnitRootIterator::isValid(), MI, llvm::MachineInstr::operands(), Reg, llvm::BitVector::reset(), llvm::BitVector::set(), and TRI.
Referenced by llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and scavengeFrameVirtualRegsInBlock().
unsigned RegScavenger::FindUnusedReg | ( | const TargetRegisterClass * | RC | ) | const |
Find an unused register of the specified register class.
Return 0 if none is found.
Definition at line 288 of file RegisterScavenging.cpp.
References llvm::dbgs(), isRegUsed(), LLVM_DEBUG, llvm::printReg(), Reg, and TRI.
Referenced by buildMUBUFOffsetLoadStore(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), getCurrentPosition(), INITIALIZE_PASS(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and ReplaceFrameIndex().
void RegScavenger::forward | ( | ) |
Move the internal MBB iterator and update register states.
Definition at line 176 of file RegisterScavenging.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::MachineBasicBlock::begin(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getParent(), I, llvm::ARM_PROC::IE, llvm::TargetRegisterInfo::isPhysicalRegister(), isRegUsed(), llvm::MCRegisterInfo::DiffListIterator::isValid(), llvm_unreachable, MI, MRI, TRI, and llvm::MachineFunction::verify().
Referenced by forward(), INITIALIZE_PASS(), llvm::Mips16InstrInfo::loadImmediate(), and llvm::PPCFrameLowering::replaceFPWithRealFP().
|
inline |
Move the internal MBB iterator and update register states until it has processed the specific iterator.
Definition at line 88 of file RegisterScavenging.h.
References llvm::MachineBasicBlock::begin(), forward(), I, and unprocess().
|
inline |
Definition at line 120 of file RegisterScavenging.h.
References FindUnusedReg(), getRegsAvailable(), isRegUsed(), and Reg.
BitVector RegScavenger::getRegsAvailable | ( | const TargetRegisterClass * | RC | ) |
Return all available registers in the register class in Mask.
Definition at line 299 of file RegisterScavenging.cpp.
References assert(), llvm::BitVector::clearBitsNotInMask(), llvm::BitVector::find_first(), llvm::MachineBasicBlock::getFirstTerminator(), InstrLimit, isRegUsed(), llvm::MCRegAliasIterator::isValid(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::BitmaskEnumDetail::Mask(), MI, llvm::BitVector::none(), llvm::BitVector::reset(), llvm::BitVector::test(), TRI, and UseMI.
Referenced by getCurrentPosition(), llvm::Mips16InstrInfo::loadImmediate(), llvm::PPCFrameLowering::replaceFPWithRealFP(), and scavengeRegister().
|
inline |
Get an array of scavenging frame indices.
Definition at line 148 of file RegisterScavenging.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::end(), I, llvm::ARM_PROC::IE, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and scavengeRegister().
Return if a specific register is currently used.
Definition at line 282 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::available().
Referenced by FindUnusedReg(), forward(), getCurrentPosition(), getRegsAvailable(), llvm::PPCFrameLowering::replaceFPWithRealFP(), llvm::SIRegisterInfo::restoreSGPR(), scavengeRegister(), and llvm::SIRegisterInfo::spillSGPR().
|
inline |
Query whether a frame index is a scavenging frame index.
Definition at line 138 of file RegisterScavenging.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::end(), I, and llvm::ARM_PROC::IE.
Referenced by llvm::ThumbRegisterInfo::eliminateFrameIndex(), llvm::AArch64RegisterInfo::eliminateFrameIndex(), and llvm::ARMBaseRegisterInfo::eliminateFrameIndex().
unsigned RegScavenger::scavengeRegister | ( | const TargetRegisterClass * | RC, |
MachineBasicBlock::iterator | I, | ||
int | SPAdj | ||
) |
Make a register of the specific register class available and do the appropriate bookkeeping.
SPAdj is the stack adjustment due to call frame, it's passed along to eliminateFrameIndex(). Returns the scavenged register. This is deprecated as it depends on the quality of the kill flags being present; Use scavengeRegisterBackwards() instead!
Definition at line 535 of file RegisterScavenging.cpp.
References llvm::BitVector::any(), llvm::dbgs(), llvm::MachineInstr::getMF(), getRegsAvailable(), I, isRegUsed(), llvm::MCRegAliasIterator::isValid(), llvm::TargetRegisterInfo::isVirtualRegister(), LLVM_DEBUG, MI, llvm::MachineInstr::operands(), llvm::printReg(), llvm::BitVector::reset(), TRI, and UseMI.
Referenced by llvm::SIInstrInfo::calculateLDSSpillAddress(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), getScavengingFrameIndices(), InsertFPConstInst(), InsertSPConstInst(), ReplaceFrameIndex(), and scavengeRegister().
|
inline |
Definition at line 163 of file RegisterScavenging.h.
References llvm::LiveRegUnits::addUnits(), llvm::LaneBitmask::getAll(), InstrLimit, llvm::MachineRegisterInfo::isReserved(), llvm::LiveRegUnits::removeUnits(), llvm::scavengeFrameVirtualRegs(), scavengeRegister(), scavengeRegisterBackwards(), setRegUsed(), and UseMI.
unsigned RegScavenger::scavengeRegisterBackwards | ( | const TargetRegisterClass & | RC, |
MachineBasicBlock::iterator | To, | ||
bool | RestoreAfter, | ||
int | SPAdj | ||
) |
Make a register of the specific register class available from the current position backwards to the place before To
.
If RestoreAfter
is true this includes the instruction following the current position. SPAdj is the stack adjustment due to call frame, it's passed along to eliminateFrameIndex(). Returns the scavenged register.
Definition at line 577 of file RegisterScavenging.cpp.
References assert(), llvm::dbgs(), llvm::MachineBasicBlock::end(), findSurvivorBackwards(), llvm::MachineBasicBlock::getParent(), llvm::TargetRegisterClass::getRawAllocationOrder(), LLVM_DEBUG, MRI, P, llvm::printReg(), Reg, llvm::LiveRegUnits::removeReg(), TRI, and UseMI.
Referenced by llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), scavengeRegister(), and scavengeVReg().
void RegScavenger::setRegUsed | ( | unsigned | Reg, |
LaneBitmask | LaneMask = LaneBitmask::getAll() |
||
) |
Tell the scavenger a register is used.
Definition at line 53 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addRegMasked(), assert(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::LiveRegUnits::init(), MRI, llvm::BitVector::resize(), SI, TII, and TRI.
Referenced by InsertFPConstInst(), llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), InsertSPConstInst(), ReplaceFrameIndex(), scavengeFrameVirtualRegsInBlock(), and scavengeRegister().
|
inline |
Move the internal MBB iterator but do not update register states.
Definition at line 114 of file RegisterScavenging.h.
References I.
void RegScavenger::unprocess | ( | ) |
Invert the behavior of forward() on the current instruction (undo the changes to the available registers made by forward()).
Definition at line 157 of file RegisterScavenging.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineInstr::isDebugInstr(), and MI.
Referenced by forward(), and unprocess().
|
inline |
Unprocess instructions until you reach the provided iterator.
Definition at line 98 of file RegisterScavenging.h.
References backward(), and unprocess().