Pack the MCSymbolELF bit fields into MCSymbol's Flags.

This reduces MCSymolfELF from 64 bytes to 56 bytes on x86_64.

While at it, also make getOther/setOther easier to use by accepting unshifted
STO_* values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239006 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-06-04 02:32:20 +00:00
parent dc967a97df
commit d90fd082f9
7 changed files with 154 additions and 76 deletions

View File

@@ -384,7 +384,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
return true;
case ELF::R_MIPS_32:
if (cast<MCSymbolELF>(Sym).getOther() & (ELF::STO_MIPS_MICROMIPS >> 2))
if (cast<MCSymbolELF>(Sym).getOther() & ELF::STO_MIPS_MICROMIPS)
return true;
// falltrough
case ELF::R_MIPS_26:

View File

@@ -44,10 +44,7 @@ void MipsELFStreamer::createPendingLabelRelocs() {
for (auto *L : Labels) {
auto *Label = cast<MCSymbolELF>(L);
getAssembler().registerSymbol(*Label);
// 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.
Label->setOther(ELF::STO_MIPS_MICROMIPS >> 2);
Label->setOther(ELF::STO_MIPS_MICROMIPS);
}
}

View File

@@ -462,10 +462,7 @@ void MipsTargetELFStreamer::emitLabel(MCSymbol *S) {
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.
Symbol->setOther(ELF::STO_MIPS_MICROMIPS >> 2);
Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
}
void MipsTargetELFStreamer::finish() {
@@ -527,13 +524,10 @@ void MipsTargetELFStreamer::emitAssignment(MCSymbol *S, const MCExpr *Value) {
const auto &RhsSym = cast<MCSymbolELF>(
static_cast<const MCSymbolRefExpr *>(Value)->getSymbol());
if (!(RhsSym.getOther() & (ELF::STO_MIPS_MICROMIPS >> 2)))
if (!(RhsSym.getOther() & ELF::STO_MIPS_MICROMIPS))
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.
Symbol->setOther(ELF::STO_MIPS_MICROMIPS >> 2);
Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
}
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {