summaryrefslogtreecommitdiff
path: root/lib/Target/Mips/MipsDelaySlotFiller.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2013-02-07 21:32:32 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2013-02-07 21:32:32 +0000
commit5dd41c95f3075fc5c01cfb6822a66ac584fcc8c7 (patch)
tree716a0c6609dfcf885551c463230b74cc20fad0ab /lib/Target/Mips/MipsDelaySlotFiller.cpp
parente0501e866ca15601f4da2dc6b5572dc2de53abc8 (diff)
downloadllvm-5dd41c95f3075fc5c01cfb6822a66ac584fcc8c7.tar.gz
llvm-5dd41c95f3075fc5c01cfb6822a66ac584fcc8c7.tar.bz2
llvm-5dd41c95f3075fc5c01cfb6822a66ac584fcc8c7.tar.xz
[mips] Make Filler a class and reduce indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsDelaySlotFiller.cpp')
-rw-r--r--lib/Target/Mips/MipsDelaySlotFiller.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/lib/Target/Mips/MipsDelaySlotFiller.cpp b/lib/Target/Mips/MipsDelaySlotFiller.cpp
index 041a9d076a..cf0d9db4cc 100644
--- a/lib/Target/Mips/MipsDelaySlotFiller.cpp
+++ b/lib/Target/Mips/MipsDelaySlotFiller.cpp
@@ -45,15 +45,8 @@ static cl::opt<bool> SkipDelaySlotFiller(
cl::Hidden);
namespace {
- struct Filler : public MachineFunctionPass {
- typedef MachineBasicBlock::instr_iterator InstrIter;
- typedef MachineBasicBlock::reverse_instr_iterator ReverseInstrIter;
-
- TargetMachine &TM;
- const TargetInstrInfo *TII;
- InstrIter LastFiller;
-
- static char ID;
+ class Filler : public MachineFunctionPass {
+ public:
Filler(TargetMachine &tm)
: MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { }
@@ -61,7 +54,6 @@ namespace {
return "Mips Delay Slot Filler";
}
- bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
bool runOnMachineFunction(MachineFunction &F) {
if (SkipDelaySlotFiller)
return false;
@@ -73,6 +65,12 @@ namespace {
return Changed;
}
+ private:
+ typedef MachineBasicBlock::instr_iterator InstrIter;
+ typedef MachineBasicBlock::reverse_instr_iterator ReverseInstrIter;
+
+ bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
+
bool isDelayFiller(MachineBasicBlock &MBB,
InstrIter candidate);
@@ -96,7 +94,11 @@ namespace {
findDelayInstr(MachineBasicBlock &MBB, InstrIter slot,
InstrIter &Filler);
+ TargetMachine &TM;
+ const TargetInstrInfo *TII;
+ InstrIter LastFiller;
+ static char ID;
};
char Filler::ID = 0;
} // end of anonymous namespace
@@ -108,31 +110,33 @@ runOnMachineBasicBlock(MachineBasicBlock &MBB) {
bool Changed = false;
LastFiller = MBB.instr_end();
- for (InstrIter I = MBB.instr_begin(); I != MBB.instr_end(); ++I)
- if (I->hasDelaySlot()) {
- ++FilledSlots;
- Changed = true;
- InstrIter InstrWithSlot = I;
- InstrIter D;
-
- // Delay slot filling is disabled at -O0.
- if (!DisableDelaySlotFiller && (TM.getOptLevel() != CodeGenOpt::None) &&
- findDelayInstr(MBB, I, D)) {
- MBB.splice(llvm::next(I), &MBB, D);
- ++UsefulSlots;
- } else
- BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
-
- // Record the filler instruction that filled the delay slot.
- // The instruction after it will be visited in the next iteration.
- LastFiller = ++I;
-
- // Bundle the delay slot filler to InstrWithSlot so that the machine
- // verifier doesn't expect this instruction to be a terminator.
- MIBundleBuilder(MBB, InstrWithSlot, llvm::next(LastFiller));
- }
- return Changed;
+ for (InstrIter I = MBB.instr_begin(); I != MBB.instr_end(); ++I) {
+ if (!I->hasDelaySlot())
+ continue;
+ ++FilledSlots;
+ Changed = true;
+ InstrIter InstrWithSlot = I;
+ InstrIter D;
+
+ // Delay slot filling is disabled at -O0.
+ if (!DisableDelaySlotFiller && (TM.getOptLevel() != CodeGenOpt::None) &&
+ findDelayInstr(MBB, I, D)) {
+ MBB.splice(llvm::next(I), &MBB, D);
+ ++UsefulSlots;
+ } else
+ BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
+
+ // Record the filler instruction that filled the delay slot.
+ // The instruction after it will be visited in the next iteration.
+ LastFiller = ++I;
+
+ // Bundle the delay slot filler to InstrWithSlot so that the machine
+ // verifier doesn't expect this instruction to be a terminator.
+ MIBundleBuilder(MBB, InstrWithSlot, llvm::next(LastFiller));
+ }
+
+ return Changed;
}
/// createMipsDelaySlotFillerPass - Returns a pass that fills in delay