Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 private: | 94 private: |
| 95 // Bottleneck functions to print into the out_buffer. | 95 // Bottleneck functions to print into the out_buffer. |
| 96 void PrintChar(const char ch); | 96 void PrintChar(const char ch); |
| 97 void Print(const char* str); | 97 void Print(const char* str); |
| 98 | 98 |
| 99 // Printing of common values. | 99 // Printing of common values. |
| 100 void PrintRegister(int reg); | 100 void PrintRegister(int reg); |
| 101 void PrintSRegister(int reg); | 101 void PrintSRegister(int reg); |
| 102 void PrintDRegister(int reg); | 102 void PrintDRegister(int reg); |
| 103 int FormatVFPRegister(Instr* instr, const char* format); | 103 int FormatVFPRegister(Instr* instr, const char* format); |
| 104 void PrintMovwMovt(Instr* instr); | |
| 104 int FormatVFPinstruction(Instr* instr, const char* format); | 105 int FormatVFPinstruction(Instr* instr, const char* format); |
| 105 void PrintCondition(Instr* instr); | 106 void PrintCondition(Instr* instr); |
| 106 void PrintShiftRm(Instr* instr); | 107 void PrintShiftRm(Instr* instr); |
| 107 void PrintShiftImm(Instr* instr); | 108 void PrintShiftImm(Instr* instr); |
| 108 void PrintPU(Instr* instr); | 109 void PrintPU(Instr* instr); |
| 109 void PrintSoftwareInterrupt(SoftwareInterruptCodes swi); | 110 void PrintSoftwareInterrupt(SoftwareInterruptCodes swi); |
| 110 | 111 |
| 111 // Handle formatting of instructions and their options. | 112 // Handle formatting of instructions and their options. |
| 112 int FormatRegister(Instr* instr, const char* option); | 113 int FormatRegister(Instr* instr, const char* option); |
| 113 int FormatOption(Instr* instr, const char* option); | 114 int FormatOption(Instr* instr, const char* option); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 return -1; | 369 return -1; |
| 369 } | 370 } |
| 370 | 371 |
| 371 | 372 |
| 372 int Decoder::FormatVFPinstruction(Instr* instr, const char* format) { | 373 int Decoder::FormatVFPinstruction(Instr* instr, const char* format) { |
| 373 Print(format); | 374 Print(format); |
| 374 return 0; | 375 return 0; |
| 375 } | 376 } |
| 376 | 377 |
| 377 | 378 |
| 379 // Print the movw or movt instruction. | |
| 380 void Decoder::PrintMovwMovt(Instr* instr) { | |
| 381 int imm = instr->ImmedMovwMovtField(); | |
| 382 int rd = instr->RdField(); | |
| 383 PrintRegister(rd); | |
| 384 if (instr->Bit(22) == 1) { | |
| 385 // Movt instruction. | |
| 386 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | |
|
Søren Thygesen Gjesse
2010/06/21 21:39:26
According to the ARM reference manual the assemble
| |
| 387 ", #0x%04x0000", imm); | |
| 388 } else { | |
| 389 // Movw instruction | |
| 390 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | |
| 391 ", #0x%04x", imm); | |
| 392 } | |
| 393 } | |
| 394 | |
| 395 | |
| 378 // FormatOption takes a formatting string and interprets it based on | 396 // FormatOption takes a formatting string and interprets it based on |
| 379 // the current instructions. The format string points to the first | 397 // the current instructions. The format string points to the first |
| 380 // character of the option string (the option escape has already been | 398 // character of the option string (the option escape has already been |
| 381 // consumed by the caller.) FormatOption returns the number of | 399 // consumed by the caller.) FormatOption returns the number of |
| 382 // characters that were consumed from the formatting string. | 400 // characters that were consumed from the formatting string. |
| 383 int Decoder::FormatOption(Instr* instr, const char* format) { | 401 int Decoder::FormatOption(Instr* instr, const char* format) { |
| 384 switch (format[0]) { | 402 switch (format[0]) { |
| 385 case 'a': { // 'a: accumulate multiplies | 403 case 'a': { // 'a: accumulate multiplies |
| 386 if (instr->Bit(21) == 0) { | 404 if (instr->Bit(21) == 0) { |
| 387 Print("ul"); | 405 Print("ul"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 } | 441 } |
| 424 return 1; | 442 return 1; |
| 425 } | 443 } |
| 426 case 'l': { // 'l: branch and link | 444 case 'l': { // 'l: branch and link |
| 427 if (instr->HasLink()) { | 445 if (instr->HasLink()) { |
| 428 Print("l"); | 446 Print("l"); |
| 429 } | 447 } |
| 430 return 1; | 448 return 1; |
| 431 } | 449 } |
| 432 case 'm': { | 450 case 'm': { |
| 433 if (format[1] == 'e') { // 'memop: load/store instructions | 451 if ((format[1] == 't') || (format[1] == 'w')) { |
| 452 // 't and 'w: movt/movw instructions. | |
| 453 PrintMovwMovt(instr); | |
| 454 return 2; | |
| 455 } | |
| 456 if (format[1] == 'e') { // 'memop: load/store instructions. | |
| 434 ASSERT(STRING_STARTS_WITH(format, "memop")); | 457 ASSERT(STRING_STARTS_WITH(format, "memop")); |
| 435 if (instr->HasL()) { | 458 if (instr->HasL()) { |
| 436 Print("ldr"); | 459 Print("ldr"); |
| 437 } else if ((instr->Bits(27, 25) == 0) && (instr->Bit(20) == 0)) { | 460 } else if ((instr->Bits(27, 25) == 0) && (instr->Bit(20) == 0)) { |
| 438 if (instr->Bits(7, 4) == 0xf) { | 461 if (instr->Bits(7, 4) == 0xf) { |
| 439 Print("strd"); | 462 Print("strd"); |
| 440 } else { | 463 } else { |
| 441 Print("ldrd"); | 464 Print("ldrd"); |
| 442 } | 465 } |
| 443 } else { | 466 } else { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 break; | 792 break; |
| 770 } | 793 } |
| 771 case RSC: { | 794 case RSC: { |
| 772 Format(instr, "rsc'cond's 'rd, 'rn, 'shift_op"); | 795 Format(instr, "rsc'cond's 'rd, 'rn, 'shift_op"); |
| 773 break; | 796 break; |
| 774 } | 797 } |
| 775 case TST: { | 798 case TST: { |
| 776 if (instr->HasS()) { | 799 if (instr->HasS()) { |
| 777 Format(instr, "tst'cond 'rn, 'shift_op"); | 800 Format(instr, "tst'cond 'rn, 'shift_op"); |
| 778 } else { | 801 } else { |
| 779 Unknown(instr); // not used by V8 | 802 Format(instr, "movw'cond 'mw"); |
| 780 } | 803 } |
| 781 break; | 804 break; |
| 782 } | 805 } |
| 783 case TEQ: { | 806 case TEQ: { |
| 784 if (instr->HasS()) { | 807 if (instr->HasS()) { |
| 785 Format(instr, "teq'cond 'rn, 'shift_op"); | 808 Format(instr, "teq'cond 'rn, 'shift_op"); |
| 786 } else { | 809 } else { |
| 787 // Other instructions matching this pattern are handled in the | 810 // Other instructions matching this pattern are handled in the |
| 788 // miscellaneous instructions part above. | 811 // miscellaneous instructions part above. |
| 789 UNREACHABLE(); | 812 UNREACHABLE(); |
| 790 } | 813 } |
| 791 break; | 814 break; |
| 792 } | 815 } |
| 793 case CMP: { | 816 case CMP: { |
| 794 if (instr->HasS()) { | 817 if (instr->HasS()) { |
| 795 Format(instr, "cmp'cond 'rn, 'shift_op"); | 818 Format(instr, "cmp'cond 'rn, 'shift_op"); |
| 796 } else { | 819 } else { |
| 797 Unknown(instr); // not used by V8 | 820 Format(instr, "movt'cond 'mt"); |
| 798 } | 821 } |
| 799 break; | 822 break; |
| 800 } | 823 } |
| 801 case CMN: { | 824 case CMN: { |
| 802 if (instr->HasS()) { | 825 if (instr->HasS()) { |
| 803 Format(instr, "cmn'cond 'rn, 'shift_op"); | 826 Format(instr, "cmn'cond 'rn, 'shift_op"); |
| 804 } else { | 827 } else { |
| 805 // Other instructions matching this pattern are handled in the | 828 // Other instructions matching this pattern are handled in the |
| 806 // miscellaneous instructions part above. | 829 // miscellaneous instructions part above. |
| 807 UNREACHABLE(); | 830 UNREACHABLE(); |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1373 pc += d.InstructionDecode(buffer, pc); | 1396 pc += d.InstructionDecode(buffer, pc); |
| 1374 fprintf(f, "%p %08x %s\n", | 1397 fprintf(f, "%p %08x %s\n", |
| 1375 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1398 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1376 } | 1399 } |
| 1377 } | 1400 } |
| 1378 | 1401 |
| 1379 | 1402 |
| 1380 } // namespace disasm | 1403 } // namespace disasm |
| 1381 | 1404 |
| 1382 #endif // V8_TARGET_ARCH_ARM | 1405 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |