Deleted Added
sdiff udiff text old ( 263508 ) new ( 266715 )
full compact
1//===-- X86AsmParser.cpp - Parse X86 assembly to MCInst instructions ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 1167 unchanged lines hidden (view full) ---

1176}
1177
1178X86Operand *
1179X86AsmParser::CreateMemForInlineAsm(unsigned SegReg, const MCExpr *Disp,
1180 unsigned BaseReg, unsigned IndexReg,
1181 unsigned Scale, SMLoc Start, SMLoc End,
1182 unsigned Size, StringRef Identifier,
1183 InlineAsmIdentifierInfo &Info){
1184 if (isa<MCSymbolRefExpr>(Disp)) {
1185 // If this is not a VarDecl then assume it is a FuncDecl or some other label
1186 // reference. We need an 'r' constraint here, so we need to create register
1187 // operand to ensure proper matching. Just pick a GPR based on the size of
1188 // a pointer.
1189 if (!Info.IsVarDecl) {
1190 unsigned RegNo = is64BitMode() ? X86::RBX : X86::EBX;
1191 return X86Operand::CreateReg(RegNo, Start, End, /*AddressOf=*/true,
1192 SMLoc(), Identifier, Info.OpDecl);
1193 }
1194 if (!Size) {
1195 Size = Info.Type * 8; // Size is in terms of bits in this context.
1196 if (Size)
1197 InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_SizeDirective, Start,
1198 /*Len=*/0, Size));
1199 }
1200 }
1201

--- 105 unchanged lines hidden (view full) ---

1307 SM.onRegister(TmpReg);
1308 UpdateLocLex = false;
1309 break;
1310 } else {
1311 if (!isParsingInlineAsm()) {
1312 if (getParser().parsePrimaryExpr(Val, End))
1313 return Error(Tok.getLoc(), "Unexpected identifier!");
1314 } else {
1315 InlineAsmIdentifierInfo &Info = SM.getIdentifierInfo();
1316 if (ParseIntelIdentifier(Val, Identifier, Info,
1317 /*Unevaluated=*/false, End))
1318 return true;
1319 }
1320 SM.onIdentifierExpr(Val, Identifier);
1321 UpdateLocLex = false;
1322 break;
1323 }
1324 return Error(Tok.getLoc(), "Unexpected identifier!");
1325 }
1326 case AsmToken::Integer:

--- 34 unchanged lines hidden (view full) ---

1361 SMLoc StartInBrac = Tok.getLoc();
1362 // Parse [ Symbol + ImmDisp ] and [ BaseReg + Scale*IndexReg + ImmDisp ]. We
1363 // may have already parsed an immediate displacement before the bracketed
1364 // expression.
1365 IntelExprStateMachine SM(ImmDisp, /*StopOnLBrac=*/false, /*AddImmPrefix=*/true);
1366 if (ParseIntelExpression(SM, End))
1367 return 0;
1368
1369 const MCExpr *Disp;
1370 if (const MCExpr *Sym = SM.getSym()) {
1371 // A symbolic displacement.
1372 Disp = Sym;
1373 if (isParsingInlineAsm())
1374 RewriteIntelBracExpression(InstInfo->AsmRewrites, SM.getSymName(),
1375 ImmDisp, SM.getImm(), BracLoc, StartInBrac,
1376 End);
1377 } else {
1378 // An immediate displacement only.
1379 Disp = MCConstantExpr::Create(SM.getImm(), getContext());
1380 }
1381
1382 // Parse the dot operator (e.g., [ebx].foo.bar).
1383 if (Tok.getString().startswith(".")) {
1384 const MCExpr *NewDisp;
1385 if (ParseIntelDotOperator(Disp, NewDisp))
1386 return 0;
1387
1388 End = Tok.getEndLoc();
1389 Parser.Lex(); // Eat the field.
1390 Disp = NewDisp;
1391 }

--- 135 unchanged lines hidden (view full) ---

1527 int64_t OrigDispVal, DotDispVal;
1528
1529 // FIXME: Handle non-constant expressions.
1530 if (const MCConstantExpr *OrigDisp = dyn_cast<MCConstantExpr>(Disp))
1531 OrigDispVal = OrigDisp->getValue();
1532 else
1533 return Error(Tok.getLoc(), "Non-constant offsets are not supported!");
1534
1535 // Drop the '.'.
1536 StringRef DotDispStr = Tok.getString().drop_front(1);
1537
1538 // .Imm gets lexed as a real.
1539 if (Tok.is(AsmToken::Real)) {
1540 APInt DotDisp;
1541 DotDispStr.getAsInteger(10, DotDisp);
1542 DotDispVal = DotDisp.getZExtValue();
1543 } else if (isParsingInlineAsm() && Tok.is(AsmToken::Identifier)) {
1544 unsigned DotDisp;

--- 1140 unchanged lines hidden ---