LLVM API Documentation

llvm::VirtRegMap Class Reference

#include <VirtRegMap.h>

Inheritance diagram for llvm::VirtRegMap:
[legend]
Collaboration diagram for llvm::VirtRegMap:
[legend]

List of all members.

Public Types

enum  { NO_PHYS_REG = 0, NO_STACK_SLOT = (1L << 30)-1, MAX_STACK_SLOT = (1L << 18)-1 }
enum  ModRef { isRef = 1, isMod = 2, isModRef = 3 }
typedef std::multimap
< MachineInstr *, std::pair
< unsigned, ModRef > > 
MI2VirtMapTy

Public Member Functions

 VirtRegMap ()
virtual bool runOnMachineFunction (MachineFunction &MF)
virtual void getAnalysisUsage (AnalysisUsage &AU) const
void grow ()
bool hasPhys (unsigned virtReg) const
 returns true if the specified virtual register is mapped to a physical register
unsigned getPhys (unsigned virtReg) const
 returns the physical register mapped to the specified virtual register
void assignVirt2Phys (unsigned virtReg, unsigned physReg)
 creates a mapping for the specified virtual register to the specified physical register
void clearVirt (unsigned virtReg)
 clears the specified virtual register's, physical register mapping
void clearAllVirt ()
 clears all virtual to physical register mappings
unsigned getRegAllocPref (unsigned virtReg)
 returns the register allocation preference.
void setIsSplitFromReg (unsigned virtReg, unsigned SReg)
 records virtReg is a split live interval from SReg.
unsigned getPreSplitReg (unsigned virtReg)
 returns the live interval virtReg is split from.
bool isAssignedReg (unsigned virtReg) const
 returns true if the specified virtual register is not mapped to a stack slot or rematerialized.
int getStackSlot (unsigned virtReg) const
 returns the stack slot mapped to the specified virtual register
int getReMatId (unsigned virtReg) const
 returns the rematerialization id mapped to the specified virtual register
int assignVirt2StackSlot (unsigned virtReg)
 create a mapping for the specifed virtual register to the next available stack slot
void assignVirt2StackSlot (unsigned virtReg, int frameIndex)
 create a mapping for the specified virtual register to the specified stack slot
int assignVirtReMatId (unsigned virtReg)
 assign an unique re-materialization id to the specified virtual register.
void assignVirtReMatId (unsigned virtReg, int id)
 assign an unique re-materialization id to the specified virtual register.
bool isReMaterialized (unsigned virtReg) const
 returns true if the specified virtual register is being re-materialized.
MachineInstr * getReMaterializedMI (unsigned virtReg) const
 returns the original machine instruction being re-issued to re-materialize the specified virtual register.
void setVirtIsReMaterialized (unsigned virtReg, MachineInstr *def)
 records the specified virtual register will be re-materialized and the original instruction which will be re-issed for this purpose. If parameter all is true, then all uses of the registers are rematerialized and it's safe to delete the definition.
void addKillPoint (unsigned virtReg, unsigned index)
 record the last use (kill) of a split virtual register.
unsigned getKillPoint (unsigned virtReg) const
void removeKillPoint (unsigned virtReg)
 remove the last use (kill) of a split virtual register.
bool isSpillPt (MachineInstr *Pt) const
 returns true if the specified MachineInstr is a spill point.
std::vector< std::pair
< unsigned, bool > > & 
getSpillPtSpills (MachineInstr *Pt)
 returns the virtual registers that should be spilled due to splitting right after the specified MachineInstr.
void addSpillPoint (unsigned virtReg, bool isKill, MachineInstr *Pt)
 records the specified MachineInstr as a spill point for virtReg.
void transferSpillPts (MachineInstr *Old, MachineInstr *New)
 
  • transfer spill point information from one instruction to another.

bool isRestorePt (MachineInstr *Pt) const
 returns true if the specified MachineInstr is a restore point.
std::vector< unsigned > & getRestorePtRestores (MachineInstr *Pt)
 returns the virtual registers that should be restoreed due to splitting right after the specified MachineInstr.
void addRestorePoint (unsigned virtReg, MachineInstr *Pt)
 records the specified MachineInstr as a restore point for virtReg.
void transferRestorePts (MachineInstr *Old, MachineInstr *New)
 
  • transfer restore point information from one instruction to another.

void addEmergencySpill (unsigned PhysReg, MachineInstr *MI)
 records that the specified physical register must be spilled around the specified machine instr.
