Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 9ea4c64

Browse files
committed
[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
1 parent 2372d8b commit 9ea4c64

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

lib/Target/X86/X86.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace llvm {
2121

2222
class FunctionPass;
2323
class ImmutablePass;
24+
class PassRegistry;
2425
class X86TargetMachine;
2526

2627
/// This pass converts a legalized DAG into a X86-specific DAG, ready for
@@ -78,6 +79,8 @@ FunctionPass *createX86ExpandPseudoPass();
7879
/// in order to eliminate partial register usage, false dependences on
7980
/// the upper portions of registers, and to save code size.
8081
FunctionPass *createX86FixupBWInsts();
82+
83+
void initializeFixupBWInstPassPass(PassRegistry &);
8184
} // End llvm namespace
8285

8386
#endif

lib/Target/X86/X86FixupBWInsts.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
#include "llvm/Target/TargetInstrInfo.h"
6161
using namespace llvm;
6262

63-
#define DEBUG_TYPE "x86-fixup-bw-insts"
63+
#define FIXUPBW_DESC "X86 Byte/Word Instruction Fixup"
64+
#define FIXUPBW_NAME "x86-fixup-bw-insts"
65+
66+
#define DEBUG_TYPE FIXUPBW_NAME
6467

6568
// Option to allow this optimization pass to have fine-grained control.
6669
// This is turned off by default so as not to affect a large number of
@@ -72,12 +75,6 @@ static cl::opt<bool>
7275

7376
namespace {
7477
class FixupBWInstPass : public MachineFunctionPass {
75-
static char ID;
76-
77-
const char *getPassName() const override {
78-
return "X86 Byte/Word Instruction Fixup";
79-
}
80-
8178
/// Loop over all of the instructions in the basic block replacing applicable
8279
/// byte or word instructions with better alternatives.
8380
void processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB);
@@ -94,7 +91,15 @@ class FixupBWInstPass : public MachineFunctionPass {
9491
MachineInstr *tryReplaceLoad(unsigned New32BitOpcode, MachineInstr *MI) const;
9592

9693
public:
97-
FixupBWInstPass() : MachineFunctionPass(ID) {}
94+
static char ID;
95+
96+
const char *getPassName() const override {
97+
return FIXUPBW_DESC;
98+
}
99+
100+
FixupBWInstPass() : MachineFunctionPass(ID) {
101+
initializeFixupBWInstPassPass(*PassRegistry::getPassRegistry());
102+
}
98103

99104
void getAnalysisUsage(AnalysisUsage &AU) const override {
100105
AU.addRequired<MachineLoopInfo>(); // Machine loop info is used to
@@ -130,6 +135,8 @@ class FixupBWInstPass : public MachineFunctionPass {
130135
char FixupBWInstPass::ID = 0;
131136
}
132137

138+
INITIALIZE_PASS(FixupBWInstPass, FIXUPBW_NAME, FIXUPBW_DESC, false, false)
139+
133140
FunctionPass *llvm::createX86FixupBWInsts() { return new FixupBWInstPass(); }
134141

135142
bool FixupBWInstPass::runOnMachineFunction(MachineFunction &MF) {

lib/Target/X86/X86TargetMachine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern "C" void LLVMInitializeX86Target() {
3939

4040
PassRegistry &PR = *PassRegistry::getPassRegistry();
4141
initializeWinEHStatePassPass(PR);
42+
initializeFixupBWInstPassPass(PR);
4243
}
4344

4445
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {

0 commit comments

Comments
 (0)