OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <assert.h> | 5 #include <assert.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #if V8_TARGET_ARCH_IA32 | 9 #if V8_TARGET_ARCH_IA32 |
10 | 10 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 break; | 1378 break; |
1379 | 1379 |
1380 case 0x81: // fall through | 1380 case 0x81: // fall through |
1381 case 0x83: // 0x81 with sign extension bit set | 1381 case 0x83: // 0x81 with sign extension bit set |
1382 data += PrintImmediateOp(data); | 1382 data += PrintImmediateOp(data); |
1383 break; | 1383 break; |
1384 | 1384 |
1385 case 0x0F: | 1385 case 0x0F: |
1386 { byte f0byte = data[1]; | 1386 { byte f0byte = data[1]; |
1387 const char* f0mnem = F0Mnem(f0byte); | 1387 const char* f0mnem = F0Mnem(f0byte); |
1388 if (f0byte == 0x10) { | 1388 if (f0byte == 0x18) { |
1389 data += 2; | 1389 data += 2; |
1390 int mod, regop, rm; | 1390 int mod, regop, rm; |
1391 get_modrm(*data, &mod, ®op, &rm); | 1391 get_modrm(*data, &mod, ®op, &rm); |
1392 AppendToBuffer("movups %s,", NameOfXMMRegister(regop)); | |
1393 data += PrintRightXMMOperand(data); | |
1394 } else if (f0byte == 0x11) { | |
1395 data += 2; | |
1396 int mod, regop, rm; | |
1397 get_modrm(*data, &mod, ®op, &rm); | |
1398 AppendToBuffer("movups "); | |
1399 data += PrintRightXMMOperand(data); | |
1400 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | |
1401 } else if (f0byte == 0x18) { | |
1402 data += 2; | |
1403 int mod, regop, rm; | |
1404 get_modrm(*data, &mod, ®op, &rm); | |
1405 const char* suffix[] = {"nta", "1", "2", "3"}; | 1392 const char* suffix[] = {"nta", "1", "2", "3"}; |
1406 AppendToBuffer("%s%s ", f0mnem, suffix[regop & 0x03]); | 1393 AppendToBuffer("%s%s ", f0mnem, suffix[regop & 0x03]); |
1407 data += PrintRightOperand(data); | 1394 data += PrintRightOperand(data); |
1408 } else if (f0byte == 0x1F && data[2] == 0) { | 1395 } else if (f0byte == 0x1F && data[2] == 0) { |
1409 AppendToBuffer("nop"); // 3 byte nop. | 1396 AppendToBuffer("nop"); // 3 byte nop. |
1410 data += 3; | 1397 data += 3; |
1411 } else if (f0byte == 0x1F && data[2] == 0x40 && data[3] == 0) { | 1398 } else if (f0byte == 0x1F && data[2] == 0x40 && data[3] == 0) { |
1412 AppendToBuffer("nop"); // 4 byte nop. | 1399 AppendToBuffer("nop"); // 4 byte nop. |
1413 data += 4; | 1400 data += 4; |
1414 } else if (f0byte == 0x1F && data[2] == 0x44 && data[3] == 0 && | 1401 } else if (f0byte == 0x1F && data[2] == 0x44 && data[3] == 0 && |
(...skipping 19 matching lines...) Expand all Loading... |
1434 AppendToBuffer("movaps %s,%s", | 1421 AppendToBuffer("movaps %s,%s", |
1435 NameOfXMMRegister(regop), | 1422 NameOfXMMRegister(regop), |
1436 NameOfXMMRegister(rm)); | 1423 NameOfXMMRegister(rm)); |
1437 data++; | 1424 data++; |
1438 } else if (f0byte == 0x2e) { | 1425 } else if (f0byte == 0x2e) { |
1439 data += 2; | 1426 data += 2; |
1440 int mod, regop, rm; | 1427 int mod, regop, rm; |
1441 get_modrm(*data, &mod, ®op, &rm); | 1428 get_modrm(*data, &mod, ®op, &rm); |
1442 AppendToBuffer("ucomiss %s,", NameOfXMMRegister(regop)); | 1429 AppendToBuffer("ucomiss %s,", NameOfXMMRegister(regop)); |
1443 data += PrintRightXMMOperand(data); | 1430 data += PrintRightXMMOperand(data); |
1444 } else if (f0byte >= 0x51 && f0byte <= 0x5F) { | 1431 } else if (f0byte >= 0x53 && f0byte <= 0x5F) { |
1445 const char* const pseudo_op[] = { | 1432 const char* const pseudo_op[] = { |
1446 "sqrtps", "rsqrtps", "rcpps", "andps", "andnps", | 1433 "rcpps", |
1447 "orps", "xorps", "addps", "mulps", "cvtps2pd", | 1434 "andps", |
1448 "cvtdq2ps", "subps", "minps", "divps", "maxps"}; | 1435 "andnps", |
| 1436 "orps", |
| 1437 "xorps", |
| 1438 "addps", |
| 1439 "mulps", |
| 1440 "cvtps2pd", |
| 1441 "cvtdq2ps", |
| 1442 "subps", |
| 1443 "minps", |
| 1444 "divps", |
| 1445 "maxps", |
| 1446 }; |
1449 | 1447 |
1450 data += 2; | 1448 data += 2; |
1451 int mod, regop, rm; | 1449 int mod, regop, rm; |
1452 get_modrm(*data, &mod, ®op, &rm); | 1450 get_modrm(*data, &mod, ®op, &rm); |
1453 AppendToBuffer("%s %s,", pseudo_op[f0byte - 0x51], | 1451 AppendToBuffer("%s %s,", |
| 1452 pseudo_op[f0byte - 0x53], |
1454 NameOfXMMRegister(regop)); | 1453 NameOfXMMRegister(regop)); |
1455 data += PrintRightXMMOperand(data); | 1454 data += PrintRightXMMOperand(data); |
1456 } else if (f0byte == 0x50) { | 1455 } else if (f0byte == 0x50) { |
1457 data += 2; | 1456 data += 2; |
1458 int mod, regop, rm; | 1457 int mod, regop, rm; |
1459 get_modrm(*data, &mod, ®op, &rm); | 1458 get_modrm(*data, &mod, ®op, &rm); |
1460 AppendToBuffer("movmskps %s,%s", | 1459 AppendToBuffer("movmskps %s,%s", |
1461 NameOfCPURegister(regop), | 1460 NameOfCPURegister(regop), |
1462 NameOfXMMRegister(rm)); | 1461 NameOfXMMRegister(rm)); |
1463 data++; | 1462 data++; |
1464 } else if (f0byte == 0xC2) { | |
1465 // Intel manual 2A, Table 3-11. | |
1466 data += 2; | |
1467 int mod, regop, rm; | |
1468 get_modrm(*data, &mod, ®op, &rm); | |
1469 const char* const pseudo_op[] = { | |
1470 "cmpeqps", "cmpltps", "cmpleps", "cmpunordps", | |
1471 "cmpneqps", "cmpnltps", "cmpnleps", "cmpordps"}; | |
1472 AppendToBuffer("%s %s,%s", pseudo_op[data[1]], | |
1473 NameOfXMMRegister(regop), NameOfXMMRegister(rm)); | |
1474 data += 2; | |
1475 } else if (f0byte== 0xC6) { | 1463 } else if (f0byte== 0xC6) { |
1476 // shufps xmm, xmm/m128, imm8 | 1464 // shufps xmm, xmm/m128, imm8 |
1477 data += 2; | 1465 data += 2; |
1478 int mod, regop, rm; | 1466 int mod, regop, rm; |
1479 get_modrm(*data, &mod, ®op, &rm); | 1467 get_modrm(*data, &mod, ®op, &rm); |
1480 int8_t imm8 = static_cast<int8_t>(data[1]); | 1468 int8_t imm8 = static_cast<int8_t>(data[1]); |
1481 AppendToBuffer("shufps %s,%s,%d", | 1469 AppendToBuffer("shufps %s,%s,%d", |
1482 NameOfXMMRegister(rm), | 1470 NameOfXMMRegister(rm), |
1483 NameOfXMMRegister(regop), | 1471 NameOfXMMRegister(regop), |
1484 static_cast<int>(imm8)); | 1472 static_cast<int>(imm8)); |
1485 data += 2; | 1473 data += 2; |
1486 } else if (f0byte == 0x5B) { | |
1487 data += 2; | |
1488 int mod, regop, rm; | |
1489 get_modrm(*data, &mod, ®op, &rm); | |
1490 AppendToBuffer("cvtdq2ps %s,", NameOfXMMRegister(rm)); | |
1491 data += PrintRightXMMOperand(data); | |
1492 } else if ((f0byte & 0xF0) == 0x80) { | 1474 } else if ((f0byte & 0xF0) == 0x80) { |
1493 data += JumpConditional(data, branch_hint); | 1475 data += JumpConditional(data, branch_hint); |
1494 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || | 1476 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || |
1495 f0byte == 0xB7 || f0byte == 0xAF) { | 1477 f0byte == 0xB7 || f0byte == 0xAF) { |
1496 data += 2; | 1478 data += 2; |
1497 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); | 1479 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); |
1498 } else if ((f0byte & 0xF0) == 0x90) { | 1480 } else if ((f0byte & 0xF0) == 0x90) { |
1499 data += SetCC(data); | 1481 data += SetCC(data); |
1500 } else if ((f0byte & 0xF0) == 0x40) { | 1482 } else if ((f0byte & 0xF0) == 0x40) { |
1501 data += CMov(data); | 1483 data += CMov(data); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 if (*data == 0x38) { | 1659 if (*data == 0x38) { |
1678 data++; | 1660 data++; |
1679 if (*data == 0x17) { | 1661 if (*data == 0x17) { |
1680 data++; | 1662 data++; |
1681 int mod, regop, rm; | 1663 int mod, regop, rm; |
1682 get_modrm(*data, &mod, ®op, &rm); | 1664 get_modrm(*data, &mod, ®op, &rm); |
1683 AppendToBuffer("ptest %s,%s", | 1665 AppendToBuffer("ptest %s,%s", |
1684 NameOfXMMRegister(regop), | 1666 NameOfXMMRegister(regop), |
1685 NameOfXMMRegister(rm)); | 1667 NameOfXMMRegister(rm)); |
1686 data++; | 1668 data++; |
1687 } else if (*data == 0x40) { | |
1688 data++; | |
1689 int mod, regop, rm; | |
1690 get_modrm(*data, &mod, ®op, &rm); | |
1691 AppendToBuffer("pmulld %s,%s", NameOfXMMRegister(regop), | |
1692 NameOfXMMRegister(rm)); | |
1693 data += PrintRightXMMOperand(data); | |
1694 } else if (*data == 0x2A) { | 1669 } else if (*data == 0x2A) { |
1695 // movntdqa | 1670 // movntdqa |
1696 UnimplementedInstruction(); | 1671 UnimplementedInstruction(); |
1697 } else { | 1672 } else { |
1698 UnimplementedInstruction(); | 1673 UnimplementedInstruction(); |
1699 } | 1674 } |
1700 } else if (*data == 0x3A) { | 1675 } else if (*data == 0x3A) { |
1701 data++; | 1676 data++; |
1702 if (*data == 0x0A) { | 1677 if (*data == 0x0A) { |
1703 data++; | 1678 data++; |
(...skipping 16 matching lines...) Expand all Loading... |
1720 } else if (*data == 0x16) { | 1695 } else if (*data == 0x16) { |
1721 data++; | 1696 data++; |
1722 int mod, regop, rm; | 1697 int mod, regop, rm; |
1723 get_modrm(*data, &mod, &rm, ®op); | 1698 get_modrm(*data, &mod, &rm, ®op); |
1724 int8_t imm8 = static_cast<int8_t>(data[1]); | 1699 int8_t imm8 = static_cast<int8_t>(data[1]); |
1725 AppendToBuffer("pextrd %s,%s,%d", | 1700 AppendToBuffer("pextrd %s,%s,%d", |
1726 NameOfCPURegister(regop), | 1701 NameOfCPURegister(regop), |
1727 NameOfXMMRegister(rm), | 1702 NameOfXMMRegister(rm), |
1728 static_cast<int>(imm8)); | 1703 static_cast<int>(imm8)); |
1729 data += 2; | 1704 data += 2; |
1730 } else if (*data == 0x21) { | |
1731 data++; | |
1732 int mod, regop, rm; | |
1733 get_modrm(*data, &mod, ®op, &rm); | |
1734 int8_t imm8 = static_cast<int8_t>(data[1]); | |
1735 AppendToBuffer("insertps %s,%s,%d", NameOfXMMRegister(regop), | |
1736 NameOfXMMRegister(rm), static_cast<int>(imm8)); | |
1737 data += 2; | |
1738 } else if (*data == 0x17) { | 1705 } else if (*data == 0x17) { |
1739 data++; | 1706 data++; |
1740 int mod, regop, rm; | 1707 int mod, regop, rm; |
1741 get_modrm(*data, &mod, ®op, &rm); | 1708 get_modrm(*data, &mod, ®op, &rm); |
1742 int8_t imm8 = static_cast<int8_t>(data[1]); | 1709 int8_t imm8 = static_cast<int8_t>(data[1]); |
1743 AppendToBuffer("extractps %s,%s,%d", | 1710 AppendToBuffer("extractps %s,%s,%d", |
1744 NameOfCPURegister(rm), | 1711 NameOfCPURegister(rm), |
1745 NameOfXMMRegister(regop), | 1712 NameOfXMMRegister(regop), |
1746 static_cast<int>(imm8)); | 1713 static_cast<int>(imm8)); |
1747 data += 2; | 1714 data += 2; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 NameOfXMMRegister(rm)); | 1764 NameOfXMMRegister(rm)); |
1798 data++; | 1765 data++; |
1799 } else if (*data == 0x57) { | 1766 } else if (*data == 0x57) { |
1800 data++; | 1767 data++; |
1801 int mod, regop, rm; | 1768 int mod, regop, rm; |
1802 get_modrm(*data, &mod, ®op, &rm); | 1769 get_modrm(*data, &mod, ®op, &rm); |
1803 AppendToBuffer("xorpd %s,%s", | 1770 AppendToBuffer("xorpd %s,%s", |
1804 NameOfXMMRegister(regop), | 1771 NameOfXMMRegister(regop), |
1805 NameOfXMMRegister(rm)); | 1772 NameOfXMMRegister(rm)); |
1806 data++; | 1773 data++; |
1807 } else if (*data == 0x5B) { | |
1808 data++; | |
1809 int mod, regop, rm; | |
1810 get_modrm(*data, &mod, ®op, &rm); | |
1811 AppendToBuffer("cvtps2dq %s,%s", NameOfXMMRegister(regop), | |
1812 NameOfXMMRegister(rm)); | |
1813 data += PrintRightXMMOperand(data); | |
1814 } else if (*data == 0x62) { | |
1815 data++; | |
1816 int mod, regop, rm; | |
1817 get_modrm(*data, &mod, ®op, &rm); | |
1818 AppendToBuffer("punpackldq %s,", NameOfXMMRegister(regop)); | |
1819 data += PrintRightXMMOperand(data); | |
1820 } else if (*data == 0xF4) { | |
1821 data++; | |
1822 int mod, regop, rm; | |
1823 get_modrm(*data, &mod, ®op, &rm); | |
1824 AppendToBuffer("pmuludq %s,", NameOfXMMRegister(regop)); | |
1825 data += PrintRightXMMOperand(data); | |
1826 } else if (*data == 0xFA) { | |
1827 data++; | |
1828 int mod, regop, rm; | |
1829 get_modrm(*data, &mod, ®op, &rm); | |
1830 AppendToBuffer("psubd %s,", NameOfXMMRegister(regop)); | |
1831 data += PrintRightXMMOperand(data); | |
1832 } else if (*data == 0xFE) { | |
1833 data++; | |
1834 int mod, regop, rm; | |
1835 get_modrm(*data, &mod, ®op, &rm); | |
1836 AppendToBuffer("paddd %s,", NameOfXMMRegister(regop)); | |
1837 data += PrintRightXMMOperand(data); | |
1838 } else if (*data == 0x6E) { | 1774 } else if (*data == 0x6E) { |
1839 data++; | 1775 data++; |
1840 int mod, regop, rm; | 1776 int mod, regop, rm; |
1841 get_modrm(*data, &mod, ®op, &rm); | 1777 get_modrm(*data, &mod, ®op, &rm); |
1842 AppendToBuffer("movd %s,", NameOfXMMRegister(regop)); | 1778 AppendToBuffer("movd %s,", NameOfXMMRegister(regop)); |
1843 data += PrintRightOperand(data); | 1779 data += PrintRightOperand(data); |
1844 } else if (*data == 0x6F) { | 1780 } else if (*data == 0x6F) { |
1845 data++; | 1781 data++; |
1846 int mod, regop, rm; | 1782 int mod, regop, rm; |
1847 get_modrm(*data, &mod, ®op, &rm); | 1783 get_modrm(*data, &mod, ®op, &rm); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 fprintf(f, " "); | 2308 fprintf(f, " "); |
2373 } | 2309 } |
2374 fprintf(f, " %s\n", buffer.start()); | 2310 fprintf(f, " %s\n", buffer.start()); |
2375 } | 2311 } |
2376 } | 2312 } |
2377 | 2313 |
2378 | 2314 |
2379 } // namespace disasm | 2315 } // namespace disasm |
2380 | 2316 |
2381 #endif // V8_TARGET_ARCH_IA32 | 2317 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |