24 #define DEBUG_TYPE "delay-slot-filler" 26 STATISTIC(FilledSlots,
"Number of delay slots filled");
30 cl::desc(
"Fill Lanai delay slots with NOPs."),
44 StringRef getPassName()
const override {
return "Lanai Delay Slot Filler"; }
56 Changed |= runOnMachineBasicBlock(*FI);
97 if (
I->getDesc().hasDelaySlot()) {
108 assert(RI->getOpcode() == Lanai::LDW_RI && RI->getOperand(0).isReg() &&
109 RI->getOperand(0).getReg() == Lanai::FP &&
110 RI->getOperand(1).isReg() &&
111 RI->getOperand(1).getReg() == Lanai::FP &&
112 RI->getOperand(2).isImm() && RI->getOperand(2).getImm() == -8);
114 assert(RI->getOpcode() == Lanai::ADD_I_LO &&
115 RI->getOperand(0).isReg() &&
116 RI->getOperand(0).getReg() == Lanai::SP &&
117 RI->getOperand(1).isReg() &&
118 RI->getOperand(1).getReg() == Lanai::FP);
120 MBB.
splice(std::next(
I), &MBB, FI,
I);
124 MBB.
splice(std::next(
I), &MBB, J);
150 insertDefsUses(Slot, RegDefs, RegUses);
152 bool SawLoad =
false;
153 bool SawStore =
false;
158 if (
I->isDebugInstr())
164 if (
I->hasUnmodeledSideEffects() ||
I->isInlineAsm() ||
I->isLabel() ||
165 FI == LastFiller ||
I->isPseudo())
168 if (delayHasHazard(FI, SawLoad, SawStore, RegDefs, RegUses)) {
169 insertDefsUses(FI, RegDefs, RegUses);
181 if (MI->isImplicitDef() || MI->isKill())
192 if (MI->mayStore()) {
200 assert((!MI->isCall() && !MI->isReturn()) &&
201 "Cannot put calls or returns in delay slot.");
203 for (
unsigned I = 0,
E = MI->getNumOperands();
I !=
E; ++
I) {
212 if (isRegInSet(RegDefs, Reg) || isRegInSet(RegUses, Reg))
217 if (isRegInSet(RegDefs, Reg))
231 : MI->getNumOperands();
232 for (
unsigned I = 0;
I !=
E; ++
I) {
250 if (MI->isCall() || MI->isReturn())
251 RegDefs.
insert(Lanai::SP);
258 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.
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.
Register getReg() const
getReg - Returns the register number.
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.