X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FSparc%2FDelaySlotFiller.cpp;h=15b26c29872f3bfefbd47a90f70d44cef8564f55;hb=4e918b2c8ca81edd63f6708e08835b2c14648615;hp=78d5baa1f9b3f8e623f015fd66deb46147582115;hpb=4185d03dc5290550f0bad33764f3971ec9a74132;p=oota-llvm.git diff --git a/lib/Target/Sparc/DelaySlotFiller.cpp b/lib/Target/Sparc/DelaySlotFiller.cpp index 78d5baa1f9b..15b26c29872 100644 --- a/lib/Target/Sparc/DelaySlotFiller.cpp +++ b/lib/Target/Sparc/DelaySlotFiller.cpp @@ -1,110 +1,74 @@ -//===-- DelaySlotFiller.cpp - SparcV8 delay slot filler -------------------===// -// +//===-- DelaySlotFiller.cpp - SPARC delay slot filler ---------------------===// +// // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// //===----------------------------------------------------------------------===// // -// Simple local delay slot filler for SparcV8 machine code +// This is a simple local pass that fills delay slots with NOPs. // //===----------------------------------------------------------------------===// -#include "SparcV8.h" +#define DEBUG_TYPE "delayslotfiller" +#include "Sparc.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" -#include "Support/Statistic.h" - +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; -namespace { - Statistic<> FilledSlots ("delayslotfiller", "Num. of delay slots filled"); +STATISTIC(FilledSlots, "Number of delay slots filled"); +namespace { struct Filler : public MachineFunctionPass { /// Target machine description which we query for reg. names, data /// layout, etc. /// TargetMachine &TM; + const TargetInstrInfo *TII; - Filler (TargetMachine &tm) : TM (tm) { } + static char ID; + Filler(TargetMachine &tm) + : MachineFunctionPass(&ID), TM(tm), TII(tm.getInstrInfo()) { } - virtual const char *getPassName () const { - return "SparcV8 Delay Slot Filler"; + virtual const char *getPassName() const { + return "SPARC Delay Slot Filler"; } - bool runOnMachineBasicBlock (MachineBasicBlock &MBB); - bool runOnMachineFunction (MachineFunction &F) { + bool runOnMachineBasicBlock(MachineBasicBlock &MBB); + bool runOnMachineFunction(MachineFunction &F) { bool Changed = false; - for (MachineFunction::iterator FI = F.begin (), FE = F.end (); + for (MachineFunction::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) - Changed |= runOnMachineBasicBlock (*FI); + Changed |= runOnMachineBasicBlock(*FI); return Changed; } }; + char Filler::ID = 0; } // end of anonymous namespace -/// createSparcV8DelaySlotFillerPass - Returns a pass that fills in delay -/// slots in SparcV8 MachineFunctions +/// createSparcDelaySlotFillerPass - Returns a pass that fills in delay +/// slots in Sparc MachineFunctions /// -FunctionPass *llvm::createSparcV8DelaySlotFillerPass (TargetMachine &tm) { - return new Filler (tm); -} - -static bool hasDelaySlot (unsigned Opcode) { - switch (Opcode) { - case V8::BA: - case V8::BCC: - case V8::BCS: - case V8::BE: - case V8::BG: - case V8::BGE: - case V8::BGU: - case V8::BL: - case V8::BLE: - case V8::BLEU: - case V8::BNE: - case V8::CALL: - case V8::JMPLrr: - case V8::RETL: - case V8::FBA: - case V8::FBN: - case V8::FBU: - case V8::FBG: - case V8::FBUG: - case V8::FBL: - case V8::FBUL: - case V8::FBLG: - case V8::FBNE: - case V8::FBE: - case V8::FBUE: - case V8::FBGE: - case V8::FBUGE: - case V8::FBLE: - case V8::FBULE: - case V8::FBO: - case V8::FCMPS: - case V8::FCMPD: - case V8::FCMPES: - case V8::FCMPED: - return true; - default: - return false; - } +FunctionPass *llvm::createSparcDelaySlotFillerPass(TargetMachine &tm) { + return new Filler(tm); } /// 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 Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) { bool Changed = false; - for (MachineBasicBlock::iterator I = MBB.begin (); I != MBB.end (); ++I) - if (hasDelaySlot (I->getOpcode ())) { + for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) + if (I->getDesc().hasDelaySlot()) { MachineBasicBlock::iterator J = I; ++J; - BuildMI (MBB, J, V8::NOP, 0); + BuildMI(MBB, J, DebugLoc::getUnknownLoc(), TII->get(SP::NOP)); ++FilledSlots; Changed = true; }