OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
6 | 6 |
7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
8 #if defined(TARGET_ARCH_ARM) | 8 #if defined(TARGET_ARCH_ARM) |
| 9 |
9 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 11 #include "vm/cpu.h" |
10 | 12 |
11 namespace dart { | 13 namespace dart { |
12 | 14 |
13 class ARMDecoder : public ValueObject { | 15 class ARMDecoder : public ValueObject { |
14 public: | 16 public: |
15 ARMDecoder(char* buffer, size_t buffer_size) | 17 ARMDecoder(char* buffer, size_t buffer_size) |
16 : buffer_(buffer), | 18 : buffer_(buffer), |
17 buffer_size_(buffer_size), | 19 buffer_size_(buffer_size), |
18 buffer_pos_(0) { | 20 buffer_pos_(0) { |
19 buffer_[buffer_pos_] = '\0'; | 21 buffer_[buffer_pos_] = '\0'; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 689 } |
688 break; | 690 break; |
689 } | 691 } |
690 default: { | 692 default: { |
691 Unknown(instr); // Not used. | 693 Unknown(instr); // Not used. |
692 break; | 694 break; |
693 } | 695 } |
694 } | 696 } |
695 } else if (instr->IsMultiplyOrSyncPrimitive()) { | 697 } else if (instr->IsMultiplyOrSyncPrimitive()) { |
696 if (instr->Bit(24) == 0) { | 698 if (instr->Bit(24) == 0) { |
| 699 if ((TargetCPUFeatures::arm_version() != ARMv7) && |
| 700 (instr->Bits(21, 3) != 0)) { |
| 701 // mla ... smlal only supported on armv7. |
| 702 Unknown(instr); |
| 703 return; |
| 704 } |
697 // multiply instructions | 705 // multiply instructions |
698 switch (instr->Bits(21, 3)) { | 706 switch (instr->Bits(21, 3)) { |
699 case 0: { | 707 case 0: { |
700 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. | 708 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. |
701 Format(instr, "mul'cond's 'rn, 'rm, 'rs"); | 709 Format(instr, "mul'cond's 'rn, 'rm, 'rs"); |
702 break; | 710 break; |
703 } | 711 } |
704 case 1: { | 712 case 1: { |
705 // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd. | 713 // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd. |
706 Format(instr, "mla'cond's 'rn, 'rm, 'rs, 'rd"); | 714 Format(instr, "mla'cond's 'rn, 'rm, 'rs, 'rd"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 default: { | 758 default: { |
751 Unknown(instr); // Not used. | 759 Unknown(instr); // Not used. |
752 break; | 760 break; |
753 } | 761 } |
754 } | 762 } |
755 } | 763 } |
756 } else if (instr->Bit(25) == 1) { | 764 } else if (instr->Bit(25) == 1) { |
757 // 16-bit immediate loads, msr (immediate), and hints | 765 // 16-bit immediate loads, msr (immediate), and hints |
758 switch (instr->Bits(20, 5)) { | 766 switch (instr->Bits(20, 5)) { |
759 case 16: { | 767 case 16: { |
760 Format(instr, "movw'cond 'rd, #'imm4_12"); | 768 if (TargetCPUFeatures::arm_version() == ARMv7) { |
| 769 Format(instr, "movw'cond 'rd, #'imm4_12"); |
| 770 } else { |
| 771 Unknown(instr); |
| 772 } |
761 break; | 773 break; |
762 } | 774 } |
763 case 18: { | 775 case 18: { |
764 if ((instr->Bits(16, 4) == 0) && (instr->Bits(0, 8) == 0)) { | 776 if ((instr->Bits(16, 4) == 0) && (instr->Bits(0, 8) == 0)) { |
765 Format(instr, "nop'cond"); | 777 Format(instr, "nop'cond"); |
766 } else { | 778 } else { |
767 Unknown(instr); // Not used. | 779 Unknown(instr); // Not used. |
768 } | 780 } |
769 break; | 781 break; |
770 } | 782 } |
771 case 20: { | 783 case 20: { |
772 Format(instr, "movt'cond 'rd, #'imm4_12"); | 784 if (TargetCPUFeatures::arm_version() == ARMv7) { |
| 785 Format(instr, "movt'cond 'rd, #'imm4_12"); |
| 786 } else { |
| 787 Unknown(instr); |
| 788 } |
773 break; | 789 break; |
774 } | 790 } |
775 default: { | 791 default: { |
776 Unknown(instr); // Not used. | 792 Unknown(instr); // Not used. |
777 break; | 793 break; |
778 } | 794 } |
779 } | 795 } |
780 } else { | 796 } else { |
781 // extra load/store instructions | 797 // extra load/store instructions |
782 switch (instr->PUField()) { | 798 switch (instr->PUField()) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 // The PU field is a 2-bit field. | 957 // The PU field is a 2-bit field. |
942 UNREACHABLE(); | 958 UNREACHABLE(); |
943 break; | 959 break; |
944 } | 960 } |
945 } | 961 } |
946 } | 962 } |
947 | 963 |
948 | 964 |
949 void ARMDecoder::DecodeType3(Instr* instr) { | 965 void ARMDecoder::DecodeType3(Instr* instr) { |
950 if (instr->IsDivision()) { | 966 if (instr->IsDivision()) { |
| 967 if (!TargetCPUFeatures::integer_division_supported()) { |
| 968 Unknown(instr); |
| 969 return; |
| 970 } |
951 if (instr->Bit(21)) { | 971 if (instr->Bit(21)) { |
952 Format(instr, "udiv'cond 'rn, 'rs, 'rm"); | 972 Format(instr, "udiv'cond 'rn, 'rs, 'rm"); |
953 } else { | 973 } else { |
954 Format(instr, "sdiv'cond 'rn, 'rs, 'rm"); | 974 Format(instr, "sdiv'cond 'rn, 'rs, 'rm"); |
955 } | 975 } |
956 return; | 976 return; |
957 } | 977 } |
958 switch (instr->PUField()) { | 978 switch (instr->PUField()) { |
959 case 0: { | 979 case 0: { |
960 if (instr->HasW()) { | 980 if (instr->HasW()) { |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 human_buffer, | 1546 human_buffer, |
1527 sizeof(human_buffer), | 1547 sizeof(human_buffer), |
1528 pc); | 1548 pc); |
1529 pc += instruction_length; | 1549 pc += instruction_length; |
1530 } | 1550 } |
1531 } | 1551 } |
1532 | 1552 |
1533 } // namespace dart | 1553 } // namespace dart |
1534 | 1554 |
1535 #endif // defined TARGET_ARCH_ARM | 1555 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |