diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.cpp b/llvm/lib/Target/Mips/MipsInstrInfo.cpp index d33652b4d2e3a..29b1058d8e620 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.cpp +++ b/llvm/lib/Target/Mips/MipsInstrInfo.cpp @@ -26,6 +26,7 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugLoc.h" +#include "llvm/MC/MCInstBuilder.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/Target/TargetMachine.h" #include @@ -53,6 +54,13 @@ bool MipsInstrInfo::isZeroImm(const MachineOperand &op) const { return op.isImm() && op.getImm() == 0; } +MCInst MipsInstrInfo::getNop() const { + return MCInstBuilder(Mips::SLL) + .addReg(Mips::ZERO) + .addReg(Mips::ZERO) + .addImm(0); +} + /// insertNoop - If data hazard condition is found insert the target nop /// instruction. void MipsInstrInfo:: diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.h b/llvm/lib/Target/Mips/MipsInstrInfo.h index 0fa8257089bc5..e4de38c7035e5 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.h +++ b/llvm/lib/Target/Mips/MipsInstrInfo.h @@ -57,6 +57,8 @@ class MipsInstrInfo : public MipsGenInstrInfo { explicit MipsInstrInfo(const MipsSubtarget &STI, unsigned UncondBrOpc); + MCInst getNop() const override; + static const MipsInstrInfo *create(MipsSubtarget &STI); /// Branch Analysis diff --git a/llvm/test/CodeGen/Mips/unreachable.ll b/llvm/test/CodeGen/Mips/unreachable.ll new file mode 100644 index 0000000000000..30087411f7b89 --- /dev/null +++ b/llvm/test/CodeGen/Mips/unreachable.ll @@ -0,0 +1,13 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=mipsel-windows-gnu < %s | FileCheck %s -check-prefix=MIPSEL + +define void @unreachable() { +; MIPSEL-LABEL: unreachable: +; MIPSEL: # %bb.0: # %entry +; MIPSEL-NEXT: .insn +; MIPSEL-NEXT: nop + +entry: + unreachable +} +