diff options
Diffstat (limited to 'llvm/lib/Target/Mips/MipsInstrInfo.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstrInfo.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.cpp b/llvm/lib/Target/Mips/MipsInstrInfo.cpp index 2bf8562895d7..5cb7a0a1804d 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.cpp +++ b/llvm/lib/Target/Mips/MipsInstrInfo.cpp @@ -54,7 +54,6 @@ bool MipsInstrInfo::isZeroImm(const MachineOperand &op) const { /// insertNoop - If data hazard condition is found insert the target nop /// instruction. -// FIXME: This appears to be dead code. void MipsInstrInfo:: insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const { @@ -62,6 +61,19 @@ insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const BuildMI(MBB, MI, DL, get(Mips::NOP)); } +MachineInstrBuilder MipsInstrInfo::insertNop(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + DebugLoc DL) const { + assert(!Subtarget.inMips16Mode() && + "insertNop does not support MIPS16e mode at this time"); + const unsigned MMOpc = + Subtarget.hasMips32r6() ? Mips::SLL_MMR6 : Mips::SLL_MM; + const unsigned Opc = Subtarget.inMicroMipsMode() ? MMOpc : Mips::SLL; + return BuildMI(MBB, MI, DL, get(Opc), Mips::ZERO) + .addReg(Mips::ZERO) + .addImm(0); +} + MachineMemOperand * MipsInstrInfo::GetMemOperand(MachineBasicBlock &MBB, int FI, MachineMemOperand::Flags Flags) const { @@ -598,6 +610,18 @@ bool MipsInstrInfo::SafeInFPUDelaySlot(const MachineInstr &MIInSlot, return true; } +/// Predicate for distinguishing instructions that are hazardous in a load delay +/// slot. Consider inline assembly as unsafe as well. +bool MipsInstrInfo::SafeInLoadDelaySlot(const MachineInstr &MIInSlot, + const MachineInstr &LoadMI) const { + if (MIInSlot.isInlineAsm()) + return false; + + return !llvm::any_of(LoadMI.defs(), [&](const MachineOperand &Op) { + return Op.isReg() && MIInSlot.readsRegister(Op.getReg()); + }); +} + /// Predicate for distingushing instructions that have forbidden slots. bool MipsInstrInfo::HasForbiddenSlot(const MachineInstr &MI) const { return (MI.getDesc().TSFlags & MipsII::HasForbiddenSlot) != 0; @@ -622,6 +646,22 @@ bool MipsInstrInfo::HasFPUDelaySlot(const MachineInstr &MI) const { } } +/// Predicate for distingushing instructions that have load delay slots. +bool MipsInstrInfo::HasLoadDelaySlot(const MachineInstr &MI) const { + switch (MI.getOpcode()) { + case Mips::LB: + case Mips::LBu: + case Mips::LH: + case Mips::LHu: + case Mips::LW: + case Mips::LWR: + case Mips::LWL: + return true; + default: + return false; + } +} + /// Return the number of bytes of code the specified instruction may be. unsigned MipsInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const { switch (MI.getOpcode()) { @@ -695,7 +735,7 @@ MipsInstrInfo::genInstrWithNewOpc(unsigned NewOpc, NewOpc == Mips::JIALC64) { if (NewOpc == Mips::JIALC || NewOpc == Mips::JIALC64) - MIB->RemoveOperand(0); + MIB->removeOperand(0); for (unsigned J = 0, E = I->getDesc().getNumOperands(); J < E; ++J) { MIB.add(I->getOperand(J)); |
