diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-14 17:55:15 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-14 17:55:15 +0000 |
commit | 6aed25d93d1cfcde5809a73ffa7dc1b0d6396f66 (patch) | |
tree | 57e2fdf1caf960d8d878e0289f32af6759832b49 /lib/Target/Mips/MipsDelaySlotFiller.cpp | |
parent | 7139cfb19b1cc28dfd5e274c07ec68835bc6d6d6 (diff) | |
parent | 1ad9253c9d34ccbce3e7e4ea5d87c266cbf93410 (diff) |
Updating branches/google/stable to r169803
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@170212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsDelaySlotFiller.cpp')
-rw-r--r-- | lib/Target/Mips/MipsDelaySlotFiller.cpp | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/lib/Target/Mips/MipsDelaySlotFiller.cpp b/lib/Target/Mips/MipsDelaySlotFiller.cpp index e3c8ed75cf..041a9d076a 100644 --- a/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -15,14 +15,14 @@ #include "Mips.h" #include "MipsTargetMachine.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/ADT/SmallSet.h" -#include "llvm/ADT/Statistic.h" using namespace llvm; @@ -112,7 +112,7 @@ runOnMachineBasicBlock(MachineBasicBlock &MBB) { if (I->hasDelaySlot()) { ++FilledSlots; Changed = true; - + InstrIter InstrWithSlot = I; InstrIter D; // Delay slot filling is disabled at -O0. @@ -127,9 +127,9 @@ runOnMachineBasicBlock(MachineBasicBlock &MBB) { // The instruction after it will be visited in the next iteration. LastFiller = ++I; - // Set InsideBundle bit so that the machine verifier doesn't expect this - // instruction to be a terminator. - LastFiller->setIsInsideBundle(); + // 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; @@ -231,31 +231,48 @@ bool Filler::delayHasHazard(InstrIter candidate, return false; } +// Helper function for getting a MachineOperand's register number and adding it +// to RegDefs or RegUses. +static void insertDefUse(const MachineOperand &MO, + SmallSet<unsigned, 32> &RegDefs, + SmallSet<unsigned, 32> &RegUses, + unsigned ExcludedReg = 0) { + unsigned Reg; + + if (!MO.isReg() || !(Reg = MO.getReg()) || (Reg == ExcludedReg)) + return; + + if (MO.isDef()) + RegDefs.insert(Reg); + else if (MO.isUse()) + RegUses.insert(Reg); +} + // Insert Defs and Uses of MI into the sets RegDefs and RegUses. void Filler::insertDefsUses(InstrIter MI, SmallSet<unsigned, 32> &RegDefs, SmallSet<unsigned, 32> &RegUses) { - // If MI is a call or return, just examine the explicit non-variadic operands. - MCInstrDesc MCID = MI->getDesc(); - unsigned e = MI->isCall() || MI->isReturn() ? MCID.getNumOperands() : - MI->getNumOperands(); + unsigned I, E = MI->getDesc().getNumOperands(); - // Add RA to RegDefs to prevent users of RA from going into delay slot. - if (MI->isCall()) - RegDefs.insert(Mips::RA); + for (I = 0; I != E; ++I) + insertDefUse(MI->getOperand(I), RegDefs, RegUses); - for (unsigned i = 0; i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - unsigned Reg; + // If MI is a call, add RA to RegDefs to prevent users of RA from going into + // delay slot. + if (MI->isCall()) { + RegDefs.insert(Mips::RA); + return; + } - if (!MO.isReg() || !(Reg = MO.getReg())) - continue; + // Return if MI is a return. + if (MI->isReturn()) + return; - if (MO.isDef()) - RegDefs.insert(Reg); - else if (MO.isUse()) - RegUses.insert(Reg); - } + // Examine the implicit operands. Exclude register AT which is in the list of + // clobbered registers of branch instructions. + E = MI->getNumOperands(); + for (; I != E; ++I) + insertDefUse(MI->getOperand(I), RegDefs, RegUses, Mips::AT); } //returns true if the Reg or its alias is in the RegSet. |