Deleted Added
full compact
X86AsmParser.cpp (263508) X86AsmParser.cpp (266715)
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){
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 }
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) {
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 {
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 {
1315 InlineAsmIdentifierInfo &Info = SM.getIdentifierInfo();
1316 if (ParseIntelIdentifier(Val, Identifier, Info,
1317 /*Unevaluated=*/false, End))
1318 return true;
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 }
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
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
1369 const MCExpr *Disp;
1381 const MCExpr *Disp = 0;
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);
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);
1377 } else {
1378 // An immediate displacement only.
1379 Disp = MCConstantExpr::Create(SM.getImm(), getContext());
1380 }
1381
1389 }
1390
1382 // Parse the dot operator (e.g., [ebx].foo.bar).
1383 if (Tok.getString().startswith(".")) {
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) {
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
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
1535 // Drop the '.'.
1536 StringRef DotDispStr = Tok.getString().drop_front(1);
1554 // Drop the optional '.'.
1555 StringRef DotDispStr = Tok.getString();
1556 if (DotDispStr.startswith("."))
1557 DotDispStr = DotDispStr.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 ---
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 ---