summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mc
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
commit6860ac7375966b81791b009a4a60b12fea85c0ce (patch)
tree303c56cf9fc2f25ad601d6748f6e84a520fe9141 /llvm/tools/llvm-mc
parent81c05241022578ed8b0e48f212e16d69b13deba3 (diff)
downloadbcm5719-llvm-6860ac7375966b81791b009a4a60b12fea85c0ce.tar.gz
bcm5719-llvm-6860ac7375966b81791b009a4a60b12fea85c0ce.zip
llvm-mc: Clean up some handling of symbol/section association to be more correct
(external was really undefined and there wasn't an explicit representation for absolute symbols). - This still needs some cleanup to how the absolute "pseudo" section is dealt with, but I haven't figured out the nicest approach yet. llvm-svn: 79733
Diffstat (limited to 'llvm/tools/llvm-mc')
-rw-r--r--llvm/tools/llvm-mc/AsmParser.cpp26
1 files changed, 5 insertions, 21 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp
index 19781212976..d92d514f8a4 100644
--- a/llvm/tools/llvm-mc/AsmParser.cpp
+++ b/llvm/tools/llvm-mc/AsmParser.cpp
@@ -149,10 +149,6 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) {
// This is a label, this should be parsed as part of an expression, to
// handle things like LFOO+4.
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getIdentifier());
-
- // If this is use of an undefined symbol then mark it external.
- if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym))
- Sym->setExternal(true);
Res = new AsmSymbolRefExpr(Sym);
Lexer.Lex(); // Eat identifier.
@@ -376,10 +372,8 @@ bool AsmParser::ParseStatement() {
// FIXME: This doesn't diagnose assignment to a symbol which has been
// implicitly marked as external.
MCSymbol *Sym = Ctx.GetOrCreateSymbol(IDVal);
- if (Sym->getSection())
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
- if (Ctx.GetSymbolValue(Sym))
- return Error(IDLoc, "symbol already used as assembler variable");
// Since we saw a label, create a symbol and emit it.
// FIXME: If the label starts with L it is an assembler temporary label.
@@ -687,15 +681,11 @@ bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
// Diagnose assignment to a label.
//
// FIXME: Diagnostics. Note the location of the definition as a label.
- // FIXME: This doesn't diagnose assignment to a symbol which has been
- // implicitly marked as external.
// FIXME: Handle '.'.
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
- if (Sym->getSection())
- return Error(EqualLoc, "invalid assignment to symbol emitted as a label");
- if (Sym->isExternal())
- return Error(EqualLoc, "invalid assignment to external symbol");
+ if (!Sym->isUndefined() && !Sym->isAbsolute())
+ return Error(EqualLoc, "symbol has already been defined");
// Do the assignment.
Out.EmitAssignment(Sym, Value, IsDotSet);
@@ -1117,10 +1107,6 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
- // If this is use of an undefined symbol then mark it external.
- if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym))
- Sym->setExternal(true);
-
Out.EmitSymbolAttribute(Sym, Attr);
if (Lexer.is(AsmToken::EndOfStatement))
@@ -1213,8 +1199,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
return Error(Pow2AlignmentLoc, "invalid '.comm' or '.lcomm' directive "
"alignment, can't be less than zero");
- // TODO: Symbol must be undefined or it is a error to re-defined the symbol
- if (Sym->getSection() || Ctx.GetSymbolValue(Sym))
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
// Create the Symbol as a common or local common with Size and Pow2Alignment
@@ -1305,8 +1290,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
return Error(Pow2AlignmentLoc, "invalid '.zerofill' directive alignment, "
"can't be less than zero");
- // TODO: Symbol must be undefined or it is a error to re-defined the symbol
- if (Sym->getSection() || Ctx.GetSymbolValue(Sym))
+ if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
// FIXME: Arch specific.
OpenPOWER on IntegriCloud