mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184437 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
027e94479c
commit
151ad37fed
@ -805,11 +805,21 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
// Look for 'b' or 'f' following an Integer as a directional label
|
// Look for 'b' or 'f' following an Integer as a directional label
|
||||||
if (Lexer.getKind() == AsmToken::Identifier) {
|
if (Lexer.getKind() == AsmToken::Identifier) {
|
||||||
StringRef IDVal = getTok().getString();
|
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"){
|
if (IDVal == "f" || IDVal == "b"){
|
||||||
MCSymbol *Sym = Ctx.GetDirectionalLocalSymbol(IntVal,
|
MCSymbol *Sym = Ctx.GetDirectionalLocalSymbol(IntVal,
|
||||||
IDVal == "f" ? 1 : 0);
|
IDVal == "f" ? 1 : 0);
|
||||||
Res = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None,
|
Res = MCSymbolRefExpr::Create(Sym, Variant, getContext());
|
||||||
getContext());
|
|
||||||
if (IDVal == "b" && Sym->isUndefined())
|
if (IDVal == "b" && Sym->isUndefined())
|
||||||
return Error(Loc, "invalid reference to undefined symbol");
|
return Error(Loc, "invalid reference to undefined symbol");
|
||||||
EndLoc = Lexer.getTok().getEndLoc();
|
EndLoc = Lexer.getTok().getEndLoc();
|
||||||
|
@ -28,6 +28,11 @@ addis 1, 1, target5+0x8000@ha
|
|||||||
|
|
||||||
.set target5, 0x10000001
|
.set target5, 0x10000001
|
||||||
|
|
||||||
|
1:
|
||||||
|
addi 1, 1, 2f-1b@l
|
||||||
|
addis 1, 1, 1b-2f@ha
|
||||||
|
2:
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
.quad v1
|
.quad v1
|
||||||
@ -49,7 +54,7 @@ addis 1, 1, target5+0x8000@ha
|
|||||||
# CHECK-NEXT: ]
|
# CHECK-NEXT: ]
|
||||||
# CHECK-NEXT: Address: 0x0
|
# CHECK-NEXT: Address: 0x0
|
||||||
# CHECK-NEXT: Offset:
|
# CHECK-NEXT: Offset:
|
||||||
# CHECK-NEXT: Size: 32
|
# CHECK-NEXT: Size: 40
|
||||||
# CHECK-NEXT: Link: 0
|
# CHECK-NEXT: Link: 0
|
||||||
# CHECK-NEXT: Info: 0
|
# CHECK-NEXT: Info: 0
|
||||||
# CHECK-NEXT: AddressAlignment: 4
|
# CHECK-NEXT: AddressAlignment: 4
|
||||||
@ -57,6 +62,7 @@ addis 1, 1, target5+0x8000@ha
|
|||||||
# CHECK-NEXT: SectionData (
|
# CHECK-NEXT: SectionData (
|
||||||
# CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
|
# CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
|
||||||
# CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
|
# CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
|
||||||
|
# CHECK-NEXT: 0020: 38210008 3C210000
|
||||||
# CHECK-NEXT: )
|
# CHECK-NEXT: )
|
||||||
# CHECK-NEXT: }
|
# CHECK-NEXT: }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user