Only mark functions as micromips.

The GNU as behavior is a bit different and very strange. It will mark any
label that contains an instruction. We can implement that, but using the
type looks more natural since gas will not mark a function if a .word is
used to output the instructions!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199287 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-01-15 03:07:12 +00:00
parent 268226b9f3
commit f6cb056e41
2 changed files with 16 additions and 2 deletions

View File

@ -68,12 +68,17 @@ void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
MipsTargetELFStreamer::MipsTargetELFStreamer() {}
void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
if (!isMicroMipsEnabled())
return;
MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Symbol);
uint8_t Type = MCELF::GetType(Data);
if (Type != ELF::STT_FUNC)
return;
// The "other" values are stored in the last 6 bits of the second byte
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
if (isMicroMipsEnabled())
MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
}
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {

View File

@ -2,15 +2,24 @@
.globl f1
.type f1, @function
.set micromips
f1:
nop
.globl d1
.type d1, @object
d1:
.word 42
.globl f2
.type f2, @function
.set nomicromips
f2:
nop
// CHECK-LABEL: Name: d1
// CHECK: Other: 0
// CHECK-LABEL: Name: f1
// CHECK: Other: 128
// CHECK-LABEL: Name: f2