LLVM  10.0.0svn
Public Member Functions | Protected Attributes | List of all members
llvm::CombinerHelper Class Reference

#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"

Collaboration diagram for llvm::CombinerHelper:
Collaboration graph
[legend]

Public Member Functions

 CombinerHelper (GISelChangeObserver &Observer, MachineIRBuilder &B, GISelKnownBits *KB=nullptr, MachineDominatorTree *MDT=nullptr)
 
void replaceRegWith (MachineRegisterInfo &MRI, Register FromReg, Register ToReg) const
 MachineRegisterInfo::replaceRegWith() and inform the observer of the changes. More...
 
void replaceRegOpWith (MachineRegisterInfo &MRI, MachineOperand &FromRegOp, Register ToReg) const
 Replace a single register operand with a new register and inform the observer of the changes. More...
 
bool tryCombineCopy (MachineInstr &MI)
 If MI is COPY, try to combine it. More...
 
bool matchCombineCopy (MachineInstr &MI)
 
void applyCombineCopy (MachineInstr &MI)
 
bool isPredecessor (MachineInstr &DefMI, MachineInstr &UseMI)
 
bool dominates (MachineInstr &DefMI, MachineInstr &UseMI)
 
bool tryCombineExtendingLoads (MachineInstr &MI)
 If MI is extend that consumes the result of a load, try to combine it. More...
 
bool matchCombineExtendingLoads (MachineInstr &MI, PreferredTuple &MatchInfo)
 
void applyCombineExtendingLoads (MachineInstr &MI, PreferredTuple &MatchInfo)
 
bool tryCombineIndexedLoadStore (MachineInstr &MI)
 Combine MI into a pre-indexed or post-indexed load/store operation if legal and the surrounding code makes it useful. More...
 
bool matchCombineBr (MachineInstr &MI)
 
bool tryCombineBr (MachineInstr &MI)
 
bool tryCombineMemCpyFamily (MachineInstr &MI, unsigned MaxLen=0)
 Optimize memcpy intrinsics et al, e.g. More...
 
bool tryCombine (MachineInstr &MI)
 Try to transform MI by using all of the above combine functions. More...
 

Protected Attributes

MachineIRBuilderBuilder
 
MachineRegisterInfoMRI
 
GISelChangeObserverObserver
 
GISelKnownBitsKB
 
MachineDominatorTreeMDT
 

Detailed Description

Definition at line 39 of file CombinerHelper.h.

Constructor & Destructor Documentation

◆ CombinerHelper()

CombinerHelper::CombinerHelper ( GISelChangeObserver Observer,
MachineIRBuilder B,
GISelKnownBits KB = nullptr,
MachineDominatorTree MDT = nullptr 
)

Definition at line 34 of file CombinerHelper.cpp.

Member Function Documentation

◆ applyCombineCopy()

void CombinerHelper::applyCombineCopy ( MachineInstr MI)

◆ applyCombineExtendingLoads()

void CombinerHelper::applyCombineExtendingLoads ( MachineInstr MI,
PreferredTuple MatchInfo 
)

◆ dominates()

bool CombinerHelper::dominates ( MachineInstr DefMI,
MachineInstr UseMI 
)

◆ isPredecessor()

bool CombinerHelper::isPredecessor ( MachineInstr DefMI,
MachineInstr UseMI 
)
Returns
true if DefMI precedes UseMI or they are the same instruction. Both must be in the same basic block.

Definition at line 362 of file CombinerHelper.cpp.

References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineInstr::getParent(), I, llvm_unreachable, and UseMI.

Referenced by dominates().

◆ matchCombineBr()

bool CombinerHelper::matchCombineBr ( MachineInstr MI)

◆ matchCombineCopy()

bool CombinerHelper::matchCombineCopy ( MachineInstr MI)

◆ matchCombineExtendingLoads()

bool CombinerHelper::matchCombineExtendingLoads ( MachineInstr MI,
PreferredTuple MatchInfo 
)

