Skip to content

Commit

Permalink
[X86][NFC] Add X86CmovConverterPass to the pass registry.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D38355

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314726 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Amjad Aboud committed Oct 2, 2017
1 parent 706e8dc commit 1fa1ab3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/Target/X86/X86CmovConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;

#define DEBUG_TYPE "x86-cmov-converter"
#define DEBUG_TYPE "x86-cmov-conversion"

STATISTIC(NumOfSkippedCmovGroups, "Number of unsupported CMOV-groups");
STATISTIC(NumOfCmovGroupCandidate, "Number of CMOV-group candidates");
STATISTIC(NumOfLoopCandidate, "Number of CMOV-conversion profitable loops");
STATISTIC(NumOfOptimizedCmovGroups, "Number of optimized CMOV-groups");

namespace llvm {
void initializeX86CmovConverterPassPass(PassRegistry &);
}

namespace {
// This internal switch can be used to turn off the cmov/branch optimization.
static cl::opt<bool>
Expand All @@ -80,17 +84,20 @@ static cl::opt<bool> ForceMemOperand(
/// Converts X86 cmov instructions into branches when profitable.
class X86CmovConverterPass : public MachineFunctionPass {
public:
X86CmovConverterPass() : MachineFunctionPass(ID) {}
X86CmovConverterPass() : MachineFunctionPass(ID) {
initializeX86CmovConverterPassPass(*PassRegistry::getPassRegistry());
}
~X86CmovConverterPass() {}

StringRef getPassName() const override { return "X86 cmov Conversion"; }
bool runOnMachineFunction(MachineFunction &MF) override;
void getAnalysisUsage(AnalysisUsage &AU) const override;

private:
/// Pass identification, replacement for typeid.
static char ID;

private:

MachineRegisterInfo *MRI;
const TargetInstrInfo *TII;
const TargetRegisterInfo *TRI;
Expand Down Expand Up @@ -125,8 +132,6 @@ class X86CmovConverterPass : public MachineFunctionPass {
void convertCmovInstsToBranches(SmallVectorImpl<MachineInstr *> &Group) const;
};

char X86CmovConverterPass::ID = 0;

void X86CmovConverterPass::getAnalysisUsage(AnalysisUsage &AU) const {
MachineFunctionPass::getAnalysisUsage(AU);
AU.addRequired<MachineLoopInfo>();
Expand Down Expand Up @@ -797,6 +802,14 @@ void X86CmovConverterPass::convertCmovInstsToBranches(

} // End anonymous namespace.

char X86CmovConverterPass::ID = 0;

INITIALIZE_PASS_BEGIN(X86CmovConverterPass, DEBUG_TYPE, "X86 cmov Conversion",
false, false)
INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
INITIALIZE_PASS_END(X86CmovConverterPass, DEBUG_TYPE, "X86 cmov Conversion",
false, false)

FunctionPass *llvm::createX86CmovConverterPass() {
return new X86CmovConverterPass();
}
2 changes: 2 additions & 0 deletions lib/Target/X86/X86TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace llvm {

void initializeWinEHStatePassPass(PassRegistry &);
void initializeFixupLEAPassPass(PassRegistry &);
void initializeX86CmovConverterPassPass(PassRegistry &);
void initializeX86ExecutionDepsFixPass(PassRegistry &);

} // end namespace llvm
Expand All @@ -73,6 +74,7 @@ extern "C" void LLVMInitializeX86Target() {
initializeFixupBWInstPassPass(PR);
initializeEvexToVexInstPassPass(PR);
initializeFixupLEAPassPass(PR);
initializeX86CmovConverterPassPass(PR);
initializeX86ExecutionDepsFixPass(PR);
}

Expand Down

0 comments on commit 1fa1ab3

Please sign in to comment.