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 this is not a VarDecl then assume it is a FuncDecl or some other label
1185 // reference. We need an 'r' constraint here, so we need to create register
1186 // operand to ensure proper matching. Just pick a GPR based on the size of
1187 // a pointer.
1188 if (isa<MCSymbolRefExpr>(Disp) && !Info.IsVarDecl) {
1189 unsigned RegNo = is64BitMode() ? X86::RBX : X86::EBX;
1190 return X86Operand::CreateReg(RegNo, Start, End, /*AddressOf=*/true,
1191 SMLoc(), Identifier, Info.OpDecl);
1192 }
1193
1194 // We either have a direct symbol reference, or an offset from a symbol. The
1195 // parser always puts the symbol on the LHS, so look there for size
1196 // calculation purposes.
1197 const MCBinaryExpr *BinOp = dyn_cast<MCBinaryExpr>(Disp);
1198 bool IsSymRef =
1199 isa<MCSymbolRefExpr>(BinOp ? BinOp->getLHS() : Disp);
1200 if (IsSymRef) {
1201 if (!Size) {
1202 Size = Info.Type * 8; // Size is in terms of bits in this context.
1203 if (Size)
1204 InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_SizeDirective, Start,
1205 /*Len=*/0, Size));
1206 }
1207 }
1208

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

1314 SM.onRegister(TmpReg);
1315 UpdateLocLex = false;
1316 break;
1317 } else {
1318 if (!isParsingInlineAsm()) {
1319 if (getParser().parsePrimaryExpr(Val, End))
1320 return Error(Tok.getLoc(), "Unexpected identifier!");
1321 } else {
1322 // This is a dot operator, not an adjacent identifier.
1323 if (Identifier.find('.') != StringRef::npos) {
1324 return false;
1325 } else {
1326 InlineAsmIdentifierInfo &Info = SM.getIdentifierInfo();
1327 if (ParseIntelIdentifier(Val, Identifier, Info,
1328 /*Unevaluated=*/false, End))
1329 return true;
1330 }
1331 }
1332 SM.onIdentifierExpr(Val, Identifier);
1333 UpdateLocLex = false;
1334 break;
1335 }
1336 return Error(Tok.getLoc(), "Unexpected identifier!");
1337 }
1338 case AsmToken::Integer:

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

1373 SMLoc StartInBrac = Tok.getLoc();
1374 // Parse [ Symbol + ImmDisp ] and [ BaseReg + Scale*IndexReg + ImmDisp ]. We
1375 // may have already parsed an immediate displacement before the bracketed
1376 // expression.
1377 IntelExprStateMachine SM(ImmDisp, /*StopOnLBrac=*/false, /*AddImmPrefix=*/true);
1378 if (ParseIntelExpression(SM, End))
1379 return 0;
1380
1381 const MCExpr *Disp = 0;
1382 if (const MCExpr *Sym = SM.getSym()) {
1383 // A symbolic displacement.
1384 Disp = Sym;
1385 if (isParsingInlineAsm())
1386 RewriteIntelBracExpression(InstInfo->AsmRewrites, SM.getSymName(),
1387 ImmDisp, SM.getImm(), BracLoc, StartInBrac,
1388 End);
1389 }
1390
1391 if (SM.getImm() || !Disp) {
1392 const MCExpr *Imm = MCConstantExpr::Create(SM.getImm(), getContext());
1393 if (Disp)
1394 Disp = MCBinaryExpr::CreateAdd(Disp, Imm, getContext());
1395 else
1396 Disp = Imm; // An immediate displacement only.
1397 }
1398
1399 // Parse struct field access. Intel requires a dot, but MSVC doesn't. MSVC
1400 // will in fact do global lookup the field name inside all global typedefs,
1401 // but we don't emulate that.
1402 if (Tok.getString().find('.') != StringRef::npos) {
1403 const MCExpr *NewDisp;
1404 if (ParseIntelDotOperator(Disp, NewDisp))
1405 return 0;
1406
1407 End = Tok.getEndLoc();
1408 Parser.Lex(); // Eat the field.
1409 Disp = NewDisp;
1410 }

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

1546 int64_t OrigDispVal, DotDispVal;
1547
1548 // FIXME: Handle non-constant expressions.
1549 if (const MCConstantExpr *OrigDisp = dyn_cast<MCConstantExpr>(Disp))
1550 OrigDispVal = OrigDisp->getValue();
1551 else
1552 return Error(Tok.getLoc(), "Non-constant offsets are not supported!");
1553
1554 // Drop the optional '.'.
1555 StringRef DotDispStr = Tok.getString();
1556 if (DotDispStr.startswith("."))
1557 DotDispStr = DotDispStr.drop_front(1);
1558
1559 // .Imm gets lexed as a real.
1560 if (Tok.is(AsmToken::Real)) {
1561 APInt DotDisp;
1562 DotDispStr.getAsInteger(10, DotDisp);
1563 DotDispVal = DotDisp.getZExtValue();
1564 } else if (isParsingInlineAsm() && Tok.is(AsmToken::Identifier)) {
1565 unsigned DotDisp;

--- 1140 unchanged lines hidden ---