aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-10 20:58:29 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-10 20:58:29 +0000
commit46836a783ab29f9cb49655d8b9cb8f5538a626fe (patch)
treec7c88f0bf9b27fff7c734fa98f5d315dfc6dfd08 /lib/MC/MCMachOStreamer.cpp
parentd80066eea98a3d5540d895bb77bc1ad50037f9e9 (diff)
downloadexternal_llvm-46836a783ab29f9cb49655d8b9cb8f5538a626fe.zip
external_llvm-46836a783ab29f9cb49655d8b9cb8f5538a626fe.tar.gz
external_llvm-46836a783ab29f9cb49655d8b9cb8f5538a626fe.tar.bz2
MC: Move the backend section and symbol data maps to MCAssembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98186 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCMachOStreamer.cpp')
-rw-r--r--lib/MC/MCMachOStreamer.cpp41
1 files changed, 11 insertions, 30 deletions
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index 9f62efee..a35aae2 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -47,8 +47,6 @@ private:
MCAssembler Assembler;
MCCodeEmitter *Emitter;
MCSectionData *CurSectionData;
- DenseMap<const MCSection*, MCSectionData*> SectionMap;
- DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
private:
MCFragment *getCurrentFragment() const {
@@ -60,24 +58,6 @@ private:
return 0;
}
- MCSectionData &getSectionData(const MCSection &Section) {
- MCSectionData *&Entry = SectionMap[&Section];
-
- if (!Entry)
- Entry = new MCSectionData(Section, &Assembler);
-
- return *Entry;
- }
-
- MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
- MCSymbolData *&Entry = SymbolMap[&Symbol];
-
- if (!Entry)
- Entry = new MCSymbolData(Symbol, 0, 0, &Assembler);
-
- return *Entry;
- }
-
public:
MCMachOStreamer(MCContext &Context, raw_ostream &_OS, MCCodeEmitter *_Emitter)
: MCStreamer(Context), Assembler(Context, _OS), Emitter(_Emitter),
@@ -98,7 +78,8 @@ public:
}
case MCExpr::SymbolRef:
- getSymbolData(cast<MCSymbolRefExpr>(Value)->getSymbol());
+ Assembler.getOrCreateSymbolData(
+ cast<MCSymbolRefExpr>(Value)->getSymbol());
break;
case MCExpr::Unary:
@@ -163,7 +144,7 @@ void MCMachOStreamer::SwitchSection(const MCSection *Section) {
if (Section == CurSection) return;
CurSection = Section;
- CurSectionData = &getSectionData(*Section);
+ CurSectionData = &Assembler.getOrCreateSectionData(*Section);
}
void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
@@ -174,7 +155,7 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
if (!F)
F = new MCDataFragment(CurSectionData);
- MCSymbolData &SD = getSymbolData(*Symbol);
+ MCSymbolData &SD = Assembler.getOrCreateSymbolData(*Symbol);
assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
SD.setFragment(F);
SD.setOffset(F->getContents().size());
@@ -220,9 +201,9 @@ void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
}
// Adding a symbol attribute always introduces the symbol, note that an
- // important side effect of calling getSymbolData here is to register the
- // symbol with the assembler.
- MCSymbolData &SD = getSymbolData(*Symbol);
+ // important side effect of calling getOrCreateSymbolData here is to register
+ // the symbol with the assembler.
+ MCSymbolData &SD = Assembler.getOrCreateSymbolData(*Symbol);
// The implementation of symbol attributes is designed to match 'as', but it
// leaves much to desired. It doesn't really make sense to arbitrarily add and
@@ -288,7 +269,7 @@ void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
// Encode the 'desc' value into the lowest implementation defined bits.
assert(DescValue == (DescValue & SF_DescFlagsMask) &&
"Invalid .desc value!");
- getSymbolData(*Symbol).setFlags(DescValue & SF_DescFlagsMask);
+ Assembler.getOrCreateSymbolData(*Symbol).setFlags(DescValue&SF_DescFlagsMask);
}
void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
@@ -296,14 +277,14 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
// FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
- MCSymbolData &SD = getSymbolData(*Symbol);
+ MCSymbolData &SD = Assembler.getOrCreateSymbolData(*Symbol);
SD.setExternal(true);
SD.setCommon(Size, ByteAlignment);
}
void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
unsigned Size, unsigned ByteAlignment) {
- MCSectionData &SectData = getSectionData(*Section);
+ MCSectionData &SectData = Assembler.getOrCreateSectionData(*Section);
// The symbol may not be present, which only creates the section.
if (!Symbol)
@@ -313,7 +294,7 @@ void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
- MCSymbolData &SD = getSymbolData(*Symbol);
+ MCSymbolData &SD = Assembler.getOrCreateSymbolData(*Symbol);
MCFragment *F = new MCZeroFillFragment(Size, ByteAlignment, &SectData);
SD.setFragment(F);