MS asm: Attempt to parse variables followed by a bracketed displacement

This is required to include MSVC's <atomic> header, which we do now in
LLVM.

Tests forthcoming in Clang, since that's where we test semantic inline
asm changes.

llvm-svn: 202865
This commit is contained in:
Reid Kleckner 2014-03-04 17:57:01 +00:00
parent af71031e3c
commit 4e3bd518f2
1 changed files with 34 additions and 2 deletions

View File

@ -1307,6 +1307,7 @@ X86Operand *X86AsmParser::ParseIntelMemOperand(int64_t ImmDisp, SMLoc Start,
// Parse ImmDisp [ BaseReg + Scale*IndexReg + Disp ].
if (getLexer().is(AsmToken::LBrac))
return ParseIntelBracExpression(/*SegReg=*/0, Start, ImmDisp, Size);
assert(ImmDisp == 0);
const MCExpr *Val;
if (!isParsingInlineAsm()) {
@ -1321,8 +1322,39 @@ X86Operand *X86AsmParser::ParseIntelMemOperand(int64_t ImmDisp, SMLoc Start,
if (ParseIntelIdentifier(Val, Identifier, Info,
/*Unevaluated=*/false, End))
return 0;
return CreateMemForInlineAsm(/*SegReg=*/0, Val, /*BaseReg=*/0, /*IndexReg=*/0,
/*Scale=*/1, Start, End, Size, Identifier, Info);
if (!getLexer().is(AsmToken::LBrac))
return CreateMemForInlineAsm(/*SegReg=*/0, Val, /*BaseReg=*/0, /*IndexReg=*/0,
/*Scale=*/1, Start, End, Size, Identifier, Info);
Parser.Lex(); // Eat '['
// Parse Identifier [ ImmDisp ]
IntelExprStateMachine SM(/*ImmDisp=*/0, /*StopOnLBrac=*/true,
/*AddImmPrefix=*/false);
if (ParseIntelExpression(SM, End))
return 0;
if (SM.getSym()) {
Error(Start, "cannot use more than one symbol in memory operand");
return 0;
}
if (SM.getBaseReg()) {
Error(Start, "cannot use base register with variable reference");
return 0;
}
if (SM.getIndexReg()) {
Error(Start, "cannot use index register with variable reference");
return 0;
}
const MCExpr *Disp = MCConstantExpr::Create(SM.getImm(), getContext());
// BaseReg is non-zero to avoid assertions. In the context of inline asm,
// we're pointing to a local variable in memory, so the base register is
// really the frame or stack pointer.
return X86Operand::CreateMem(/*SegReg=*/0, Disp, /*BaseReg=*/1, /*IndexReg=*/0,
/*Scale=*/1, Start, End, Size, Identifier,
Info.OpDecl);
}
/// Parse the '.' operator.