LLVM 20.0.0git
|
#include "llvm/CodeGen/RegisterScavenging.h"
Public Member Functions | |
RegScavenger ()=default | |
void | assignRegToScavengingIndex (int FI, Register Reg, MachineInstr *Restore=nullptr) |
Record that Reg is in use at scavenging index FI . | |
void | enterBasicBlock (MachineBasicBlock &MBB) |
Start tracking liveness from the begin of basic block MBB . | |
void | enterBasicBlockEnd (MachineBasicBlock &MBB) |
Start tracking liveness from the end of basic block MBB . | |
void | backward () |
Update internal register state and move MBB iterator backwards. | |
void | backward (MachineBasicBlock::iterator I) |
Call backward() to update internal register state to just before *I . | |
bool | isRegUsed (Register Reg, bool includeReserved=true) const |
Return if a specific register is currently used. | |
BitVector | getRegsAvailable (const TargetRegisterClass *RC) |
Return all available registers in the register class in Mask. | |
Register | FindUnusedReg (const TargetRegisterClass *RC) const |
Find an unused register of the specified register class. | |
void | addScavengingFrameIndex (int FI) |
Add a scavenging frame index. | |
bool | isScavengingFrameIndex (int FI) const |
Query whether a frame index is a scavenging frame index. | |
void | getScavengingFrameIndices (SmallVectorImpl< int > &A) const |
Get an array of scavenging frame indices. | |
Register | scavengeRegisterBackwards (const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj, bool AllowSpill=true) |
Make a register of the specific register class available from the current position backwards to the place before To . | |
void | setRegUsed (Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) |
Tell the scavenger a register is used. | |
Definition at line 34 of file RegisterScavenging.h.
|
default |
|
inline |
Add a scavenging frame index.
Definition at line 112 of file RegisterScavenging.h.
References llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::PPCFrameLowering::addScavengingSpillSlot(), llvm::AArch64FrameLowering::determineCalleeSaves(), llvm::ARMFrameLowering::determineCalleeSaves(), llvm::CSKYFrameLowering::determineCalleeSaves(), llvm::HexagonFrameLowering::determineCalleeSaves(), llvm::MipsSEFrameLowering::determineCalleeSaves(), llvm::ARCFrameLowering::processFunctionBeforeFrameFinalized(), llvm::LoongArchFrameLowering::processFunctionBeforeFrameFinalized(), llvm::RISCVFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SystemZELFFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SystemZXPLINKFrameLowering::processFunctionBeforeFrameFinalized(), llvm::XtensaFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SIFrameLowering::processFunctionBeforeFrameFinalized(), and llvm::XCoreFrameLowering::processFunctionBeforeFrameFinalized().
|
inline |
Record that Reg
is in use at scavenging index FI
.
This is for targets which need to directly manage the spilling process, and need to update the scavenger's internal state. It's expected this be called a second time with Restore
set to a non-null value, so that the externally inserted restore instruction resets the scavenged slot liveness when encountered.
Definition at line 70 of file RegisterScavenging.h.
References assert(), llvm_unreachable, and Reg.
Referenced by llvm::SGPRSpillBuilder::prepare(), and llvm::SGPRSpillBuilder::restore().
void RegScavenger::backward | ( | ) |
Update internal register state and move MBB iterator backwards.
This method gives precise results even in the absence of kill flags.
Definition at line 82 of file RegisterScavenging.cpp.
References I, MI, and llvm::LiveRegUnits::stepBackward().
Referenced by analyzeCompressibleUses(), backward(), indirectCopyToAGPR(), llvm::Mips16InstrInfo::loadImmediate(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), llvm::SIFrameLowering::processFunctionBeforeFrameFinalized(), and scavengeFrameVirtualRegsInBlock().
|
inline |
Call backward() to update internal register state to just before *I
.
Definition at line 96 of file RegisterScavenging.h.
References backward(), I, and MBBI.
void RegScavenger::enterBasicBlock | ( | MachineBasicBlock & | MBB | ) |
Start tracking liveness from the begin of basic block MBB
.
Definition at line 70 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addLiveIns(), llvm::MachineBasicBlock::begin(), and MBB.
Referenced by llvm::RISCVFrameLowering::canUseAsPrologue(), and llvm::SIInstrInfo::insertIndirectBranch().
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.
Definition at line 76 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addLiveOuts(), llvm::MachineBasicBlock::end(), and MBB.
Referenced by analyzeCompressibleUses(), indirectCopyToAGPR(), llvm::AArch64InstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), llvm::LoongArchInstrInfo::insertIndirectBranch(), llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::Mips16InstrInfo::loadImmediate(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), llvm::SIFrameLowering::processFunctionBeforeFrameFinalized(), and scavengeFrameVirtualRegsInBlock().
Register RegScavenger::FindUnusedReg | ( | const TargetRegisterClass * | RC | ) | const |
Find an unused register of the specified register class.
Return 0 if none is found.
Definition at line 101 of file RegisterScavenging.cpp.
References llvm::dbgs(), isRegUsed(), LLVM_DEBUG, and llvm::printReg().
Referenced by llvm::LanaiRegisterInfo::eliminateFrameIndex(), llvm::AArch64InstrInfo::insertIndirectBranch(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and replaceFrameIndex().
BitVector RegScavenger::getRegsAvailable | ( | const TargetRegisterClass * | RC | ) |
Return all available registers in the register class in Mask.
Definition at line 112 of file RegisterScavenging.cpp.
References llvm::MCRegisterInfo::getNumRegs(), and isRegUsed().
Referenced by llvm::PPCRegisterInfo::eliminateFrameIndex(), and llvm::Mips16InstrInfo::loadImmediate().
|
inline |
Get an array of scavenging frame indices.
Definition at line 126 of file RegisterScavenging.h.
Return if a specific register is currently used.
Definition at line 95 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::available().
Referenced by llvm::SIRegisterInfo::buildSpillLoadStore(), llvm::RISCVFrameLowering::canUseAsPrologue(), llvm::SIRegisterInfo::eliminateFrameIndex(), FindUnusedReg(), llvm::SIInstrInfo::getAddNoCarry(), getRegsAvailable(), llvm::AArch64InstrInfo::insertIndirectBranch(), llvm::SGPRSpillBuilder::prepare(), and llvm::SGPRSpillBuilder::readWriteTmpVGPR().
|
inline |
Query whether a frame index is a scavenging frame index.
Definition at line 117 of file RegisterScavenging.h.
Referenced by llvm::AArch64RegisterInfo::eliminateFrameIndex(), llvm::ARMBaseRegisterInfo::eliminateFrameIndex(), and llvm::ThumbRegisterInfo::eliminateFrameIndex().
Register RegScavenger::scavengeRegisterBackwards | ( | const TargetRegisterClass & | RC, |
MachineBasicBlock::iterator | To, | ||
bool | RestoreAfter, | ||
int | SPAdj, | ||
bool | AllowSpill = true |
||
) |
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.
If AllowSpill
is false, fail if a spill is required to make the register available, and return NoRegister.
Definition at line 296 of file RegisterScavenging.cpp.
References assert(), llvm::dbgs(), llvm::MachineBasicBlock::end(), findSurvivorBackwards(), llvm::MachineBasicBlock::getParent(), llvm::TargetRegisterClass::getRawAllocationOrder(), LLVM_DEBUG, MBB, P, llvm::printReg(), llvm::LiveRegUnits::removeReg(), and UseMI.
Referenced by analyzeCompressibleUses(), llvm::SIRegisterInfo::buildSpillLoadStore(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), llvm::SIRegisterInfo::eliminateFrameIndex(), llvm::SIInstrInfo::getAddNoCarry(), indirectCopyToAGPR(), InsertFPConstInst(), llvm::SIInstrInfo::insertIndirectBranch(), llvm::LoongArchInstrInfo::insertIndirectBranch(), llvm::RISCVInstrInfo::insertIndirectBranch(), InsertSPConstInst(), llvm::SGPRSpillBuilder::prepare(), replaceFrameIndex(), and scavengeVReg().
void RegScavenger::setRegUsed | ( | Register | Reg, |
LaneBitmask | LaneMask = LaneBitmask::getAll() |
||
) |
Tell the scavenger a register is used.
Definition at line 51 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::addRegMasked().
Referenced by llvm::SIRegisterInfo::buildSpillLoadStore(), indirectCopyToAGPR(), InsertFPConstInst(), llvm::AArch64InstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), llvm::LoongArchInstrInfo::insertIndirectBranch(), llvm::RISCVInstrInfo::insertIndirectBranch(), InsertSPConstInst(), llvm::SGPRSpillBuilder::prepare(), replaceFrameIndex(), and scavengeFrameVirtualRegsInBlock().