aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-24 04:31:49 +0000
committerChris Lattner <sabre@nondot.org>2009-06-24 04:31:49 +0000
commitc69485e34d57e17fe2c3acab64e519d6a6945197 (patch)
tree26910e29853b269ea7cd8ee87dc65b8f3381280d /lib/MC
parent98d5982e0020e0c18d2847798ba2f40c4711af5a (diff)
downloadexternal_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.zip
external_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.tar.gz
external_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.tar.bz2
add trivial support for passing label definitions through the MCStreamer.
This is suboptimal in several aspects, see the commented out assertion. I need to talk to Daniel about this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAsmStreamer.cpp4
-rw-r--r--lib/MC/MCContext.cpp14
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 1956c2e..d268fb7 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -84,8 +84,8 @@ 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->getAtom()->getSection() == CurSection &&
+ // "The label for a symbol must match its section!");
OS << Symbol->getName() << ":\n";
}
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index cad0d56..f7793b9 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -44,6 +44,20 @@ MCSymbol *MCContext::CreateSymbol(MCAtom *Atom, const char *Name) {
return Entry = new (*this) MCSymbol(Atom, 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);
+}
+
+
MCSymbol *MCContext::CreateTemporarySymbol(MCAtom *Atom, const char *Name) {
// If unnamed, just create a symbol.
if (Name[0] == '\0')