aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-24 17:00:42 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-24 17:00:42 +0000
commit71d259bc4be4f5c7a8a30c6be8da105074ff805a (patch)
treeb0ae8bb92b558364d2f86fe249cf3b12dfc19ada /lib/MC
parentd814b2150950114a44b607c90ea7a0725c40a8e6 (diff)
downloadexternal_llvm-71d259bc4be4f5c7a8a30c6be8da105074ff805a.zip
external_llvm-71d259bc4be4f5c7a8a30c6be8da105074ff805a.tar.gz
external_llvm-71d259bc4be4f5c7a8a30c6be8da105074ff805a.tar.bz2
We decided to not worry about Atoms for now, it should be straightforward to
reintroduce them later. Also, don't require MCSection* when creating a symbol. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAsmStreamer.cpp21
-rw-r--r--lib/MC/MCContext.cpp23
2 files changed, 20 insertions, 24 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 33d72e2..73d6f04 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -9,7 +9,6 @@
#include "llvm/MC/MCStreamer.h"
-#include "llvm/MC/MCAtom.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
@@ -82,20 +81,26 @@ void MCAsmStreamer::SwitchSection(MCSection *Section) {
}
void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
- // FIXME: We need to enforce that we aren't printing atoms which are more
- // complicated than the assembler understands.
- //assert(Symbol->getAtom()->getSection() == CurSection &&
- // "The label for a symbol must match its section!");
+ assert(Symbol->getSection() == 0 && "Cannot emit a symbol twice!");
+ assert(CurSection && "Cannot emit before setting section!");
+ assert(!getContext().GetSymbolValue(Symbol) &&
+ "Cannot emit symbol which was directly assigned to!");
+
OS << Symbol->getName() << ":\n";
+ Symbol->setSection(CurSection);
}
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
bool MakeAbsolute) {
+ assert(!Symbol->getSection() && "Cannot assign to a label!");
+
if (MakeAbsolute) {
OS << ".set " << Symbol->getName() << ", " << Value << '\n';
} else {
OS << Symbol->getName() << " = " << Value << '\n';
}
+
+ getContext().SetSymbolValue(Symbol, Value);
}
void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
@@ -119,12 +124,13 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
}
void MCAsmStreamer::EmitBytes(const char *Data, unsigned Length) {
- for (unsigned i = 0; i != Length; ++i) {
+ assert(CurSection && "Cannot emit contents before setting section!");
+ for (unsigned i = 0; i != Length; ++i)
OS << ".byte " << (unsigned) Data[i] << '\n';
- }
}
void MCAsmStreamer::EmitValue(const MCValue &Value, unsigned Size) {
+ assert(CurSection && "Cannot emit contents before setting section!");
// Need target hooks to know how to print this.
switch (Size) {
default:
@@ -139,6 +145,7 @@ void MCAsmStreamer::EmitValue(const MCValue &Value, unsigned Size) {
}
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
+ assert(CurSection && "Cannot emit contents before setting section!");
// FIXME: Implement.
OS << "# FIXME: Implement instruction printing!\n";
}
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index f7793b9..6c6019c 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -9,7 +9,6 @@
#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCAtom.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
@@ -30,43 +29,33 @@ MCSection *MCContext::GetSection(const char *Name) {
return Entry;
}
-
-MCAtom *MCContext::CreateAtom(MCSection *Section) {
- return new (*this) MCAtom(Section);
-}
-MCSymbol *MCContext::CreateSymbol(MCAtom *Atom, const char *Name) {
+MCSymbol *MCContext::CreateSymbol(const char *Name) {
assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
// Create and bind the symbol, and ensure that names are unique.
MCSymbol *&Entry = Symbols[Name];
assert(!Entry && "Duplicate symbol definition!");
- return Entry = new (*this) MCSymbol(Atom, Name, false);
+ return Entry = new (*this) MCSymbol(Name, false);
}
-/// GetOrCreateSymbol - Lookup the symbol inside with the specified
-/// @param Name. If it exists, return it. If not, create a forward
-/// reference and return it.
-///
-/// @param Name - The symbol name, which must be unique across all symbols.
MCSymbol *MCContext::GetOrCreateSymbol(const char *Name) {
MCSymbol *&Entry = Symbols[Name];
if (Entry) return Entry;
- // FIXME: is a null atom the right way to make a forward ref?
- return Entry = new (*this) MCSymbol(0, Name, false);
+ return Entry = new (*this) MCSymbol(Name, false);
}
-MCSymbol *MCContext::CreateTemporarySymbol(MCAtom *Atom, const char *Name) {
+MCSymbol *MCContext::CreateTemporarySymbol(const char *Name) {
// If unnamed, just create a symbol.
if (Name[0] == '\0')
- new (*this) MCSymbol(Atom, "", true);
+ new (*this) MCSymbol("", true);
// Otherwise create as usual.
MCSymbol *&Entry = Symbols[Name];
assert(!Entry && "Duplicate symbol definition!");
- return Entry = new (*this) MCSymbol(Atom, Name, true);
+ return Entry = new (*this) MCSymbol(Name, true);
}
MCSymbol *MCContext::LookupSymbol(const char *Name) const {