bool hasEmergencySpills (MachineInstr *MI) const
 returns true if one or more physical registers must be spilled around the specified instruction.
std::vector< unsigned > & getEmergencySpills (MachineInstr *MI)
 returns the physical registers to be spilled and restored around the instruction.
void transferEmergencySpills (MachineInstr *Old, MachineInstr *New)
 
  • transfer emergency spill information from one instruction to another.

int getEmergencySpillSlot (const TargetRegisterClass *RC)
 return or get a emergency spill slot for the register class.
int getLowSpillSlot () const
 Return lowest spill slot index.
int getHighSpillSlot () const
 Return highest spill slot index.
void addSpillSlotUse (int FrameIndex, MachineInstr *MI)
 Records a spill slot use.
bool isSpillSlotUsed (int FrameIndex) const
 Returns true if spill slot has been used.
void setIsImplicitlyDefined (unsigned VirtReg)
 Mark the specified register as being implicitly defined.
bool isImplicitlyDefined (unsigned VirtReg) const
 Returns true if the virtual register is implicitly defined.
void virtFolded (unsigned VirtReg, MachineInstr *OldMI, MachineInstr *NewMI, ModRef MRInfo)
 Updates information about the specified virtual register's value folded into newMI machine instruction.
void virtFolded (unsigned VirtReg, MachineInstr *MI, ModRef MRInfo)
 Updates information about the specified virtual register's value folded into the specified machine instruction.
std::pair
< MI2VirtMapTy::const_iterator,
MI2VirtMapTy::const_iterator > 
getFoldedVirts (MachineInstr *MI) const
 returns the virtual registers' values folded in memory operands of this instruction
void RemoveMachineInstrFromMaps (MachineInstr *MI)
bool FindUnusedRegisters (LiveIntervals *LIs)
bool HasUnusedRegisters () const
void setRegisterUsed (unsigned Reg)
 setRegisterUsed - Remember the physical register is now used.
bool isRegisterUnused (unsigned Reg) const
unsigned getFirstUnusedRegister (const TargetRegisterClass *RC)
void print (std::ostream &OS, const Module *M=0) const
void print (std::ostream *OS) const
void print (raw_ostream &OS, const Module *M=0) const
void print (raw_ostream *OS) const
void dump () const

Static Public Attributes

static char ID = 0


Detailed Description

Definition at line 39 of file VirtRegMap.h.


Member Typedef Documentation

typedef std::multimap<MachineInstr*, std::pair<unsigned, ModRef> > llvm::VirtRegMap::MI2VirtMapTy

Definition at line 49 of file VirtRegMap.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
NO_PHYS_REG 
NO_STACK_SLOT 
MAX_STACK_SLOT 

Definition at line 41 of file VirtRegMap.h.

Enumerator:
isRef 
isMod 
isModRef 

Definition at line 47 of file VirtRegMap.h.


Constructor & Destructor Documentation

llvm::VirtRegMap::VirtRegMap (  )  [inline]

Definition at line 142 of file VirtRegMap.h.


Member Function Documentation

bool VirtRegMap::runOnMachineFunction ( MachineFunction &  MF  )  [virtual]

virtual void llvm::VirtRegMap::getAnalysisUsage ( AnalysisUsage &  AU  )  const [inline, virtual]

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.

Reimplemented from llvm::MachineFunctionPass.

Definition at line 150 of file VirtRegMap.h.

References llvm::MachineFunctionPass::getAnalysisUsage(), and llvm::AnalysisUsage::setPreservesAll().

void VirtRegMap::grow (  ) 

bool llvm::VirtRegMap::hasPhys ( unsigned  virtReg  )  const [inline]

returns true if the specified virtual register is mapped to a physical register

Definition at line 159 of file VirtRegMap.h.

References getPhys(), and NO_PHYS_REG.

Referenced by llvm::LiveIntervals::conflictsWithPhysRegDef(), FoldsStackSlotModRef(), and getRegAllocPref().

unsigned llvm::VirtRegMap::getPhys ( unsigned  virtReg  )  const [inline]

returns the physical register mapped to the specified virtual register

Definition at line 165 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::isVirtualRegister().

Referenced by llvm::LiveIntervals::conflictsWithPhysRegDef(), FoldsStackSlotModRef(), getRegAllocPref(), hasPhys(), and ReMaterialize().

void llvm::VirtRegMap::assignVirt2Phys ( unsigned  virtReg,
unsigned  physReg 
) [inline]

creates a mapping for the specified virtual register to the specified physical register

