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

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 28 of file RegisterCoalescer.h.

Constructor & Destructor Documentation

◆ CoalescerPair() [1/2]

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

Definition at line 60 of file RegisterCoalescer.h.

References TRI.

◆ CoalescerPair() [2/2]

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

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

No need to call setRegisters().

Definition at line 64 of file RegisterCoalescer.h.

References TRI.

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 540 of file RegisterCoalescer.cpp.

References llvm::Register::isPhysical(), and std::swap().

◆ getDstIdx()

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

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

Definition at line 103 of file RegisterCoalescer.h.

◆ getDstReg()

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

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

Definition at line 97 of file RegisterCoalescer.h.

◆ getNewRC()

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

Return the register class of the coalesced register.

Definition at line 109 of file RegisterCoalescer.h.

◆ getSrcIdx()

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

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

Definition at line 106 of file RegisterCoalescer.h.

◆ getSrcReg()

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

Return the virtual register that will be coalesced away.

Definition at line 100 of file RegisterCoalescer.h.

◆ 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 549 of file RegisterCoalescer.cpp.

References assert(), isMoveInstr(), llvm::Register::isPhysical(), MI, std::swap(), and TRI.

◆ 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 89 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 93 of file RegisterCoalescer.h.

◆ 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 85 of file RegisterCoalescer.h.

◆ isPhys()

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

Return true if DstReg is a physical register.

Definition at line 81 of file RegisterCoalescer.h.

◆ setRegisters()

bool CoalescerPair::setRegisters ( const MachineInstr MI)

Set registers to match the copy instruction MI.

Return false if MI is not a coalescable copy instruction.

Definition at line 452 of file RegisterCoalescer.cpp.

References assert(), isMoveInstr(), MI, MRI, std::swap(), and TRI.


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