LLVM 24.0.0git
DelaySlotFiller.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "delay-slot-filler"

Functions

 STATISTIC (FilledSlots, "Number of delay slots filled")
static bool combineRestoreADD (MachineBasicBlock &MBB, MachineBasicBlock::iterator RestoreMI, MachineBasicBlock::iterator AddMI, const TargetInstrInfo *TII)
static bool combineRestoreOR (MachineBasicBlock &MBB, MachineBasicBlock::iterator RestoreMI, MachineBasicBlock::iterator OrMI, const TargetInstrInfo *TII)
static bool combineRestoreSETHIi (MachineBasicBlock::iterator RestoreMI, MachineBasicBlock::iterator SetHiMI, const TargetInstrInfo *TII)
static bool tryCombineRestoreWithPrevInst (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const SparcSubtarget *Subtarget)
static MachineBasicBlock::iterator findRequiredDelayInstr (MachineBasicBlock &MBB, MachineBasicBlock::iterator slot)
 The restore before a tail call must run in its delay slot: jmp reg reads a register of the current window, and call writes o7.
static void insertCallDefsUses (MachineBasicBlock::iterator MI, SmallSet< unsigned, 32 > &RegDefs, SmallSet< unsigned, 32 > &RegUses)
static void insertDefsUses (MachineBasicBlock::iterator MI, SmallSet< unsigned, 32 > &RegDefs, SmallSet< unsigned, 32 > &RegUses, const SparcSubtarget *Subtarget)
static bool IsRegInSet (SmallSet< unsigned, 32 > &RegSet, unsigned Reg, const SparcSubtarget *Subtarget)
static bool delayHasHazard (MachineBasicBlock::iterator candidate, bool &sawLoad, bool &sawStore, SmallSet< unsigned, 32 > &RegDefs, SmallSet< unsigned, 32 > &RegUses, const SparcSubtarget *Subtarget)
static MachineBasicBlock::iterator findDelayInstr (MachineBasicBlock &MBB, MachineBasicBlock::iterator slot, const SparcSubtarget *Subtarget)
static bool isWriteY (const MachineInstr &MI)
static bool padWriteYHazards (MachineBasicBlock &MBB, const SparcSubtarget *Subtarget)
 On SPARC V8 a write to y may take until the third instruction after it completes to take effect, so an instruction that reads y within that window (MULScc, RDY, SDIV, SDIVcc, UDIV, UDIVcc) gets an undefined value.
static bool runOnMachineBasicBlock (MachineBasicBlock &MBB)
 runOnMachineBasicBlock - Fill in delay slots for the given basic block.
static bool runDelaySlotFillerOnMachineFunction (MachineFunction &MF)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "delay-slot-filler"

Definition at line 32 of file DelaySlotFiller.cpp.

Function Documentation

◆ combineRestoreADD()

bool combineRestoreADD ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator RestoreMI,
MachineBasicBlock::iterator AddMI,
const TargetInstrInfo * TII )
static

Definition at line 64 of file DelaySlotFiller.cpp.

References MBB, TII, and TRI.

Referenced by tryCombineRestoreWithPrevInst().

◆ combineRestoreOR()

bool combineRestoreOR ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator RestoreMI,
MachineBasicBlock::iterator OrMI,
const TargetInstrInfo * TII )
static

Definition at line 104 of file DelaySlotFiller.cpp.

References MBB, TII, and TRI.

Referenced by tryCombineRestoreWithPrevInst().

◆ combineRestoreSETHIi()

bool combineRestoreSETHIi ( MachineBasicBlock::iterator RestoreMI,
MachineBasicBlock::iterator SetHiMI,
const TargetInstrInfo * TII )
static

Definition at line 150 of file DelaySlotFiller.cpp.

References assert(), llvm::isInt(), and TII.

Referenced by tryCombineRestoreWithPrevInst().

◆ delayHasHazard()

bool delayHasHazard ( MachineBasicBlock::iterator candidate,
bool & sawLoad,
bool & sawStore,
SmallSet< unsigned, 32 > & RegDefs,
SmallSet< unsigned, 32 > & RegUses,
const SparcSubtarget * Subtarget )
static

Definition at line 337 of file DelaySlotFiller.cpp.

References IsRegInSet(), Reg, and Subtarget.

Referenced by findDelayInstr().

◆ findDelayInstr()

◆ findRequiredDelayInstr()

MachineBasicBlock::iterator findRequiredDelayInstr ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator slot )
static

The restore before a tail call must run in its delay slot: jmp reg reads a register of the current window, and call writes o7.

For the same reason a leaf call needs the copy of o7 back from g1 that SparcFrameLowering emits.

Definition at line 251 of file DelaySlotFiller.cpp.

References MBB, Opc, and llvm::skipMetaInstructionsBackward().

Referenced by runOnMachineBasicBlock().

◆ insertCallDefsUses()

◆ insertDefsUses()

void insertDefsUses ( MachineBasicBlock::iterator MI,
SmallSet< unsigned, 32 > & RegDefs,
SmallSet< unsigned, 32 > & RegUses,
const SparcSubtarget * Subtarget )
static

Definition at line 303 of file DelaySlotFiller.cpp.

References llvm::SmallSet< T, N, C >::insert(), MI, Reg, and Subtarget.

Referenced by findDelayInstr().

◆ IsRegInSet()

bool IsRegInSet ( SmallSet< unsigned, 32 > & RegSet,
unsigned Reg,
const SparcSubtarget * Subtarget )
static

◆ isWriteY()

bool isWriteY ( const MachineInstr & MI)
static

Definition at line 467 of file DelaySlotFiller.cpp.

References MI.

Referenced by padWriteYHazards().

◆ padWriteYHazards()

bool padWriteYHazards ( MachineBasicBlock & MBB,
const SparcSubtarget * Subtarget )
static

On SPARC V8 a write to y may take until the third instruction after it completes to take effect, so an instruction that reads y within that window (MULScc, RDY, SDIV, SDIVcc, UDIV, UDIVcc) gets an undefined value.

V9 removed the delay. As in GCC, make sure there are at least three instructions between a WRY and the next reader of y. This runs after the delay slots are filled so that the instructions are counted in the order they execute, and a filled delay slot can no longer shrink the gap.

Definition at line 479 of file DelaySlotFiller.cpp.

References llvm::BuildMI(), Changed, E(), I, isWriteY(), MBB, readsRegister(), Subtarget, TII, and TRI.

Referenced by runOnMachineBasicBlock().

◆ runDelaySlotFillerOnMachineFunction()

◆ runOnMachineBasicBlock()

bool runOnMachineBasicBlock ( MachineBasicBlock & MBB)
static

runOnMachineBasicBlock - Fill in delay slots for the given basic block.

We assume there is only one delay slot per delayed instruction.

Definition at line 517 of file DelaySlotFiller.cpp.

References llvm::MachineInstrBuilder::addImm(), assert(), llvm::BuildMI(), Changed, D(), findDelayInstr(), findRequiredDelayInstr(), I, MBB, MI, llvm::None, padWriteYHazards(), Subtarget, TII, and tryCombineRestoreWithPrevInst().

Referenced by runDelaySlotFillerOnMachineFunction().

◆ STATISTIC()

STATISTIC ( FilledSlots ,
"Number of delay slots filled"  )

◆ tryCombineRestoreWithPrevInst()