mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[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. llvm-svn: 184437
This commit is contained in:
parent
99f0423d50
commit
8c70d558d3
@ -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();
|
||||
|
@ -28,6 +28,11 @@ addis 1, 1, target5+0x8000@ha
|
||||
|
||||
.set target5, 0x10000001
|
||||
|
||||
1:
|
||||
addi 1, 1, 2f-1b@l
|
||||
addis 1, 1, 1b-2f@ha
|
||||
2:
|
||||
|
||||
.data
|
||||
|
||||
.quad v1
|
||||
@ -49,7 +54,7 @@ addis 1, 1, target5+0x8000@ha
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset:
|
||||
# CHECK-NEXT: Size: 32
|
||||
# CHECK-NEXT: Size: 40
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
# CHECK-NEXT: AddressAlignment: 4
|
||||
@ -57,6 +62,7 @@ addis 1, 1, target5+0x8000@ha
|
||||
# CHECK-NEXT: SectionData (
|
||||
# CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
|
||||
# CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
|
||||
# CHECK-NEXT: 0020: 38210008 3C210000
|
||||
# CHECK-NEXT: )
|
||||
# CHECK-NEXT: }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user