aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-28 15:54:36 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-28 15:54:36 +0000
commitf90a2de72c25e24f26577b0dd8145ac21fe10f5e (patch)
tree3b13e72595e8cab716f1754fccfdfe3f1b07af4b
parent175ccab75f3a355285cf4533c201cbcecfd5928d (diff)
downloadexternal_llvm-f90a2de72c25e24f26577b0dd8145ac21fe10f5e.zip
external_llvm-f90a2de72c25e24f26577b0dd8145ac21fe10f5e.tar.gz
external_llvm-f90a2de72c25e24f26577b0dd8145ac21fe10f5e.tar.bz2
Factor some duplicated code into MCObjectStreamer::EmitLabel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120245 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCObjectStreamer.h1
-rw-r--r--lib/MC/MCELFStreamer.cpp17
-rw-r--r--lib/MC/MCMachOStreamer.cpp17
-rw-r--r--lib/MC/MCObjectStreamer.cpp20
-rw-r--r--lib/MC/WinCOFFStreamer.cpp23
5 files changed, 24 insertions, 54 deletions
diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h
index 8c21c10..ccfba43 100644
--- a/include/llvm/MC/MCObjectStreamer.h
+++ b/include/llvm/MC/MCObjectStreamer.h
@@ -60,6 +60,7 @@ public:
/// @name MCStreamer Interface
/// @{
+ virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 2e0d85a..0286991 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -189,26 +189,13 @@ void MCELFStreamer::InitSections() {
}
void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
- assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
-
- Symbol->setSection(*CurSection);
-
- MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+ MCObjectStreamer::EmitLabel(Symbol);
const MCSectionELF &Section =
static_cast<const MCSectionELF&>(Symbol->getSection());
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
if (Section.getFlags() & MCSectionELF::SHF_TLS)
SetType(SD, ELF::STT_TLS);
-
- // FIXME: This is wasteful, we don't necessarily need to create a data
- // fragment. Instead, we should mark the symbol as pointing into the data
- // fragment if it exists, otherwise we should just queue the label and set its
- // fragment pointer when we emit the next fragment.
- MCDataFragment *F = getOrCreateDataFragment();
-
- assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
- SD.setFragment(F);
- SD.setOffset(F->getContents().size());
}
void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index 3f93604..02a1f08 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -105,14 +105,6 @@ void MCMachOStreamer::InitSections() {
}
void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
- // TODO: This is almost exactly the same as WinCOFFStreamer. Consider merging
- // into MCObjectStreamer.
- assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
- assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
- assert(CurSection && "Cannot emit before setting section!");
-
- Symbol->setSection(*CurSection);
-
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
// We have to create a new fragment if this is an atom defining symbol,
@@ -120,14 +112,7 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
if (getAssembler().isSymbolLinkerVisible(SD.getSymbol()))
new MCDataFragment(getCurrentSectionData());
- // FIXME: This is wasteful, we don't necessarily need to create a data
- // fragment. Instead, we should mark the symbol as pointing into the data
- // fragment if it exists, otherwise we should just queue the label and set its
- // fragment pointer when we emit the next fragment.
- MCDataFragment *F = getOrCreateDataFragment();
- assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
- SD.setFragment(F);
- SD.setOffset(F->getContents().size());
+ MCObjectStreamer::EmitLabel(Symbol);
// This causes the reference type flag to be cleared. Darwin 'as' was "trying"
// to clear the weak reference and weak definition bits too, but the
diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp
index a40c754..1b5c078 100644
--- a/lib/MC/MCObjectStreamer.cpp
+++ b/lib/MC/MCObjectStreamer.cpp
@@ -14,6 +14,7 @@
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/TargetAsmBackend.h"
using namespace llvm;
@@ -75,6 +76,25 @@ const MCExpr *MCObjectStreamer::AddValueSymbols(const MCExpr *Value) {
return Value;
}
+void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
+ assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+ assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
+ assert(CurSection && "Cannot emit before setting section!");
+
+ Symbol->setSection(*CurSection);
+
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+
+ // FIXME: This is wasteful, we don't necessarily need to create a data
+ // fragment. Instead, we should mark the symbol as pointing into the data
+ // fragment if it exists, otherwise we should just queue the label and set its
+ // fragment pointer when we emit the next fragment.
+ MCDataFragment *F = getOrCreateDataFragment();
+ assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+ SD.setFragment(F);
+ SD.setOffset(F->getContents().size());
+}
+
void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value,
unsigned AddrSpace) {
new MCLEBFragment(*Value, false, getCurrentSectionData());
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp
index cba7188..1754ed3 100644
--- a/lib/MC/WinCOFFStreamer.cpp
+++ b/lib/MC/WinCOFFStreamer.cpp
@@ -49,7 +49,6 @@ public:
// MCStreamer interface
virtual void InitSections();
- virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
virtual void EmitThumbFunc(MCSymbol *Func);
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
@@ -175,28 +174,6 @@ void WinCOFFStreamer::InitSections() {
SetSectionText();
}
-void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
- // TODO: This is copied almost exactly from the MachOStreamer. Consider
- // merging into MCObjectStreamer?
- assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
- assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
- assert(CurSection && "Cannot emit before setting section!");
-
- Symbol->setSection(*CurSection);
-
- MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
-
- // FIXME: This is wasteful, we don't necessarily need to create a data
- // fragment. Instead, we should mark the symbol as pointing into the data
- // fragment if it exists, otherwise we should just queue the label and set its
- // fragment pointer when we emit the next fragment.
- MCDataFragment *DF = getOrCreateDataFragment();
-
- assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
- SD.setFragment(DF);
- SD.setOffset(DF->getContents().size());
-}
-
void WinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
llvm_unreachable("not implemented");
}