aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
commit145449b1e420787bb99721a429341fa6be3adfb6 (patch)
tree1d56ae694a6de602e348dd80165cf881a36600ed /llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
parentecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff)
Diffstat (limited to 'llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp')
-rw-r--r--llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index 57cd016da4dc..caae5890fae1 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -11,17 +11,19 @@
//===----------------------------------------------------------------------===//
#include "MipsTargetStreamer.h"
-#include "MipsInstPrinter.h"
#include "MCTargetDesc/MipsABIInfo.h"
#include "MipsELFStreamer.h"
+#include "MipsInstPrinter.h"
#include "MipsMCExpr.h"
#include "MipsMCTargetDesc.h"
#include "MipsTargetObjectFile.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbolELF.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
@@ -38,6 +40,10 @@ static bool isMicroMips(const MCSubtargetInfo *STI) {
return STI->getFeatureBits()[Mips::FeatureMicroMips];
}
+static bool isMips32r6(const MCSubtargetInfo *STI) {
+ return STI->getFeatureBits()[Mips::FeatureMips32r6];
+}
+
MipsTargetStreamer::MipsTargetStreamer(MCStreamer &S)
: MCTargetStreamer(S), GPReg(Mips::GP), ModuleDirectiveAllowed(true) {
GPRInfoSet = FPRInfoSet = FrameInfoSet = false;
@@ -277,10 +283,18 @@ void MipsTargetStreamer::emitDSLL(unsigned DstReg, unsigned SrcReg,
void MipsTargetStreamer::emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc,
const MCSubtargetInfo *STI) {
- if (hasShortDelaySlot)
- emitRR(Mips::MOVE16_MM, Mips::ZERO, Mips::ZERO, IDLoc, STI);
- else
- emitRRI(Mips::SLL, Mips::ZERO, Mips::ZERO, 0, IDLoc, STI);
+ // The default case of `nop` is `sll $zero, $zero, 0`.
+ unsigned Opc = Mips::SLL;
+ if (isMicroMips(STI) && hasShortDelaySlot) {
+ Opc = isMips32r6(STI) ? Mips::MOVE16_MMR6 : Mips::MOVE16_MM;
+ emitRR(Opc, Mips::ZERO, Mips::ZERO, IDLoc, STI);
+ return;
+ }
+
+ if (isMicroMips(STI))
+ Opc = isMips32r6(STI) ? Mips::SLL_MMR6 : Mips::SLL_MM;
+
+ emitRRI(Opc, Mips::ZERO, Mips::ZERO, 0, IDLoc, STI);
}
void MipsTargetStreamer::emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI) {
@@ -900,8 +914,8 @@ void MipsTargetELFStreamer::finish() {
unsigned Alignment = Section.getAlignment();
if (Alignment) {
- OS.SwitchSection(&Section);
- if (Section.UseCodeAlign())
+ OS.switchSection(&Section);
+ if (Section.useCodeAlign())
OS.emitCodeAlignment(Alignment, &STI, Alignment);
else
OS.emitValueToAlignment(Alignment, 0, 1, Alignment);
@@ -1012,9 +1026,9 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) {
MCA.registerSection(*Sec);
Sec->setAlignment(Align(4));
- OS.PushSection();
+ OS.pushSection();
- OS.SwitchSection(Sec);
+ OS.switchSection(Sec);
OS.emitValueImpl(ExprRef, 4);
@@ -1032,7 +1046,7 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) {
// the information gathered up until this point.
GPRInfoSet = FPRInfoSet = FrameInfoSet = false;
- OS.PopSection();
+ OS.popSection();
// .end also implicitly sets the size.
MCSymbol *CurPCSym = Context.createTempSymbol();
@@ -1312,7 +1326,7 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() {
".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24);
MCA.registerSection(*Sec);
Sec->setAlignment(Align(8));
- OS.SwitchSection(Sec);
+ OS.switchSection(Sec);
OS << ABIFlagsSection;
}