Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: src/a64/disasm-a64.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/a64/deoptimizer-a64.cc ('k') | src/a64/frames-a64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Format(instr, "unallocated", "(LogicalImmediate)"); 248 Format(instr, "unallocated", "(LogicalImmediate)");
249 return; 249 return;
250 } 250 }
251 251
252 switch (instr->Mask(LogicalImmediateMask)) { 252 switch (instr->Mask(LogicalImmediateMask)) {
253 case AND_w_imm: 253 case AND_w_imm:
254 case AND_x_imm: mnemonic = "and"; break; 254 case AND_x_imm: mnemonic = "and"; break;
255 case ORR_w_imm: 255 case ORR_w_imm:
256 case ORR_x_imm: { 256 case ORR_x_imm: {
257 mnemonic = "orr"; 257 mnemonic = "orr";
258 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize 258 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSizeInBits
259 : kWRegSize; 259 : kWRegSizeInBits;
260 if (rn_is_zr && !IsMovzMovnImm(reg_size, instr->ImmLogical())) { 260 if (rn_is_zr && !IsMovzMovnImm(reg_size, instr->ImmLogical())) {
261 mnemonic = "mov"; 261 mnemonic = "mov";
262 form = "'Rds, 'ITri"; 262 form = "'Rds, 'ITri";
263 } 263 }
264 break; 264 break;
265 } 265 }
266 case EOR_w_imm: 266 case EOR_w_imm:
267 case EOR_x_imm: mnemonic = "eor"; break; 267 case EOR_x_imm: mnemonic = "eor"; break;
268 case ANDS_w_imm: 268 case ANDS_w_imm:
269 case ANDS_x_imm: { 269 case ANDS_x_imm: {
270 mnemonic = "ands"; 270 mnemonic = "ands";
271 if (rd_is_zr) { 271 if (rd_is_zr) {
272 mnemonic = "tst"; 272 mnemonic = "tst";
273 form = "'Rn, 'ITri"; 273 form = "'Rn, 'ITri";
274 } 274 }
275 break; 275 break;
276 } 276 }
277 default: UNREACHABLE(); 277 default: UNREACHABLE();
278 } 278 }
279 Format(instr, mnemonic, form); 279 Format(instr, mnemonic, form);
280 } 280 }
281 281
282 282
283 bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) { 283 bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) {
284 ASSERT((reg_size == kXRegSize) || 284 ASSERT((reg_size == kXRegSizeInBits) ||
285 ((reg_size == kWRegSize) && (value <= 0xffffffff))); 285 ((reg_size == kWRegSizeInBits) && (value <= 0xffffffff)));
286 286
287 // Test for movz: 16-bits set at positions 0, 16, 32 or 48. 287 // Test for movz: 16-bits set at positions 0, 16, 32 or 48.
288 if (((value & 0xffffffffffff0000UL) == 0UL) || 288 if (((value & 0xffffffffffff0000UL) == 0UL) ||
289 ((value & 0xffffffff0000ffffUL) == 0UL) || 289 ((value & 0xffffffff0000ffffUL) == 0UL) ||
290 ((value & 0xffff0000ffffffffUL) == 0UL) || 290 ((value & 0xffff0000ffffffffUL) == 0UL) ||
291 ((value & 0x0000ffffffffffffUL) == 0UL)) { 291 ((value & 0x0000ffffffffffffUL) == 0UL)) {
292 return true; 292 return true;
293 } 293 }
294 294
295 // Test for movn: NOT(16-bits set at positions 0, 16, 32 or 48). 295 // Test for movn: NOT(16-bits set at positions 0, 16, 32 or 48).
296 if ((reg_size == kXRegSize) && 296 if ((reg_size == kXRegSizeInBits) &&
297 (((value & 0xffffffffffff0000UL) == 0xffffffffffff0000UL) || 297 (((value & 0xffffffffffff0000UL) == 0xffffffffffff0000UL) ||
298 ((value & 0xffffffff0000ffffUL) == 0xffffffff0000ffffUL) || 298 ((value & 0xffffffff0000ffffUL) == 0xffffffff0000ffffUL) ||
299 ((value & 0xffff0000ffffffffUL) == 0xffff0000ffffffffUL) || 299 ((value & 0xffff0000ffffffffUL) == 0xffff0000ffffffffUL) ||
300 ((value & 0x0000ffffffffffffUL) == 0x0000ffffffffffffUL))) { 300 ((value & 0x0000ffffffffffffUL) == 0x0000ffffffffffffUL))) {
301 return true; 301 return true;
302 } 302 }
303 if ((reg_size == kWRegSize) && 303 if ((reg_size == kWRegSizeInBits) &&
304 (((value & 0xffff0000) == 0xffff0000) || 304 (((value & 0xffff0000) == 0xffff0000) ||
305 ((value & 0x0000ffff) == 0x0000ffff))) { 305 ((value & 0x0000ffff) == 0x0000ffff))) {
306 return true; 306 return true;
307 } 307 }
308 return false; 308 return false;
309 } 309 }
310 310
311 311
312 void Disassembler::VisitLogicalShifted(Instruction* instr) { 312 void Disassembler::VisitLogicalShifted(Instruction* instr) {
313 bool rd_is_zr = RdIsZROrSP(instr); 313 bool rd_is_zr = RdIsZROrSP(instr);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 default: UNREACHABLE(); 440 default: UNREACHABLE();
441 } 441 }
442 Format(instr, mnemonic, form); 442 Format(instr, mnemonic, form);
443 } 443 }
444 444
445 445
446 void Disassembler::VisitBitfield(Instruction* instr) { 446 void Disassembler::VisitBitfield(Instruction* instr) {
447 unsigned s = instr->ImmS(); 447 unsigned s = instr->ImmS();
448 unsigned r = instr->ImmR(); 448 unsigned r = instr->ImmR();
449 unsigned rd_size_minus_1 = 449 unsigned rd_size_minus_1 =
450 ((instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize) - 1; 450 ((instr->SixtyFourBits() == 1) ? kXRegSizeInBits : kWRegSizeInBits) - 1;
451 const char *mnemonic = ""; 451 const char *mnemonic = "";
452 const char *form = ""; 452 const char *form = "";
453 const char *form_shift_right = "'Rd, 'Rn, 'IBr"; 453 const char *form_shift_right = "'Rd, 'Rn, 'IBr";
454 const char *form_extend = "'Rd, 'Wn"; 454 const char *form_extend = "'Rd, 'Wn";
455 const char *form_bfiz = "'Rd, 'Rn, 'IBZ-r, 'IBs+1"; 455 const char *form_bfiz = "'Rd, 'Rn, 'IBZ-r, 'IBs+1";
456 const char *form_bfx = "'Rd, 'Rn, 'IBr, 'IBs-r+1"; 456 const char *form_bfx = "'Rd, 'Rn, 'IBr, 'IBs-r+1";
457 const char *form_lsl = "'Rd, 'Rn, 'IBZ-r"; 457 const char *form_lsl = "'Rd, 'Rn, 'IBZ-r";
458 458
459 switch (instr->Mask(BitfieldMask)) { 459 switch (instr->Mask(BitfieldMask)) {
460 case SBFM_w: 460 case SBFM_w:
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 case 'S': { // IS - Test and branch bit. 1481 case 'S': { // IS - Test and branch bit.
1482 AppendToOutput("#%d", (instr->ImmTestBranchBit5() << 5) | 1482 AppendToOutput("#%d", (instr->ImmTestBranchBit5() << 5) |
1483 instr->ImmTestBranchBit40()); 1483 instr->ImmTestBranchBit40());
1484 return 2; 1484 return 2;
1485 } 1485 }
1486 case 'D': { // IDebug - HLT and BRK instructions. 1486 case 'D': { // IDebug - HLT and BRK instructions.
1487 AppendToOutput("#0x%x", instr->ImmException()); 1487 AppendToOutput("#0x%x", instr->ImmException());
1488 return 6; 1488 return 6;
1489 } 1489 }
1490 default: { 1490 default: {
1491 UNIMPLEMENTED(); 1491 UNREACHABLE();
1492 return 0; 1492 return 0;
1493 } 1493 }
1494 } 1494 }
1495 } 1495 }
1496 1496
1497 1497
1498 int Disassembler::SubstituteBitfieldImmediateField(Instruction* instr, 1498 int Disassembler::SubstituteBitfieldImmediateField(Instruction* instr,
1499 const char* format) { 1499 const char* format) {
1500 ASSERT((format[0] == 'I') && (format[1] == 'B')); 1500 ASSERT((format[0] == 'I') && (format[1] == 'B'));
1501 unsigned r = instr->ImmR(); 1501 unsigned r = instr->ImmR();
1502 unsigned s = instr->ImmS(); 1502 unsigned s = instr->ImmS();
1503 1503
1504 switch (format[2]) { 1504 switch (format[2]) {
1505 case 'r': { // IBr. 1505 case 'r': { // IBr.
1506 AppendToOutput("#%d", r); 1506 AppendToOutput("#%d", r);
1507 return 3; 1507 return 3;
1508 } 1508 }
1509 case 's': { // IBs+1 or IBs-r+1. 1509 case 's': { // IBs+1 or IBs-r+1.
1510 if (format[3] == '+') { 1510 if (format[3] == '+') {
1511 AppendToOutput("#%d", s + 1); 1511 AppendToOutput("#%d", s + 1);
1512 return 5; 1512 return 5;
1513 } else { 1513 } else {
1514 ASSERT(format[3] == '-'); 1514 ASSERT(format[3] == '-');
1515 AppendToOutput("#%d", s - r + 1); 1515 AppendToOutput("#%d", s - r + 1);
1516 return 7; 1516 return 7;
1517 } 1517 }
1518 } 1518 }
1519 case 'Z': { // IBZ-r. 1519 case 'Z': { // IBZ-r.
1520 ASSERT((format[3] == '-') && (format[4] == 'r')); 1520 ASSERT((format[3] == '-') && (format[4] == 'r'));
1521 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize; 1521 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSizeInBits
1522 : kWRegSizeInBits;
1522 AppendToOutput("#%d", reg_size - r); 1523 AppendToOutput("#%d", reg_size - r);
1523 return 5; 1524 return 5;
1524 } 1525 }
1525 default: { 1526 default: {
1526 UNREACHABLE(); 1527 UNREACHABLE();
1527 return 0; 1528 return 0;
1528 } 1529 }
1529 } 1530 }
1530 } 1531 }
1531 1532
(...skipping 25 matching lines...) Expand all
1557 } // Fall through. 1558 } // Fall through.
1558 case 'L': { // HLo. 1559 case 'L': { // HLo.
1559 if (instr->ImmDPShift() != 0) { 1560 if (instr->ImmDPShift() != 0) {
1560 const char* shift_type[] = {"lsl", "lsr", "asr", "ror"}; 1561 const char* shift_type[] = {"lsl", "lsr", "asr", "ror"};
1561 AppendToOutput(", %s #%" PRId64, shift_type[instr->ShiftDP()], 1562 AppendToOutput(", %s #%" PRId64, shift_type[instr->ShiftDP()],
1562 instr->ImmDPShift()); 1563 instr->ImmDPShift());
1563 } 1564 }
1564 return 3; 1565 return 3;
1565 } 1566 }
1566 default: 1567 default:
1567 UNIMPLEMENTED(); 1568 UNREACHABLE();
1568 return 0; 1569 return 0;
1569 } 1570 }
1570 } 1571 }
1571 1572
1572 1573
1573 int Disassembler::SubstituteConditionField(Instruction* instr, 1574 int Disassembler::SubstituteConditionField(Instruction* instr,
1574 const char* format) { 1575 const char* format) {
1575 ASSERT(format[0] == 'C'); 1576 ASSERT(format[0] == 'C');
1576 const char* condition_code[] = { "eq", "ne", "hs", "lo", 1577 const char* condition_code[] = { "eq", "ne", "hs", "lo",
1577 "mi", "pl", "vs", "vc", 1578 "mi", "pl", "vs", "vc",
(...skipping 21 matching lines...) Expand all
1599 int offset = instr->ImmPCRel(); 1600 int offset = instr->ImmPCRel();
1600 1601
1601 // Only ADR (AddrPCRelByte) is supported. 1602 // Only ADR (AddrPCRelByte) is supported.
1602 ASSERT(strcmp(format, "AddrPCRelByte") == 0); 1603 ASSERT(strcmp(format, "AddrPCRelByte") == 0);
1603 1604
1604 char sign = '+'; 1605 char sign = '+';
1605 if (offset < 0) { 1606 if (offset < 0) {
1606 offset = -offset; 1607 offset = -offset;
1607 sign = '-'; 1608 sign = '-';
1608 } 1609 }
1609 // TODO(jbramley): Can we print the target address here? 1610 STATIC_ASSERT(sizeof(*instr) == 1);
1610 AppendToOutput("#%c0x%x", sign, offset); 1611 AppendToOutput("#%c0x%x (addr %p)", sign, offset, instr + offset);
1611 return 13; 1612 return 13;
1612 } 1613 }
1613 1614
1614 1615
1615 int Disassembler::SubstituteBranchTargetField(Instruction* instr, 1616 int Disassembler::SubstituteBranchTargetField(Instruction* instr,
1616 const char* format) { 1617 const char* format) {
1617 ASSERT(strncmp(format, "BImm", 4) == 0); 1618 ASSERT(strncmp(format, "BImm", 4) == 0);
1618 1619
1619 int64_t offset = 0; 1620 int64_t offset = 0;
1620 switch (format[5]) { 1621 switch (format[5]) {
1621 // BImmUncn - unconditional branch immediate. 1622 // BImmUncn - unconditional branch immediate.
1622 case 'n': offset = instr->ImmUncondBranch(); break; 1623 case 'n': offset = instr->ImmUncondBranch(); break;
1623 // BImmCond - conditional branch immediate. 1624 // BImmCond - conditional branch immediate.
1624 case 'o': offset = instr->ImmCondBranch(); break; 1625 case 'o': offset = instr->ImmCondBranch(); break;
1625 // BImmCmpa - compare and branch immediate. 1626 // BImmCmpa - compare and branch immediate.
1626 case 'm': offset = instr->ImmCmpBranch(); break; 1627 case 'm': offset = instr->ImmCmpBranch(); break;
1627 // BImmTest - test and branch immediate. 1628 // BImmTest - test and branch immediate.
1628 case 'e': offset = instr->ImmTestBranch(); break; 1629 case 'e': offset = instr->ImmTestBranch(); break;
1629 default: UNIMPLEMENTED(); 1630 default: UNREACHABLE();
1630 } 1631 }
1631 offset <<= kInstructionSizeLog2; 1632 offset <<= kInstructionSizeLog2;
1632 char sign = '+'; 1633 char sign = '+';
1633 if (offset < 0) { 1634 if (offset < 0) {
1634 offset = -offset; 1635 offset = -offset;
1635 sign = '-'; 1636 sign = '-';
1636 } 1637 }
1637 // TODO(mcapewel): look up pc + offset in label table. 1638 STATIC_ASSERT(sizeof(*instr) == 1);
1638 AppendToOutput("#%c0x%" PRIx64, sign, offset); 1639 AppendToOutput("#%c0x%" PRIx64 " (addr %p)", sign, offset, instr + offset);
1639 return 8; 1640 return 8;
1640 } 1641 }
1641 1642
1642 1643
1643 int Disassembler::SubstituteExtendField(Instruction* instr, 1644 int Disassembler::SubstituteExtendField(Instruction* instr,
1644 const char* format) { 1645 const char* format) {
1645 ASSERT(strncmp(format, "Ext", 3) == 0); 1646 ASSERT(strncmp(format, "Ext", 3) == 0);
1646 ASSERT(instr->ExtendMode() <= 7); 1647 ASSERT(instr->ExtendMode() <= 7);
1647 USE(format); 1648 USE(format);
1648 1649
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 decoder.AppendVisitor(&disasm); 1847 decoder.AppendVisitor(&disasm);
1847 1848
1848 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) { 1849 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) {
1849 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc)); 1850 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc));
1850 } 1851 }
1851 } 1852 }
1852 1853
1853 } // namespace disasm 1854 } // namespace disasm
1854 1855
1855 #endif // V8_TARGET_ARCH_A64 1856 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « src/a64/deoptimizer-a64.cc ('k') | src/a64/frames-a64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698