llvm.org GIT mirror llvm / a9a43d0
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202865 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 6 years ago
1 changed file(s) with 34 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
13061306 // Parse ImmDisp [ BaseReg + Scale*IndexReg + Disp ].
13071307 if (getLexer().is(AsmToken::LBrac))
13081308 return ParseIntelBracExpression(/*SegReg=*/0, Start, ImmDisp, Size);
1309 assert(ImmDisp == 0);
13091310
13101311 const MCExpr *Val;
13111312 if (!isParsingInlineAsm()) {
13201321 if (ParseIntelIdentifier(Val, Identifier, Info,
13211322 /*Unevaluated=*/false, End))
13221323 return 0;
1323 return CreateMemForInlineAsm(/*SegReg=*/0, Val, /*BaseReg=*/0, /*IndexReg=*/0,
1324 /*Scale=*/1, Start, End, Size, Identifier, Info);
1324
1325 if (!getLexer().is(AsmToken::LBrac))
1326 return CreateMemForInlineAsm(/*SegReg=*/0, Val, /*BaseReg=*/0, /*IndexReg=*/0,
1327 /*Scale=*/1, Start, End, Size, Identifier, Info);
1328
1329 Parser.Lex(); // Eat '['
1330
1331 // Parse Identifier [ ImmDisp ]
1332 IntelExprStateMachine SM(/*ImmDisp=*/0, /*StopOnLBrac=*/true,
1333 /*AddImmPrefix=*/false);
1334 if (ParseIntelExpression(SM, End))
1335 return 0;
1336
1337 if (SM.getSym()) {
1338 Error(Start, "cannot use more than one symbol in memory operand");
1339 return 0;
1340 }
1341 if (SM.getBaseReg()) {
1342 Error(Start, "cannot use base register with variable reference");
1343 return 0;
1344 }
1345 if (SM.getIndexReg()) {
1346 Error(Start, "cannot use index register with variable reference");
1347 return 0;
1348 }
1349
1350 const MCExpr *Disp = MCConstantExpr::Create(SM.getImm(), getContext());
1351 // BaseReg is non-zero to avoid assertions. In the context of inline asm,
1352 // we're pointing to a local variable in memory, so the base register is
1353 // really the frame or stack pointer.
1354 return X86Operand::CreateMem(/*SegReg=*/0, Disp, /*BaseReg=*/1, /*IndexReg=*/0,
1355 /*Scale=*/1, Start, End, Size, Identifier,
1356 Info.OpDecl);
13251357 }
13261358
13271359 /// Parse the '.' operator.