Definition at line 172 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::TargetRegisterInfo::isVirtualRegister(), and NO_PHYS_REG.

void llvm::VirtRegMap::clearVirt ( unsigned  virtReg  )  [inline]

clears the specified virtual register's, physical register mapping

Definition at line 183 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::isVirtualRegister(), and NO_PHYS_REG.

void llvm::VirtRegMap::clearAllVirt (  )  [inline]

clears all virtual to physical register mappings

Definition at line 191 of file VirtRegMap.h.

References grow().

unsigned VirtRegMap::getRegAllocPref ( unsigned  virtReg  ) 

void llvm::VirtRegMap::setIsSplitFromReg ( unsigned  virtReg,
unsigned  SReg 
) [inline]

records virtReg is a split live interval from SReg.

Definition at line 200 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

unsigned llvm::VirtRegMap::getPreSplitReg ( unsigned  virtReg  )  [inline]

returns the live interval virtReg is split from.

Definition at line 205 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

bool llvm::VirtRegMap::isAssignedReg ( unsigned  virtReg  )  const [inline]

returns true if the specified virtual register is not mapped to a stack slot or rematerialized.

Definition at line 211 of file VirtRegMap.h.

References getReMatId(), getStackSlot(), NO_PHYS_REG, and NO_STACK_SLOT.

int llvm::VirtRegMap::getStackSlot ( unsigned  virtReg  )  const [inline]

returns the stack slot mapped to the specified virtual register

Definition at line 222 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::isVirtualRegister().

Referenced by llvm::LiveIntervals::addIntervalsForSpills(), addStackInterval(), FoldsStackSlotModRef(), and isAssignedReg().

int llvm::VirtRegMap::getReMatId ( unsigned  virtReg  )  const [inline]

returns the rematerialization id mapped to the specified virtual register

Definition at line 229 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::isVirtualRegister().

Referenced by isAssignedReg().

int VirtRegMap::assignVirt2StackSlot ( unsigned  virtReg  ) 

void VirtRegMap::assignVirt2StackSlot ( unsigned  virtReg,
int  frameIndex 
)

create a mapping for the specified virtual register to the specified stack slot

Definition at line 134 of file VirtRegMap.cpp.

References llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getObjectIndexBegin(), llvm::TargetRegisterInfo::isVirtualRegister(), MF, and NO_STACK_SLOT.

int VirtRegMap::assignVirtReMatId ( unsigned  virtReg  ) 

assign an unique re-materialization id to the specified virtual register.

Definition at line 144 of file VirtRegMap.cpp.

References llvm::TargetRegisterInfo::isVirtualRegister(), and NO_STACK_SLOT.

void VirtRegMap::assignVirtReMatId ( unsigned  virtReg,
int  id 
)

assign an unique re-materialization id to the specified virtual register.

Definition at line 152 of file VirtRegMap.cpp.

References llvm::TargetRegisterInfo::isVirtualRegister(), and NO_STACK_SLOT.

bool llvm::VirtRegMap::isReMaterialized ( unsigned  virtReg  )  const [inline]

returns true if the specified virtual register is being re-materialized.

Definition at line 250 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

MachineInstr* llvm::VirtRegMap::getReMaterializedMI ( unsigned  virtReg  )  const [inline]

returns the original machine instruction being re-issued to re-materialize the specified virtual register.

Definition at line 256 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills(), and ReMaterialize().

void llvm::VirtRegMap::setVirtIsReMaterialized ( unsigned  virtReg,
MachineInstr *  def 
) [inline]

records the specified virtual register will be re-materialized and the original instruction which will be re-issed for this purpose. If parameter all is true, then all uses of the registers are rematerialized and it's safe to delete the definition.

Definition at line 264 of file VirtRegMap.h.

void llvm::VirtRegMap::addKillPoint ( unsigned  virtReg,
unsigned  index 
) [inline]

record the last use (kill) of a split virtual register.

Definition at line 269 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

unsigned llvm::VirtRegMap::getKillPoint ( unsigned  virtReg  )  const [inline]

Definition at line 273 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

void llvm::VirtRegMap::removeKillPoint ( unsigned  virtReg  )  [inline]

remove the last use (kill) of a split virtual register.

Definition at line 278 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills().

bool llvm::VirtRegMap::isSpillPt ( MachineInstr *  Pt  )  const [inline]

returns true if the specified MachineInstr is a spill point.

Definition at line 283 of file VirtRegMap.h.

Referenced by FoldsStackSlotModRef().

