LLVM  8.0.1
Classes | Public Types | Public Member Functions | List of all members
llvm::LiveRangeEdit Class Reference

#include "llvm/CodeGen/LiveRangeEdit.h"

Inheritance diagram for llvm::LiveRangeEdit:
Inheritance graph
[legend]
Collaboration diagram for llvm::LiveRangeEdit:
Collaboration graph
[legend]

Classes

class  Delegate
 Callback methods for LiveRangeEdit owners. More...
 
struct  Remat
 Remat - Information needed to rematerialize at a specific location. More...
 

Public Types

using iterator = SmallVectorImpl< unsigned >::const_iterator
 Iterator for accessing the new registers added by this edit. More...
 

Public Member Functions

 LiveRangeEdit (LiveInterval *parent, SmallVectorImpl< unsigned > &newRegs, MachineFunction &MF, LiveIntervals &lis, VirtRegMap *vrm, Delegate *delegate=nullptr, SmallPtrSet< MachineInstr *, 32 > *deadRemats=nullptr)
 Create a LiveRangeEdit for breaking down parent into smaller pieces. More...
 
 ~LiveRangeEdit () override
 
LiveIntervalgetParent () const
 
unsigned getReg () const
 
iterator begin () const
 
iterator end () const
 
unsigned size () const
 
bool empty () const
 
unsigned get (unsigned idx) const
 
void pop_back ()
 pop_back - It allows LiveRangeEdit users to drop new registers. More...
 
ArrayRef< unsignedregs () const
 
unsigned createFrom (unsigned OldReg)
 createFrom - Create a new virtual register based on OldReg. More...
 
LiveIntervalcreateEmptyInterval ()
 create - Create a new register with the same class and original slot as parent. More...
 
unsigned create ()
 
bool anyRematerializable (AliasAnalysis *)
 anyRematerializable - Return true if any parent values may be rematerializable. More...
 
bool checkRematerializable (VNInfo *VNI, const MachineInstr *DefMI, AliasAnalysis *)
 checkRematerializable - Manually add VNI to the list of rematerializable values if DefMI may be rematerializable. More...
 
bool canRematerializeAt (Remat &RM, VNInfo *OrigVNI, SlotIndex UseIdx, bool cheapAsAMove)
 canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx. More...
 
SlotIndex rematerializeAt (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, const Remat &RM, const TargetRegisterInfo &, bool Late=false)
 rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an instruction into MBB before MI. More...
 
void markRematerialized (const VNInfo *ParentVNI)
 markRematerialized - explicitly mark a value as rematerialized after doing it manually. More...
 
bool didRematerialize (const VNInfo *ParentVNI) const
 didRematerialize - Return true if ParentVNI was rematerialized anywhere. More...
 
void eraseVirtReg (unsigned Reg)
 eraseVirtReg - Notify the delegate that Reg is no longer in use, and try to erase it from LIS. More...
 
void eliminateDeadDefs (SmallVectorImpl< MachineInstr *> &Dead, ArrayRef< unsigned > RegsBeingSpilled=None, AliasAnalysis *AA=nullptr)
 eliminateDeadDefs - Try to delete machine instructions that are now dead (allDefsAreDead returns true). More...
 
void calculateRegClassAndHint (MachineFunction &, const MachineLoopInfo &, const MachineBlockFrequencyInfo &)
 calculateRegClassAndHint - Recompute register class and hint for each new register. More...
 

Detailed Description

Definition at line 46 of file LiveRangeEdit.h.

Member Typedef Documentation

◆ iterator

Iterator for accessing the new registers added by this edit.

Definition at line 159 of file LiveRangeEdit.h.

Constructor & Destructor Documentation

◆ LiveRangeEdit()

llvm::LiveRangeEdit::LiveRangeEdit ( LiveInterval parent,
SmallVectorImpl< unsigned > &  newRegs,
MachineFunction MF,
LiveIntervals lis,
VirtRegMap vrm,
Delegate delegate = nullptr,
SmallPtrSet< MachineInstr *, 32 > *  deadRemats = nullptr 
)
inline

Create a LiveRangeEdit for breaking down parent into smaller pieces.

Parameters
parentThe register being spilled or split.
newRegsList to receive any new registers created. This needn't be empty initially, any existing registers are ignored.
MFThe MachineFunction the live range edit is taking place in.
lisThe collection of all live intervals in this function.
vrmMap of virtual registers to physical registers for this function. If NULL, no virtual register map updates will be done. This could be the case if called before Regalloc.
deadRematsThe collection of all the instructions defining an original reg and are dead after remat.

Definition at line 139 of file LiveRangeEdit.h.

