[llvm] r179323 - [ms-inline asm] Remove brackets from around a symbol reference in the target
Chad Rosier
mcrosier at apple.com
Thu Apr 11 14:49:30 PDT 2013
Author: mcrosier
Date: Thu Apr 11 16:49:30 2013
New Revision: 179323
URL: http://llvm.org/viewvc/llvm-project?rev=179323&view=rev
Log:
[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
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=179323&r1=179322&r2=179323&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Apr 11 16:49:30 2013
@@ -4196,12 +4196,8 @@ AsmParser::parseMSInlineAsm(void *AsmLoc
// Emit everything up to the immediate/expression.
unsigned Len = Loc - AsmStart;
- if (Len) {
- // For Input/Output operands we need to remove the brackets, if present.
- if ((Kind == AOK_Input || Kind == AOK_Output) && Loc[-1] == '[')
- --Len;
+ if (Len)
OS << StringRef(AsmStart, Len);
- }
// Skip the original expression.
if (Kind == AOK_Skip) {
@@ -4255,11 +4251,6 @@ AsmParser::parseMSInlineAsm(void *AsmLoc
// Skip the original expression.
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.
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=179323&r1=179322&r2=179323&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Apr 11 16:49:30 2013
@@ -1140,6 +1140,11 @@ X86Operand *X86AsmParser::ParseIntelBrac
if (getLexer().isNot(AsmToken::RBrac))
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();
StringRef SymName(IdentStart.getPointer(), Len);
Parser.Lex(); // Eat ']'
@@ -1211,6 +1216,11 @@ X86Operand *X86AsmParser::ParseIntelBrac
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)
Disp = MCConstantExpr::Create(SM.getDisp(), getContext());
More information about the llvm-commits
mailing list