24#define DEBUG_TYPE "delay-slot-filler"
26STATISTIC(FilledSlots,
"Number of delay slots filled");
30 cl::desc(
"Fill Lanai delay slots with NOPs."),
55 Changed |= runOnMachineBasicBlock(
MBB);
61 MachineFunctionProperties::Property::NoVRegs);
96 if (
I->getDesc().hasDelaySlot()) {
102 if (
I->getOpcode() == Lanai::RET) {
107 assert(RI->getOpcode() == Lanai::LDW_RI && RI->getOperand(0).isReg() &&
108 RI->getOperand(0).getReg() == Lanai::FP &&
109 RI->getOperand(1).isReg() &&
110 RI->getOperand(1).getReg() == Lanai::FP &&
111 RI->getOperand(2).isImm() && RI->getOperand(2).getImm() == -8);
113 assert(RI->getOpcode() == Lanai::ADD_I_LO &&
114 RI->getOperand(0).isReg() &&
115 RI->getOperand(0).getReg() == Lanai::SP &&
116 RI->getOperand(1).isReg() &&
117 RI->getOperand(1).getReg() == Lanai::FP);
149 insertDefsUses(Slot, RegDefs, RegUses);
151 bool SawLoad =
false;
152 bool SawStore =
false;
157 if (
I->isDebugInstr())
163 if (
I->hasUnmodeledSideEffects() ||
I->isInlineAsm() ||
I->isLabel() ||
164 FI == LastFiller ||
I->isPseudo())
167 if (delayHasHazard(FI, SawLoad, SawStore, RegDefs, RegUses)) {
168 insertDefsUses(FI, RegDefs, RegUses);
180 if (
MI->isImplicitDef() ||
MI->isKill())
191 if (
MI->mayStore()) {
200 "Cannot put calls or returns in delay slot.");
205 if (!MO.isReg() || !(Reg = MO.getReg()))
210 if (isRegInSet(RegDefs, Reg) || isRegInSet(RegUses, Reg))
215 if (isRegInSet(RegDefs, Reg))
229 :
MI->getNumOperands();
230 for (
unsigned I = 0;
I != E; ++
I) {
248 if (
MI->isCall() ||
MI->isReturn())
249 RegDefs.
insert(Lanai::SP);
256 if (RegSet.
count(*AI))
const HexagonInstrInfo * TII
static cl::opt< bool > NopDelaySlotFiller("lanai-nop-delay-filler", cl::init(false), cl::desc("Fill Lanai delay slots with NOPs."), cl::Hidden)
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
FunctionPass class - This class is used to implement most global optimizations.
const LanaiRegisterInfo * getRegisterInfo() const override
const LanaiInstrInfo * getInstrInfo() const override
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
MCRegAliasIterator enumerates all registers aliasing Reg.
Helper class for constructing bundles of MachineInstrs.
instr_iterator instr_begin()
reverse_instr_iterator instr_rend()
Instructions::iterator instr_iterator
instr_iterator instr_end()
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 '...
Instructions::reverse_iterator reverse_instr_iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Reg
All possible values of the reg field in the ModR/M byte.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createLanaiDelaySlotFillerPass(const LanaiTargetMachine &TM)