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 == 0x18) { | 1388 if (f0byte == 0x10) { |
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); |
1392 const char* suffix[] = {"nta", "1", "2", "3"}; | 1405 const char* suffix[] = {"nta", "1", "2", "3"}; |
1393 AppendToBuffer("%s%s ", f0mnem, suffix[regop & 0x03]); | 1406 AppendToBuffer("%s%s ", f0mnem, suffix[regop & 0x03]); |
1394 data += PrintRightOperand(data); | 1407 data += PrintRightOperand(data); |
1395 } else if (f0byte == 0x1F && data[2] == 0) { | 1408 } else if (f0byte == 0x1F && data[2] == 0) { |
1396 AppendToBuffer("nop"); // 3 byte nop. | 1409 AppendToBuffer("nop"); // 3 byte nop. |
1397 data += 3; | 1410 data += 3; |
1398 } else if (f0byte == 0x1F && data[2] == 0x40 && data[3] == 0) { | 1411 } else if (f0byte == 0x1F && data[2] == 0x40 && data[3] == 0) { |
1399 AppendToBuffer("nop"); // 4 byte nop. | 1412 AppendToBuffer("nop"); // 4 byte nop. |
1400 data += 4; | 1413 data += 4; |
1401 } else if (f0byte == 0x1F && data[2] == 0x44 && data[3] == 0 && | 1414 } else if (f0byte == 0x1F && data[2] == 0x44 && data[3] == 0 && |
(...skipping 19 matching lines...) Expand all Loading... |
1421 AppendToBuffer("movaps %s,%s", | 1434 AppendToBuffer("movaps %s,%s", |
1422 NameOfXMMRegister(regop), | 1435 NameOfXMMRegister(regop), |
1423 NameOfXMMRegister(rm)); | 1436 NameOfXMMRegister(rm)); |
1424 data++; | 1437 data++; |
1425 } else if (f0byte == 0x2e) { | 1438 } else if (f0byte == 0x2e) { |
1426 data += 2; | 1439 data += 2; |
1427 int mod, regop, rm; | 1440 int mod, regop, rm; |
1428 get_modrm(*data, &mod, ®op, &rm); | 1441 get_modrm(*data, &mod, ®op, &rm); |
1429 AppendToBuffer("ucomiss %s,", NameOfXMMRegister(regop)); | 1442 AppendToBuffer("ucomiss %s,", NameOfXMMRegister(regop)); |
1430 data += PrintRightXMMOperand(data); | 1443 data += PrintRightXMMOperand(data); |
1431 } else if (f0byte >= 0x53 && f0byte <= 0x5F) { | 1444 } else if (f0byte >= 0x51 && f0byte <= 0x5F) { |
1432 const char* const pseudo_op[] = { | 1445 const char* const pseudo_op[] = { |
1433 "rcpps", | 1446 "sqrtps", "rsqrtps", "rcpps", "andps", "andnps", |
1434 "andps", | 1447 "orps", "xorps", "addps", "mulps", "cvtps2pd", |
1435 "andnps", | 1448 "cvtdq2ps", "subps", "minps", "divps", "maxps"}; |
1436 "orps", | |
1437 "xorps", | |
1438 "addps", | |
1439 "mulps", | |
1440 "cvtps2pd", | |
1441 "cvtdq2ps", | |
1442 "subps", | |
1443 "minps", | |
1444 "divps", | |
1445 "maxps", | |
1446 }; | |
1447 | 1449 |
1448 data += 2; | 1450 data += 2; |
1449 int mod, regop, rm; | 1451 int mod, regop, rm; |
1450 get_modrm(*data, &mod, ®op, &rm); | 1452 get_modrm(*data, &mod, ®op, &rm); |
1451 AppendToBuffer("%s %s,", | 1453 AppendToBuffer("%s %s,", pseudo_op[f0byte - 0x51], |
1452 pseudo_op[f0byte - 0x53], | |
1453 NameOfXMMRegister(regop)); | 1454 NameOfXMMRegister(regop)); |
1454 data += PrintRightXMMOperand(data); | 1455 data += PrintRightXMMOperand(data); |
1455 } else if (f0byte == 0x50) { | 1456 } else if (f0byte == 0x50) { |
1456 data += 2; | 1457 data += 2; |
1457 int mod, regop, rm; | 1458 int mod, regop, rm; |
1458 get_modrm(*data, &mod, ®op, &rm); | 1459 get_modrm(*data, &mod, ®op, &rm); |
1459 AppendToBuffer("movmskps %s,%s", | 1460 AppendToBuffer("movmskps %s,%s", |
1460 NameOfCPURegister(regop), | 1461 NameOfCPURegister(regop), |
1461 NameOfXMMRegister(rm)); | 1462 NameOfXMMRegister(rm)); |
1462 data++; | 1463 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; |
1463 } else if (f0byte== 0xC6) { | 1475 } else if (f0byte== 0xC6) { |
1464 // shufps xmm, xmm/m128, imm8 | 1476 // shufps xmm, xmm/m128, imm8 |
1465 data += 2; | 1477 data += 2; |
1466 int mod, regop, rm; | 1478 int mod, regop, rm; |
1467 get_modrm(*data, &mod, ®op, &rm); | 1479 get_modrm(*data, &mod, ®op, &rm); |
1468 int8_t imm8 = static_cast<int8_t>(data[1]); | 1480 int8_t imm8 = static_cast<int8_t>(data[1]); |
1469 AppendToBuffer("shufps %s,%s,%d", | 1481 AppendToBuffer("shufps %s,%s,%d", |
1470 NameOfXMMRegister(rm), | 1482 NameOfXMMRegister(rm), |
1471 NameOfXMMRegister(regop), | 1483 NameOfXMMRegister(regop), |
1472 static_cast<int>(imm8)); | 1484 static_cast<int>(imm8)); |
1473 data += 2; | 1485 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); |
1474 } else if ((f0byte & 0xF0) == 0x80) { | 1492 } else if ((f0byte & 0xF0) == 0x80) { |
1475 data += JumpConditional(data, branch_hint); | 1493 data += JumpConditional(data, branch_hint); |
1476 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || | 1494 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || |
1477 f0byte == 0xB7 || f0byte == 0xAF) { | 1495 f0byte == 0xB7 || f0byte == 0xAF) { |
1478 data += 2; | 1496 data += 2; |
1479 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); | 1497 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); |
1480 } else if ((f0byte & 0xF0) == 0x90) { | 1498 } else if ((f0byte & 0xF0) == 0x90) { |
1481 data += SetCC(data); | 1499 data += SetCC(data); |
1482 } else if ((f0byte & 0xF0) == 0x40) { | 1500 } else if ((f0byte & 0xF0) == 0x40) { |
1483 data += CMov(data); | 1501 data += CMov(data); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 if (*data == 0x38) { | 1677 if (*data == 0x38) { |
1660 data++; | 1678 data++; |
1661 if (*data == 0x17) { | 1679 if (*data == 0x17) { |
1662 data++; | 1680 data++; |
1663 int mod, regop, rm; | 1681 int mod, regop, rm; |
1664 get_modrm(*data, &mod, ®op, &rm); | 1682 get_modrm(*data, &mod, ®op, &rm); |
1665 AppendToBuffer("ptest %s,%s", | 1683 AppendToBuffer("ptest %s,%s", |
1666 NameOfXMMRegister(regop), | 1684 NameOfXMMRegister(regop), |
1667 NameOfXMMRegister(rm)); | 1685 NameOfXMMRegister(rm)); |
1668 data++; | 1686 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); |
1669 } else if (*data == 0x2A) { | 1694 } else if (*data == 0x2A) { |
1670 // movntdqa | 1695 // movntdqa |
1671 UnimplementedInstruction(); | 1696 UnimplementedInstruction(); |
1672 } else { | 1697 } else { |
1673 UnimplementedInstruction(); | 1698 UnimplementedInstruction(); |
1674 } | 1699 } |
1675 } else if (*data == 0x3A) { | 1700 } else if (*data == 0x3A) { |
1676 data++; | 1701 data++; |
1677 if (*data == 0x0A) { | 1702 if (*data == 0x0A) { |
1678 data++; | 1703 data++; |
(...skipping 16 matching lines...) Expand all Loading... |
1695 } else if (*data == 0x16) { | 1720 } else if (*data == 0x16) { |
1696 data++; | 1721 data++; |
1697 int mod, regop, rm; | 1722 int mod, regop, rm; |
1698 get_modrm(*data, &mod, &rm, ®op); | 1723 get_modrm(*data, &mod, &rm, ®op); |
1699 int8_t imm8 = static_cast<int8_t>(data[1]); | 1724 int8_t imm8 = static_cast<int8_t>(data[1]); |
1700 AppendToBuffer("pextrd %s,%s,%d", | 1725 AppendToBuffer("pextrd %s,%s,%d", |
1701 NameOfCPURegister(regop), | 1726 NameOfCPURegister(regop), |
1702 NameOfXMMRegister(rm), | 1727 NameOfXMMRegister(rm), |
1703 static_cast<int>(imm8)); | 1728 static_cast<int>(imm8)); |
1704 data += 2; | 1729 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; |
1705 } else if (*data == 0x17) { | 1738 } else if (*data == 0x17) { |
1706 data++; | 1739 data++; |
1707 int mod, regop, rm; | 1740 int mod, regop, rm; |
1708 get_modrm(*data, &mod, ®op, &rm); | 1741 get_modrm(*data, &mod, ®op, &rm); |
1709 int8_t imm8 = static_cast<int8_t>(data[1]); | 1742 int8_t imm8 = static_cast<int8_t>(data[1]); |
1710 AppendToBuffer("extractps %s,%s,%d", | 1743 AppendToBuffer("extractps %s,%s,%d", |
1711 NameOfCPURegister(rm), | 1744 NameOfCPURegister(rm), |
1712 NameOfXMMRegister(regop), | 1745 NameOfXMMRegister(regop), |
1713 static_cast<int>(imm8)); | 1746 static_cast<int>(imm8)); |
1714 data += 2; | 1747 data += 2; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 NameOfXMMRegister(rm)); | 1797 NameOfXMMRegister(rm)); |
1765 data++; | 1798 data++; |
1766 } else if (*data == 0x57) { | 1799 } else if (*data == 0x57) { |
1767 data++; | 1800 data++; |
1768 int mod, regop, rm; | 1801 int mod, regop, rm; |
1769 get_modrm(*data, &mod, ®op, &rm); | 1802 get_modrm(*data, &mod, ®op, &rm); |
1770 AppendToBuffer("xorpd %s,%s", | 1803 AppendToBuffer("xorpd %s,%s", |
1771 NameOfXMMRegister(regop), | 1804 NameOfXMMRegister(regop), |
1772 NameOfXMMRegister(rm)); | 1805 NameOfXMMRegister(rm)); |
1773 data++; | 1806 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); |
1774 } else if (*data == 0x6E) { | 1838 } else if (*data == 0x6E) { |
1775 data++; | 1839 data++; |
1776 int mod, regop, rm; | 1840 int mod, regop, rm; |
1777 get_modrm(*data, &mod, ®op, &rm); | 1841 get_modrm(*data, &mod, ®op, &rm); |
1778 AppendToBuffer("movd %s,", NameOfXMMRegister(regop)); | 1842 AppendToBuffer("movd %s,", NameOfXMMRegister(regop)); |
1779 data += PrintRightOperand(data); | 1843 data += PrintRightOperand(data); |
1780 } else if (*data == 0x6F) { | 1844 } else if (*data == 0x6F) { |
1781 data++; | 1845 data++; |
1782 int mod, regop, rm; | 1846 int mod, regop, rm; |
1783 get_modrm(*data, &mod, ®op, &rm); | 1847 get_modrm(*data, &mod, ®op, &rm); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 fprintf(f, " "); | 2372 fprintf(f, " "); |
2309 } | 2373 } |
2310 fprintf(f, " %s\n", buffer.start()); | 2374 fprintf(f, " %s\n", buffer.start()); |
2311 } | 2375 } |
2312 } | 2376 } |
2313 | 2377 |
2314 | 2378 |
2315 } // namespace disasm | 2379 } // namespace disasm |
2316 | 2380 |
2317 #endif // V8_TARGET_ARCH_IA32 | 2381 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |