LLVM  8.0.1
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 *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...
 

Detailed Description

Definition at line 35 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 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().

◆ 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 108 of file RegisterScavenging.h.

References backward().

◆ enterBasicBlock()

void RegScavenger::enterBasicBlock ( MachineBasicBlock MBB)

◆ enterBasicBlockEnd()

void RegScavenger::enterBasicBlockEnd ( MachineBasicBlock MBB)

◆ FindUnusedReg()

unsigned RegScavenger::FindUnusedReg ( const TargetRegisterClass RC) const

◆ 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 88 of file RegisterScavenging.h.

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

◆ getCurrentPosition()

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

Definition at line 120 of file RegisterScavenging.h.

References FindUnusedReg(), getRegsAvailable(), isRegUsed(), and Reg.

◆ getRegsAvailable()

BitVector RegScavenger::getRegsAvailable ( const TargetRegisterClass RC)

◆ getScavengingFrameIndices()

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

◆ isRegUsed()

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

◆ isScavengingFrameIndex()

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

◆ scavengeRegister() [1/2]

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().

◆ scavengeRegister() [2/2]

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

◆ scavengeRegisterBackwards()

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().

◆ setRegUsed()

void RegScavenger::setRegUsed ( unsigned  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 114 of file RegisterScavenging.h.

References I.

◆ unprocess() [1/2]

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().

◆ unprocess() [2/2]

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 backward(), and unprocess().


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