Use TargetMachine::hasDelaySlot() instead of our old switch statement

to find instrs that have delay slots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16610 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Brian Gaeke 2004-09-30 04:04:47 +00:00
parent 0fc27ccdd3
commit 870248b164
2 changed files with 12 additions and 90 deletions

View File

@ -7,13 +7,15 @@
//
//===----------------------------------------------------------------------===//
//
// Simple local delay slot filler for SparcV8 machine code
// This is a simple local pass that fills delay slots with NOPs.
//
//===----------------------------------------------------------------------===//
#include "SparcV8.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
@ -26,8 +28,9 @@ namespace {
/// layout, etc.
///
TargetMachine &TM;
const TargetInstrInfo *TII;
Filler (TargetMachine &tm) : TM (tm) { }
Filler (TargetMachine &tm) : TM (tm), TII (tm.getInstrInfo ()) { }
virtual const char *getPassName () const {
return "SparcV8 Delay Slot Filler";
@ -52,48 +55,6 @@ 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;
}
}
/// 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.
@ -101,7 +62,7 @@ static bool hasDelaySlot (unsigned Opcode) {
bool Filler::runOnMachineBasicBlock (MachineBasicBlock &MBB) {
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin (); I != MBB.end (); ++I)
if (hasDelaySlot (I->getOpcode ())) {
if (TII->hasDelaySlot (I->getOpcode ())) {
MachineBasicBlock::iterator J = I;
++J;
BuildMI (MBB, J, V8::NOP, 0);

View File

@ -7,13 +7,15 @@
//
//===----------------------------------------------------------------------===//
//
// Simple local delay slot filler for SparcV8 machine code
// This is a simple local pass that fills delay slots with NOPs.
//
//===----------------------------------------------------------------------===//
#include "SparcV8.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
@ -26,8 +28,9 @@ namespace {
/// layout, etc.
///
TargetMachine &TM;
const TargetInstrInfo *TII;
Filler (TargetMachine &tm) : TM (tm) { }
Filler (TargetMachine &tm) : TM (tm), TII (tm.getInstrInfo ()) { }
virtual const char *getPassName () const {
return "SparcV8 Delay Slot Filler";
@ -52,48 +55,6 @@ 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;
}
}
/// 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.
@ -101,7 +62,7 @@ static bool hasDelaySlot (unsigned Opcode) {
bool Filler::runOnMachineBasicBlock (MachineBasicBlock &MBB) {
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin (); I != MBB.end (); ++I)
if (hasDelaySlot (I->getOpcode ())) {
if (TII->hasDelaySlot (I->getOpcode ())) {
MachineBasicBlock::iterator J = I;
++J;
BuildMI (MBB, J, V8::NOP, 0);