Skip to content

Commit 3204740

Browse files
committed
[M68k] Register MIR Passes with the PassRegistry
In order to use the -stop-before/after infrastructure. Also remove the creator function for M68kConvertMOVToMOVMPass, which has never been created. NFC.
1 parent 5864149 commit 3204740

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

llvm/lib/Target/M68k/M68k.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ FunctionPass *createM68kGlobalBaseRegPass();
4242
/// emission so that all possible MOVEM are already in place.
4343
FunctionPass *createM68kCollapseMOVEMPass();
4444

45-
/// Finds MOVE instructions before any conditioanl branch instruction and
46-
/// replaces them with MOVEM instruction. Motorola's MOVEs do trash(V,C) flags
47-
/// register which prevents branch from taking the correct route. This pass
48-
/// has to be run after all pseudo expansions and prologue/epilogue emission
49-
/// so that all possible MOVEs are present.
50-
FunctionPass *createM68kConvertMOVToMOVMPass();
51-
5245
InstructionSelector *
5346
createM68kInstructionSelector(const M68kTargetMachine &, const M68kSubtarget &,
5447
const M68kRegisterBankInfo &);
5548

5649
void initializeM68kDAGToDAGISelPass(PassRegistry &);
50+
void initializeM68kExpandPseudoPass(PassRegistry &);
51+
void initializeM68kGlobalBaseRegPass(PassRegistry &);
52+
void initializeM68kCollapseMOVEMPass(PassRegistry &);
5753

5854
} // namespace llvm
5955

llvm/lib/Target/M68k/M68kCollapseMOVEMPass.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
using namespace llvm;
3131

32-
#define DEBUG_TYPE "M68k-collapse-movem"
32+
#define DEBUG_TYPE "m68k-collapse-movem"
33+
#define PASS_NAME "M68k MOVEM collapser pass"
3334

3435
namespace {
3536

@@ -294,13 +295,13 @@ class M68kCollapseMOVEM : public MachineFunctionPass {
294295

295296
return Modified;
296297
}
297-
298-
StringRef getPassName() const override { return "M68k MOVEM collapser pass"; }
299298
};
300299

301300
char M68kCollapseMOVEM::ID = 0;
302301
} // anonymous namespace.
303302

303+
INITIALIZE_PASS(M68kCollapseMOVEM, DEBUG_TYPE, PASS_NAME, false, false)
304+
304305
/// Returns an instance of the pseudo instruction expansion pass.
305306
FunctionPass *llvm::createM68kCollapseMOVEMPass() {
306307
return new M68kCollapseMOVEM();

llvm/lib/Target/M68k/M68kExpandPseudo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
using namespace llvm;
3030

31-
#define DEBUG_TYPE "M68k-expand-pseudos"
31+
#define DEBUG_TYPE "m68k-expand-pseudo"
32+
#define PASS_NAME "M68k pseudo instruction expansion pass"
3233

3334
namespace {
3435
class M68kExpandPseudo : public MachineFunctionPass {
@@ -56,17 +57,15 @@ class M68kExpandPseudo : public MachineFunctionPass {
5657
MachineFunctionProperties::Property::NoVRegs);
5758
}
5859

59-
StringRef getPassName() const override {
60-
return "M68k pseudo instruction expansion pass";
61-
}
62-
6360
private:
6461
bool ExpandMI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI);
6562
bool ExpandMBB(MachineBasicBlock &MBB);
6663
};
6764
char M68kExpandPseudo::ID = 0;
6865
} // End anonymous namespace.
6966

67+
INITIALIZE_PASS(M68kExpandPseudo, DEBUG_TYPE, PASS_NAME, false, false)
68+
7069
/// If \p MBBI is a pseudo instruction, this method expands
7170
/// it to the corresponding (sequence of) actual instruction(s).
7271
/// \returns true if \p MBBI has been expanded.

llvm/lib/Target/M68k/M68kInstrInfo.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ unsigned M68kInstrInfo::getGlobalBaseReg(MachineFunction *MF) const {
781781
return GlobalBaseReg;
782782

783783
// Create the register. The code to initialize it is inserted later,
784-
// by the CGBR pass (below).
784+
// by the M68kGlobalBaseReg pass (below).
785785
//
786786
// NOTE
787787
// Normally M68k uses A5 register as global base pointer but this will
@@ -813,11 +813,16 @@ M68kInstrInfo::getSerializableDirectMachineOperandTargetFlags() const {
813813
return ArrayRef(TargetFlags);
814814
}
815815

816+
#undef DEBUG_TYPE
817+
#define DEBUG_TYPE "m68k-create-global-base-reg"
818+
819+
#define PASS_NAME "M68k PIC Global Base Reg Initialization"
820+
816821
namespace {
817-
/// Create Global Base Reg pass. This initializes the PIC global base register
818-
struct CGBR : public MachineFunctionPass {
822+
/// This initializes the PIC global base register
823+
struct M68kGlobalBaseReg : public MachineFunctionPass {
819824
static char ID;
820-
CGBR() : MachineFunctionPass(ID) {}
825+
M68kGlobalBaseReg() : MachineFunctionPass(ID) {}
821826

822827
bool runOnMachineFunction(MachineFunction &MF) override {
823828
const M68kSubtarget &STI = MF.getSubtarget<M68kSubtarget>();
@@ -842,16 +847,16 @@ struct CGBR : public MachineFunctionPass {
842847
return true;
843848
}
844849

845-
StringRef getPassName() const override {
846-
return "M68k PIC Global Base Reg Initialization";
847-
}
848-
849850
void getAnalysisUsage(AnalysisUsage &AU) const override {
850851
AU.setPreservesCFG();
851852
MachineFunctionPass::getAnalysisUsage(AU);
852853
}
853854
};
855+
char M68kGlobalBaseReg::ID = 0;
854856
} // namespace
855857

856-
char CGBR::ID = 0;
857-
FunctionPass *llvm::createM68kGlobalBaseRegPass() { return new CGBR(); }
858+
INITIALIZE_PASS(M68kGlobalBaseReg, DEBUG_TYPE, PASS_NAME, false, false)
859+
860+
FunctionPass *llvm::createM68kGlobalBaseRegPass() {
861+
return new M68kGlobalBaseReg();
862+
}

llvm/lib/Target/M68k/M68kTargetMachine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeM68kTarget() {
3838
auto *PR = PassRegistry::getPassRegistry();
3939
initializeGlobalISel(*PR);
4040
initializeM68kDAGToDAGISelPass(*PR);
41+
initializeM68kExpandPseudoPass(*PR);
42+
initializeM68kGlobalBaseRegPass(*PR);
43+
initializeM68kCollapseMOVEMPass(*PR);
4144
}
4245

4346
namespace {

0 commit comments

Comments
 (0)