diff options
author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2013-06-20 16:24:17 +0000 |
---|---|---|
committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2013-06-20 16:24:17 +0000 |
commit | 151ad37fed2685f020bbed5b342ad7c0c35616bd (patch) | |
tree | 60b1a168d8491148277818368ac08233e4bd142d /lib | |
parent | 027e94479c9e69eb3c3c5536fa9990d0b96e9510 (diff) | |
download | llvm-151ad37fed2685f020bbed5b342ad7c0c35616bd.tar.gz llvm-151ad37fed2685f020bbed5b342ad7c0c35616bd.tar.bz2 llvm-151ad37fed2685f020bbed5b342ad7c0c35616bd.tar.xz |
[MC] Support @ variants with directional labels
The assembler parser common code supports recognizing symbol variants
using the @ modifer. On PowerPC, it should also be possible to use
(some of) those modifiers with directional labels, like "1f@l".
This patch adds support for accepting symbol variants on directional
labels as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 270579717a..167e64174f 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -805,11 +805,21 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { // Look for 'b' or 'f' following an Integer as a directional label if (Lexer.getKind() == AsmToken::Identifier) { StringRef IDVal = getTok().getString(); + // Lookup the symbol variant if used. + std::pair<StringRef, StringRef> Split = IDVal.split('@'); + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + if (Split.first.size() != IDVal.size()) { + Variant = MCSymbolRefExpr::getVariantKindForName(Split.second); + if (Variant == MCSymbolRefExpr::VK_Invalid) { + Variant = MCSymbolRefExpr::VK_None; + return TokError("invalid variant '" + Split.second + "'"); + } + IDVal = Split.first; + } if (IDVal == "f" || IDVal == "b"){ MCSymbol *Sym = Ctx.GetDirectionalLocalSymbol(IntVal, IDVal == "f" ? 1 : 0); - Res = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, - getContext()); + Res = MCSymbolRefExpr::Create(Sym, Variant, getContext()); if (IDVal == "b" && Sym->isUndefined()) return Error(Loc, "invalid reference to undefined symbol"); EndLoc = Lexer.getTok().getEndLoc(); |