25 #define DEBUG_TYPE "delay-slot-filler" 27 STATISTIC(FilledSlots,
"Number of delay slots filled");
31 cl::desc(
"Fill Lanai delay slots with NOPs."),
45 StringRef getPassName()
const override {
return "Lanai Delay Slot Filler"; }
57 Changed |= runOnMachineBasicBlock(*FI);
98 if (
I->getDesc().hasDelaySlot()) {
109 assert(RI->getOpcode() == Lanai::LDW_RI && RI->getOperand(0).isReg() &&
110 RI->getOperand(0).getReg() ==
Lanai::FP &&
111 RI->getOperand(1).isReg() &&
112 RI->getOperand(1).getReg() ==
Lanai::FP &&
113 RI->getOperand(2).isImm() && RI->getOperand(2).getImm() == -8);
115 assert(RI->getOpcode() == Lanai::ADD_I_LO &&
116 RI->getOperand(0).isReg() &&
117 RI->getOperand(0).getReg() == Lanai::SP &&
118 RI->getOperand(1).isReg() &&
119 RI->getOperand(1).getReg() ==
Lanai::FP);
121 MBB.
splice(std::next(
I), &MBB, FI,
I);
125 MBB.
splice(std::next(
I), &MBB, J);
151 insertDefsUses(Slot, RegDefs, RegUses);
153 bool SawLoad =
false;
154 bool SawStore =
false;
159 if (
I->isDebugInstr())
165 if (
I->hasUnmodeledSideEffects() ||
I->isInlineAsm() ||
I->isLabel() ||
166 FI == LastFiller ||
I->isPseudo())
169 if (delayHasHazard(FI, SawLoad, SawStore, RegDefs, RegUses)) {
170 insertDefsUses(FI, RegDefs, RegUses);
182 if (MI->isImplicitDef() || MI->isKill())
193 if (MI->mayStore()) {
201 assert((!MI->isCall() && !MI->isReturn()) &&
202 "Cannot put calls or returns in delay slot.");
204 for (
unsigned I = 0,
E = MI->getNumOperands();
I !=
E; ++
I) {
213 if (isRegInSet(RegDefs, Reg) || isRegInSet(RegUses, Reg))
218 if (isRegInSet(RegDefs, Reg))
232 : MI->getNumOperands();
233 for (
unsigned I = 0;
I !=
E; ++
I) {
251 if (MI->isCall() || MI->isReturn())
252 RegDefs.
insert(Lanai::SP);
259 if (RegSet.
count(*AI))
static cl::opt< bool > NopDelaySlotFiller("lanai-nop-delay-filler", cl::init(false), cl::desc("Fill Lanai delay slots with NOPs."), cl::Hidden)
instr_iterator instr_begin()
instr_iterator instr_end()
This class represents lattice values for constants.
const LanaiInstrInfo * getInstrInfo() const override
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
FunctionPass * createLanaiDelaySlotFillerPass(const LanaiTargetMachine &TM)
TargetInstrInfo - Interface to description of machine instruction set.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
MCRegAliasIterator enumerates all registers aliasing Reg.
FunctionPass class - This class is used to implement most global optimizations.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Iterator for intrusive lists based on ilist_node.
MachineOperand class - Representation of each machine instruction operand.
reverse_instr_iterator instr_rend()
MachineFunctionProperties & set(Property P)
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
ilist_iterator< OptionsT, !IsReverse, IsConst > getReverse() const
Get a reverse iterator to the same node.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
const LanaiRegisterInfo * getRegisterInfo() const override
Properties which a MachineFunction may have at a given point in time.
Helper class for constructing bundles of MachineInstrs.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.