std::vector<std::pair<unsigned,bool> >& llvm::VirtRegMap::getSpillPtSpills ( MachineInstr *  Pt  )  [inline]

returns the virtual registers that should be spilled due to splitting right after the specified MachineInstr.

Definition at line 289 of file VirtRegMap.h.

void llvm::VirtRegMap::addSpillPoint ( unsigned  virtReg,
bool  isKill,
MachineInstr *  Pt 
) [inline]

records the specified MachineInstr as a spill point for virtReg.

Definition at line 294 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills(), llvm::LiveIntervals::addIntervalsForSpillsFast(), and transferSpillPts().

void llvm::VirtRegMap::transferSpillPts ( MachineInstr *  Old,
MachineInstr *  New 
) [inline]

  • transfer spill point information from one instruction to another.

Definition at line 308 of file VirtRegMap.h.

References addSpillPoint().

bool llvm::VirtRegMap::isRestorePt ( MachineInstr *  Pt  )  const [inline]

returns true if the specified MachineInstr is a restore point.

Definition at line 323 of file VirtRegMap.h.

std::vector<unsigned>& llvm::VirtRegMap::getRestorePtRestores ( MachineInstr *  Pt  )  [inline]

returns the virtual registers that should be restoreed due to splitting right after the specified MachineInstr.

Definition at line 329 of file VirtRegMap.h.

void llvm::VirtRegMap::addRestorePoint ( unsigned  virtReg,
MachineInstr *  Pt 
) [inline]

records the specified MachineInstr as a restore point for virtReg.

Definition at line 334 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills(), llvm::LiveIntervals::addIntervalsForSpillsFast(), and transferRestorePts().

void llvm::VirtRegMap::transferRestorePts ( MachineInstr *  Old,
MachineInstr *  New 
) [inline]

  • transfer restore point information from one instruction to another.

Definition at line 348 of file VirtRegMap.h.

References addRestorePoint().

void llvm::VirtRegMap::addEmergencySpill ( unsigned  PhysReg,
MachineInstr *  MI 
) [inline]

records that the specified physical register must be spilled around the specified machine instr.

Definition at line 363 of file VirtRegMap.h.

Referenced by llvm::LiveIntervals::spillPhysRegAroundRegDefsUses(), and transferEmergencySpills().

bool llvm::VirtRegMap::hasEmergencySpills ( MachineInstr *  MI  )  const [inline]

returns true if one or more physical registers must be spilled around the specified instruction.

Definition at line 375 of file VirtRegMap.h.

Referenced by FoldsStackSlotModRef().

std::vector<unsigned>& llvm::VirtRegMap::getEmergencySpills ( MachineInstr *  MI  )  [inline]

returns the physical registers to be spilled and restored around the instruction.

Definition at line 381 of file VirtRegMap.h.

void llvm::VirtRegMap::transferEmergencySpills ( MachineInstr *  Old,
MachineInstr *  New 
) [inline]

  • transfer emergency spill information from one instruction to another.

Definition at line 387 of file VirtRegMap.h.

References addEmergencySpill().

int VirtRegMap::getEmergencySpillSlot ( const TargetRegisterClass *  RC  ) 

int llvm::VirtRegMap::getLowSpillSlot (  )  const [inline]

Return lowest spill slot index.

Definition at line 404 of file VirtRegMap.h.

int llvm::VirtRegMap::getHighSpillSlot (  )  const [inline]

Return highest spill slot index.

Definition at line 409 of file VirtRegMap.h.

void VirtRegMap::addSpillSlotUse ( int  FrameIndex,
MachineInstr *  MI 
)

Records a spill slot use.

Definition at line 174 of file VirtRegMap.cpp.

References llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::isFixedObjectIndex(), and MF.

bool llvm::VirtRegMap::isSpillSlotUsed ( int  FrameIndex  )  const [inline]

Returns true if spill slot has been used.

Definition at line 417 of file VirtRegMap.h.

void llvm::VirtRegMap::setIsImplicitlyDefined ( unsigned  VirtReg  )  [inline]

Mark the specified register as being implicitly defined.

Definition at line 423 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::FirstVirtualRegister, and llvm::BitVector::set().

bool llvm::VirtRegMap::isImplicitlyDefined ( unsigned  VirtReg  )  const [inline]

Returns true if the virtual register is implicitly defined.

Definition at line 428 of file VirtRegMap.h.

References llvm::TargetRegisterInfo::FirstVirtualRegister.

void VirtRegMap::virtFolded ( unsigned  VirtReg,
MachineInstr *  OldMI,
MachineInstr *  NewMI,
ModRef  MRInfo 
)

Updates information about the specified virtual register's value folded into newMI machine instruction.

Definition at line 187 of file VirtRegMap.cpp.

References E.

void VirtRegMap::virtFolded ( unsigned  VirtReg,
MachineInstr *  MI,
ModRef  MRInfo 
)

Updates information about the specified virtual register's value folded into the specified machine instruction.

Definition at line 201 of file VirtRegMap.cpp.

std::pair<MI2VirtMapTy::const_iterator, MI2VirtMapTy::const_iterator> llvm::VirtRegMap::getFoldedVirts ( MachineInstr *  MI  )  const [inline]

returns the virtual registers' values folded in memory operands of this instruction

Definition at line 444 of file VirtRegMap.h.

Referenced by FoldsStackSlotModRef().

void VirtRegMap::RemoveMachineInstrFromMaps ( MachineInstr *  MI  ) 

RemoveMachineInstrFromMaps - MI is being erased, remove it from the the folded instruction map and spill point map.

Definition at line 206 of file VirtRegMap.cpp.

References FI, llvm::MachineFunction::getFrameInfo(), llvm::MachineOperand::getIndex(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::isFI(), llvm::MachineFrameInfo::isFixedObjectIndex(), and MF.

bool VirtRegMap::FindUnusedRegisters ( LiveIntervals *  LIs  ) 

FindUnusedRegisters - Gather a list of allocatable registers that have not been allocated to any virtual register.

FindUnusedRegisters - Gather a list of allocatable registers that have not been allocated to any virtual register.

Definition at line 230 of file VirtRegMap.cpp.

References llvm::TargetRegisterInfo::FirstVirtualRegister, llvm::TargetRegisterInfo::getAliasSet(), llvm::TargetRegisterInfo::getAllocatableSet(), llvm::MachineRegisterInfo::getLastVirtReg(), llvm::TargetRegisterInfo::getNumRegs(), llvm::MachineFunction::getRegInfo(), llvm::LiveIntervals::hasInterval(), MF, NO_PHYS_REG, Reg, llvm::BitVector::reset(), llvm::BitVector::resize(), llvm::BitVector::set(), and TRI.

bool llvm::VirtRegMap::HasUnusedRegisters (  )  const [inline]

HasUnusedRegisters - Return true if there are any allocatable registers that have not been allocated to any virtual register.

Definition at line 458 of file VirtRegMap.h.

References llvm::BitVector::none().

void llvm::VirtRegMap::setRegisterUsed ( unsigned  Reg  )  [inline]

setRegisterUsed - Remember the physical register is now used.

Definition at line 463 of file VirtRegMap.h.

References llvm::BitVector::reset().

bool llvm::VirtRegMap::isRegisterUnused ( unsigned  Reg  )  const [inline]

isRegisterUnused - Return true if the physical register has not been used.

Definition at line 469 of file VirtRegMap.h.

unsigned llvm::VirtRegMap::getFirstUnusedRegister ( const TargetRegisterClass *  RC  )  [inline]

getFirstUnusedRegister - Return the first physical register that has not been used.

Definition at line 475 of file VirtRegMap.h.

References llvm::BitVector::find_first(), llvm::BitVector::find_next(), and Reg.

void VirtRegMap::print ( std::ostream &  O,
const Module *  M = 0 
) const [virtual]

print - Print out the internal state of the pass. This is called by Analyze to print out the contents of an analysis. Otherwise it is not necessary to implement this method. Beware that the module pointer MAY be null. This automatically forwards to a virtual function that does not provide the Module* in case the analysis doesn't need it it can just be ignored.

Reimplemented from llvm::Pass.

Definition at line 262 of file VirtRegMap.cpp.

Referenced by dump(), llvm::operator<<(), and print().

void llvm::VirtRegMap::print ( std::ostream *  OS  )  const [inline]

Definition at line 486 of file VirtRegMap.h.

References print().

void VirtRegMap::print ( raw_ostream &  OS,
const Module *  M = 0 
) const

void llvm::VirtRegMap::print ( raw_ostream *  OS  )  const [inline]

Definition at line 488 of file VirtRegMap.h.

References print().

void VirtRegMap::dump (  )  const

Reimplemented from llvm::Pass.

Definition at line 285 of file VirtRegMap.cpp.

References llvm::cerr(), and print().


Member Data Documentation

char VirtRegMap::ID = 0 [static]

Definition at line 141 of file VirtRegMap.h.


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