[llvm-commits] [llvm] r41150 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Fri Sep 14 08:32:42 PDT 2007


Hi Evan,

Sorry, I was reviewing my commits and i only saw your email now.
I'll change that! :)

2007/8/27, Evan Cheng <evan.cheng at apple.com>:
> Hi Bruno,
>
> Sparc backend also has a delay slot filler that does exactly the same
> thing. Can you change this into a target independent pass instead
> (then you just need to add a target hook to emit nop)?
>
> Evan
>
> On Aug 17, 2007, at 6:50 PM, Bruno Cardoso Lopes wrote:
>
> > Author: bruno
> > Date: Fri Aug 17 20:50:47 2007
> > New Revision: 41150
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=41150&view=rev
> > Log:
> > A Pass to insert Nops on intructions with DelaySlot
> >
> > Added:
> >    llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp
> >
> > Added: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=41150&view=auto
> >
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > ======================================================================
> > --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (added)
> > +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Fri Aug 17
> > 20:50:47 2007
> > @@ -0,0 +1,77 @@
> > +//===-- DelaySlotFiller.cpp - Mips delay slot filler
> > ---------------------===//
> > +//
> > +//                     The LLVM Compiler Infrastructure
> > +//
> > +// This file was developed by Bruno Cardoso Lopes and is
> > distributed under
> > +// the University of Illinois Open Source License. See LICENSE.TXT
> > for details.
> > +//
> > +//
> > =
> > =
> > =
> > ----------------------------------------------------------------------=
> > ==//
> > +//
> > +// Simple pass to fills delay slots with NOPs.
> > +//
> > +//
> > =
> > =
> > =
> > ----------------------------------------------------------------------=
> > ==//
> > +
> > +#define DEBUG_TYPE "delay-slot-filler"
> > +
> > +#include "Mips.h"
> > +#include "MipsTargetMachine.h"
> > +#include "llvm/CodeGen/MachineFunctionPass.h"
> > +#include "llvm/CodeGen/MachineInstrBuilder.h"
> > +#include "llvm/Target/TargetInstrInfo.h"
> > +#include "llvm/ADT/Statistic.h"
> > +
> > +using namespace llvm;
> > +
> > +STATISTIC(FilledSlots, "Number of delay slots filled");
> > +
> > +namespace {
> > +  struct Filler : public MachineFunctionPass {
> > +
> > +    TargetMachine &TM;
> > +    const TargetInstrInfo *TII;
> > +
> > +    static char ID;
> > +    Filler(TargetMachine &tm)
> > +      : MachineFunctionPass((intptr_t)&ID), TM(tm),
> > TII(tm.getInstrInfo()) { }
> > +
> > +    virtual const char *getPassName() const {
> > +      return "Mips Delay Slot Filler";
> > +    }
> > +
> > +    bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
> > +    bool runOnMachineFunction(MachineFunction &F) {
> > +      bool Changed = false;
> > +      for (MachineFunction::iterator FI = F.begin(), FE = F.end();
> > +           FI != FE; ++FI)
> > +        Changed |= runOnMachineBasicBlock(*FI);
> > +      return Changed;
> > +    }
> > +
> > +  };
> > +  char Filler::ID = 0;
> > +} // end of anonymous namespace
> > +
> > +/// runOnMachineBasicBlock - Fill in delay slots for the given
> > basic block.
> > +/// Currently, we fill delay slots with NOPs. We assume there is
> > only one
> > +/// delay slot per delayed instruction.
> > +bool Filler::
> > +runOnMachineBasicBlock(MachineBasicBlock &MBB)
> > +{
> > +  bool Changed = false;
> > +  for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end();
> > ++I)
> > +    if (TII->hasDelaySlot(I->getOpcode())) {
> > +      MachineBasicBlock::iterator J = I;
> > +      ++J;
> > +      BuildMI(MBB, J, TII->get(Mips::NOP));
> > +      ++FilledSlots;
> > +      Changed = true;
> > +    }
> > +  return Changed;
> > +}
> > +
> > +/// createMipsDelaySlotFillerPass - Returns a pass that fills in
> > delay
> > +/// slots in Mips MachineFunctions
> > +FunctionPass *llvm::createMipsDelaySlotFillerPass(MipsTargetMachine
> > &tm) {
> > +  return new Filler(tm);
> > +}
> > +
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>


-- 
Bruno Cardoso Lopes
http://www.brunocardoso.org

"The Man in Black fled across the desert and the gunslinger followed"
  - Childe Roland to the Dark Tower Came



More information about the llvm-commits mailing list