Pass MCSymbols to the helper functions in MCELF.h.
llvm-svn: 238596
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
index 204a1ab..3bf480f 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -165,8 +165,8 @@
Name + "." + Twine(MappingSymbolCounter++));
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
- MCELF::SetType(SD, ELF::STT_NOTYPE);
- MCELF::SetBinding(SD, ELF::STB_LOCAL);
+ MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
+ MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
auto Sec = getCurrentSection().first;
assert(Sec && "need a section");
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
index 74b81af..c7ce35d 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
@@ -121,8 +121,7 @@
// We're known to be under a TLS fixup, so any symbol should be
// modified. There should be only one.
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
- MCSymbolData &SD = Asm.getOrCreateSymbolData(SymRef.getSymbol());
- MCELF::SetType(SD, ELF::STT_TLS);
+ MCELF::SetType(SymRef.getSymbol(), ELF::STT_TLS);
break;
}
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 4dc3dac..10d66e9 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -567,8 +567,8 @@
Twine(MappingSymbolCounter++));
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
- MCELF::SetType(SD, ELF::STT_NOTYPE);
- MCELF::SetBinding(SD, ELF::STB_LOCAL);
+ MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
+ MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
AssignSection(Symbol, getCurrentSection().first);
@@ -972,8 +972,8 @@
if (!Streamer.IsThumb)
return;
- const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
- unsigned Type = MCELF::GetType(SD);
+ Streamer.getOrCreateSymbolData(Symbol);
+ unsigned Type = MCELF::GetType(*Symbol);
if (Type == ELF_STT_Func || Type == ELF_STT_GnuIFunc)
Streamer.EmitThumbFunc(Symbol);
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index d95b448..8cc6b3b 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -271,9 +271,7 @@
if (Type == ELF::R_MIPS16_HI16)
return ELF::R_MIPS16_LO16;
- const MCSymbolData &SD = Reloc.Symbol->getData();
-
- if (MCELF::GetBinding(SD) != ELF::STB_LOCAL)
+ if (MCELF::GetBinding(*Reloc.Symbol) != ELF::STB_LOCAL)
return ELF::R_MIPS_NONE;
if (Type == ELF::R_MIPS_GOT16)
@@ -433,7 +431,7 @@
return true;
case ELF::R_MIPS_32:
- if (MCELF::getOther(Sym.getData()) & (ELF::STO_MIPS_MICROMIPS >> 2))
+ if (MCELF::getOther(Sym) & (ELF::STO_MIPS_MICROMIPS >> 2))
return true;
// falltrough
case ELF::R_MIPS_26:
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
index d2b5183..8abd93b 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
@@ -42,11 +42,11 @@
// FIXME: Also mark labels when in MIPS16 mode.
if (ELFTargetStreamer->isMicroMipsEnabled()) {
for (auto Label : Labels) {
- MCSymbolData &Data = getOrCreateSymbolData(Label);
+ getOrCreateSymbolData(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.
- MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
+ MCELF::setOther(*Label, ELF::STO_MIPS_MICROMIPS >> 2);
}
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index 0ff14e4..aa414d7 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -441,15 +441,15 @@
void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
if (!isMicroMipsEnabled())
return;
- MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Symbol);
- uint8_t Type = MCELF::GetType(Data);
+ getStreamer().getOrCreateSymbolData(Symbol);
+ uint8_t Type = MCELF::GetType(*Symbol);
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.
- MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
+ MCELF::setOther(*Symbol, ELF::STO_MIPS_MICROMIPS >> 2);
}
void MipsTargetELFStreamer::finish() {
@@ -510,16 +510,14 @@
return;
const MCSymbol &RhsSym =
static_cast<const MCSymbolRefExpr *>(Value)->getSymbol();
- MCSymbolData &Data = getStreamer().getOrCreateSymbolData(&RhsSym);
- if (!(MCELF::getOther(Data) & (ELF::STO_MIPS_MICROMIPS >> 2)))
+ if (!(MCELF::getOther(RhsSym) & (ELF::STO_MIPS_MICROMIPS >> 2)))
return;
- MCSymbolData &SymbolData = getStreamer().getOrCreateSymbolData(Symbol);
// 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.
- MCELF::setOther(SymbolData, ELF::STO_MIPS_MICROMIPS >> 2);
+ MCELF::setOther(*Symbol, ELF::STO_MIPS_MICROMIPS >> 2);
}
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
index 1bfa153..0fe3534 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -142,11 +142,10 @@
// to resolve the fixup directly. Emit a relocation and leave
// resolution of the final target address to the linker.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
- const MCSymbolData &Data = A->getSymbol().getData();
// 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.
- unsigned Other = MCELF::getOther(Data) << 2;
+ unsigned Other = MCELF::getOther(A->getSymbol()) << 2;
if ((Other & ELF::STO_PPC64_LOCAL_MASK) != 0)
IsResolved = false;
}
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
index 704caff..c014776 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
@@ -407,7 +407,7 @@
// 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.
- unsigned Other = MCELF::getOther(Sym.getData()) << 2;
+ unsigned Other = MCELF::getOther(Sym) << 2;
return (Other & ELF::STO_PPC64_LOCAL_MASK) != 0;
}
}
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
index 8474376..ef1db07 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
@@ -161,7 +161,6 @@
}
void emitLocalEntry(MCSymbol *S, const MCExpr *LocalOffset) override {
MCAssembler &MCA = getStreamer().getAssembler();
- MCSymbolData &Data = getStreamer().getOrCreateSymbolData(S);
int64_t Res;
if (!LocalOffset->EvaluateAsAbsolute(Res, MCA))
@@ -174,10 +173,10 @@
// 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.
- unsigned Other = MCELF::getOther(Data) << 2;
+ unsigned Other = MCELF::getOther(*S) << 2;
Other &= ~ELF::STO_PPC64_LOCAL_MASK;
Other |= Encoded;
- MCELF::setOther(Data, Other >> 2);
+ MCELF::setOther(*S, Other >> 2);
// For GAS compatibility, unless we already saw a .abiversion directive,
// set e_flags to indicate ELFv2 ABI.
@@ -192,15 +191,13 @@
return;
const MCSymbol &RhsSym =
static_cast<const MCSymbolRefExpr *>(Value)->getSymbol();
- MCSymbolData &Data = getStreamer().getOrCreateSymbolData(&RhsSym);
- MCSymbolData &SymbolData = getStreamer().getOrCreateSymbolData(Symbol);
// 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.
- unsigned Other = MCELF::getOther(SymbolData) << 2;
+ unsigned Other = MCELF::getOther(*Symbol) << 2;
Other &= ~ELF::STO_PPC64_LOCAL_MASK;
- Other |= (MCELF::getOther(Data) << 2) & ELF::STO_PPC64_LOCAL_MASK;
- MCELF::setOther(SymbolData, Other >> 2);
+ Other |= (MCELF::getOther(RhsSym) << 2) & ELF::STO_PPC64_LOCAL_MASK;
+ MCELF::setOther(*Symbol, Other >> 2);
}
};
diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
index d97e3a2..c485320 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
@@ -184,8 +184,7 @@
case MCExpr::SymbolRef: {
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
- MCSymbolData &SD = Asm.getOrCreateSymbolData(SymRef.getSymbol());
- MCELF::SetType(SD, ELF::STT_TLS);
+ MCELF::SetType(SymRef.getSymbol(), ELF::STT_TLS);
break;
}