1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

Avoid using MCSymbolData on the asm streamer.

Only the object streamers need to track if a symbol should be marked thumb or
not. This ports the ELF case. The COFF case is not ported since it is currently
not working for some other reason (I will report a bug).

llvm-svn: 207366
This commit is contained in:
Rafael Espindola 2014-04-27 17:10:46 +00:00
parent 0d344f3333
commit 947137e8a0
3 changed files with 13 additions and 42 deletions

View File

@ -59,10 +59,6 @@ private:
EHPrivateExtern = 1 << 2 };
DenseMap<const MCSymbol*, unsigned> FlagMap;
// Using std::unordered_map to ensure pointers to MCSymbolData remain valid
// over insertions/removals from the SymbolMap.
std::unordered_map<const MCSymbol*, MCSymbolData> SymbolMap;
void EmitRegisterName(int64_t Register);
void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
@ -258,8 +254,6 @@ public:
void EmitRawTextImpl(StringRef String) override;
void FinishImpl() override;
virtual MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) override;
};
} // end anonymous namespace.
@ -1472,14 +1466,6 @@ void MCAsmStreamer::FinishImpl() {
EmitFrames(AsmBackend.get(), false);
}
MCSymbolData &MCAsmStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) {
auto Iter = SymbolMap.find(Symbol);
if (Iter == SymbolMap.end())
Iter = SymbolMap.insert(
Iter, std::make_pair(Symbol, MCSymbolData(*Symbol, nullptr, 0)));
return Iter->second;
}
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
formatted_raw_ostream &OS,
bool isVerboseAsm, bool useCFI,

View File

@ -22,9 +22,7 @@
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCELF.h"
#include "llvm/MC/MCELFStreamer.h"
#include "llvm/MC/MCELFSymbolFlags.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
@ -8364,32 +8362,6 @@ void ARMAsmParser::onLabelParsed(MCSymbol *Symbol) {
if (NextSymbolIsThumb) {
getParser().getStreamer().EmitThumbFunc(Symbol);
NextSymbolIsThumb = false;
return;
}
if (!isThumb())
return;
const MCObjectFileInfo::Environment Format =
getContext().getObjectFileInfo()->getObjectFileType();
switch (Format) {
case MCObjectFileInfo::IsCOFF: {
const MCSymbolData &SD =
getParser().getStreamer().getOrCreateSymbolData(Symbol);
char Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
if (SD.getFlags() & (Type << COFF::SF_TypeShift))
getParser().getStreamer().EmitThumbFunc(Symbol);
break;
}
case MCObjectFileInfo::IsELF: {
const MCSymbolData &SD =
getParser().getStreamer().getOrCreateSymbolData(Symbol);
if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
getParser().getStreamer().EmitThumbFunc(Symbol);
break;
}
case MCObjectFileInfo::IsMachO:
break;
}
}

View File

@ -30,6 +30,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSection.h"
@ -406,6 +407,7 @@ private:
void emitFPU(unsigned FPU) override;
void emitInst(uint32_t Inst, char Suffix = '\0') override;
void finishAttributeSection() override;
void emitLabel(MCSymbol *Symbol) override;
void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
@ -981,6 +983,17 @@ void ARMTargetELFStreamer::finishAttributeSection() {
Contents.clear();
FPU = ARM::INVALID_FPU;
}
void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
ARMELFStreamer &Streamer = getStreamer();
if (!Streamer.IsThumb)
return;
const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
Streamer.EmitThumbFunc(Symbol);
}
void
ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
getStreamer().EmitFixup(S, FK_Data_4);