aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCParser
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-15 23:51:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-15 23:51:06 +0000
commit4e815f8a8cae6c846cdca52420046cab902865de (patch)
treeed69728cefdd2dedaf79a60c4e7ceed59ced9e74 /lib/MC/MCParser
parent1bbf72b069d8f01779e99c8de2de8501dd3df20c (diff)
downloadexternal_llvm-4e815f8a8cae6c846cdca52420046cab902865de.zip
external_llvm-4e815f8a8cae6c846cdca52420046cab902865de.tar.gz
external_llvm-4e815f8a8cae6c846cdca52420046cab902865de.tar.bz2
MC: Allow modifiers in MCSymbolRefExpr, and eliminate X86MCTargetExpr.
- Although it would be nice to allow this decoupling, the assembler needs to be able to reason about MCSymbolRefExprs in too many places to make this viable. We can use a target specific encoding of the variant if this becomes an issue. - This patch also extends llvm-mc to support parsing of the modifiers, as opposed to lumping them in with the symbol. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index a241106..4ec5247 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -262,19 +262,29 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
case AsmToken::String:
case AsmToken::Identifier: {
// This is a symbol reference.
- MCSymbol *Sym = CreateSymbol(getTok().getIdentifier());
+ std::pair<StringRef, StringRef> Split = getTok().getIdentifier().split('@');
+ MCSymbol *Sym = CreateSymbol(Split.first);
+
+ // Lookup the symbol variant if used.
+ MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
+ if (Split.first.size() != getTok().getIdentifier().size())
+ Variant = MCSymbolRefExpr::getVariantKindForName(Split.second);
+
EndLoc = Lexer.getLoc();
Lex(); // Eat identifier.
// If this is an absolute variable reference, substitute it now to preserve
// semantics in the face of reassignment.
if (Sym->getValue() && isa<MCConstantExpr>(Sym->getValue())) {
+ if (Variant)
+ return Error(EndLoc, "unexpected modified on variable reference");
+
Res = Sym->getValue();
return false;
}
// Otherwise create a symbol ref.
- Res = MCSymbolRefExpr::Create(Sym, getContext());
+ Res = MCSymbolRefExpr::Create(Sym, Variant, getContext());
return false;
}
case AsmToken::Integer: