LLVM  5.0.0
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 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 *RegClass) 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 *RegClass, 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...
 

Detailed Description

Definition at line 35 of file RegisterScavenging.h.

Constructor & Destructor Documentation

llvm::RegScavenger::RegScavenger ( )
default

Member Function Documentation

void llvm::RegScavenger::addScavengingFrameIndex ( int  FI)
inline
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 258 of file RegisterScavenging.cpp.

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

Referenced by backward(), and scavengeFrameVirtualRegsInBlock().

void llvm::RegScavenger::backward ( MachineBasicBlock::iterator  I)
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 81 of file RegisterScavenging.cpp.

References llvm::LiveRegUnits::addLiveIns(), and llvm::cl::init().

Referenced by llvm::SIInstrInfo::calculateLDSSpillAddress(), and llvm::Mips16InstrInfo::loadImmediate().

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

References llvm::LiveRegUnits::addLiveOuts(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and llvm::cl::init().

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

unsigned RegScavenger::FindUnusedReg ( const TargetRegisterClass *  RegClass) const

Find an unused register of the specified register class.

Return 0 if none is found.

Definition at line 285 of file RegisterScavenging.cpp.

References llvm::dbgs(), DEBUG, llvm::MCRegisterInfo::getName(), and isRegUsed().

Referenced by llvm::LanaiRegisterInfo::eliminateFrameIndex().

void RegScavenger::forward ( )
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 88 of file RegisterScavenging.h.

References llvm::MachineBasicBlock::begin(), forward(), and I.

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

Definition at line 120 of file RegisterScavenging.h.

BitVector RegScavenger::getRegsAvailable ( const TargetRegisterClass *  RC)

Return all available registers in the register class in Mask.

Definition at line 296 of file RegisterScavenging.cpp.

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

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

void llvm::RegScavenger::getScavengingFrameIndices ( SmallVectorImpl< int > &  A) const
inline
bool RegScavenger::isRegUsed ( unsigned  Reg,
bool  includeReserved = true 
) const

Return if a specific register is currently used.

Definition at line 279 of file RegisterScavenging.cpp.

References llvm::LiveRegUnits::available().

Referenced by FindUnusedReg(), forward(), getRegsAvailable(), llvm::SIRegisterInfo::restoreSGPR(), scavengeRegister(), and llvm::SIRegisterInfo::spillSGPR().

bool llvm::RegScavenger::isScavengingFrameIndex ( int  FI) const
inline
unsigned RegScavenger::scavengeRegister ( const TargetRegisterClass *  RegClass,
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 532 of file RegisterScavenging.cpp.

References llvm::BitVector::any(), llvm::dbgs(), DEBUG, llvm::TargetRegisterInfo::getAllocatableSet(), llvm::MCRegisterInfo::getName(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), getRegsAvailable(), I, isRegUsed(), llvm::MCRegAliasIterator::isValid(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::MachineInstr::operands(), llvm::BitVector::reset(), and UseMI.

Referenced by llvm::SIInstrInfo::calculateLDSSpillAddress(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), InsertFPConstInst(), llvm::SIInstrInfo::insertIndirectBranch(), InsertSPConstInst(), and scavengeRegister().

unsigned llvm::RegScavenger::scavengeRegister ( const TargetRegisterClass *  RegClass,
int  SPAdj 
)
inline

Definition at line 163 of file RegisterScavenging.h.

References scavengeRegister().

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

References assert(), llvm::dbgs(), DEBUG, llvm::MachineBasicBlock::end(), findSurvivorBackwards(), llvm::MachineBasicBlock::getParent(), llvm::TargetRegisterClass::getRawAllocationOrder(), MRI, P, llvm::PrintReg(), llvm::LiveRegUnits::removeReg(), and UseMI.

Referenced by scavengeVReg().

void RegScavenger::setRegUsed ( unsigned  Reg,
LaneBitmask  LaneMask = LaneBitmask::getAll() 
)
void llvm::RegScavenger::skipTo ( MachineBasicBlock::iterator  I)
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 154 of file RegisterScavenging.cpp.

References assert(), llvm::MachineBasicBlock::begin(), and llvm::MachineInstr::isDebugValue().

Referenced by unprocess().

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

Unprocess instructions until you reach the provided iterator.

Definition at line 98 of file RegisterScavenging.h.

References unprocess().


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