Skip to content

Commit 34f79c8

Browse files
committed
[Mips] Implement getNop() operation
Previously, this was calling TargetInstrInfo::getNop(), which contains: llvm_unreachable("Not implemented"); Fixes #134913.
1 parent 7940b05 commit 34f79c8

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: mips-registered-target
2+
// RUN: %clang_cc1 -triple mipsel-w64-windows-gnu -x c++ -mrelocation-model static -emit-obj %s -o - | llvm-objdump -a - | FileCheck %s
3+
// CHECK: file format coff-mips
4+
5+
[[__noreturn__]] inline void g() {
6+
__builtin_unreachable();
7+
}
8+
9+
void f(int i)
10+
{
11+
if (i == 0)
12+
g();
13+
}

llvm/lib/Target/Mips/MipsInstrInfo.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ MipsInstrInfo::GetMemOperand(MachineBasicBlock &MBB, int FI,
8787
MFI.getObjectAlign(FI));
8888
}
8989

90+
MCInst MipsInstrInfo::getNop() const {
91+
MCInst Nop;
92+
// using Mips::NOP gives "fatal error: error in backend: Not supported instr: <MCInst 580>"
93+
Nop.setOpcode(Mips::SSNOP);
94+
return Nop;
95+
}
96+
9097
//===----------------------------------------------------------------------===//
9198
// Branch Analysis
9299
//===----------------------------------------------------------------------===//

llvm/lib/Target/Mips/MipsInstrInfo.h

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class MipsInstrInfo : public MipsGenInstrInfo {
5959

6060
static const MipsInstrInfo *create(MipsSubtarget &STI);
6161

62+
MCInst getNop() const override;
63+
6264
/// Branch Analysis
6365
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
6466
MachineBasicBlock *&FBB,

0 commit comments

Comments
 (0)