llvm.org GIT mirror llvm / 70883a2
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207366 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
3 changed file(s) with 13 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
5858 EHPrivateExtern = 1 << 2 };
5959 DenseMap FlagMap;
6060
61 // Using std::unordered_map to ensure pointers to MCSymbolData remain valid
62 // over insertions/removals from the SymbolMap.
63 std::unordered_map SymbolMap;
64
6561 void EmitRegisterName(int64_t Register);
6662 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
6763 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
257253 void EmitRawTextImpl(StringRef String) override;
258254
259255 void FinishImpl() override;
260
261 virtual MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) override;
262256 };
263257
264258 } // end anonymous namespace.
14711465 EmitFrames(AsmBackend.get(), false);
14721466 }
14731467
1474 MCSymbolData &MCAsmStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) {
1475 auto Iter = SymbolMap.find(Symbol);
1476 if (Iter == SymbolMap.end())
1477 Iter = SymbolMap.insert(
1478 Iter, std::make_pair(Symbol, MCSymbolData(*Symbol, nullptr, 0)));
1479 return Iter->second;
1480 }
1481
14821468 MCStreamer *llvm::createAsmStreamer(MCContext &Context,
14831469 formatted_raw_ostream &OS,
14841470 bool isVerboseAsm, bool useCFI,
2121 #include "llvm/MC/MCAssembler.h"
2222 #include "llvm/MC/MCContext.h"
2323 #include "llvm/MC/MCDisassembler.h"
24 #include "llvm/MC/MCELF.h"
2524 #include "llvm/MC/MCELFStreamer.h"
26 #include "llvm/MC/MCELFSymbolFlags.h"
2725 #include "llvm/MC/MCExpr.h"
2826 #include "llvm/MC/MCInst.h"
2927 #include "llvm/MC/MCInstrDesc.h"
83638361 if (NextSymbolIsThumb) {
83648362 getParser().getStreamer().EmitThumbFunc(Symbol);
83658363 NextSymbolIsThumb = false;
8366 return;
8367 }
8368
8369 if (!isThumb())
8370 return;
8371
8372 const MCObjectFileInfo::Environment Format =
8373 getContext().getObjectFileInfo()->getObjectFileType();
8374 switch (Format) {
8375 case MCObjectFileInfo::IsCOFF: {
8376 const MCSymbolData &SD =
8377 getParser().getStreamer().getOrCreateSymbolData(Symbol);
8378 char Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
8379 if (SD.getFlags() & (Type << COFF::SF_TypeShift))
8380 getParser().getStreamer().EmitThumbFunc(Symbol);
8381 break;
8382 }
8383 case MCObjectFileInfo::IsELF: {
8384 const MCSymbolData &SD =
8385 getParser().getStreamer().getOrCreateSymbolData(Symbol);
8386 if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
8387 getParser().getStreamer().EmitThumbFunc(Symbol);
8388 break;
8389 }
8390 case MCObjectFileInfo::IsMachO:
8391 break;
83928364 }
83938365 }
83948366
2929 #include "llvm/MC/MCExpr.h"
3030 #include "llvm/MC/MCInst.h"
3131 #include "llvm/MC/MCInstPrinter.h"
32 #include "llvm/MC/MCObjectFileInfo.h"
3233 #include "llvm/MC/MCObjectStreamer.h"
3334 #include "llvm/MC/MCRegisterInfo.h"
3435 #include "llvm/MC/MCSection.h"
405406 void emitFPU(unsigned FPU) override;
406407 void emitInst(uint32_t Inst, char Suffix = '\0') override;
407408 void finishAttributeSection() override;
409 void emitLabel(MCSymbol *Symbol) override;
408410
409411 void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
410412
980982 Contents.clear();
981983 FPU = ARM::INVALID_FPU;
982984 }
985
986 void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
987 ARMELFStreamer &Streamer = getStreamer();
988 if (!Streamer.IsThumb)
989 return;
990
991 const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
992 if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
993 Streamer.EmitThumbFunc(Symbol);
994 }
995
983996 void
984997 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
985998 getStreamer().EmitFixup(S, FK_Data_4);