Skip to content

Commit d5ae039

Browse files
committed
[SystemZ] Properly register machine passes.
Registering the passes enables use of -stop-before=/-stop-after options. Reviewed By: uweigand Differential Revision: https://reviews.llvm.org/D117823
1 parent 7e3bcae commit d5ae039

9 files changed

+48
-47
lines changed

llvm/lib/Target/SystemZ/SystemZ.h

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace llvm {
2121
class SystemZTargetMachine;
2222
class FunctionPass;
23+
class PassRegistry;
2324

2425
namespace SystemZ {
2526
// Condition-code mask values.
@@ -196,6 +197,15 @@ FunctionPass *createSystemZLDCleanupPass(SystemZTargetMachine &TM);
196197
FunctionPass *createSystemZCopyPhysRegsPass(SystemZTargetMachine &TM);
197198
FunctionPass *createSystemZPostRewritePass(SystemZTargetMachine &TM);
198199
FunctionPass *createSystemZTDCPass();
200+
201+
void initializeSystemZElimComparePass(PassRegistry &);
202+
void initializeSystemZShortenInstPass(PassRegistry &);
203+
void initializeSystemZLongBranchPass(PassRegistry &);
204+
void initializeSystemZLDCleanupPass(PassRegistry &);
205+
void initializeSystemZCopyPhysRegsPass(PassRegistry &);
206+
void initializeSystemZPostRewritePass(PassRegistry &);
207+
void initializeSystemZTDCPassPass(PassRegistry &);
208+
199209
} // end namespace llvm
200210

201211
#endif

llvm/lib/Target/SystemZ/SystemZCopyPhysRegs.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525

2626
using namespace llvm;
2727

28-
#define SYSTEMZ_COPYPHYSREGS_NAME "SystemZ Copy Physregs"
29-
30-
namespace llvm {
31-
void initializeSystemZCopyPhysRegsPass(PassRegistry&);
32-
}
33-
3428
namespace {
3529

3630
class SystemZCopyPhysRegs : public MachineFunctionPass {
@@ -41,8 +35,6 @@ class SystemZCopyPhysRegs : public MachineFunctionPass {
4135
initializeSystemZCopyPhysRegsPass(*PassRegistry::getPassRegistry());
4236
}
4337

44-
StringRef getPassName() const override { return SYSTEMZ_COPYPHYSREGS_NAME; }
45-
4638
bool runOnMachineFunction(MachineFunction &MF) override;
4739
void getAnalysisUsage(AnalysisUsage &AU) const override;
4840

@@ -59,7 +51,7 @@ char SystemZCopyPhysRegs::ID = 0;
5951
} // end anonymous namespace
6052

6153
INITIALIZE_PASS(SystemZCopyPhysRegs, "systemz-copy-physregs",
62-
SYSTEMZ_COPYPHYSREGS_NAME, false, false)
54+
"SystemZ Copy Physregs", false, false)
6355

6456
FunctionPass *llvm::createSystemZCopyPhysRegsPass(SystemZTargetMachine &TM) {
6557
return new SystemZCopyPhysRegs();

llvm/lib/Target/SystemZ/SystemZElimCompare.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ class SystemZElimCompare : public MachineFunctionPass {
6565
public:
6666
static char ID;
6767

68-
SystemZElimCompare(const SystemZTargetMachine &tm)
69-
: MachineFunctionPass(ID) {}
70-
71-
StringRef getPassName() const override {
72-
return "SystemZ Comparison Elimination";
68+
SystemZElimCompare() : MachineFunctionPass(ID) {
69+
initializeSystemZElimComparePass(*PassRegistry::getPassRegistry());
7370
}
7471

7572
bool processBlock(MachineBasicBlock &MBB);
@@ -106,6 +103,9 @@ char SystemZElimCompare::ID = 0;
106103

107104
} // end anonymous namespace
108105

106+
INITIALIZE_PASS(SystemZElimCompare, DEBUG_TYPE,
107+
"SystemZ Comparison Elimination", false, false)
108+
109109
// Returns true if MI is an instruction whose output equals the value in Reg.
110110
static bool preservesValueOf(MachineInstr &MI, unsigned Reg) {
111111
switch (MI.getOpcode()) {
@@ -746,5 +746,5 @@ bool SystemZElimCompare::runOnMachineFunction(MachineFunction &F) {
746746
}
747747

748748
FunctionPass *llvm::createSystemZElimComparePass(SystemZTargetMachine &TM) {
749-
return new SystemZElimCompare(TM);
749+
return new SystemZElimCompare();
750750
}

llvm/lib/Target/SystemZ/SystemZLDCleanup.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ namespace {
2929
class SystemZLDCleanup : public MachineFunctionPass {
3030
public:
3131
static char ID;
32-
SystemZLDCleanup(const SystemZTargetMachine &tm)
33-
: MachineFunctionPass(ID), TII(nullptr), MF(nullptr) {}
34-
35-
StringRef getPassName() const override {
36-
return "SystemZ Local Dynamic TLS Access Clean-up";
32+
SystemZLDCleanup() : MachineFunctionPass(ID), TII(nullptr), MF(nullptr) {
33+
initializeSystemZLDCleanupPass(*PassRegistry::getPassRegistry());
3734
}
3835

3936
bool runOnMachineFunction(MachineFunction &MF) override;
@@ -52,8 +49,11 @@ char SystemZLDCleanup::ID = 0;
5249

5350
} // end anonymous namespace
5451

52+
INITIALIZE_PASS(SystemZLDCleanup, "systemz-ld-cleanup",
53+
"SystemZ Local Dynamic TLS Access Clean-up", false, false)
54+
5555
FunctionPass *llvm::createSystemZLDCleanupPass(SystemZTargetMachine &TM) {
56-
return new SystemZLDCleanup(TM);
56+
return new SystemZLDCleanup();
5757
}
5858

5959
void SystemZLDCleanup::getAnalysisUsage(AnalysisUsage &AU) const {

llvm/lib/Target/SystemZ/SystemZLongBranch.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ class SystemZLongBranch : public MachineFunctionPass {
135135
public:
136136
static char ID;
137137

138-
SystemZLongBranch(const SystemZTargetMachine &tm)
139-
: MachineFunctionPass(ID) {}
140-
141-
StringRef getPassName() const override { return "SystemZ Long Branch"; }
138+
SystemZLongBranch() : MachineFunctionPass(ID) {
139+
initializeSystemZLongBranchPass(*PassRegistry::getPassRegistry());
140+
}
142141

143142
bool runOnMachineFunction(MachineFunction &F) override;
144143

@@ -174,6 +173,9 @@ const uint64_t MaxForwardRange = 0xfffe;
174173

175174
} // end anonymous namespace
176175

176+
INITIALIZE_PASS(SystemZLongBranch, DEBUG_TYPE, "SystemZ Long Branch", false,
177+
false)
178+
177179
// Position describes the state immediately before Block. Update Block
178180
// accordingly and move Position to the end of the block's non-terminator
179181
// instructions.
@@ -481,5 +483,5 @@ bool SystemZLongBranch::runOnMachineFunction(MachineFunction &F) {
481483
}
482484

483485
FunctionPass *llvm::createSystemZLongBranchPass(SystemZTargetMachine &TM) {
484-
return new SystemZLongBranch(TM);
486+
return new SystemZLongBranch();
485487
}

llvm/lib/Target/SystemZ/SystemZPostRewrite.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,10 @@
2121
#include "llvm/CodeGen/MachineInstrBuilder.h"
2222
using namespace llvm;
2323

24-
#define SYSTEMZ_POSTREWRITE_NAME "SystemZ Post Rewrite pass"
25-
2624
#define DEBUG_TYPE "systemz-postrewrite"
2725
STATISTIC(MemFoldCopies, "Number of copies inserted before folded mem ops.");
2826
STATISTIC(LOCRMuxJumps, "Number of LOCRMux jump-sequences (lower is better)");
2927

30-
namespace llvm {
31-
void initializeSystemZPostRewritePass(PassRegistry&);
32-
}
33-
3428
namespace {
3529

3630
class SystemZPostRewrite : public MachineFunctionPass {
@@ -44,8 +38,6 @@ class SystemZPostRewrite : public MachineFunctionPass {
4438

4539
bool runOnMachineFunction(MachineFunction &Fn) override;
4640

47-
StringRef getPassName() const override { return SYSTEMZ_POSTREWRITE_NAME; }
48-
4941
private:
5042
void selectLOCRMux(MachineBasicBlock &MBB,
5143
MachineBasicBlock::iterator MBBI,
@@ -70,7 +62,7 @@ char SystemZPostRewrite::ID = 0;
7062
} // end anonymous namespace
7163

7264
INITIALIZE_PASS(SystemZPostRewrite, "systemz-post-rewrite",
73-
SYSTEMZ_POSTREWRITE_NAME, false, false)
65+
"SystemZ Post Rewrite pass", false, false)
7466

7567
/// Returns an instance of the Post Rewrite pass.
7668
FunctionPass *llvm::createSystemZPostRewritePass(SystemZTargetMachine &TM) {

llvm/lib/Target/SystemZ/SystemZShortenInst.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ namespace {
2626
class SystemZShortenInst : public MachineFunctionPass {
2727
public:
2828
static char ID;
29-
SystemZShortenInst(const SystemZTargetMachine &tm);
30-
31-
StringRef getPassName() const override {
32-
return "SystemZ Instruction Shortening";
33-
}
29+
SystemZShortenInst();
3430

3531
bool processBlock(MachineBasicBlock &MBB);
3632
bool runOnMachineFunction(MachineFunction &F) override;
@@ -56,12 +52,17 @@ class SystemZShortenInst : public MachineFunctionPass {
5652
char SystemZShortenInst::ID = 0;
5753
} // end anonymous namespace
5854

55+
INITIALIZE_PASS(SystemZShortenInst, DEBUG_TYPE,
56+
"SystemZ Instruction Shortening", false, false)
57+
5958
FunctionPass *llvm::createSystemZShortenInstPass(SystemZTargetMachine &TM) {
60-
return new SystemZShortenInst(TM);
59+
return new SystemZShortenInst();
6160
}
6261

63-
SystemZShortenInst::SystemZShortenInst(const SystemZTargetMachine &tm)
64-
: MachineFunctionPass(ID), TII(nullptr) {}
62+
SystemZShortenInst::SystemZShortenInst()
63+
: MachineFunctionPass(ID), TII(nullptr) {
64+
initializeSystemZShortenInstPass(*PassRegistry::getPassRegistry());
65+
}
6566

6667
// Tie operands if MI has become a two-address instruction.
6768
static void tieOpsIfNeeded(MachineInstr &MI) {

llvm/lib/Target/SystemZ/SystemZTDC.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@
6161

6262
using namespace llvm;
6363

64-
namespace llvm {
65-
void initializeSystemZTDCPassPass(PassRegistry&);
66-
}
67-
6864
namespace {
6965

7066
class SystemZTDCPass : public FunctionPass {

llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ using namespace llvm;
3232
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTarget() {
3333
// Register the target.
3434
RegisterTargetMachine<SystemZTargetMachine> X(getTheSystemZTarget());
35+
auto &PR = *PassRegistry::getPassRegistry();
36+
initializeSystemZElimComparePass(PR);
37+
initializeSystemZShortenInstPass(PR);
38+
initializeSystemZLongBranchPass(PR);
39+
initializeSystemZLDCleanupPass(PR);
40+
initializeSystemZShortenInstPass(PR);
41+
initializeSystemZPostRewritePass(PR);
42+
initializeSystemZTDCPassPass(PR);
3543
}
3644

3745
// Determine whether we use the vector ABI.

0 commit comments

Comments
 (0)