LLVM  3.7.0
Public Member Functions | Friends | List of all members
llvm::MachineSSAUpdater Class Reference

MachineSSAUpdater - This class updates SSA form for a set of virtual registers defined in multiple blocks. More...

#include <MachineSSAUpdater.h>

Public Member Functions

 MachineSSAUpdater (MachineFunction &MF, SmallVectorImpl< MachineInstr * > *InsertedPHIs=nullptr)
 MachineSSAUpdater constructor. More...
 
 ~MachineSSAUpdater ()
 
void Initialize (unsigned V)
 Initialize - Reset this object to get ready for a new set of SSA updates. More...
 
void AddAvailableValue (MachineBasicBlock *BB, unsigned V)
 AddAvailableValue - Indicate that a rewritten value is available at the end of the specified block with the specified value. More...
 
bool HasValueForBlock (MachineBasicBlock *BB) const
 HasValueForBlock - Return true if the MachineSSAUpdater already has a value for the specified block. More...
 
unsigned GetValueAtEndOfBlock (MachineBasicBlock *BB)
 GetValueAtEndOfBlock - Construct SSA form, materializing a value that is live at the end of the specified block. More...
 
unsigned GetValueInMiddleOfBlock (MachineBasicBlock *BB)
 GetValueInMiddleOfBlock - Construct SSA form, materializing a value that is live in the middle of the specified block. More...
 
void RewriteUse (MachineOperand &U)
 RewriteUse - Rewrite a use of the symbolic value. More...
 

Friends

class SSAUpdaterTraits< MachineSSAUpdater >
 

Detailed Description

MachineSSAUpdater - This class updates SSA form for a set of virtual registers defined in multiple blocks.

This is used when code duplication or another unstructured transformation wants to rewrite a set of uses of one vreg with uses of a set of vregs.

Definition at line 35 of file MachineSSAUpdater.h.

Constructor & Destructor Documentation

MachineSSAUpdater::MachineSSAUpdater ( MachineFunction MF,
SmallVectorImpl< MachineInstr * > *  InsertedPHIs = nullptr 
)
explicit

MachineSSAUpdater constructor.

If InsertedPHIs is specified, it will be filled in with all PHI Nodes created by rewriting.

Definition at line 39 of file MachineSSAUpdater.cpp.

References llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getRegInfo(), and llvm::MachineFunction::getSubtarget().

MachineSSAUpdater::~MachineSSAUpdater ( )

Definition at line 46 of file MachineSSAUpdater.cpp.

Member Function Documentation

void MachineSSAUpdater::AddAvailableValue ( MachineBasicBlock BB,
unsigned  V 
)

AddAvailableValue - Indicate that a rewritten value is available at the end of the specified block with the specified value.

AddAvailableValue - Indicate that a rewritten value is available in the specified block with the specified value.

Definition at line 70 of file MachineSSAUpdater.cpp.

References getAvailableVals().

unsigned MachineSSAUpdater::GetValueAtEndOfBlock ( MachineBasicBlock BB)

GetValueAtEndOfBlock - Construct SSA form, materializing a value that is live at the end of the specified block.

Definition at line 76 of file MachineSSAUpdater.cpp.

unsigned MachineSSAUpdater::GetValueInMiddleOfBlock ( MachineBasicBlock BB)

GetValueInMiddleOfBlock - Construct SSA form, materializing a value that is live in the middle of the specified block.

GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one important case: if there is a definition of the rewritten value after the 'use' in BB. Consider code like this:

 X1 = ...

SomeBB: use(X) X2 = ... br Cond, SomeBB, OutBB

In this case, there are two values (X1 and X2) added to the AvailableVals set by the client of the rewriter, and those values are both live out of their respective blocks. However, the use of X happens in the middle of a block. Because of this, we need to insert a new PHI node in SomeBB to merge the appropriate values, and this value isn't live out of the block.

Definition at line 142 of file MachineSSAUpdater.cpp.

References llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::begin(), llvm::dbgs(), DEBUG, llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::eraseFromParent(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), HasValueForBlock(), llvm::TargetOpcode::IMPLICIT_DEF, InsertNewDef(), llvm::MachineInstr::isConstantValuePHI(), LookForIdenticalPHI(), llvm::TargetOpcode::PHI, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_empty(), llvm::MachineBasicBlock::pred_end(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::SmallVectorTemplateCommon< T >::size().

Referenced by RewriteUse().

bool MachineSSAUpdater::HasValueForBlock ( MachineBasicBlock BB) const

HasValueForBlock - Return true if the MachineSSAUpdater already has a value for the specified block.

Definition at line 64 of file MachineSSAUpdater.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), and getAvailableVals().

Referenced by GetValueInMiddleOfBlock().

void MachineSSAUpdater::Initialize ( unsigned  V)

Initialize - Reset this object to get ready for a new set of SSA updates.

ProtoValue is the value used to name PHI nodes.

Definition at line 52 of file MachineSSAUpdater.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), getAvailableVals(), and llvm::MachineRegisterInfo::getRegClass().

void MachineSSAUpdater::RewriteUse ( MachineOperand U)

RewriteUse - Rewrite a use of the symbolic value.

This handles PHI nodes, which use their value in the corresponding predecessor. Note that this will not work if the use is supposed to be rewritten to a value defined in the same block as the use, but above it. Any 'AddAvailableValue's added for the use's block will be considered to be below it.

This handles PHI nodes, which use their value in the corresponding predecessor.

Definition at line 222 of file MachineSSAUpdater.cpp.

References findCorrespondingPred(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getParent(), GetValueInMiddleOfBlock(), llvm::MachineInstr::isPHI(), and llvm::MachineOperand::setReg().

Friends And Related Function Documentation

friend class SSAUpdaterTraits< MachineSSAUpdater >
friend

Definition at line 36 of file MachineSSAUpdater.h.


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