mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 18:20:39 +00:00
sink uniquing of sections out of MCContext into the ELF and PECOFF TLOF implementations.
MCContext no longer maintains a string -> section map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78874 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -47,16 +47,6 @@ namespace llvm {
|
|||||||
MCContext();
|
MCContext();
|
||||||
~MCContext();
|
~MCContext();
|
||||||
|
|
||||||
/// GetSection - Look up a section with the given @param Name, returning
|
|
||||||
/// null if it doesn't exist.
|
|
||||||
MCSection *GetSection(const StringRef &Name) const;
|
|
||||||
|
|
||||||
void SetSection(const StringRef &Name, MCSection *S) {
|
|
||||||
MCSection *&Entry = Sections[Name];
|
|
||||||
assert(Entry == 0 && "Multiple sections with the same name created");
|
|
||||||
Entry = S;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// CreateSymbol - Create a new symbol with the specified @param Name.
|
/// CreateSymbol - Create a new symbol with the specified @param Name.
|
||||||
///
|
///
|
||||||
/// @param Name - The symbol name, which must be unique across all symbols.
|
/// @param Name - The symbol name, which must be unique across all symbols.
|
||||||
|
|||||||
@@ -52,8 +52,9 @@ namespace llvm {
|
|||||||
/// of a syntactic one.
|
/// of a syntactic one.
|
||||||
bool IsDirective;
|
bool IsDirective;
|
||||||
|
|
||||||
MCSectionELF(const StringRef &Name, bool IsDirective, SectionKind K,
|
MCSectionELF(const StringRef &name, bool isDirective, SectionKind K)
|
||||||
MCContext &Ctx);
|
: MCSection(K), Name(name), IsDirective(isDirective) {
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static MCSectionELF *Create(const StringRef &Name, bool IsDirective,
|
static MCSectionELF *Create(const StringRef &Name, bool IsDirective,
|
||||||
@@ -77,8 +78,9 @@ namespace llvm {
|
|||||||
/// of a syntactic one.
|
/// of a syntactic one.
|
||||||
bool IsDirective;
|
bool IsDirective;
|
||||||
|
|
||||||
MCSectionCOFF(const StringRef &Name, bool IsDirective, SectionKind K,
|
MCSectionCOFF(const StringRef &name, bool isDirective, SectionKind K)
|
||||||
MCContext &Ctx);
|
: MCSection(K), Name(name), IsDirective(isDirective) {
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective,
|
static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective,
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ protected:
|
|||||||
|
|
||||||
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
||||||
bool HasCrazyBSS;
|
bool HasCrazyBSS;
|
||||||
|
mutable void *UniquingMap;
|
||||||
protected:
|
protected:
|
||||||
/// TLSDataSection - Section directive for Thread Local data.
|
/// TLSDataSection - Section directive for Thread Local data.
|
||||||
///
|
///
|
||||||
@@ -208,7 +209,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
TargetLoweringObjectFileELF(// FIXME: REMOVE AFTER UNIQUING IS FIXED.
|
TargetLoweringObjectFileELF(// FIXME: REMOVE AFTER UNIQUING IS FIXED.
|
||||||
bool hasCrazyBSS = false)
|
bool hasCrazyBSS = false)
|
||||||
: HasCrazyBSS(hasCrazyBSS) {}
|
: HasCrazyBSS(hasCrazyBSS), UniquingMap(0) {}
|
||||||
|
|
||||||
|
~TargetLoweringObjectFileELF();
|
||||||
|
|
||||||
|
|
||||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
@@ -302,7 +306,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
||||||
|
mutable void *UniquingMap;
|
||||||
public:
|
public:
|
||||||
|
TargetLoweringObjectFileCOFF() : UniquingMap(0) {}
|
||||||
|
~TargetLoweringObjectFileCOFF();
|
||||||
|
|
||||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual const MCSection *
|
virtual const MCSection *
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ MCContext::~MCContext() {
|
|||||||
// we don't need to free them here.
|
// we don't need to free them here.
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *MCContext::GetSection(const StringRef &Name) const {
|
|
||||||
StringMap<MCSection*>::const_iterator I = Sections.find(Name);
|
|
||||||
return I != Sections.end() ? I->second : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
|
MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
|
||||||
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
|
||||||
|
|
||||||
|
|||||||
@@ -27,16 +27,9 @@ MCSection::~MCSection() {
|
|||||||
|
|
||||||
MCSectionELF *MCSectionELF::
|
MCSectionELF *MCSectionELF::
|
||||||
Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
||||||
return new (Ctx) MCSectionELF(Name, IsDirective, K, Ctx);
|
return new (Ctx) MCSectionELF(Name, IsDirective, K);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSectionELF::MCSectionELF(const StringRef &name, bool isDirective,
|
|
||||||
SectionKind K, MCContext &Ctx)
|
|
||||||
: MCSection(K), Name(name), IsDirective(isDirective) {
|
|
||||||
Ctx.SetSection(Name, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
|
void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
|
||||||
raw_ostream &OS) const {
|
raw_ostream &OS) const {
|
||||||
if (isDirective()) {
|
if (isDirective()) {
|
||||||
@@ -118,16 +111,9 @@ void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
|
|||||||
|
|
||||||
MCSectionCOFF *MCSectionCOFF::
|
MCSectionCOFF *MCSectionCOFF::
|
||||||
Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
||||||
return new (Ctx) MCSectionCOFF(Name, IsDirective, K, Ctx);
|
return new (Ctx) MCSectionCOFF(Name, IsDirective, K);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSectionCOFF::MCSectionCOFF(const StringRef &name, bool isDirective,
|
|
||||||
SectionKind K, MCContext &Ctx)
|
|
||||||
: MCSection(K), Name(name), IsDirective(isDirective) {
|
|
||||||
Ctx.SetSection(Name, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MCSectionCOFF::PrintSwitchToSection(const TargetAsmInfo &TAI,
|
void MCSectionCOFF::PrintSwitchToSection(const TargetAsmInfo &TAI,
|
||||||
raw_ostream &OS) const {
|
raw_ostream &OS) const {
|
||||||
|
|
||||||
|
|||||||
@@ -280,12 +280,25 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ELF
|
// ELF
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
typedef StringMap<const MCSectionELF*> ELFUniqueMapTy;
|
||||||
|
|
||||||
|
TargetLoweringObjectFileELF::~TargetLoweringObjectFileELF() {
|
||||||
|
// If we have the section uniquing map, free it.
|
||||||
|
delete (ELFUniqueMapTy*)UniquingMap;
|
||||||
|
}
|
||||||
|
|
||||||
const MCSection *TargetLoweringObjectFileELF::
|
const MCSection *TargetLoweringObjectFileELF::
|
||||||
getELFSection(const char *Name, bool isDirective, SectionKind Kind) const {
|
getELFSection(const char *Name, bool isDirective, SectionKind Kind) const {
|
||||||
if (MCSection *S = getContext().GetSection(Name))
|
// Create the map if it doesn't already exist.
|
||||||
return S;
|
if (UniquingMap == 0)
|
||||||
return MCSectionELF::Create(Name, isDirective, Kind, getContext());
|
UniquingMap = new ELFUniqueMapTy();
|
||||||
|
ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)UniquingMap;
|
||||||
|
|
||||||
|
// Do the lookup, if we have a hit, return it.
|
||||||
|
const MCSectionELF *&Entry = Map[Name];
|
||||||
|
if (Entry) return Entry;
|
||||||
|
|
||||||
|
return Entry = MCSectionELF::Create(Name, isDirective, Kind, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
|
void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
|
||||||
@@ -805,12 +818,25 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
|
|||||||
// COFF
|
// COFF
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
|
||||||
|
|
||||||
|
TargetLoweringObjectFileCOFF::~TargetLoweringObjectFileCOFF() {
|
||||||
|
delete (COFFUniqueMapTy*)UniquingMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const MCSection *TargetLoweringObjectFileCOFF::
|
const MCSection *TargetLoweringObjectFileCOFF::
|
||||||
getCOFFSection(const char *Name, bool isDirective, SectionKind Kind) const {
|
getCOFFSection(const char *Name, bool isDirective, SectionKind Kind) const {
|
||||||
if (MCSection *S = getContext().GetSection(Name))
|
// Create the map if it doesn't already exist.
|
||||||
return S;
|
if (UniquingMap == 0)
|
||||||
return MCSectionCOFF::Create(Name, isDirective, Kind, getContext());
|
UniquingMap = new MachOUniqueMapTy();
|
||||||
|
COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)UniquingMap;
|
||||||
|
|
||||||
|
// Do the lookup, if we have a hit, return it.
|
||||||
|
const MCSectionCOFF *&Entry = Map[Name];
|
||||||
|
if (Entry) return Entry;
|
||||||
|
|
||||||
|
return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user