mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 02:24:29 +00:00
MS asm: Properly handle quoted symbol names
We would get confused by '@' characters in symbol names, we would mistake the text following them for the variant kind. When an identifier a string, the variant kind will never show up inside of it. Instead, check to see if there is a variant following the string. This fixes PR19965. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -812,7 +812,19 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
// Parse symbol variant
|
// Parse symbol variant
|
||||||
std::pair<StringRef, StringRef> Split;
|
std::pair<StringRef, StringRef> Split;
|
||||||
if (!MAI.useParensForSymbolVariant()) {
|
if (!MAI.useParensForSymbolVariant()) {
|
||||||
|
if (FirstTokenKind == AsmToken::String) {
|
||||||
|
if (Lexer.is(AsmToken::At)) {
|
||||||
|
Lexer.Lex(); // eat @
|
||||||
|
SMLoc AtLoc = getLexer().getLoc();
|
||||||
|
StringRef VName;
|
||||||
|
if (parseIdentifier(VName))
|
||||||
|
return Error(AtLoc, "expected symbol variant after '@'");
|
||||||
|
|
||||||
|
Split = std::make_pair(Identifier, VName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Split = Identifier.split('@');
|
Split = Identifier.split('@');
|
||||||
|
}
|
||||||
} else if (Lexer.is(AsmToken::LParen)) {
|
} else if (Lexer.is(AsmToken::LParen)) {
|
||||||
Lexer.Lex(); // eat (
|
Lexer.Lex(); // eat (
|
||||||
StringRef VName;
|
StringRef VName;
|
||||||
|
@ -1061,7 +1061,8 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
|
|||||||
if (SM.getStopOnLBrac() && getLexer().getKind() == AsmToken::LBrac)
|
if (SM.getStopOnLBrac() && getLexer().getKind() == AsmToken::LBrac)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (getLexer().getKind()) {
|
AsmToken::TokenKind TK = getLexer().getKind();
|
||||||
|
switch (TK) {
|
||||||
default: {
|
default: {
|
||||||
if (SM.isValidEndState()) {
|
if (SM.isValidEndState()) {
|
||||||
Done = true;
|
Done = true;
|
||||||
@ -1073,13 +1074,14 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
|
|||||||
Done = true;
|
Done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AsmToken::String:
|
||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
// This could be a register or a symbolic displacement.
|
// This could be a register or a symbolic displacement.
|
||||||
unsigned TmpReg;
|
unsigned TmpReg;
|
||||||
const MCExpr *Val;
|
const MCExpr *Val;
|
||||||
SMLoc IdentLoc = Tok.getLoc();
|
SMLoc IdentLoc = Tok.getLoc();
|
||||||
StringRef Identifier = Tok.getString();
|
StringRef Identifier = Tok.getString();
|
||||||
if(!ParseRegister(TmpReg, IdentLoc, End)) {
|
if (TK != AsmToken::String && !ParseRegister(TmpReg, IdentLoc, End)) {
|
||||||
SM.onRegister(TmpReg);
|
SM.onRegister(TmpReg);
|
||||||
UpdateLocLex = false;
|
UpdateLocLex = false;
|
||||||
break;
|
break;
|
||||||
|
@ -599,3 +599,11 @@ fxrstor64 opaque ptr [rax]
|
|||||||
// CHECK: movq _g0+8, %rcx
|
// CHECK: movq _g0+8, %rcx
|
||||||
mov rbx, qword ptr [_g0]
|
mov rbx, qword ptr [_g0]
|
||||||
mov rcx, qword ptr [_g0 + 8]
|
mov rcx, qword ptr [_g0 + 8]
|
||||||
|
|
||||||
|
"?half@?0??bar@@YAXXZ@4NA":
|
||||||
|
.quad 4602678819172646912
|
||||||
|
|
||||||
|
fadd "?half@?0??bar@@YAXXZ@4NA"
|
||||||
|
fadd "?half@?0??bar@@YAXXZ@4NA"@IMGREL
|
||||||
|
// CHECK: fadds "?half@?0??bar@@YAXXZ@4NA"
|
||||||
|
// CHECK: fadds "?half@?0??bar@@YAXXZ@4NA"@IMGREL32
|
||||||
|
Reference in New Issue
Block a user