LLVM  14.0.0git
Classes | Public Member Functions | List of all members
llvm::RegScavenger Class Reference

#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 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 (Register 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...
 
Register 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...
 
Register scavengeRegister (const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj, bool AllowSpill=true)
 Make a register of the specific register class available and do the appropriate bookkeeping. More...
 
Register scavengeRegister (const TargetRegisterClass *RegClass, int SPAdj, bool AllowSpill=true)
 
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. More...
 
void setRegUsed (Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
 Tell the scavenger a register is used. More...
 

Detailed Description

Definition at line 34 of file RegisterScavenging.h.

Constructor & Destructor Documentation

◆ RegScavenger()

llvm::RegScavenger::RegScavenger ( )
default

Member Function Documentation

◆ addScavengingFrameIndex()

void llvm::RegScavenger::addScavengingFrameIndex ( int  FI)
inline

◆ backward() [1/2]

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 241 of file RegisterScavenging.cpp.

References assert(), llvm::MachineBasicBlock::begin(), I, MBB, MBBI, MI, and llvm::LiveRegUnits::stepBackward().

Referenced by backward(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and scavengeFrameVirtualRegsInBlock().

◆ backward() [2/2]

void llvm::RegScavenger::backward ( MachineBasicBlock::iterator  I)
inline

Call backward() as long as the internal iterator does not point to I.

Definition at line 98 of file RegisterScavenging.h.

References backward(), I, and MBBI.

◆ enterBasicBlock()

void RegScavenger::enterBasicBlock ( MachineBasicBlock MBB)

◆ enterBasicBlockEnd()

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(), llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::end(), llvm::cl::init(), MBB, and MBBI.

Referenced by llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and scavengeFrameVirtualRegsInBlock().

◆ FindUnusedReg()

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 268 of file RegisterScavenging.cpp.

References llvm::dbgs(), isRegUsed(), LLVM_DEBUG, llvm::printReg(), Reg, and TRI.

Referenced by llvm::LanaiRegisterInfo::eliminateFrameIndex(), indirectCopyToAGPR(), llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized(), and replaceFrameIndex().

◆ forward() [1/2]

void RegScavenger::forward ( )

◆ forward() [2/2]

void llvm::RegScavenger::forward ( MachineBasicBlock::iterator  I)
inline

Move the internal MBB iterator and update register states until it has processed the specific iterator.

Definition at line 87 of file RegisterScavenging.h.

References forward(), I, MBB, and MBBI.

◆ getCurrentPosition()

MachineBasicBlock::iterator llvm::RegScavenger::getCurrentPosition ( ) const
inline

Definition at line 110 of file RegisterScavenging.h.

References MBBI.

◆ getRegsAvailable()

BitVector RegScavenger::getRegsAvailable ( const TargetRegisterClass RC)

Return all available registers in the register class in Mask.

Definition at line 279 of file RegisterScavenging.cpp.

References llvm::MCRegisterInfo::getNumRegs(), isRegUsed(), llvm::BitmaskEnumDetail::Mask(), Reg, and TRI.

Referenced by llvm::Mips16InstrInfo::loadImmediate(), and scavengeRegister().

◆ getScavengingFrameIndices()

void llvm::RegScavenger::getScavengingFrameIndices ( SmallVectorImpl< int > &  A) const
inline

Get an array of scavenging frame indices.

Definition at line 138 of file RegisterScavenging.h.

References I, and llvm::ARM_PROC::IE.

◆ isRegUsed()

bool RegScavenger::isRegUsed ( Register  Reg,
bool  includeReserved = true 
) const

◆ isScavengingFrameIndex()

bool llvm::RegScavenger::isScavengingFrameIndex ( int  FI) const
inline

Query whether a frame index is a scavenging frame index.

Definition at line 128 of file RegisterScavenging.h.

References I, and llvm::ARM_PROC::IE.

Referenced by llvm::ThumbRegisterInfo::eliminateFrameIndex(), llvm::AArch64RegisterInfo::eliminateFrameIndex(), and llvm::ARMBaseRegisterInfo::eliminateFrameIndex().

◆ scavengeRegister() [1/2]

Register RegScavenger::scavengeRegister ( const TargetRegisterClass RC,
MachineBasicBlock::iterator  I,
int  SPAdj,
bool  AllowSpill = true 
)

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!

If AllowSpill is false, fail if a spill is required to make the register available, and return NoRegister.

Definition at line 520 of file RegisterScavenging.cpp.

References Available, llvm::dbgs(), llvm::TargetRegisterInfo::getAllocatableSet(), getRegsAvailable(), I, isRegUsed(), llvm::MCRegAliasIterator::isValid(), llvm::Register::isVirtualRegister(), LLVM_DEBUG, MI, llvm::printReg(), llvm::BitVector::reset(), spill, TRI, and UseMI.

Referenced by llvm::SIRegisterInfo::buildSpillLoadStore(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), llvm::SIRegisterInfo::eliminateFrameIndex(), llvm::SIInstrInfo::getAddNoCarry(), indirectCopyToAGPR(), InsertFPConstInst(), InsertSPConstInst(), llvm::SGPRSpillBuilder::prepare(), replaceFrameIndex(), and scavengeRegister().

◆ scavengeRegister() [2/2]

Register llvm::RegScavenger::scavengeRegister ( const TargetRegisterClass RegClass,
int  SPAdj,
bool  AllowSpill = true 
)
inline

Definition at line 157 of file RegisterScavenging.h.

References MBBI, and scavengeRegister().

◆ scavengeRegisterBackwards()

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 565 of file RegisterScavenging.cpp.

References assert(), llvm::dbgs(), llvm::MachineBasicBlock::end(), findSurvivorBackwards(), llvm::MachineBasicBlock::getParent(), llvm::TargetRegisterClass::getRawAllocationOrder(), LLVM_DEBUG, MBB, MBBI, MRI, P, llvm::printReg(), Reg, llvm::LiveRegUnits::removeReg(), spill, TRI, and UseMI.

Referenced by llvm::RISCVInstrInfo::insertIndirectBranch(), llvm::SIInstrInfo::insertIndirectBranch(), and scavengeVReg().

◆ setRegUsed()

void RegScavenger::setRegUsed ( Register  Reg,
LaneBitmask  LaneMask = LaneBitmask::getAll() 
)

◆ skipTo()

void llvm::RegScavenger::skipTo ( MachineBasicBlock::iterator  I)
inline

Move the internal MBB iterator but do not update register states.

Definition at line 104 of file RegisterScavenging.h.

References I, and MBBI.


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