LLVM  8.0.1
Public Member Functions | List of all members
llvm::CoalescerPair Class Reference

A helper class for register coalescers. More...

#include "CodeGen/RegisterCoalescer.h"

Public Member Functions

 CoalescerPair (const TargetRegisterInfo &tri)
 
 CoalescerPair (unsigned VirtReg, unsigned PhysReg, const TargetRegisterInfo &tri)
 Create a CoalescerPair representing a virtreg-to-physreg copy. More...
 
bool setRegisters (const MachineInstr *)
 Set registers to match the copy instruction MI. More...
 
bool flip ()
 Swap SrcReg and DstReg. More...
 
bool isCoalescable (const MachineInstr *) const
 Return true if MI is a copy instruction that will become an identity copy after coalescing. More...
 
bool isPhys () const
 Return true if DstReg is a physical register. More...
 
bool isPartial () const
 Return true if the original copy instruction did not copy the full register, but was a subreg operation. More...
 
bool isCrossClass () const
 Return true if DstReg is virtual and NewRC is a smaller register class than DstReg's. More...
 
bool isFlipped () const
 Return true when getSrcReg is the register being defined by the original copy instruction. More...
 
unsigned getDstReg () const
 Return the register (virtual or physical) that will remain after coalescing. More...
 
unsigned getSrcReg () const
 Return the virtual register that will be coalesced away. More...
 
unsigned getDstIdx () const
 Return the subregister index that DstReg will be coalesced into, or 0. More...
 
unsigned getSrcIdx () const
 Return the subregister index that SrcReg will be coalesced into, or 0. More...
 
const TargetRegisterClassgetNewRC () const
 Return the register class of the coalesced register. More...
 

Detailed Description

A helper class for register coalescers.

When deciding if two registers can be coalesced, CoalescerPair can determine if a copy instruction would become an identity copy after coalescing.

Definition at line 27 of file RegisterCoalescer.h.

Constructor & Destructor Documentation

◆ CoalescerPair() [1/2]

llvm::CoalescerPair::CoalescerPair ( const TargetRegisterInfo tri)
inline

Definition at line 59 of file RegisterCoalescer.h.

◆ CoalescerPair() [2/2]

llvm::CoalescerPair::CoalescerPair ( unsigned  VirtReg,
unsigned  PhysReg,
const TargetRegisterInfo tri 
)
inline

Create a CoalescerPair representing a virtreg-to-physreg copy.

No need to call setRegisters().

Definition at line 63 of file RegisterCoalescer.h.

References flip(), isCoalescable(), and setRegisters().

Member Function Documentation

◆ flip()

bool CoalescerPair::flip ( )

Swap SrcReg and DstReg.

Return false if swapping is impossible because DstReg is a physical register, or SubIdx is set.

Definition at line 463 of file RegisterCoalescer.cpp.

References llvm::TargetRegisterInfo::isPhysicalRegister(), and std::swap().

Referenced by CoalescerPair().

◆ getDstIdx()

unsigned llvm::CoalescerPair::getDstIdx ( ) const
inline

Return the subregister index that DstReg will be coalesced into, or 0.

Definition at line 102 of file RegisterCoalescer.h.

Referenced by definesFullReg().

◆ getDstReg()

unsigned llvm::CoalescerPair::getDstReg ( ) const
inline

Return the register (virtual or physical) that will remain after coalescing.

Definition at line 96 of file RegisterCoalescer.h.

Referenced by addSegmentsWithValNo(), definesFullReg(), isCoalescable(), and isDefInSubRange().

◆ getNewRC()

const TargetRegisterClass* llvm::CoalescerPair::getNewRC ( ) const
inline

Return the register class of the coalesced register.

Definition at line 108 of file RegisterCoalescer.h.

Referenced by definesFullReg(), and isDefInSubRange().

◆ getSrcIdx()

unsigned llvm::CoalescerPair::getSrcIdx ( ) const
inline

Return the subregister index that SrcReg will be coalesced into, or 0.

Definition at line 105 of file RegisterCoalescer.h.

Referenced by definesFullReg(), and isDefInSubRange().

◆ getSrcReg()

unsigned llvm::CoalescerPair::getSrcReg ( ) const
inline

Return the virtual register that will be coalesced away.

Definition at line 99 of file RegisterCoalescer.h.

Referenced by addSegmentsWithValNo(), definesFullReg(), isCoalescable(), and isDefInSubRange().

◆ isCoalescable()

bool CoalescerPair::isCoalescable ( const MachineInstr MI) const

Return true if MI is a copy instruction that will become an identity copy after coalescing.

Definition at line 472 of file RegisterCoalescer.cpp.

References llvm::AnalysisUsage::addPreserved(), llvm::AnalysisUsage::addPreservedID(), llvm::AnalysisUsage::addRequired(), llvm::LiveRange::addSegment(), assert(), llvm::LiveRange::begin(), llvm::TargetRegisterInfo::composeSubRegIndices(), llvm::HexagonISD::CP, llvm::dbgs(), llvm::VNInfo::def, llvm::LiveRangeEdit::eliminateDeadDefs(), llvm::LiveRange::Segment::end, llvm::LiveRange::end(), llvm::MachineInstr::findRegisterUseOperandIdx(), llvm::LiveRange::FindSegmentContaining(), llvm::MachineFunctionPass::getAnalysisUsage(), getDstReg(), llvm::LiveIntervals::getInstructionFromIndex(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::SlotIndex::getPrevSlot(), llvm::SlotIndex::getRegSlot(), getSrcReg(), llvm::MCRegisterInfo::getSubReg(), llvm::LiveIntervals::hasPHIKill(), llvm::SmallPtrSetImpl< PtrType >::insert(), isCoalescable(), isFlipped(), llvm::MachineInstr::isFullCopy(), isMoveInstr(), isPartial(), isPhys(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::SlotIndex::isSameInstr(), LLVM_DEBUG, llvm::MachineDominatorsID, llvm::LiveRange::MergeValueNumberInto(), llvm::printReg(), llvm::LiveInterval::reg, llvm::LiveRange::segments, llvm::MachineOperand::setIsKill(), llvm::AnalysisUsage::setPreservesCFG(), llvm::LiveRange::Segment::start, llvm::LiveInterval::subranges(), llvm::MachineInstr::substituteRegister(), std::swap(), llvm::upper_bound(), and llvm::LiveRange::Segment::valno.

Referenced by CoalescerPair(), isCoalescable(), and llvm::LiveRange::overlaps().

◆ isCrossClass()

bool llvm::CoalescerPair::isCrossClass ( ) const
inline

Return true if DstReg is virtual and NewRC is a smaller register class than DstReg's.

Definition at line 88 of file RegisterCoalescer.h.

◆ isFlipped()

bool llvm::CoalescerPair::isFlipped ( ) const
inline

Return true when getSrcReg is the register being defined by the original copy instruction.

Definition at line 92 of file RegisterCoalescer.h.

Referenced by addSegmentsWithValNo(), definesFullReg(), and isCoalescable().

◆ isPartial()

bool llvm::CoalescerPair::isPartial ( ) const
inline

Return true if the original copy instruction did not copy the full register, but was a subreg operation.

Definition at line 84 of file RegisterCoalescer.h.

Referenced by isCoalescable().

◆ isPhys()

bool llvm::CoalescerPair::isPhys ( ) const
inline

Return true if DstReg is a physical register.

Definition at line 80 of file RegisterCoalescer.h.

Referenced by addSegmentsWithValNo(), isCoalescable(), and isDefInSubRange().

◆ setRegisters()

bool CoalescerPair::setRegisters ( const MachineInstr MI)

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