◆ replaceRegOpWith()

void CombinerHelper::replaceRegOpWith ( MachineRegisterInfo MRI,
MachineOperand FromRegOp,
Register  ToReg 
) const

Replace a single register operand with a new register and inform the observer of the changes.

Definition at line 54 of file CombinerHelper.cpp.

References assert(), llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), llvm::MachineOperand::getParent(), Observer, and llvm::MachineOperand::setReg().

Referenced by applyCombineExtendingLoads().

◆ replaceRegWith()

void CombinerHelper::replaceRegWith ( MachineRegisterInfo MRI,
Register  FromReg,
Register  ToReg 
) const

◆ tryCombine()

bool CombinerHelper::tryCombine ( MachineInstr MI)

Try to transform MI by using all of the above combine functions.

Returns true if changed.

Definition at line 1121 of file CombinerHelper.cpp.

References tryCombineCopy(), tryCombineExtendingLoads(), and tryCombineIndexedLoadStore().

◆ tryCombineBr()

bool CombinerHelper::tryCombineBr ( MachineInstr MI)

◆ tryCombineCopy()

bool CombinerHelper::tryCombineCopy ( MachineInstr MI)

If MI is COPY, try to combine it.

Returns true if MI changed.

Definition at line 65 of file CombinerHelper.cpp.

References applyCombineCopy(), and matchCombineCopy().

Referenced by tryCombine().

◆ tryCombineExtendingLoads()

bool CombinerHelper::tryCombineExtendingLoads ( MachineInstr MI)

If MI is extend that consumes the result of a load, try to combine it.

Returns true if MI changed.

Definition at line 177 of file CombinerHelper.cpp.

References applyCombineExtendingLoads(), and matchCombineExtendingLoads().

Referenced by tryCombine().

◆ tryCombineIndexedLoadStore()

bool CombinerHelper::tryCombineIndexedLoadStore ( MachineInstr MI)

◆ tryCombineMemCpyFamily()

bool CombinerHelper::tryCombineMemCpyFamily ( MachineInstr MI,
unsigned  MaxLen = 0 
)

Optimize memcpy intrinsics et al, e.g.

constant len calls. /p MaxLen if non-zero specifies the max length of a mem libcall to inline.

For example (pre-indexed):

$addr = G_GEP $base, $offset
[...]
$val = G_LOAD $addr
[...]
$whatever = COPY $addr

–>

$val, $addr = G_INDEXED_LOAD $base, $offset, 1 (IsPre)
[...]
$whatever = COPY $addr

or (post-indexed):

G_STORE $val, $base
[...]
$addr = G_GEP $base, $offset
[...]
$whatever = COPY $addr

–>

$addr = G_INDEXED_STORE $val, $base, $offset
[...]
$whatever = COPY $addr  

Definition at line 1070 of file CombinerHelper.cpp.

References assert(), llvm::MachineInstr::eraseFromParent(), llvm::MachineMemOperand::getBaseAlignment(), llvm::getConstantVRegValWithLookThrough(), llvm::MachineInstr::getIntrinsicID(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineMemOperand::isVolatile(), llvm::MachineInstr::memoperands_begin(), llvm::MachineInstr::memoperands_end(), and MRI.

Member Data Documentation

◆ Builder

MachineIRBuilder& llvm::CombinerHelper::Builder
protected

Definition at line 41 of file CombinerHelper.h.

Referenced by applyCombineCopy(), applyCombineExtendingLoads(), and replaceRegWith().

◆ KB

GISelKnownBits* llvm::CombinerHelper::KB
protected

Definition at line 44 of file CombinerHelper.h.

◆ MDT

MachineDominatorTree* llvm::CombinerHelper::MDT
protected

Definition at line 45 of file CombinerHelper.h.

Referenced by dominates().

◆ MRI

MachineRegisterInfo& llvm::CombinerHelper::MRI
protected

◆ Observer

GISelChangeObserver& llvm::CombinerHelper::Observer
protected

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