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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 private: | 93 private: |
| 94 // Bottleneck functions to print into the out_buffer. | 94 // Bottleneck functions to print into the out_buffer. |
| 95 void PrintChar(const char ch); | 95 void PrintChar(const char ch); |
| 96 void Print(const char* str); | 96 void Print(const char* str); |
| 97 | 97 |
| 98 // Printing of common values. | 98 // Printing of common values. |
| 99 void PrintRegister(int reg); | 99 void PrintRegister(int reg); |
| 100 void PrintSRegister(int reg); | 100 void PrintSRegister(int reg); |
| 101 void PrintDRegister(int reg); | 101 void PrintDRegister(int reg); |
| 102 int FormatVFPRegister(Instr* instr, const char* format); | 102 int FormatVFPRegister(Instr* instr, const char* format); |
| 103 void PrintMovwMovt(Instr* instr); | |
| 103 int FormatVFPinstruction(Instr* instr, const char* format); | 104 int FormatVFPinstruction(Instr* instr, const char* format); |
| 104 void PrintCondition(Instr* instr); | 105 void PrintCondition(Instr* instr); |
| 105 void PrintShiftRm(Instr* instr); | 106 void PrintShiftRm(Instr* instr); |
| 106 void PrintShiftImm(Instr* instr); | 107 void PrintShiftImm(Instr* instr); |
| 107 void PrintPU(Instr* instr); | 108 void PrintPU(Instr* instr); |
| 108 void PrintSoftwareInterrupt(SoftwareInterruptCodes swi); | 109 void PrintSoftwareInterrupt(SoftwareInterruptCodes swi); |
| 109 | 110 |
| 110 // Handle formatting of instructions and their options. | 111 // Handle formatting of instructions and their options. |
| 111 int FormatRegister(Instr* instr, const char* option); | 112 int FormatRegister(Instr* instr, const char* option); |
| 112 int FormatOption(Instr* instr, const char* option); | 113 int FormatOption(Instr* instr, const char* option); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 return -1; | 368 return -1; |
| 368 } | 369 } |
| 369 | 370 |
| 370 | 371 |
| 371 int Decoder::FormatVFPinstruction(Instr* instr, const char* format) { | 372 int Decoder::FormatVFPinstruction(Instr* instr, const char* format) { |
| 372 Print(format); | 373 Print(format); |
| 373 return 0; | 374 return 0; |
| 374 } | 375 } |
| 375 | 376 |
| 376 | 377 |
| 378 // Print the movw or movt instruction. | |
| 379 void Decoder::PrintMovwMovt(Instr* instr) { | |
| 380 int imm = instr->ImmedMovwMovtField(); | |
| 381 int rd = instr->RdField(); | |
| 382 PrintRegister(rd); | |
| 383 if (instr->Bit(22) == 1) { | |
| 384 // movt instruction. | |
| 385 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | |
| 386 ", #%d0000", imm); | |
|
Erik Corry
2010/05/03 10:06:28
This line has wrong alignment.
| |
| 387 } else { | |
| 388 // movw instruction | |
| 389 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | |
| 390 ", #%d", imm); | |
| 391 } | |
| 392 } | |
| 393 | |
| 394 | |
| 377 // FormatOption takes a formatting string and interprets it based on | 395 // FormatOption takes a formatting string and interprets it based on |
| 378 // the current instructions. The format string points to the first | 396 // the current instructions. The format string points to the first |
| 379 // character of the option string (the option escape has already been | 397 // character of the option string (the option escape has already been |
| 380 // consumed by the caller.) FormatOption returns the number of | 398 // consumed by the caller.) FormatOption returns the number of |
| 381 // characters that were consumed from the formatting string. | 399 // characters that were consumed from the formatting string. |
| 382 int Decoder::FormatOption(Instr* instr, const char* format) { | 400 int Decoder::FormatOption(Instr* instr, const char* format) { |
| 383 switch (format[0]) { | 401 switch (format[0]) { |
| 384 case 'a': { // 'a: accumulate multiplies | 402 case 'a': { // 'a: accumulate multiplies |
| 385 if (instr->Bit(21) == 0) { | 403 if (instr->Bit(21) == 0) { |
| 386 Print("ul"); | 404 Print("ul"); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 408 } | 426 } |
| 409 return 1; | 427 return 1; |
| 410 } | 428 } |
| 411 case 'l': { // 'l: branch and link | 429 case 'l': { // 'l: branch and link |
| 412 if (instr->HasLink()) { | 430 if (instr->HasLink()) { |
| 413 Print("l"); | 431 Print("l"); |
| 414 } | 432 } |
| 415 return 1; | 433 return 1; |
| 416 } | 434 } |
| 417 case 'm': { | 435 case 'm': { |
| 436 if ((format[1] == 't') || (format[1] == 'w')) { | |
| 437 // 't and 'w: movt/movw instructions | |
| 438 PrintMovwMovt(instr); | |
| 439 return 2; | |
| 440 } | |
| 418 if (format[1] == 'e') { // 'memop: load/store instructions | 441 if (format[1] == 'e') { // 'memop: load/store instructions |
| 419 ASSERT(STRING_STARTS_WITH(format, "memop")); | 442 ASSERT(STRING_STARTS_WITH(format, "memop")); |
| 420 if (instr->HasL()) { | 443 if (instr->HasL()) { |
| 421 Print("ldr"); | 444 Print("ldr"); |
| 422 } else { | 445 } else { |
| 423 Print("str"); | 446 Print("str"); |
| 424 } | 447 } |
| 425 return 5; | 448 return 5; |
| 426 } | 449 } |
| 427 // 'msg: for simulator break instructions | 450 // 'msg: for simulator break instructions |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 break; | 704 break; |
| 682 } | 705 } |
| 683 case RSC: { | 706 case RSC: { |
| 684 Format(instr, "rsc'cond's 'rd, 'rn, 'shift_op"); | 707 Format(instr, "rsc'cond's 'rd, 'rn, 'shift_op"); |
| 685 break; | 708 break; |
| 686 } | 709 } |
| 687 case TST: { | 710 case TST: { |
| 688 if (instr->HasS()) { | 711 if (instr->HasS()) { |
| 689 Format(instr, "tst'cond 'rn, 'shift_op"); | 712 Format(instr, "tst'cond 'rn, 'shift_op"); |
| 690 } else { | 713 } else { |
| 691 Unknown(instr); // not used by V8 | 714 Format(instr, "movw'cond 'mw"); |
| 692 } | 715 } |
| 693 break; | 716 break; |
| 694 } | 717 } |
| 695 case TEQ: { | 718 case TEQ: { |
| 696 if (instr->HasS()) { | 719 if (instr->HasS()) { |
| 697 Format(instr, "teq'cond 'rn, 'shift_op"); | 720 Format(instr, "teq'cond 'rn, 'shift_op"); |
| 698 } else { | 721 } else { |
| 699 switch (instr->Bits(7, 4)) { | 722 switch (instr->Bits(7, 4)) { |
| 700 case BX: | 723 case BX: |
| 701 Format(instr, "bx'cond 'rm"); | 724 Format(instr, "bx'cond 'rm"); |
| 702 break; | 725 break; |
| 703 case BLX: | 726 case BLX: |
| 704 Format(instr, "blx'cond 'rm"); | 727 Format(instr, "blx'cond 'rm"); |
| 705 break; | 728 break; |
| 706 default: | 729 default: |
| 707 Unknown(instr); // not used by V8 | 730 Unknown(instr); // not used by V8 |
| 708 break; | 731 break; |
| 709 } | 732 } |
| 710 } | 733 } |
| 711 break; | 734 break; |
| 712 } | 735 } |
| 713 case CMP: { | 736 case CMP: { |
| 714 if (instr->HasS()) { | 737 if (instr->HasS()) { |
| 715 Format(instr, "cmp'cond 'rn, 'shift_op"); | 738 Format(instr, "cmp'cond 'rn, 'shift_op"); |
| 716 } else { | 739 } else { |
| 717 Unknown(instr); // not used by V8 | 740 Format(instr, "movt'cond 'mt"); |
| 718 } | 741 } |
| 719 break; | 742 break; |
| 720 } | 743 } |
| 721 case CMN: { | 744 case CMN: { |
| 722 if (instr->HasS()) { | 745 if (instr->HasS()) { |
| 723 Format(instr, "cmn'cond 'rn, 'shift_op"); | 746 Format(instr, "cmn'cond 'rn, 'shift_op"); |
| 724 } else { | 747 } else { |
| 725 switch (instr->Bits(7, 4)) { | 748 switch (instr->Bits(7, 4)) { |
| 726 case CLZ: | 749 case CLZ: |
| 727 Format(instr, "clz'cond 'rd, 'rm"); | 750 Format(instr, "clz'cond 'rd, 'rm"); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1280 buffer[0] = '\0'; | 1303 buffer[0] = '\0'; |
| 1281 byte* prev_pc = pc; | 1304 byte* prev_pc = pc; |
| 1282 pc += d.InstructionDecode(buffer, pc); | 1305 pc += d.InstructionDecode(buffer, pc); |
| 1283 fprintf(f, "%p %08x %s\n", | 1306 fprintf(f, "%p %08x %s\n", |
| 1284 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1307 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1285 } | 1308 } |
| 1286 } | 1309 } |
| 1287 | 1310 |
| 1288 | 1311 |
| 1289 } // namespace disasm | 1312 } // namespace disasm |
| OLD | NEW |