References llvm::MachineRegisterInfo::setDelegate().

◆ ~LiveRangeEdit()

llvm::LiveRangeEdit::~LiveRangeEdit ( )
inlineoverride

Definition at line 149 of file LiveRangeEdit.h.

References llvm::MachineRegisterInfo::resetDelegate().

Member Function Documentation

◆ anyRematerializable()

bool LiveRangeEdit::anyRematerializable ( AliasAnalysis aa)

anyRematerializable - Return true if any parent values may be rematerializable.

This function must be called before any rematerialization is attempted.

Definition at line 99 of file LiveRangeEdit.cpp.

References llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::SlotIndex::getRegSlot(), llvm::LiveRange::getVNInfoAt(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::SlotIndex::isSameInstr(), MRI, and llvm::MachineOperand::readsReg().

Referenced by create(), and llvm::SplitEditor::reset().

◆ begin()

iterator llvm::LiveRangeEdit::begin ( ) const
inline

◆ calculateRegClassAndHint()

void LiveRangeEdit::calculateRegClassAndHint ( MachineFunction MF,
const MachineLoopInfo Loops,
const MachineBlockFrequencyInfo MBFI 
)

◆ canRematerializeAt()

bool LiveRangeEdit::canRematerializeAt ( Remat RM,
VNInfo OrigVNI,
SlotIndex  UseIdx,
bool  cheapAsAMove 
)

canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx.

It is assumed that parent_.getVNINfoAt(UseIdx) == ParentVNI. When cheapAsAMove is set, only cheap remats are allowed.

Definition at line 141 of file LiveRangeEdit.cpp.

References assert(), llvm::LiveRangeEdit::Remat::OrigMI, and TII.

Referenced by llvm::SplitEditor::dump(), and llvm::LiveRangeEdit::Remat::Remat().

◆ checkRematerializable()

bool LiveRangeEdit::checkRematerializable ( VNInfo VNI,
const MachineInstr DefMI,
AliasAnalysis aa 
)

checkRematerializable - Manually add VNI to the list of rematerializable values if DefMI may be rematerializable.

Definition at line 71 of file LiveRangeEdit.cpp.

References aa, assert(), llvm::VNInfo::def, DefMI, getParent(), getReg(), llvm::LiveRange::getVNInfoAt(), and TII.

Referenced by create().

◆ create()

unsigned llvm::LiveRangeEdit::create ( )
inline

◆ createEmptyInterval()

LiveInterval& llvm::LiveRangeEdit::createEmptyInterval ( )
inline

create - Create a new register with the same class and original slot as parent.

Definition at line 185 of file LiveRangeEdit.h.

References getReg().

Referenced by llvm::SplitEditor::openIntv().

◆ createFrom()

unsigned LiveRangeEdit::createFrom ( unsigned  OldReg)

createFrom - Create a new virtual register based on OldReg.

Definition at line 55 of file LiveRangeEdit.cpp.

References MRI.

Referenced by create(), and regs().

◆ didRematerialize()

bool llvm::LiveRangeEdit::didRematerialize ( const VNInfo ParentVNI) const
inline

didRematerialize - Return true if ParentVNI was rematerialized anywhere.

Definition at line 232 of file LiveRangeEdit.h.

References calculateRegClassAndHint(), llvm::SmallPtrSetImpl< PtrType >::count(), eliminateDeadDefs(), eraseVirtReg(), llvm::None, and Reg.

◆ eliminateDeadDefs()

void LiveRangeEdit::eliminateDeadDefs ( SmallVectorImpl< MachineInstr *> &  Dead,
ArrayRef< unsigned RegsBeingSpilled = None,
AliasAnalysis AA = nullptr 
)

eliminateDeadDefs - Try to delete machine instructions that are now dead (allDefsAreDead returns true).

This may cause live intervals to be trimmed and further dead efs to be eliminated. RegsBeingSpilled lists registers currently being spilled by the register allocator. These registers should not be split into new intervals as currently those new intervals are not guaranteed to spill.

Definition at line 391 of file LiveRangeEdit.cpp.

References llvm::SetVector< T, Vector, Set >::back(), llvm::SmallVectorBase::empty(), llvm::SetVector< T, Vector, Set >::empty(), llvm::SmallVectorTemplateBase< T, bool >::grow(), llvm::SetVector< T, Vector, Set >::pop_back(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::LiveInterval::reg, llvm::LiveRange::RenumberValues(), and llvm::ArrayRef< T >::size().

Referenced by didRematerialize(), and llvm::CoalescerPair::isCoalescable().

◆ empty()

bool llvm::LiveRangeEdit::empty ( ) const
inline

Definition at line 163 of file LiveRangeEdit.h.

References size().

Referenced by getNumAllocatableRegsForConstraints(), and llvm::SplitEditor::openIntv().

◆ end()

iterator llvm::LiveRangeEdit::end ( ) const
inline

◆ eraseVirtReg()

void LiveRangeEdit::eraseVirtReg ( unsigned  Reg)

eraseVirtReg - Notify the delegate that Reg is no longer in use, and try to erase it from LIS.

Definition at line 181 of file LiveRangeEdit.cpp.

References llvm::MachineInstr::addRegisterDead(), llvm::LiveRange::addSegment(), llvm::MachineInstr::allDefsAreDead(), assert(), llvm::MachineInstr::canFoldAsLoad(), llvm::dbgs(), llvm::RegState::Dead, llvm::VNInfo::def, DefMI, llvm::LiveRange::empty(), llvm::MachineInstr::eraseFromParent(), llvm::MachineInstr::getDesc(), llvm::LiveRange::getNextValue(), llvm::MCInstrDesc::getNumDefs(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getParent(), llvm::MachineOperand::getReg(), llvm::SlotIndex::getRegSlot(), llvm::MachineOperand::getSubReg(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), llvm::LiveRange::getVNInfoAt(), llvm::SetVector< T, Vector, Set >::insert(), llvm::MachineInstr::isBundled(), llvm::MachineInstr::isCopy(), llvm::MachineOperand::isDef(), llvm::MachineInstr::isInlineAsm(), llvm::LiveQueryResult::isKill(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::MachineInstr::isSafeToMove(), llvm::SlotIndex::isSameInstr(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::AMDGPUISD::KILL, LLVM_DEBUG, MI, MRI, llvm::MachineInstr::operands_begin(), llvm::MachineInstr::operands_end(), pop_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LiveRange::Query(), llvm::MachineInstr::readsVirtualRegister(), llvm::MachineInstr::readsWritesVirtualRegister(), llvm::LiveInterval::reg, Reg, llvm::SetVector< T, Vector, Set >::remove(), llvm::MachineInstr::RemoveOperand(), llvm::MachineInstr::setDesc(), llvm::MachineOperand::setIsDead(), llvm::SmallVectorBase::size(), llvm::LiveInterval::subranges(), SubReg, llvm::MachineInstr::substituteRegister(), TII, TRI, and UseMI.

Referenced by didRematerialize().

◆ get()

unsigned llvm::LiveRangeEdit::get ( unsigned  idx) const
inline

◆ getParent()

LiveInterval& llvm::LiveRangeEdit::getParent ( ) const
inline

◆ getReg()

unsigned llvm::LiveRangeEdit::getReg ( ) const
inline

◆ markRematerialized()

void llvm::LiveRangeEdit::markRematerialized ( const VNInfo ParentVNI)
inline

markRematerialized - explicitly mark a value as rematerialized after doing it manually.

Definition at line 227 of file LiveRangeEdit.h.

References llvm::SmallPtrSetImpl< PtrType >::insert().

◆ pop_back()

void llvm::LiveRangeEdit::pop_back ( )
inline

pop_back - It allows LiveRangeEdit users to drop new registers.

The context is when an original def instruction of a register is dead after rematerialization, we still want to keep it for following rematerializations. We save the def instruction in DeadRemats, and replace the original dst register with a new dummy register so the live range of original dst register can be shrinked normally. We don't want to allocate phys register for the dummy register, so we want to drop it from the NewRegs set.

Definition at line 174 of file LiveRangeEdit.h.

References llvm::SmallVectorTemplateBase< T, bool >::pop_back().

Referenced by eraseVirtReg().

◆ regs()

ArrayRef<unsigned> llvm::LiveRangeEdit::regs ( ) const
inline

Definition at line 176 of file LiveRangeEdit.h.

References createFrom(), and llvm::makeArrayRef().

Referenced by getNumAllocatableRegsForConstraints().

◆ rematerializeAt()

SlotIndex LiveRangeEdit::rematerializeAt ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
unsigned  DestReg,
const Remat RM,
const TargetRegisterInfo tri,
bool  Late = false 
)

rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an instruction into MBB before MI.

The new instruction is mapped, but liveness is not updated. Return the SlotIndex of the new instruction.

Definition at line 165 of file LiveRangeEdit.cpp.

References assert(), MI, llvm::LiveRangeEdit::Remat::OrigMI, llvm::LiveRangeEdit::Remat::ParentVNI, and TII.

Referenced by llvm::SplitEditor::dump(), and llvm::LiveRangeEdit::Remat::Remat().

◆ size()

unsigned llvm::LiveRangeEdit::size ( ) const
inline

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