LLVM 22.0.0git
llvm::LiveRangeEdit Class Reference

#include "llvm/CodeGen/LiveRangeEdit.h"

Inheritance diagram for llvm::LiveRangeEdit:
[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<Register>::const_iterator
 Iterator for accessing the new registers added by this edit.

Public Member Functions

 LiveRangeEdit (const LiveInterval *parent, SmallVectorImpl< Register > &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.
 ~LiveRangeEdit () override
const LiveIntervalgetParent () const
Register getReg () const
iterator begin () const
iterator end () const
unsigned size () const
bool empty () const
Register get (unsigned idx) const
void pop_back ()
 pop_back - It allows LiveRangeEdit users to drop new registers.
ArrayRef< Registerregs () const
Register createFrom (Register OldReg)
 createFrom - Create a new virtual register based on OldReg.
LiveIntervalcreateEmptyInterval ()
 create - Create a new register with the same class and original slot as parent.
Register create ()
bool anyRematerializable ()
 anyRematerializable - Return true if any parent values may be rematerializable.
bool allUsesAvailableAt (const MachineInstr *OrigMI, SlotIndex OrigIdx, SlotIndex UseIdx) const
 allUsesAvailableAt - Return true if all registers used by OrigMI at OrigIdx are also available with the same value at UseIdx.
bool canRematerializeAt (Remat &RM, VNInfo *OrigVNI, SlotIndex UseIdx)
 canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx.
SlotIndex rematerializeAt (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, const Remat &RM, const TargetRegisterInfo &, bool Late=false, unsigned SubIdx=0, MachineInstr *ReplaceIndexMI=nullptr)
 rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an instruction into MBB before MI.
void markRematerialized (const VNInfo *ParentVNI)
 markRematerialized - explicitly mark a value as rematerialized after doing it manually.
bool didRematerialize (const VNInfo *ParentVNI) const
 didRematerialize - Return true if ParentVNI was rematerialized anywhere.
void eraseVirtReg (Register Reg)
 eraseVirtReg - Notify the delegate that Reg is no longer in use, and try to erase it from LIS.
void eliminateDeadDefs (SmallVectorImpl< MachineInstr * > &Dead, ArrayRef< Register > RegsBeingSpilled={})
 eliminateDeadDefs - Try to delete machine instructions that are now dead (allDefsAreDead returns true).
void calculateRegClassAndHint (MachineFunction &, VirtRegAuxInfo &)
 calculateRegClassAndHint - Recompute register class and hint for each new register.

Detailed Description

Definition at line 42 of file LiveRangeEdit.h.

Member Typedef Documentation

◆ iterator

Iterator for accessing the new registers added by this edit.

Definition at line 148 of file LiveRangeEdit.h.

Constructor & Destructor Documentation

◆ LiveRangeEdit()

llvm::LiveRangeEdit::LiveRangeEdit ( const LiveInterval * parent,
SmallVectorImpl< Register > & 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 128 of file LiveRangeEdit.h.

References size().

◆ ~LiveRangeEdit()

llvm::LiveRangeEdit::~LiveRangeEdit ( )
inlineoverride

Definition at line 138 of file LiveRangeEdit.h.

Member Function Documentation

◆ allUsesAvailableAt()

bool LiveRangeEdit::allUsesAvailableAt ( const MachineInstr * OrigMI,
SlotIndex OrigIdx,
SlotIndex UseIdx ) const

allUsesAvailableAt - Return true if all registers used by OrigMI at OrigIdx are also available with the same value at UseIdx.

Definition at line 97 of file LiveRangeEdit.cpp.

References llvm::SlotIndex::getRegSlot(), llvm::LiveRange::getVNInfoAt(), llvm::LiveInterval::hasSubRanges(), llvm::SlotIndex::isSameInstr(), llvm::LaneBitmask::none(), llvm::MachineInstr::operands(), llvm::LiveInterval::subranges(), SubReg, and TRI.

Referenced by canRematerializeAt().

◆ anyRematerializable()

bool LiveRangeEdit::anyRematerializable ( )

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

This function must be called before canRematerializeAt is called..

Definition at line 89 of file LiveRangeEdit.cpp.

◆ begin()

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

Definition at line 149 of file LiveRangeEdit.h.

◆ calculateRegClassAndHint()

void LiveRangeEdit::calculateRegClassAndHint ( MachineFunction & MF,
VirtRegAuxInfo & VRAI )

◆ canRematerializeAt()

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

canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx.

It is assumed that parent_.getVNINfoAt(UseIdx) == ParentVNI.

Definition at line 149 of file LiveRangeEdit.cpp.

References allUsesAvailableAt(), and assert().

◆ create()

Register llvm::LiveRangeEdit::create ( )
inline

Definition at line 176 of file LiveRangeEdit.h.

References createFrom(), and getReg().

◆ createEmptyInterval()

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

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

Definition at line 172 of file LiveRangeEdit.h.

References getReg().

◆ createFrom()

Register LiveRangeEdit::createFrom ( Register OldReg)

createFrom - Create a new virtual register based on OldReg.

Definition at line 55 of file LiveRangeEdit.cpp.

Referenced by create().

◆ didRematerialize()

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

didRematerialize - Return true if ParentVNI was rematerialized anywhere.

Definition at line 219 of file LiveRangeEdit.h.

◆ eliminateDeadDefs()

void LiveRangeEdit::eliminateDeadDefs ( SmallVectorImpl< MachineInstr * > & Dead,
ArrayRef< Register > RegsBeingSpilled = {} )

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 428 of file LiveRangeEdit.cpp.

References llvm::SetVector< T, Vector, Set, N >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::is_contained(), llvm::SetVector< T, Vector, Set, N >::pop_back_val(), llvm::LiveInterval::reg(), Register, and llvm::LiveRange::RenumberValues().

◆ empty()

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

Definition at line 152 of file LiveRangeEdit.h.

References size().

◆ end()

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

Definition at line 150 of file LiveRangeEdit.h.

◆ eraseVirtReg()

void LiveRangeEdit::eraseVirtReg ( Register Reg)

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

Definition at line 192 of file LiveRangeEdit.cpp.

◆ get()

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

Definition at line 153 of file LiveRangeEdit.h.

Referenced by calculateRegClassAndHint().

◆ getParent()

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

Definition at line 140 of file LiveRangeEdit.h.

References assert().

Referenced by getReg().

◆ getReg()

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

Definition at line 145 of file LiveRangeEdit.h.

References getParent(), and llvm::LiveInterval::reg().

Referenced by create(), and createEmptyInterval().

◆ markRematerialized()

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

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

Definition at line 214 of file LiveRangeEdit.h.

◆ 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 163 of file LiveRangeEdit.h.

◆ regs()

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

Definition at line 165 of file LiveRangeEdit.h.

References llvm::ArrayRef().

◆ rematerializeAt()

SlotIndex LiveRangeEdit::rematerializeAt ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MI,
Register DestReg,
const Remat & RM,
const TargetRegisterInfo & tri,
bool Late = false,
unsigned SubIdx = 0,
MachineInstr * ReplaceIndexMI = nullptr )

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

The new instruction is mapped, but liveness is not updated. If ReplaceIndexMI is not null it will be replaced by new MI in the index map. Return the SlotIndex of the new instruction.

Definition at line 169 of file LiveRangeEdit.cpp.

References assert(), MBB, and MI.

◆ size()

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

Definition at line 151 of file LiveRangeEdit.h.

Referenced by calculateRegClassAndHint(), empty(), and LiveRangeEdit().


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