LLVM  8.0.1
Classes | Namespaces | Macros | Functions | Variables
PPCReduceCRLogicals.cpp File Reference
#include "PPC.h"
#include "PPCInstrInfo.h"
#include "PPCTargetMachine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Debug.h"
Include dependency graph for PPCReduceCRLogicals.cpp:

Go to the source code of this file.

Classes

struct  BlockSplitInfo
 

Namespaces

 llvm
 This class represents lattice values for constants.
 

Macros

#define DEBUG_TYPE   "ppc-reduce-cr-ops"
 

Functions

 STATISTIC (NumContainedSingleUseBinOps, "Number of single-use binary CR logical ops contained in a block")
 
 STATISTIC (NumToSplitBlocks, "Number of binary CR logical ops that can be used to split blocks")
 
 STATISTIC (TotalCRLogicals, "Number of CR logical ops.")
 
 STATISTIC (TotalNullaryCRLogicals, "Number of nullary CR logical ops (CRSET/CRUNSET).")
 
 STATISTIC (TotalUnaryCRLogicals, "Number of unary CR logical ops.")
 
 STATISTIC (TotalBinaryCRLogicals, "Number of CR logical ops.")
 
 STATISTIC (NumBlocksSplitOnBinaryCROp, "Number of blocks split on CR binary logical ops.")
 
 STATISTIC (NumNotSplitIdenticalOperands, "Number of blocks not split due to operands being identical.")
 
 STATISTIC (NumNotSplitChainCopies, "Number of blocks not split due to operands being chained copies.")
 
 STATISTIC (NumNotSplitWrongOpcode, "Number of blocks not split due to the wrong opcode.")
 
void llvm::initializePPCReduceCRLogicalsPass (PassRegistry &)
 
static void updatePHIs (MachineBasicBlock *Successor, MachineBasicBlock *OrigMBB, MachineBasicBlock *NewMBB, MachineRegisterInfo *MRI)
 Given a basic block Successor that potentially contains PHIs, this function will look for any incoming values in the PHIs that are supposed to be coming from OrigMBB but whose definition is actually in NewMBB. More...
 
static void addIncomingValuesToPHIs (MachineBasicBlock *Successor, MachineBasicBlock *OrigMBB, MachineBasicBlock *NewMBB, MachineRegisterInfo *MRI)
 Given a basic block Successor that potentially contains PHIs, this function will look for PHIs that have an incoming value from OrigMBB and will add the same incoming value from NewMBB. More...
 
static bool splitMBB (BlockSplitInfo &BSI)
 Splits a MachineBasicBlock to branch before SplitBefore. More...
 
static bool isBinary (MachineInstr &MI)
 
static bool isNullary (MachineInstr &MI)
 
static void computeBranchTargetAndInversion (unsigned CROp, unsigned BROp, bool UsingDef1, bool &InvertNewBranch, bool &InvertOrigBranch, bool &TargetIsFallThrough)
 Given a CR logical operation CROp, branch opcode BROp as well as a flag to indicate if the first operand of CROp is used as the SplitBefore operand, determines whether either of the branches are to be inverted as well as whether the new target should be the original fall-through block. More...
 
 INITIALIZE_PASS_BEGIN (PPCReduceCRLogicals, DEBUG_TYPE, "PowerPC Reduce CR logical Operation", false, false) INITIALIZE_PASS_END(PPCReduceCRLogicals
 

Variables

 DEBUG_TYPE
 
PowerPC Reduce CR logical Operation
 
PowerPC Reduce CR logical false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "ppc-reduce-cr-ops"

Definition at line 32 of file PPCReduceCRLogicals.cpp.

Referenced by computeBranchTargetAndInversion().

Function Documentation

◆ addIncomingValuesToPHIs()

static void addIncomingValuesToPHIs ( MachineBasicBlock Successor,
MachineBasicBlock OrigMBB,
MachineBasicBlock NewMBB,
MachineRegisterInfo MRI 
)
static

Given a basic block Successor that potentially contains PHIs, this function will look for PHIs that have an incoming value from OrigMBB and will add the same incoming value from NewMBB.

NOTE: This should only be used if NewMBB is an immediate dominator of OrigMBB.

Definition at line 89 of file PPCReduceCRLogicals.cpp.

References llvm::MachineInstrBuilder::addReg(), assert(), llvm::MachineOperand::getMBB(), llvm::MachineBasicBlock::instrs(), llvm::MachineBasicBlock::isSuccessor(), and MI.

Referenced by splitMBB().

◆ computeBranchTargetAndInversion()

static void computeBranchTargetAndInversion ( unsigned  CROp,
unsigned  BROp,
bool  UsingDef1,
bool InvertNewBranch,
bool InvertOrigBranch,
bool TargetIsFallThrough 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( PPCReduceCRLogicals  ,
DEBUG_TYPE  ,
"PowerPC Reduce CR logical Operation ,
false  ,
false   
)

◆ isBinary()

static bool isBinary ( MachineInstr MI)
static

◆ isNullary()

static bool isNullary ( MachineInstr MI)
static

◆ splitMBB()

static bool splitMBB ( BlockSplitInfo BSI)
static

Splits a MachineBasicBlock to branch before SplitBefore.

The original branch is OrigBranch. The target of the new branch can either be the same as the target of the original branch or the fallthrough successor of the original block as determined by BranchToFallThrough. The branch conditions will be inverted according to InvertNewBranch and InvertOrigBranch. If an instruction that previously fed the branch is to be deleted, it is provided in MIToDelete and NewCond will be used as the branch condition. The branch probabilities will be set if the MachineBranchProbabilityInfo isn't null.

Definition at line 144 of file PPCReduceCRLogicals.cpp.

References addIncomingValuesToPHIs(), BlockSplitInfo::allInstrsInSameMBB(), assert(), B, BlockSplitInfo::BranchToFallThrough, llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::dbgs(), llvm::MachineBasicBlock::dump(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::eraseFromParent(), llvm::BranchProbability::getCompl(), llvm::MachineInstr::getDebugLoc(), llvm::MachineBranchProbabilityInfo::getEdgeProbability(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), llvm::BranchProbability::getUnknown(), llvm::MachineFunction::insert(), BlockSplitInfo::InvertNewBranch, BlockSplitInfo::InvertOrigBranch, llvm::MachineRegisterInfo::isSSA(), LLVM_DEBUG, BlockSplitInfo::MBPI, BlockSplitInfo::MIToDelete, MRI, BlockSplitInfo::NewCond, BlockSplitInfo::OrigBranch, llvm::MachineBasicBlock::splice(), BlockSplitInfo::SplitBefore, BlockSplitInfo::SplitCond, llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::successors(), TII, llvm::MachineBasicBlock::transferSuccessors(), and updatePHIs().

Referenced by computeBranchTargetAndInversion(), and getNonDebugInstr().

◆ STATISTIC() [1/10]

STATISTIC ( NumContainedSingleUseBinOps  ,
"Number of single-use binary CR logical ops contained in a block"   
)

◆ STATISTIC() [2/10]

STATISTIC ( NumToSplitBlocks  ,
"Number of binary CR logical ops that can be used to split blocks"   
)

◆ STATISTIC() [3/10]

STATISTIC ( TotalCRLogicals  ,
"Number of CR logical ops."   
)

◆ STATISTIC() [4/10]

STATISTIC ( TotalNullaryCRLogicals  ,
"Number of nullary CR logical ops (CRSET/CRUNSET)."   
)

◆ STATISTIC() [5/10]

STATISTIC ( TotalUnaryCRLogicals  ,
"Number of unary CR logical ops."   
)

◆ STATISTIC() [6/10]

STATISTIC ( TotalBinaryCRLogicals  ,
"Number of CR logical ops."   
)

◆ STATISTIC() [7/10]

STATISTIC ( NumBlocksSplitOnBinaryCROp  ,
"Number of blocks split on CR binary logical ops."   
)

◆ STATISTIC() [8/10]

STATISTIC ( NumNotSplitIdenticalOperands  ,
"Number of blocks not split due to operands being identical."   
)

◆ STATISTIC() [9/10]

STATISTIC ( NumNotSplitChainCopies  ,
"Number of blocks not split due to operands being chained copies."   
)

◆ STATISTIC() [10/10]

STATISTIC ( NumNotSplitWrongOpcode  ,
"Number of blocks not split due to the wrong opcode."   
)

◆ updatePHIs()

static void updatePHIs ( MachineBasicBlock Successor,
MachineBasicBlock OrigMBB,
MachineBasicBlock NewMBB,
MachineRegisterInfo MRI 
)
static

Given a basic block Successor that potentially contains PHIs, this function will look for any incoming values in the PHIs that are supposed to be coming from OrigMBB but whose definition is actually in NewMBB.

Any such PHIs will be updated to reflect reality.

Definition at line 60 of file PPCReduceCRLogicals.cpp.

References DefMI, llvm::MachineOperand::getMBB(), llvm::MachineInstr::getParent(), llvm::MachineRegisterInfo::getVRegDef(), llvm::MachineBasicBlock::instrs(), llvm::MachineBasicBlock::isSuccessor(), MI, and llvm::MachineOperand::setMBB().

Referenced by splitMBB().

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 707 of file PPCReduceCRLogicals.cpp.

◆ false

PowerPC Reduce CR logical false

Definition at line 707 of file PPCReduceCRLogicals.cpp.

◆ Operation

PowerPC Reduce CR logical Operation