From 9ea4c644e105dc6636a4aeb3c32d2c71ad3f99e5 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Sat, 7 May 2016 01:11:10 +0000 Subject: [PATCH] [X86] Register and initialize the FixupBW pass. That lets us use it in MIR tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268830 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86.h | 3 +++ lib/Target/X86/X86FixupBWInsts.cpp | 23 +++++++++++++++-------- lib/Target/X86/X86TargetMachine.cpp | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/Target/X86/X86.h b/lib/Target/X86/X86.h index d16cc375e98..c12554c9b92 100644 --- a/lib/Target/X86/X86.h +++ b/lib/Target/X86/X86.h @@ -21,6 +21,7 @@ namespace llvm { class FunctionPass; class ImmutablePass; +class PassRegistry; class X86TargetMachine; /// This pass converts a legalized DAG into a X86-specific DAG, ready for @@ -78,6 +79,8 @@ FunctionPass *createX86ExpandPseudoPass(); /// in order to eliminate partial register usage, false dependences on /// the upper portions of registers, and to save code size. FunctionPass *createX86FixupBWInsts(); + +void initializeFixupBWInstPassPass(PassRegistry &); } // End llvm namespace #endif diff --git a/lib/Target/X86/X86FixupBWInsts.cpp b/lib/Target/X86/X86FixupBWInsts.cpp index 045a4ed8dca..ad152824c18 100644 --- a/lib/Target/X86/X86FixupBWInsts.cpp +++ b/lib/Target/X86/X86FixupBWInsts.cpp @@ -60,7 +60,10 @@ #include "llvm/Target/TargetInstrInfo.h" using namespace llvm; -#define DEBUG_TYPE "x86-fixup-bw-insts" +#define FIXUPBW_DESC "X86 Byte/Word Instruction Fixup" +#define FIXUPBW_NAME "x86-fixup-bw-insts" + +#define DEBUG_TYPE FIXUPBW_NAME // Option to allow this optimization pass to have fine-grained control. // This is turned off by default so as not to affect a large number of @@ -72,12 +75,6 @@ static cl::opt namespace { class FixupBWInstPass : public MachineFunctionPass { - static char ID; - - const char *getPassName() const override { - return "X86 Byte/Word Instruction Fixup"; - } - /// Loop over all of the instructions in the basic block replacing applicable /// byte or word instructions with better alternatives. void processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB); @@ -94,7 +91,15 @@ class FixupBWInstPass : public MachineFunctionPass { MachineInstr *tryReplaceLoad(unsigned New32BitOpcode, MachineInstr *MI) const; public: - FixupBWInstPass() : MachineFunctionPass(ID) {} + static char ID; + + const char *getPassName() const override { + return FIXUPBW_DESC; + } + + FixupBWInstPass() : MachineFunctionPass(ID) { + initializeFixupBWInstPassPass(*PassRegistry::getPassRegistry()); + } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired(); // Machine loop info is used to @@ -130,6 +135,8 @@ private: char FixupBWInstPass::ID = 0; } +INITIALIZE_PASS(FixupBWInstPass, FIXUPBW_NAME, FIXUPBW_DESC, false, false) + FunctionPass *llvm::createX86FixupBWInsts() { return new FixupBWInstPass(); } bool FixupBWInstPass::runOnMachineFunction(MachineFunction &MF) { diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 397303003a9..065389e9130 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -39,6 +39,7 @@ extern "C" void LLVMInitializeX86Target() { PassRegistry &PR = *PassRegistry::getPassRegistry(); initializeWinEHStatePassPass(PR); + initializeFixupBWInstPassPass(PR); } static std::unique_ptr createTLOF(const Triple &TT) { -- 2.50.1