LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
PeepholeOptimizer.cpp File Reference
#include "llvm/CodeGen/Passes.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetRegisterInfo.h"
Include dependency graph for PeepholeOptimizer.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "peephole-opt"
 

Functions

 STATISTIC (NumReuse,"Number of extension results reused")
 
 STATISTIC (NumCmps,"Number of compares eliminated")
 
 STATISTIC (NumImmFold,"Number of move immediate folded")
 
 STATISTIC (NumLoadFold,"Number of loads folded")
 
 STATISTIC (NumSelects,"Number of selects optimized")
 
 STATISTIC (NumCopiesBitcasts,"Number of copies/bitcasts optimized")
 
 INITIALIZE_PASS_BEGIN (PeepholeOptimizer,"peephole-opts","Peephole Optimizations", false, false) INITIALIZE_PASS_END(PeepholeOptimizer
 
static bool shareSameRegisterFile (const TargetRegisterInfo &TRI, const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg)
 Check if the registers defined by the pair (RegisterClass, SubReg) share the same register file. More...
 
static bool getCopyOrBitcastDefUseIdx (const MachineInstr &Copy, unsigned &DefIdx, unsigned &SrcIdx)
 Get the index of the definition and source for Copy instruction. More...
 

Variables

static cl::opt< boolAggressive ("aggressive-ext-opt", cl::Hidden, cl::desc("Aggressive extension optimization"))
 
static cl::opt< boolDisablePeephole ("disable-peephole", cl::Hidden, cl::init(false), cl::desc("Disable the peephole optimizer"))
 
peephole opts
 
peephole Peephole Optimizations
 
peephole Peephole false
 

Macro Definition Documentation

#define DEBUG_TYPE   "peephole-opt"

Definition at line 69 of file PeepholeOptimizer.cpp.

Function Documentation

static bool getCopyOrBitcastDefUseIdx ( const MachineInstr Copy,
unsigned DefIdx,
unsigned SrcIdx 
)
static

Get the index of the definition and source for Copy instruction.

Precondition
Copy.isCopy() or Copy.isBitcast().
Returns
True if the Copy instruction has only one register source and one register definition. Otherwise, DefIdx and SrcIdx are invalid.

Definition at line 388 of file PeepholeOptimizer.cpp.

References llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getNumDefs(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineInstr::isBitcast(), llvm::MachineInstr::isCopy(), llvm::MachineOperand::isDef(), and llvm::MachineOperand::isReg().

INITIALIZE_PASS_BEGIN ( PeepholeOptimizer  ,
"peephole-opts ,
"Peephole Optimizations ,
false  ,
false   
)
static bool shareSameRegisterFile ( const TargetRegisterInfo TRI,
const TargetRegisterClass DefRC,
unsigned  DefSubReg,
const TargetRegisterClass SrcRC,
unsigned  SrcSubReg 
)
static

Check if the registers defined by the pair (RegisterClass, SubReg) share the same register file.

Definition at line 354 of file PeepholeOptimizer.cpp.

References llvm::TargetRegisterInfo::getCommonSubClass(), llvm::TargetRegisterInfo::getCommonSuperRegClass(), llvm::TargetRegisterInfo::getMatchingSuperRegClass(), and std::swap().

STATISTIC ( NumReuse  ,
"Number of extension results reused"   
)
STATISTIC ( NumCmps  ,
"Number of compares eliminated"   
)
STATISTIC ( NumImmFold  ,
"Number of move immediate folded"   
)
STATISTIC ( NumLoadFold  ,
"Number of loads folded"   
)
STATISTIC ( NumSelects  ,
"Number of selects optimized"   
)
STATISTIC ( NumCopiesBitcasts  ,
"Number of copies/bitcasts optimized"   
)

Variable Documentation

cl::opt<bool> Aggressive("aggressive-ext-opt", cl::Hidden, cl::desc("Aggressive extension optimization"))
static
cl::opt<bool> DisablePeephole("disable-peephole", cl::Hidden, cl::init(false), cl::desc("Disable the peephole optimizer"))
static
peephole Peephole false

Definition at line 145 of file PeepholeOptimizer.cpp.

peephole Peephole Optimizations

Definition at line 145 of file PeepholeOptimizer.cpp.

peephole opts

Definition at line 145 of file PeepholeOptimizer.cpp.