mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 05:29:23 +00:00
Create a MCSymbolELF.
This create a MCSymbolELF class and moves SymbolSize since only ELF needs a size expression. This reduces the size of MCSymbol from 56 to 48 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238801 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
398f175c45
commit
f7e0685b9a
@ -30,6 +30,7 @@ namespace llvm {
|
|||||||
class MCExpr;
|
class MCExpr;
|
||||||
class MCSection;
|
class MCSection;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
|
class MCSymbolELF;
|
||||||
class MCLabel;
|
class MCLabel;
|
||||||
struct MCDwarfFile;
|
struct MCDwarfFile;
|
||||||
class MCDwarfLoc;
|
class MCDwarfLoc;
|
||||||
@ -75,7 +76,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// ELF sections can have a corresponding symbol. This maps one to the
|
/// ELF sections can have a corresponding symbol. This maps one to the
|
||||||
/// other.
|
/// other.
|
||||||
DenseMap<const MCSectionELF *, MCSymbol *> SectionSymbols;
|
DenseMap<const MCSectionELF *, MCSymbolELF *> SectionSymbols;
|
||||||
|
|
||||||
/// A mapping from a local label number and an instance count to a symbol.
|
/// A mapping from a local label number and an instance count to a symbol.
|
||||||
/// For example, in the assembly
|
/// For example, in the assembly
|
||||||
@ -205,6 +206,8 @@ namespace llvm {
|
|||||||
/// Do automatic reset in destructor
|
/// Do automatic reset in destructor
|
||||||
bool AutoReset;
|
bool AutoReset;
|
||||||
|
|
||||||
|
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
|
||||||
|
bool IsTemporary);
|
||||||
MCSymbol *CreateSymbol(StringRef Name, bool AlwaysAddSuffix);
|
MCSymbol *CreateSymbol(StringRef Name, bool AlwaysAddSuffix);
|
||||||
|
|
||||||
MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
|
MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
|
||||||
@ -263,7 +266,7 @@ namespace llvm {
|
|||||||
/// \param Name - The symbol name, which must be unique across all symbols.
|
/// \param Name - The symbol name, which must be unique across all symbols.
|
||||||
MCSymbol *getOrCreateSymbol(const Twine &Name);
|
MCSymbol *getOrCreateSymbol(const Twine &Name);
|
||||||
|
|
||||||
MCSymbol *getOrCreateSectionSymbol(const MCSectionELF &Section);
|
MCSymbolELF *getOrCreateSectionSymbol(const MCSectionELF &Section);
|
||||||
|
|
||||||
/// Gets a symbol that will be defined to the final stack offset of a local
|
/// Gets a symbol that will be defined to the final stack offset of a local
|
||||||
/// variable after codegen.
|
/// variable after codegen.
|
||||||
|
@ -23,7 +23,6 @@ class MCAssembler;
|
|||||||
class MCCodeEmitter;
|
class MCCodeEmitter;
|
||||||
class MCExpr;
|
class MCExpr;
|
||||||
class MCInst;
|
class MCInst;
|
||||||
class MCSymbol;
|
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
class MCELFStreamer : public MCObjectStreamer {
|
class MCELFStreamer : public MCObjectStreamer {
|
||||||
@ -61,7 +60,7 @@ public:
|
|||||||
void EmitCOFFSymbolType(int Type) override;
|
void EmitCOFFSymbolType(int Type) override;
|
||||||
void EndCOFFSymbolDef() override;
|
void EndCOFFSymbolDef() override;
|
||||||
|
|
||||||
void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
|
void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) override;
|
||||||
|
|
||||||
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) override;
|
unsigned ByteAlignment) override;
|
||||||
|
@ -34,6 +34,7 @@ class MCInstPrinter;
|
|||||||
class MCSection;
|
class MCSection;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
|
class MCSymbolELF;
|
||||||
class MCSymbolRefExpr;
|
class MCSymbolRefExpr;
|
||||||
class MCSubtargetInfo;
|
class MCSubtargetInfo;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
@ -450,7 +451,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// This corresponds to an assembler statement such as:
|
/// This corresponds to an assembler statement such as:
|
||||||
/// .size symbol, expression
|
/// .size symbol, expression
|
||||||
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
|
virtual void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value);
|
||||||
|
|
||||||
/// \brief Emit a Linker Optimization Hint (LOH) directive.
|
/// \brief Emit a Linker Optimization Hint (LOH) directive.
|
||||||
/// \param Args - Arguments of the LOH.
|
/// \param Args - Arguments of the LOH.
|
||||||
|
@ -83,13 +83,11 @@ class MCSymbol {
|
|||||||
|
|
||||||
mutable unsigned HasFragment : 1;
|
mutable unsigned HasFragment : 1;
|
||||||
|
|
||||||
|
unsigned IsELF : 1;
|
||||||
|
|
||||||
/// Index field, for use by the object file implementation.
|
/// Index field, for use by the object file implementation.
|
||||||
mutable uint32_t Index = 0;
|
mutable uint32_t Index = 0;
|
||||||
|
|
||||||
/// An expression describing how to calculate the size of a symbol. If a
|
|
||||||
/// symbol has no size this field will be NULL.
|
|
||||||
const MCExpr *SymbolSize = nullptr;
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
/// The offset to apply to the fragment address to form this symbol's value.
|
/// The offset to apply to the fragment address to form this symbol's value.
|
||||||
uint64_t Offset;
|
uint64_t Offset;
|
||||||
@ -107,16 +105,18 @@ class MCSymbol {
|
|||||||
/// additional per symbol information which is not easily classified.
|
/// additional per symbol information which is not easily classified.
|
||||||
mutable uint32_t Flags = 0;
|
mutable uint32_t Flags = 0;
|
||||||
|
|
||||||
private: // MCContext creates and uniques these.
|
protected: // MCContext creates and uniques these.
|
||||||
friend class MCExpr;
|
friend class MCExpr;
|
||||||
friend class MCContext;
|
friend class MCContext;
|
||||||
MCSymbol(const StringMapEntry<bool> *Name, bool isTemporary)
|
MCSymbol(bool IsELF, const StringMapEntry<bool> *Name, bool isTemporary)
|
||||||
: Name(Name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
|
: Name(Name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
|
||||||
IsRedefinable(false), IsUsed(false), IsRegistered(false),
|
IsRedefinable(false), IsUsed(false), IsRegistered(false),
|
||||||
IsExternal(false), IsPrivateExtern(false), HasFragment(false) {
|
IsExternal(false), IsPrivateExtern(false), HasFragment(false),
|
||||||
|
IsELF(IsELF) {
|
||||||
Offset = 0;
|
Offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
MCSymbol(const MCSymbol &) = delete;
|
MCSymbol(const MCSymbol &) = delete;
|
||||||
void operator=(const MCSymbol &) = delete;
|
void operator=(const MCSymbol &) = delete;
|
||||||
MCSection *getSectionPtr() const {
|
MCSection *getSectionPtr() const {
|
||||||
@ -197,6 +197,8 @@ public:
|
|||||||
Section = nullptr;
|
Section = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isELF() const { return IsELF; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// \name Variable Symbols
|
/// \name Variable Symbols
|
||||||
/// @{
|
/// @{
|
||||||
@ -225,10 +227,6 @@ public:
|
|||||||
Index = Value;
|
Index = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSize(const MCExpr *SS) { SymbolSize = SS; }
|
|
||||||
|
|
||||||
const MCExpr *getSize() const { return SymbolSize; }
|
|
||||||
|
|
||||||
uint64_t getOffset() const {
|
uint64_t getOffset() const {
|
||||||
assert(!isCommon());
|
assert(!isCommon());
|
||||||
return Offset;
|
return Offset;
|
||||||
|
31
include/llvm/MC/MCSymbolELF.h
Normal file
31
include/llvm/MC/MCSymbolELF.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//===- MCSymbolELF.h - -----------------------------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#ifndef LLVM_MC_MCSYMBOLELF_H
|
||||||
|
#define LLVM_MC_MCSYMBOLELF_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
class MCSymbolELF : public MCSymbol {
|
||||||
|
/// An expression describing how to calculate the size of a symbol. If a
|
||||||
|
/// symbol has no size this field will be NULL.
|
||||||
|
const MCExpr *SymbolSize = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
|
||||||
|
: MCSymbol(true, Name, isTemporary) {}
|
||||||
|
void setSize(const MCExpr *SS) { SymbolSize = SS; }
|
||||||
|
|
||||||
|
const MCExpr *getSize() const { return SymbolSize; }
|
||||||
|
|
||||||
|
static bool classof(const MCSymbol *S) { return S->isELF(); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -53,7 +53,6 @@ public:
|
|||||||
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
|
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
|
||||||
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
|
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
|
||||||
void EmitCOFFSecRel32(MCSymbol const *Symbol) override;
|
void EmitCOFFSecRel32(MCSymbol const *Symbol) override;
|
||||||
void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
|
|
||||||
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) override;
|
unsigned ByteAlignment) override;
|
||||||
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
@ -512,7 +512,8 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
|
|
||||||
if (MAI->hasDotTypeDotSizeDirective())
|
if (MAI->hasDotTypeDotSizeDirective())
|
||||||
// .size foo, 42
|
// .size foo, 42
|
||||||
OutStreamer->EmitELFSize(GVSym, MCConstantExpr::create(Size, OutContext));
|
OutStreamer->emitELFSize(cast<MCSymbolELF>(GVSym),
|
||||||
|
MCConstantExpr::create(Size, OutContext));
|
||||||
|
|
||||||
OutStreamer->AddBlankLine();
|
OutStreamer->AddBlankLine();
|
||||||
}
|
}
|
||||||
@ -904,7 +905,7 @@ void AsmPrinter::EmitFunctionBody() {
|
|||||||
MCSymbolRefExpr::create(CurrentFnSymForSize,
|
MCSymbolRefExpr::create(CurrentFnSymForSize,
|
||||||
OutContext),
|
OutContext),
|
||||||
OutContext);
|
OutContext);
|
||||||
OutStreamer->EmitELFSize(CurrentFnSym, SizeExp);
|
OutStreamer->emitELFSize(cast<MCSymbolELF>(CurrentFnSym), SizeExp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
#include "llvm/Support/Dwarf.h"
|
#include "llvm/Support/Dwarf.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
@ -63,7 +63,8 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
|||||||
const MCSymbol *Sym) const {
|
const MCSymbol *Sym) const {
|
||||||
SmallString<64> NameData("DW.ref.");
|
SmallString<64> NameData("DW.ref.");
|
||||||
NameData += Sym->getName();
|
NameData += Sym->getName();
|
||||||
MCSymbol *Label = getContext().getOrCreateSymbol(NameData);
|
MCSymbolELF *Label =
|
||||||
|
cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
|
||||||
Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
|
Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
|
||||||
Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
|
Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
|
||||||
StringRef Prefix = ".data.";
|
StringRef Prefix = ".data.";
|
||||||
@ -76,7 +77,7 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
|||||||
Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
|
Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
|
||||||
Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
|
Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
|
||||||
const MCExpr *E = MCConstantExpr::create(Size, getContext());
|
const MCExpr *E = MCConstantExpr::create(Size, getContext());
|
||||||
Streamer.EmitELFSize(Label, E);
|
Streamer.emitELFSize(Label, E);
|
||||||
Streamer.EmitLabel(Label);
|
Streamer.EmitLabel(Label);
|
||||||
|
|
||||||
Streamer.EmitSymbolValue(Sym, Size);
|
Streamer.EmitSymbolValue(Sym, Size);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/MC/MCFixupKindInfo.h"
|
#include "llvm/MC/MCFixupKindInfo.h"
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
#include "llvm/MC/StringTableBuilder.h"
|
#include "llvm/MC/StringTableBuilder.h"
|
||||||
#include "llvm/Support/Compression.h"
|
#include "llvm/Support/Compression.h"
|
||||||
@ -79,7 +80,7 @@ class ELFObjectWriter : public MCObjectWriter {
|
|||||||
|
|
||||||
/// Helper struct for containing some precomputed information on symbols.
|
/// Helper struct for containing some precomputed information on symbols.
|
||||||
struct ELFSymbolData {
|
struct ELFSymbolData {
|
||||||
const MCSymbol *Symbol;
|
const MCSymbolELF *Symbol;
|
||||||
uint32_t SectionIndex;
|
uint32_t SectionIndex;
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
|
|
||||||
@ -451,7 +452,8 @@ void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
|
|||||||
assert((!Symbol.getFragment() ||
|
assert((!Symbol.getFragment() ||
|
||||||
(Symbol.getFragment()->getParent() == &Symbol.getSection())) &&
|
(Symbol.getFragment()->getParent() == &Symbol.getSection())) &&
|
||||||
"The symbol's section doesn't match the fragment's symbol");
|
"The symbol's section doesn't match the fragment's symbol");
|
||||||
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
const MCSymbolELF *Base =
|
||||||
|
cast_or_null<MCSymbolELF>(Layout.getBaseSymbol(Symbol));
|
||||||
|
|
||||||
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
|
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
|
||||||
// SHN_COMMON.
|
// SHN_COMMON.
|
||||||
@ -810,7 +812,7 @@ void ELFObjectWriter::computeSymbolTable(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
ELFSymbolData MSD;
|
ELFSymbolData MSD;
|
||||||
MSD.Symbol = &Symbol;
|
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
|
||||||
|
|
||||||
// Undefined symbols are global, but this is the first place we
|
// Undefined symbols are global, but this is the first place we
|
||||||
// are able to set it.
|
// are able to set it.
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCSectionCOFF.h"
|
#include "llvm/MC/MCSectionCOFF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
@ -139,7 +139,7 @@ public:
|
|||||||
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
|
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
|
||||||
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
|
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
|
||||||
void EmitCOFFSecRel32(MCSymbol const *Symbol) override;
|
void EmitCOFFSecRel32(MCSymbol const *Symbol) override;
|
||||||
void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
|
void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) override;
|
||||||
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) override;
|
unsigned ByteAlignment) override;
|
||||||
|
|
||||||
@ -502,7 +502,7 @@ void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
|
|||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
||||||
assert(MAI->hasDotTypeDotSizeDirective());
|
assert(MAI->hasDotTypeDotSizeDirective());
|
||||||
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
@ -119,8 +119,8 @@ MCSymbol *MCContext::getOrCreateSymbol(const Twine &Name) {
|
|||||||
return Sym;
|
return Sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
|
MCSymbolELF *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
|
||||||
MCSymbol *&Sym = SectionSymbols[&Section];
|
MCSymbolELF *&Sym = SectionSymbols[&Section];
|
||||||
if (Sym)
|
if (Sym)
|
||||||
return Sym;
|
return Sym;
|
||||||
|
|
||||||
@ -128,12 +128,12 @@ MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
|
|||||||
|
|
||||||
MCSymbol *&OldSym = Symbols[Name];
|
MCSymbol *&OldSym = Symbols[Name];
|
||||||
if (OldSym && OldSym->isUndefined()) {
|
if (OldSym && OldSym->isUndefined()) {
|
||||||
Sym = OldSym;
|
Sym = cast<MCSymbolELF>(OldSym);
|
||||||
return OldSym;
|
return Sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;
|
auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;
|
||||||
Sym = new (*this) MCSymbol(&*NameIter, /*isTemporary*/ false);
|
Sym = new (*this) MCSymbolELF(&*NameIter, /*isTemporary*/ false);
|
||||||
|
|
||||||
if (!OldSym)
|
if (!OldSym)
|
||||||
OldSym = Sym;
|
OldSym = Sym;
|
||||||
@ -157,6 +157,14 @@ MCSymbol *MCContext::getOrCreateLSDASymbol(StringRef FuncName) {
|
|||||||
FuncName);
|
FuncName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
|
||||||
|
bool IsTemporary) {
|
||||||
|
bool IsELF = MOFI && MOFI->getObjectFileType() == MCObjectFileInfo::IsELF;
|
||||||
|
if (IsELF)
|
||||||
|
return new (*this) MCSymbolELF(Name, IsTemporary);
|
||||||
|
return new (*this) MCSymbol(false, Name, IsTemporary);
|
||||||
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
||||||
// Determine whether this is an assembler temporary or normal label, if used.
|
// Determine whether this is an assembler temporary or normal label, if used.
|
||||||
bool IsTemporary = false;
|
bool IsTemporary = false;
|
||||||
@ -164,7 +172,7 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
|||||||
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
|
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
|
||||||
|
|
||||||
if (IsTemporary && AlwaysAddSuffix && !UseNamesOnTempLabels)
|
if (IsTemporary && AlwaysAddSuffix && !UseNamesOnTempLabels)
|
||||||
return new (*this) MCSymbol(nullptr, true);
|
return createSymbolImpl(nullptr, true);
|
||||||
|
|
||||||
SmallString<128> NewName = Name;
|
SmallString<128> NewName = Name;
|
||||||
bool AddSuffix = AlwaysAddSuffix;
|
bool AddSuffix = AlwaysAddSuffix;
|
||||||
@ -178,8 +186,7 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
|||||||
if (NameEntry.second) {
|
if (NameEntry.second) {
|
||||||
// Ok, we found a name. Have the MCSymbol object itself refer to the copy
|
// Ok, we found a name. Have the MCSymbol object itself refer to the copy
|
||||||
// of the string that is embedded in the UsedNames entry.
|
// of the string that is embedded in the UsedNames entry.
|
||||||
MCSymbol *Result = new (*this) MCSymbol(&*NameEntry.first, IsTemporary);
|
return createSymbolImpl(&*NameEntry.first, IsTemporary);
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
assert(IsTemporary && "Cannot rename non-temporary symbols");
|
assert(IsTemporary && "Cannot rename non-temporary symbols");
|
||||||
AddSuffix = true;
|
AddSuffix = true;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "llvm/MC/MCObjectStreamer.h"
|
#include "llvm/MC/MCObjectStreamer.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
@ -333,10 +334,11 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
Symbol->setCommon(Size, ByteAlignment);
|
Symbol->setCommon(Size, ByteAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol->setSize(MCConstantExpr::create(Size, getContext()));
|
cast<MCSymbolELF>(Symbol)
|
||||||
|
->setSize(MCConstantExpr::create(Size, getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCELFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
void MCELFStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
||||||
Symbol->setSize(Value);
|
Symbol->setSize(Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,6 @@ public:
|
|||||||
void EndCOFFSymbolDef() override {
|
void EndCOFFSymbolDef() override {
|
||||||
llvm_unreachable("macho doesn't support this directive");
|
llvm_unreachable("macho doesn't support this directive");
|
||||||
}
|
}
|
||||||
void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override {
|
|
||||||
llvm_unreachable("macho doesn't support this directive");
|
|
||||||
}
|
|
||||||
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) override;
|
unsigned ByteAlignment) override;
|
||||||
void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
|
void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
|
|||||||
StringRef Name;
|
StringRef Name;
|
||||||
if (getParser().parseIdentifier(Name))
|
if (getParser().parseIdentifier(Name))
|
||||||
return TokError("expected identifier in directive");
|
return TokError("expected identifier in directive");
|
||||||
MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
|
MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name));
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
@ -222,7 +222,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
|
|||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
|
||||||
getStreamer().EmitELFSize(Sym, Expr);
|
getStreamer().emitELFSize(Sym, Expr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ void MCStreamer::EndCOFFSymbolDef() {}
|
|||||||
void MCStreamer::EmitFileDirective(StringRef Filename) {}
|
void MCStreamer::EmitFileDirective(StringRef Filename) {}
|
||||||
void MCStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {}
|
void MCStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {}
|
||||||
void MCStreamer::EmitCOFFSymbolType(int Type) {}
|
void MCStreamer::EmitCOFFSymbolType(int Type) {}
|
||||||
void MCStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
|
void MCStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {}
|
||||||
void MCStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void MCStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) {}
|
unsigned ByteAlignment) {}
|
||||||
void MCStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
|
void MCStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
|
||||||
|
@ -195,10 +195,6 @@ void MCWinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
|
|||||||
DF->getContents().resize(DF->getContents().size() + 4, 0);
|
DF->getContents().resize(DF->getContents().size() + 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCWinCOFFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
|
||||||
llvm_unreachable("not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) {
|
unsigned ByteAlignment) {
|
||||||
assert((!Symbol->isInSection() ||
|
assert((!Symbol->isInSection() ||
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -983,7 +983,8 @@ void MipsAsmPrinter::EmitFPCallStub(
|
|||||||
// __call_stub_fp_xxxx:
|
// __call_stub_fp_xxxx:
|
||||||
//
|
//
|
||||||
std::string x = "__call_stub_fp_" + std::string(Symbol);
|
std::string x = "__call_stub_fp_" + std::string(Symbol);
|
||||||
MCSymbol *Stub = OutContext.getOrCreateSymbol(StringRef(x));
|
MCSymbolELF *Stub =
|
||||||
|
cast<MCSymbolELF>(OutContext.getOrCreateSymbol(StringRef(x)));
|
||||||
TS.emitDirectiveEnt(*Stub);
|
TS.emitDirectiveEnt(*Stub);
|
||||||
MCSymbol *MType =
|
MCSymbol *MType =
|
||||||
OutContext.getOrCreateSymbol("__call_stub_fp_" + Twine(Symbol));
|
OutContext.getOrCreateSymbol("__call_stub_fp_" + Twine(Symbol));
|
||||||
@ -1031,7 +1032,7 @@ void MipsAsmPrinter::EmitFPCallStub(
|
|||||||
const MCSymbolRefExpr *E = MCSymbolRefExpr::create(Stub, OutContext);
|
const MCSymbolRefExpr *E = MCSymbolRefExpr::create(Stub, OutContext);
|
||||||
const MCSymbolRefExpr *T = MCSymbolRefExpr::create(Tmp, OutContext);
|
const MCSymbolRefExpr *T = MCSymbolRefExpr::create(Tmp, OutContext);
|
||||||
const MCExpr *T_min_E = MCBinaryExpr::createSub(T, E, OutContext);
|
const MCExpr *T_min_E = MCBinaryExpr::createSub(T, E, OutContext);
|
||||||
OutStreamer->EmitELFSize(Stub, T_min_E);
|
OutStreamer->emitELFSize(Stub, T_min_E);
|
||||||
TS.emitDirectiveEnd(x);
|
TS.emitDirectiveEnd(x);
|
||||||
OutStreamer->PopSection();
|
OutStreamer->PopSection();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbolELF.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -157,7 +157,8 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
unsigned Size = TD->getTypeAllocSize(C->getType());
|
unsigned Size = TD->getTypeAllocSize(C->getType());
|
||||||
if (MAI->hasDotTypeDotSizeDirective()) {
|
if (MAI->hasDotTypeDotSizeDirective()) {
|
||||||
OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);
|
OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);
|
||||||
OutStreamer->EmitELFSize(GVSym, MCConstantExpr::create(Size, OutContext));
|
OutStreamer->emitELFSize(cast<MCSymbolELF>(GVSym),
|
||||||
|
MCConstantExpr::create(Size, OutContext));
|
||||||
}
|
}
|
||||||
OutStreamer->EmitLabel(GVSym);
|
OutStreamer->EmitLabel(GVSym);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user