mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
[ms-inline asm] Remove brackets from around a symbol reference in the target
specific logic. This makes the code much less fragile. Test case coming on the clang side in a moment. rdar://13634327 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179323 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -4196,12 +4196,8 @@ AsmParser::parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
|
|||||||
|
|
||||||
// Emit everything up to the immediate/expression.
|
// Emit everything up to the immediate/expression.
|
||||||
unsigned Len = Loc - AsmStart;
|
unsigned Len = Loc - AsmStart;
|
||||||
if (Len) {
|
if (Len)
|
||||||
// For Input/Output operands we need to remove the brackets, if present.
|
|
||||||
if ((Kind == AOK_Input || Kind == AOK_Output) && Loc[-1] == '[')
|
|
||||||
--Len;
|
|
||||||
OS << StringRef(AsmStart, Len);
|
OS << StringRef(AsmStart, Len);
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the original expression.
|
// Skip the original expression.
|
||||||
if (Kind == AOK_Skip) {
|
if (Kind == AOK_Skip) {
|
||||||
@@ -4255,11 +4251,6 @@ AsmParser::parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
|
|||||||
|
|
||||||
// Skip the original expression.
|
// Skip the original expression.
|
||||||
AsmStart = Loc + (*I).Len + AdditionalSkip;
|
AsmStart = Loc + (*I).Len + AdditionalSkip;
|
||||||
|
|
||||||
// For Input/Output operands we need to remove the brackets, if present.
|
|
||||||
if ((Kind == AOK_Input || Kind == AOK_Output) && AsmStart != AsmEnd &&
|
|
||||||
*AsmStart == ']')
|
|
||||||
++AsmStart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the remainder of the asm string.
|
// Emit the remainder of the asm string.
|
||||||
|
@@ -1140,6 +1140,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
|||||||
if (getLexer().isNot(AsmToken::RBrac))
|
if (getLexer().isNot(AsmToken::RBrac))
|
||||||
return ErrorOperand(Tok.getLoc(), "Expected ']' token!");
|
return ErrorOperand(Tok.getLoc(), "Expected ']' token!");
|
||||||
|
|
||||||
|
if (isParsingInlineAsm()) {
|
||||||
|
// Remove the '[' and ']' from the IR string.
|
||||||
|
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1));
|
||||||
|
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Tok.getLoc(), 1));
|
||||||
|
}
|
||||||
unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
|
unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
|
||||||
StringRef SymName(IdentStart.getPointer(), Len);
|
StringRef SymName(IdentStart.getPointer(), Len);
|
||||||
Parser.Lex(); // Eat ']'
|
Parser.Lex(); // Eat ']'
|
||||||
@@ -1211,6 +1216,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
|
|||||||
Parser.Lex(); // Consume the token.
|
Parser.Lex(); // Consume the token.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isParsingInlineAsm() && Disp && isa<MCSymbolRefExpr>(Disp)) {
|
||||||
|
// Remove the '[' and ']' from the IR string.
|
||||||
|
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1));
|
||||||
|
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, End, 1));
|
||||||
|
}
|
||||||
|
|
||||||
if (!Disp)
|
if (!Disp)
|
||||||
Disp = MCConstantExpr::Create(SM.getDisp(), getContext());
|
Disp = MCConstantExpr::Create(SM.getDisp(), getContext());
|
||||||
|
Reference in New Issue
Block a user