LLVM  8.0.1
Classes | Namespaces | Macros | Enumerations | Functions | Variables
MIRCanonicalizerPass.cpp File Reference
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/raw_ostream.h"
#include <queue>
Include dependency graph for MIRCanonicalizerPass.cpp:

Go to the source code of this file.

Classes

class  TypedVReg
 

Namespaces

 llvm
 This class represents lattice values for constants.
 

Macros

#define DEBUG_TYPE   "mir-canonicalizer"
 

Enumerations

enum  VRType { RSE_Reg = 0, RSE_FrameIndex, RSE_NewCandidate }
 

Functions

 INITIALIZE_PASS_BEGIN (MIRCanonicalizer, "mir-canonicalizer", "Rename Register Operands Canonically", false, false) INITIALIZE_PASS_END(MIRCanonicalizer
 
mir Rename Register Operands static false std::vector< MachineBasicBlock * > GetRPOList (MachineFunction &MF)
 
static bool rescheduleLexographically (std::vector< MachineInstr *> instructions, MachineBasicBlock *MBB, std::function< MachineBasicBlock::iterator()> getPos)
 
static bool rescheduleCanonically (unsigned &PseudoIdempotentInstCount, MachineBasicBlock *MBB)
 
static bool propagateLocalCopies (MachineBasicBlock *MBB)
 
static std::vector< MachineInstr * > populateCandidates (MachineBasicBlock *MBB)
 Here we find our candidates. More...
 
static void doCandidateWalk (std::vector< TypedVReg > &VRegs, std::queue< TypedVReg > &RegQueue, std::vector< MachineInstr *> &VisitedMIs, const MachineBasicBlock *MBB)
 
static std::map< unsigned, unsignedGetVRegRenameMap (const std::vector< TypedVReg > &VRegs, const std::vector< unsigned > &renamedInOtherBB, MachineRegisterInfo &MRI, NamedVRegCursor &NVC)
 
static bool doVRegRenaming (std::vector< unsigned > &RenamedInOtherBB, const std::map< unsigned, unsigned > &VRegRenameMap, MachineRegisterInfo &MRI)
 
static bool doDefKillClear (MachineBasicBlock *MBB)
 
static bool runOnBasicBlock (MachineBasicBlock *MBB, std::vector< StringRef > &bbNames, std::vector< unsigned > &renamedInOtherBB, unsigned &basicBlockNum, unsigned &VRegGapIndex, NamedVRegCursor &NVC)
 

Variables

charllvm::MIRCanonicalizerID = MIRCanonicalizer::ID
 
static cl::opt< unsignedCanonicalizeFunctionNumber ("canon-nth-function", cl::Hidden, cl::init(~0u), cl::value_desc("N"), cl::desc("Function number to canonicalize."))
 
static cl::opt< unsignedCanonicalizeBasicBlockNumber ("canon-nth-basicblock", cl::Hidden, cl::init(~0u), cl::value_desc("N"), cl::desc("BasicBlock number to canonicalize."))
 
mir canonicalizer
 
mir Rename Register Operands Canonically
 
mir Rename Register Operands false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mir-canonicalizer"

Definition at line 43 of file MIRCanonicalizerPass.cpp.

Enumeration Type Documentation

◆ VRType

enum VRType
Enumerator
RSE_Reg 
RSE_FrameIndex 
RSE_NewCandidate 

Definition at line 75 of file MIRCanonicalizerPass.cpp.

Function Documentation

◆ doCandidateWalk()

static void doCandidateWalk ( std::vector< TypedVReg > &  VRegs,
std::queue< TypedVReg > &  RegQueue,
std::vector< MachineInstr *> &  VisitedMIs,
const MachineBasicBlock MBB 
)
static

◆ doDefKillClear()

static bool doDefKillClear ( MachineBasicBlock MBB)
static

Definition at line 613 of file MIRCanonicalizerPass.cpp.

References MI.

Referenced by runOnBasicBlock().

◆ doVRegRenaming()

static bool doVRegRenaming ( std::vector< unsigned > &  RenamedInOtherBB,
const std::map< unsigned, unsigned > &  VRegRenameMap,
MachineRegisterInfo MRI 
)
static

Definition at line 585 of file MIRCanonicalizerPass.cpp.

References E, I, and llvm::MachineRegisterInfo::reg_operands().

Referenced by runOnBasicBlock().

◆ GetRPOList()

mir Rename Register Operands static false std::vector<MachineBasicBlock *> GetRPOList ( MachineFunction MF)
static

Definition at line 107 of file MIRCanonicalizerPass.cpp.

Referenced by runOnBasicBlock().

◆ GetVRegRenameMap()

static std::map<unsigned, unsigned> GetVRegRenameMap ( const std::vector< TypedVReg > &  VRegs,
const std::vector< unsigned > &  renamedInOtherBB,
MachineRegisterInfo MRI,
NamedVRegCursor &  NVC 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( MIRCanonicalizer  ,
"mir-canonicalizer ,
"Rename Register Operands Canonically ,
false  ,
false   
)

◆ populateCandidates()

static std::vector<MachineInstr *> populateCandidates ( MachineBasicBlock MBB)
static

Here we find our candidates.

What makes an interesting candidate? An candidate for a canonicalization tree root is normally any kind of instruction that causes side effects such as a store to memory or a copy to a physical register or a return instruction. We use these as an expression tree root that we walk inorder to build a canonical walk which should result in canoncal vreg renaming.

Definition at line 366 of file MIRCanonicalizerPass.cpp.

References llvm::MachineBasicBlock::begin(), llvm::dbgs(), llvm::MachineInstr::dump(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::ARM_PROC::IE, llvm::MachineInstr::isBranch(), llvm::MachineOperand::isReg(), llvm::TargetRegisterInfo::isVirtualRegister(), LLVM_DEBUG, llvm::MachineInstr::mayStore(), MI, MRI, llvm::MachineRegisterInfo::use_begin(), and llvm::MachineRegisterInfo::use_end().

Referenced by runOnBasicBlock().

◆ propagateLocalCopies()

static bool propagateLocalCopies ( MachineBasicBlock MBB)
static

◆ rescheduleCanonically()

static bool rescheduleCanonically ( unsigned PseudoIdempotentInstCount,
MachineBasicBlock MBB 
)
static

◆ rescheduleLexographically()

static bool rescheduleLexographically ( std::vector< MachineInstr *>  instructions,
MachineBasicBlock MBB,
std::function< MachineBasicBlock::iterator()>  getPos 
)
static

◆ runOnBasicBlock()

static bool runOnBasicBlock ( MachineBasicBlock MBB,
std::vector< StringRef > &  bbNames,
std::vector< unsigned > &  renamedInOtherBB,
unsigned basicBlockNum,
unsigned VRegGapIndex,
NamedVRegCursor &  NVC 
)
static

Variable Documentation

◆ CanonicalizeBasicBlockNumber

cl::opt<unsigned> CanonicalizeBasicBlockNumber("canon-nth-basicblock", cl::Hidden, cl::init(~0u), cl::value_desc("N"), cl::desc("BasicBlock number to canonicalize."))
static

Referenced by runOnBasicBlock().

◆ CanonicalizeFunctionNumber

cl::opt<unsigned> CanonicalizeFunctionNumber("canon-nth-function", cl::Hidden, cl::init(~0u), cl::value_desc("N"), cl::desc("Function number to canonicalize."))
static

Referenced by runOnBasicBlock().

◆ canonicalizer

mir canonicalizer

Definition at line 104 of file MIRCanonicalizerPass.cpp.

◆ Canonically

mir Rename Register Operands Canonically

Definition at line 104 of file MIRCanonicalizerPass.cpp.

◆ false

mir Rename Register Operands false

Definition at line 104 of file MIRCanonicalizerPass.cpp.