OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 int mod, regop, rm; | 1031 int mod, regop, rm; |
1032 if (opcode == 0x3A) { | 1032 if (opcode == 0x3A) { |
1033 byte third_byte = *current; | 1033 byte third_byte = *current; |
1034 current = data + 3; | 1034 current = data + 3; |
1035 if (third_byte == 0x17) { | 1035 if (third_byte == 0x17) { |
1036 get_modrm(*current, &mod, ®op, &rm); | 1036 get_modrm(*current, &mod, ®op, &rm); |
1037 AppendToBuffer("extractps "); // reg/m32, xmm, imm8 | 1037 AppendToBuffer("extractps "); // reg/m32, xmm, imm8 |
1038 current += PrintRightOperand(current); | 1038 current += PrintRightOperand(current); |
1039 AppendToBuffer(",%s,%d", NameOfXMMRegister(regop), (*current) & 3); | 1039 AppendToBuffer(",%s,%d", NameOfXMMRegister(regop), (*current) & 3); |
1040 current += 1; | 1040 current += 1; |
| 1041 } else if (third_byte == 0x21) { |
| 1042 get_modrm(*current, &mod, ®op, &rm); |
| 1043 // insertps xmm, xmm, imm8 |
| 1044 AppendToBuffer("insertps %s,%s,%d", |
| 1045 NameOfXMMRegister(regop), |
| 1046 NameOfXMMRegister(rm), |
| 1047 (*(current + 1)) & 3); |
| 1048 current += 2; |
| 1049 } else if (third_byte == 0x22) { |
| 1050 get_modrm(*current, &mod, ®op, &rm); |
| 1051 // pinsrd xmm, reg32, imm8 |
| 1052 AppendToBuffer("pinsrd %s,%s,%d", |
| 1053 NameOfXMMRegister(regop), |
| 1054 NameOfCPURegister(rm), |
| 1055 (*(current + 1)) & 3); |
| 1056 current += 2; |
1041 } else if (third_byte == 0x0b) { | 1057 } else if (third_byte == 0x0b) { |
1042 get_modrm(*current, &mod, ®op, &rm); | 1058 get_modrm(*current, &mod, ®op, &rm); |
1043 // roundsd xmm, xmm/m64, imm8 | 1059 // roundsd xmm, xmm/m64, imm8 |
1044 AppendToBuffer("roundsd %s,", NameOfXMMRegister(regop)); | 1060 AppendToBuffer("roundsd %s,", NameOfXMMRegister(regop)); |
1045 current += PrintRightXMMOperand(current); | 1061 current += PrintRightXMMOperand(current); |
1046 AppendToBuffer(",%d", (*current) & 3); | 1062 AppendToBuffer(",%d", (*current) & 3); |
1047 current += 1; | 1063 current += 1; |
1048 } else { | 1064 } else { |
1049 UnimplementedInstruction(); | 1065 UnimplementedInstruction(); |
1050 } | 1066 } |
| 1067 } else if (opcode == 0x38) { |
| 1068 byte third_byte = *current; |
| 1069 current = data + 3; |
| 1070 if (third_byte == 0x40) { |
| 1071 get_modrm(*current, &mod, ®op, &rm); |
| 1072 AppendToBuffer("pmulld %s, ", NameOfXMMRegister(regop)); |
| 1073 current += PrintRightXMMOperand(current); |
| 1074 } else { |
| 1075 UnimplementedInstruction(); |
| 1076 } |
1051 } else { | 1077 } else { |
1052 get_modrm(*current, &mod, ®op, &rm); | 1078 get_modrm(*current, &mod, ®op, &rm); |
1053 if (opcode == 0x1f) { | 1079 if (opcode == 0x1f) { |
1054 current++; | 1080 current++; |
1055 if (rm == 4) { // SIB byte present. | 1081 if (rm == 4) { // SIB byte present. |
1056 current++; | 1082 current++; |
1057 } | 1083 } |
1058 if (mod == 1) { // Byte displacement. | 1084 if (mod == 1) { // Byte displacement. |
1059 current += 1; | 1085 current += 1; |
1060 } else if (mod == 2) { // 32-bit displacement. | 1086 } else if (mod == 2) { // 32-bit displacement. |
1061 current += 4; | 1087 current += 4; |
1062 } // else no immediate displacement. | 1088 } // else no immediate displacement. |
1063 AppendToBuffer("nop"); | 1089 AppendToBuffer("nop"); |
1064 } else if (opcode == 0x28) { | 1090 } else if (opcode == 0x28) { |
1065 AppendToBuffer("movapd %s,", NameOfXMMRegister(regop)); | 1091 AppendToBuffer("movapd %s,", NameOfXMMRegister(regop)); |
1066 current += PrintRightXMMOperand(current); | 1092 current += PrintRightXMMOperand(current); |
1067 } else if (opcode == 0x29) { | 1093 } else if (opcode == 0x29) { |
1068 AppendToBuffer("movapd "); | 1094 AppendToBuffer("movapd "); |
1069 current += PrintRightXMMOperand(current); | 1095 current += PrintRightXMMOperand(current); |
1070 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | 1096 AppendToBuffer(",%s", NameOfXMMRegister(regop)); |
1071 } else if (opcode == 0x6E) { | 1097 } else if (opcode == 0x6E) { |
1072 AppendToBuffer("mov%c %s,", | 1098 AppendToBuffer("mov%c %s,", |
1073 rex_w() ? 'q' : 'd', | 1099 rex_w() ? 'q' : 'd', |
1074 NameOfXMMRegister(regop)); | 1100 NameOfXMMRegister(regop)); |
1075 current += PrintRightOperand(current); | 1101 current += PrintRightOperand(current); |
1076 } else if (opcode == 0x6F) { | 1102 } else if (opcode == 0x6F) { |
1077 AppendToBuffer("movdqa %s,", | 1103 AppendToBuffer("movdqa %s,", |
1078 NameOfXMMRegister(regop)); | 1104 NameOfXMMRegister(regop)); |
1079 current += PrintRightXMMOperand(current); | 1105 current += PrintRightXMMOperand(current); |
| 1106 } else if (opcode == 0x70) { |
| 1107 AppendToBuffer("pshufd %s,", |
| 1108 NameOfXMMRegister(regop)); |
| 1109 current += PrintRightXMMOperand(current); |
| 1110 AppendToBuffer(",0x%x", (*current) & 0xff); |
| 1111 current += 1; |
| 1112 } else if (opcode == 0x5B) { |
| 1113 AppendToBuffer("cvtps2dq %s,", |
| 1114 NameOfXMMRegister(regop)); |
| 1115 current += PrintRightXMMOperand(current); |
| 1116 } else if (opcode == 0xFE) { |
| 1117 AppendToBuffer("paddd %s,", |
| 1118 NameOfXMMRegister(regop)); |
| 1119 current += PrintRightXMMOperand(current); |
| 1120 } else if (opcode == 0xFA) { |
| 1121 AppendToBuffer("psubd %s,", |
| 1122 NameOfXMMRegister(regop)); |
| 1123 current += PrintRightXMMOperand(current); |
1080 } else if (opcode == 0x7E) { | 1124 } else if (opcode == 0x7E) { |
1081 AppendToBuffer("mov%c ", | 1125 AppendToBuffer("mov%c ", |
1082 rex_w() ? 'q' : 'd'); | 1126 rex_w() ? 'q' : 'd'); |
1083 current += PrintRightOperand(current); | 1127 current += PrintRightOperand(current); |
1084 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | 1128 AppendToBuffer(",%s", NameOfXMMRegister(regop)); |
1085 } else if (opcode == 0x7F) { | 1129 } else if (opcode == 0x7F) { |
1086 AppendToBuffer("movdqa "); | 1130 AppendToBuffer("movdqa "); |
1087 current += PrintRightXMMOperand(current); | 1131 current += PrintRightXMMOperand(current); |
1088 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | 1132 AppendToBuffer(",%s", NameOfXMMRegister(regop)); |
1089 } else if (opcode == 0xD6) { | 1133 } else if (opcode == 0xD6) { |
1090 AppendToBuffer("movq "); | 1134 AppendToBuffer("movq "); |
1091 current += PrintRightXMMOperand(current); | 1135 current += PrintRightXMMOperand(current); |
1092 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | 1136 AppendToBuffer(",%s", NameOfXMMRegister(regop)); |
1093 } else if (opcode == 0x50) { | 1137 } else if (opcode == 0x50) { |
1094 AppendToBuffer("movmskpd %s,", NameOfCPURegister(regop)); | 1138 AppendToBuffer("movmskpd %s,", NameOfCPURegister(regop)); |
1095 current += PrintRightXMMOperand(current); | 1139 current += PrintRightXMMOperand(current); |
| 1140 } else if (opcode == 0x62) { |
| 1141 AppendToBuffer("punpackldq %s,", NameOfXMMRegister(regop)); |
| 1142 current += PrintRightXMMOperand(current); |
| 1143 } else if (opcode == 0x73) { |
| 1144 AppendToBuffer("psrldq "); |
| 1145 current += PrintRightXMMOperand(current); |
| 1146 AppendToBuffer(",0x%x", (*current) & 0xff); |
| 1147 current += 1; |
| 1148 } else if (opcode == 0xF4) { |
| 1149 AppendToBuffer("pmuludq %s,", NameOfXMMRegister(regop)); |
| 1150 current += PrintRightXMMOperand(current); |
1096 } else { | 1151 } else { |
1097 const char* mnemonic = "?"; | 1152 const char* mnemonic = "?"; |
1098 if (opcode == 0x54) { | 1153 if (opcode == 0x54) { |
1099 mnemonic = "andpd"; | 1154 mnemonic = "andpd"; |
1100 } else if (opcode == 0x56) { | 1155 } else if (opcode == 0x56) { |
1101 mnemonic = "orpd"; | 1156 mnemonic = "orpd"; |
1102 } else if (opcode == 0x57) { | 1157 } else if (opcode == 0x57) { |
1103 mnemonic = "xorpd"; | 1158 mnemonic = "xorpd"; |
1104 } else if (opcode == 0x2E) { | 1159 } else if (opcode == 0x2E) { |
1105 mnemonic = "ucomisd"; | 1160 mnemonic = "ucomisd"; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 current += PrintRightXMMOperand(current); | 1297 current += PrintRightXMMOperand(current); |
1243 | 1298 |
1244 } else if (opcode == 0x29) { | 1299 } else if (opcode == 0x29) { |
1245 // movaps xmm/m128, xmm | 1300 // movaps xmm/m128, xmm |
1246 int mod, regop, rm; | 1301 int mod, regop, rm; |
1247 get_modrm(*current, &mod, ®op, &rm); | 1302 get_modrm(*current, &mod, ®op, &rm); |
1248 AppendToBuffer("movaps "); | 1303 AppendToBuffer("movaps "); |
1249 current += PrintRightXMMOperand(current); | 1304 current += PrintRightXMMOperand(current); |
1250 AppendToBuffer(",%s", NameOfXMMRegister(regop)); | 1305 AppendToBuffer(",%s", NameOfXMMRegister(regop)); |
1251 | 1306 |
| 1307 } else if (opcode == 0x10) { |
| 1308 // movaps xmm, xmm/m128 |
| 1309 int mod, regop, rm; |
| 1310 get_modrm(*current, &mod, ®op, &rm); |
| 1311 AppendToBuffer("movups %s, ", NameOfXMMRegister(regop)); |
| 1312 current += PrintRightXMMOperand(current); |
| 1313 |
| 1314 } else if (opcode == 0x11) { |
| 1315 // movaps xmm/m128, xmm |
| 1316 int mod, regop, rm; |
| 1317 get_modrm(*current, &mod, ®op, &rm); |
| 1318 AppendToBuffer("movups "); |
| 1319 current += PrintRightXMMOperand(current); |
| 1320 AppendToBuffer(", %s", NameOfXMMRegister(regop)); |
| 1321 |
1252 } else if (opcode == 0xA2) { | 1322 } else if (opcode == 0xA2) { |
1253 // CPUID | 1323 // CPUID |
1254 AppendToBuffer("%s", mnemonic); | 1324 AppendToBuffer("%s", mnemonic); |
1255 | 1325 |
1256 } else if ((opcode & 0xF0) == 0x40) { | 1326 } else if ((opcode & 0xF0) == 0x40) { |
1257 // CMOVcc: conditional move. | 1327 // CMOVcc: conditional move. |
1258 int condition = opcode & 0x0F; | 1328 int condition = opcode & 0x0F; |
1259 const InstructionDesc& idesc = cmov_instructions[condition]; | 1329 const InstructionDesc& idesc = cmov_instructions[condition]; |
1260 byte_size_operand_ = idesc.byte_size_operation; | 1330 byte_size_operand_ = idesc.byte_size_operation; |
1261 current += PrintOperands(idesc.mnem, idesc.op_order_, current); | 1331 current += PrintOperands(idesc.mnem, idesc.op_order_, current); |
(...skipping 23 matching lines...) Expand all Loading... |
1285 | 1355 |
1286 } else if (opcode == 0xC6) { | 1356 } else if (opcode == 0xC6) { |
1287 // shufps xmm, xmm/m128, imm8 | 1357 // shufps xmm, xmm/m128, imm8 |
1288 int mod, regop, rm; | 1358 int mod, regop, rm; |
1289 get_modrm(*current, &mod, ®op, &rm); | 1359 get_modrm(*current, &mod, ®op, &rm); |
1290 AppendToBuffer("shufps %s, ", NameOfXMMRegister(regop)); | 1360 AppendToBuffer("shufps %s, ", NameOfXMMRegister(regop)); |
1291 current += PrintRightXMMOperand(current); | 1361 current += PrintRightXMMOperand(current); |
1292 AppendToBuffer(", %d", (*current) & 3); | 1362 AppendToBuffer(", %d", (*current) & 3); |
1293 current += 1; | 1363 current += 1; |
1294 | 1364 |
| 1365 } else if (opcode == 0xC6) { |
| 1366 // shufps xmm, xmm/m128, imm8 |
| 1367 int mod, regop, rm; |
| 1368 get_modrm(*current, &mod, ®op, &rm); |
| 1369 AppendToBuffer("shufps %s, ", NameOfXMMRegister(regop)); |
| 1370 current += PrintRightXMMOperand(current); |
| 1371 AppendToBuffer(", %d", (*current) & 3); |
| 1372 current += 1; |
| 1373 |
| 1374 } else if (opcode == 0x54) { |
| 1375 // andps xmm, xmm/m128 |
| 1376 int mod, regop, rm; |
| 1377 get_modrm(*current, &mod, ®op, &rm); |
| 1378 AppendToBuffer("andps %s, ", NameOfXMMRegister(regop)); |
| 1379 current += PrintRightXMMOperand(current); |
| 1380 |
| 1381 } else if (opcode == 0x56) { |
| 1382 // orps xmm, xmm/m128 |
| 1383 int mod, regop, rm; |
| 1384 get_modrm(*current, &mod, ®op, &rm); |
| 1385 AppendToBuffer("orps %s, ", NameOfXMMRegister(regop)); |
| 1386 current += PrintRightXMMOperand(current); |
| 1387 |
| 1388 } else if (opcode == 0x58) { |
| 1389 // addps xmm, xmm/m128 |
| 1390 int mod, regop, rm; |
| 1391 get_modrm(*current, &mod, ®op, &rm); |
| 1392 AppendToBuffer("addps %s, ", NameOfXMMRegister(regop)); |
| 1393 current += PrintRightXMMOperand(current); |
| 1394 |
| 1395 } else if (opcode == 0x59) { |
| 1396 // mulps xmm, xmm/m128 |
| 1397 int mod, regop, rm; |
| 1398 get_modrm(*current, &mod, ®op, &rm); |
| 1399 AppendToBuffer("mulps %s, ", NameOfXMMRegister(regop)); |
| 1400 current += PrintRightXMMOperand(current); |
| 1401 |
| 1402 } else if (opcode == 0x5C) { |
| 1403 // subps xmm, xmm/m128 |
| 1404 int mod, regop, rm; |
| 1405 get_modrm(*current, &mod, ®op, &rm); |
| 1406 AppendToBuffer("subps %s, ", NameOfXMMRegister(regop)); |
| 1407 current += PrintRightXMMOperand(current); |
| 1408 |
| 1409 } else if (opcode == 0x5E) { |
| 1410 // divps xmm, xmm/m128 |
| 1411 int mod, regop, rm; |
| 1412 get_modrm(*current, &mod, ®op, &rm); |
| 1413 AppendToBuffer("divps %s, ", NameOfXMMRegister(regop)); |
| 1414 current += PrintRightXMMOperand(current); |
| 1415 |
| 1416 } else if (opcode == 0x5D) { |
| 1417 // minps xmm, xmm/m128 |
| 1418 int mod, regop, rm; |
| 1419 get_modrm(*current, &mod, ®op, &rm); |
| 1420 AppendToBuffer("minps %s, ", NameOfXMMRegister(regop)); |
| 1421 current += PrintRightXMMOperand(current); |
| 1422 |
| 1423 } else if (opcode == 0x5F) { |
| 1424 // maxps xmm, xmm/m128 |
| 1425 int mod, regop, rm; |
| 1426 get_modrm(*current, &mod, ®op, &rm); |
| 1427 AppendToBuffer("maxps %s, ", NameOfXMMRegister(regop)); |
| 1428 current += PrintRightXMMOperand(current); |
| 1429 |
| 1430 } else if (opcode == 0x5B) { |
| 1431 // cvtdq2ps xmm, xmm/m128 |
| 1432 int mod, regop, rm; |
| 1433 get_modrm(*current, &mod, ®op, &rm); |
| 1434 AppendToBuffer("cvtdq2ps %s, ", NameOfXMMRegister(regop)); |
| 1435 current += PrintRightXMMOperand(current); |
| 1436 |
| 1437 |
| 1438 } else if (opcode == 0x53) { |
| 1439 // rcpps xmm, xmm/m128 |
| 1440 int mod, regop, rm; |
| 1441 get_modrm(*current, &mod, ®op, &rm); |
| 1442 AppendToBuffer("rcpps %s, ", NameOfXMMRegister(regop)); |
| 1443 current += PrintRightXMMOperand(current); |
| 1444 |
| 1445 } else if (opcode == 0x52) { |
| 1446 // rsqrtps xmm, xmm/m128 |
| 1447 int mod, regop, rm; |
| 1448 get_modrm(*current, &mod, ®op, &rm); |
| 1449 AppendToBuffer("rsqrtps %s, ", NameOfXMMRegister(regop)); |
| 1450 current += PrintRightXMMOperand(current); |
| 1451 |
| 1452 } else if (opcode == 0x51) { |
| 1453 // sqrtps xmm, xmm/m128 |
| 1454 int mod, regop, rm; |
| 1455 get_modrm(*current, &mod, ®op, &rm); |
| 1456 AppendToBuffer("sqrtps %s, ", NameOfXMMRegister(regop)); |
| 1457 current += PrintRightXMMOperand(current); |
| 1458 |
1295 } else if (opcode == 0x50) { | 1459 } else if (opcode == 0x50) { |
1296 // movmskps reg, xmm | 1460 // movmskps reg, xmm |
1297 int mod, regop, rm; | 1461 int mod, regop, rm; |
1298 get_modrm(*current, &mod, ®op, &rm); | 1462 get_modrm(*current, &mod, ®op, &rm); |
1299 AppendToBuffer("movmskps %s,", NameOfCPURegister(regop)); | 1463 AppendToBuffer("movmskps %s,", NameOfCPURegister(regop)); |
1300 current += PrintRightXMMOperand(current); | 1464 current += PrintRightXMMOperand(current); |
1301 | 1465 |
| 1466 } else if (opcode == 0xC2) { |
| 1467 // Intel manual 2A, Table 3-11. |
| 1468 int mod, regop, rm; |
| 1469 get_modrm(*current, &mod, ®op, &rm); |
| 1470 const char* const pseudo_op[] = { |
| 1471 "cmpeqps", |
| 1472 "cmpltps", |
| 1473 "cmpleps", |
| 1474 "cmpunordps", |
| 1475 "cmpneqps", |
| 1476 "cmpnltps", |
| 1477 "cmpnleps", |
| 1478 "cmpordps" |
| 1479 }; |
| 1480 AppendToBuffer("%s %s,%s", |
| 1481 pseudo_op[current[1]], |
| 1482 NameOfXMMRegister(regop), |
| 1483 NameOfXMMRegister(rm)); |
| 1484 current += 2; |
| 1485 |
1302 } else if ((opcode & 0xF0) == 0x80) { | 1486 } else if ((opcode & 0xF0) == 0x80) { |
1303 // Jcc: Conditional jump (branch). | 1487 // Jcc: Conditional jump (branch). |
1304 current = data + JumpConditional(data); | 1488 current = data + JumpConditional(data); |
1305 | 1489 |
1306 } else if (opcode == 0xBE || opcode == 0xBF || opcode == 0xB6 || | 1490 } else if (opcode == 0xBE || opcode == 0xBF || opcode == 0xB6 || |
1307 opcode == 0xB7 || opcode == 0xAF) { | 1491 opcode == 0xB7 || opcode == 0xAF) { |
1308 // Size-extending moves, IMUL. | 1492 // Size-extending moves, IMUL. |
1309 current += PrintOperands(mnemonic, REG_OPER_OP_ORDER, current); | 1493 current += PrintOperands(mnemonic, REG_OPER_OP_ORDER, current); |
1310 | 1494 |
1311 } else if ((opcode & 0xF0) == 0x90) { | 1495 } else if ((opcode & 0xF0) == 0x90) { |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 2100 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
1917 fprintf(f, " "); | 2101 fprintf(f, " "); |
1918 } | 2102 } |
1919 fprintf(f, " %s\n", buffer.start()); | 2103 fprintf(f, " %s\n", buffer.start()); |
1920 } | 2104 } |
1921 } | 2105 } |
1922 | 2106 |
1923 } // namespace disasm | 2107 } // namespace disasm |
1924 | 2108 |
1925 #endif // V8_TARGET_ARCH_X64 | 2109 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |