[llvm] r269639 - [mips][ias] EF_MIPS_MICROMIPS should iff microMIPS code was emitted.
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 02:10:13 PDT 2016
Author: dsanders
Date: Mon May 16 04:10:13 2016
New Revision: 269639
URL: http://llvm.org/viewvc/llvm-project?rev=269639&view=rev
Log:
[mips][ias] EF_MIPS_MICROMIPS should iff microMIPS code was emitted.
Summary:
This fixes PR27682. Additionally, '.set micromips' by itself is not sufficient
to raise the EF_MIPS_MICROMIPS flag. It is also necessary to emit a microMIPS
instruction. This has also been fixed.
Reviewers: sdardis, vkalintiris, rafael
Subscribers: rafael, dsanders, sdardis, llvm-commits
Differential Revision: http://reviews.llvm.org/D20214
Added:
llvm/trunk/test/MC/Mips/elf_eflags_micromips2.s
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
llvm/trunk/test/MC/Mips/elf_eflags_micromips.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=269639&r1=269638&r2=269639&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Mon May 16 04:10:13 2016
@@ -1900,6 +1900,11 @@ bool MipsAsmParser::processInstruction(M
return true;
}
+ // We know we emitted an instruction on the MER_NotAMacro or MER_Success path.
+ // If we're in microMIPS mode then we must also set EF_MIPS_MICROMIPS.
+ if (inMicroMipsMode())
+ TOut.setUsesMicroMips();
+
// If this instruction has a delay slot and .set reorder is active,
// emit a NOP after it.
if (FillDelaySlot) {
@@ -5288,6 +5293,7 @@ bool MipsAsmParser::parseSetFeature(uint
getTargetStreamer().emitDirectiveSetDsp();
break;
case Mips::FeatureMicroMips:
+ setFeatureBits(Mips::FeatureMicroMips, "micromips");
getTargetStreamer().emitDirectiveSetMicroMips();
break;
case Mips::FeatureMips1:
@@ -5586,6 +5592,7 @@ bool MipsAsmParser::parseDirectiveSet()
} else if (Tok.getString() == "nomips16") {
return parseSetNoMips16Directive();
} else if (Tok.getString() == "nomicromips") {
+ clearFeatureBits(Mips::FeatureMicroMips, "micromips");
getTargetStreamer().emitDirectiveSetNoMicroMips();
Parser.eatToEndOfStatement();
return false;
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=269639&r1=269638&r2=269639&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Mon May 16 04:10:13 2016
@@ -40,6 +40,7 @@ MipsTargetStreamer::MipsTargetStreamer(M
}
void MipsTargetStreamer::emitDirectiveSetMicroMips() {}
void MipsTargetStreamer::emitDirectiveSetNoMicroMips() {}
+void MipsTargetStreamer::setUsesMicroMips() {}
void MipsTargetStreamer::emitDirectiveSetMips16() {}
void MipsTargetStreamer::emitDirectiveSetNoMips16() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetReorder() { forbidModuleDirective(); }
@@ -830,11 +831,6 @@ MCELFStreamer &MipsTargetELFStreamer::ge
void MipsTargetELFStreamer::emitDirectiveSetMicroMips() {
MicroMipsEnabled = true;
-
- MCAssembler &MCA = getStreamer().getAssembler();
- unsigned Flags = MCA.getELFHeaderEFlags();
- Flags |= ELF::EF_MIPS_MICROMIPS;
- MCA.setELFHeaderEFlags(Flags);
forbidModuleDirective();
}
@@ -843,6 +839,13 @@ void MipsTargetELFStreamer::emitDirectiv
forbidModuleDirective();
}
+void MipsTargetELFStreamer::setUsesMicroMips() {
+ MCAssembler &MCA = getStreamer().getAssembler();
+ unsigned Flags = MCA.getELFHeaderEFlags();
+ Flags |= ELF::EF_MIPS_MICROMIPS;
+ MCA.setELFHeaderEFlags(Flags);
+}
+
void MipsTargetELFStreamer::emitDirectiveSetMips16() {
MCAssembler &MCA = getStreamer().getAssembler();
unsigned Flags = MCA.getELFHeaderEFlags();
Modified: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h?rev=269639&r1=269638&r2=269639&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h Mon May 16 04:10:13 2016
@@ -30,6 +30,7 @@ public:
virtual void emitDirectiveSetMicroMips();
virtual void emitDirectiveSetNoMicroMips();
+ virtual void setUsesMicroMips();
virtual void emitDirectiveSetMips16();
virtual void emitDirectiveSetNoMips16();
@@ -290,6 +291,7 @@ public:
void emitDirectiveSetMicroMips() override;
void emitDirectiveSetNoMicroMips() override;
+ void setUsesMicroMips() override;
void emitDirectiveSetMips16() override;
void emitDirectiveSetNoReorder() override;
Modified: llvm/trunk/test/MC/Mips/elf_eflags_micromips.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf_eflags_micromips.s?rev=269639&r1=269638&r2=269639&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/elf_eflags_micromips.s (original)
+++ llvm/trunk/test/MC/Mips/elf_eflags_micromips.s Mon May 16 04:10:13 2016
@@ -1,7 +1,12 @@
-# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o -| llvm-readobj -h | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 \
+# RUN: -mattr=+micromips < /dev/null -o -| llvm-readobj -h | FileCheck \
+# RUN: -check-prefix=NO-MM %s
+# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o - \
+# RUN: | llvm-readobj -h | FileCheck %s
# This *MUST* match the output of 'gcc -c' compiled with the same triple.
# CHECK: Flags [ (0x52001004)
+# NO-MM: Flags [ (0x50001004)
.set micromips
f:
Added: llvm/trunk/test/MC/Mips/elf_eflags_micromips2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf_eflags_micromips2.s?rev=269639&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/elf_eflags_micromips2.s (added)
+++ llvm/trunk/test/MC/Mips/elf_eflags_micromips2.s Mon May 16 04:10:13 2016
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o - \
+# RUN: | llvm-readobj -h | FileCheck %s
+
+# This *MUST* match the output of 'gcc -c' compiled with the same triple.
+# The microMIPS flag is not set if no microMIPS code was emitted.
+# CHECK: Flags [ (0x50001004)
+
+ nop
+ .set micromips
+ .set nomicromips
+ nop
More information about the llvm-commits
mailing list