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

Side by Side Diff: src/arm/assembler-thumb.cc

Issue 23536056: Thumb2 Backend: Enable Assembler to encode Thumb2 instructions Base URL: HEAD^
Patch Set: Created 7 years, 2 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
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/constants-arm.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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 uint32_t j2 = (imm >> 18) & 1; 723 uint32_t j2 = (imm >> 18) & 1;
724 uint32_t s = (imm >> 19) & 1; 724 uint32_t s = (imm >> 19) & 1;
725 emit32(thumb32_mode4(B_32_3) | s*BH10 | cond_thumb*BH6 | 725 emit32(thumb32_mode4(B_32_3) | s*BH10 | cond_thumb*BH6 |
726 imm6*BH0 | j1*B13 | j2*B11 | imm11); 726 imm6*BH0 | j1*B13 | j2*B11 | imm11);
727 return; 727 return;
728 } 728 }
729 UNREACHABLE(); 729 UNREACHABLE();
730 } 730 }
731 731
732 732
733 int Assembler::target_at_thumb(int pos) {
734 Instr16 tinstr = thumb16_instr_at(pos);
735 if (((tinstr >> 12) & 0xf) == 13) {
736 int imm9 = (tinstr << 24) >> 23;
737 ASSERT(is_int9(imm9));
738 return pos + kThumbPcLoadDelta + imm9;
739 } else if (((tinstr >> 11) & 0x1f) == 28) {
740 int imm12 = (tinstr << 21) >> 20;
741 ASSERT(is_int12(imm12));
742 return pos + kThumbPcLoadDelta + imm12;
743 }
744 Instr tinstr32 = thumb32_instr_at(pos);
745 if ((tinstr32 & B12) == 0) {
746 int s = (tinstr32 & BH10) >> 7;
747 int j2 = (tinstr32 & B11) << 7;
748 int j1 = (tinstr32 & B13) << 4;
749 int imm6 = (tinstr32 & (0x3f * BH0)) >> 5;
750 int imm11 = tinstr32 & 0x7ff;
751 int imm20 = (s | j2 | j1 | imm6 | imm11);
752 int imm21 = (imm20 << 12) >> 11;
753 ASSERT(is_int21(imm21));
754 return pos + kThumbPcLoadDelta + imm21;
755 } else {
756 int s = (tinstr32 & BH10) >> 26;
757 int j2 = (tinstr32 & B11) >> 11;
758 int j1 = (tinstr32 & B13) >> 13;
759 int imm10 = (tinstr32 & (0x3ff * BH0)) >> 5;
760 int imm11 = tinstr32 & 0x7ff;
761 int i1 = !(j1 ^ s);
762 int i2 = !(j2 ^ s);
763 int imm24 = (s*B23 | i1*B22 | i2*B21 | imm10 | imm11);
764 int imm25 = (imm24 << 8) >> 7;
765 return pos + kThumbPcLoadDelta + imm25;
766 }
767 UNREACHABLE();
768 return 0;
769 }
770
771
772 void Assembler::target_at_put_thumb(int pos, int target_pos) {
773 int imm = (target_pos - (pos + kThumbPcLoadDelta)) >> 1;
774 Instr16 tinstr = thumb16_instr_at(pos);
775 if (((tinstr >> 12) & 0xf) == 13) {
776 ASSERT(is_int8(imm));
777 tinstr &= ~0xff;
778 thumb16_instr_at_put(pos, tinstr | (imm & 0xff));
779 return;
780 } else if (((tinstr >> 11) & 0x1f) == 28) {
781 ASSERT(is_int11(imm));
782 tinstr &= ~0x7ff;
783 thumb16_instr_at_put(pos, tinstr | (imm & 0x7ff));
784 return;
785 }
786
787 Instr tinstr32 = thumb32_instr_at(pos);
788 if ((tinstr32 & B12) == 0) {
789 tinstr32 &= ~(BH10 | (0x3f*BH0) | B13 | B11 | 0x7ff);
790 ASSERT(is_int20(imm));
791 uint32_t imm11 = imm & 0x7ff;
792 uint32_t imm6 = (imm >> 11) & 0x3f;
793 uint32_t j1 = (imm >> 17) & 1;
794 uint32_t j2 = (imm >> 18) & 1;
795 uint32_t s = (imm >> 19) & 1;
796 tinstr32 |= s*BH10 | imm6*BH0 | j1*B13 | j2*B11 | imm11;
797 thumb32_instr_at_put(pos, tinstr32);
798 return;
799 } else {
800 ASSERT(is_int24(imm));
801 tinstr32 &= ~(BH10 | (0x3ff*BH0) | B13 | B11 | 0x7ff);
802 tinstr32 |= thumb32_sign_extend_imm24(imm);
803 thumb32_instr_at_put(pos, tinstr32);
804 }
805 }
806
807
733 // from ldr_thumb_reg 808 // from ldr_thumb_reg
734 bool Assembler::fits_thumb16_mode_4_1(Register reg, const MemOperand& op) { 809 bool Assembler::fits_thumb16_mode_4_1(Register reg, const MemOperand& op) {
735 return (is_uint3(op.rm().code()) && 810 return (is_uint3(op.rm().code()) &&
736 is_uint3(op.rn().code()) && 811 is_uint3(op.rn().code()) &&
737 is_uint3(reg.code()) && 812 is_uint3(reg.code()) &&
738 op.shift_imm_ == 0); 813 op.shift_imm_ == 0);
739 } 814 }
740 815
741 816
742 // other than 4_1 and 4_5 817 // other than 4_1 and 4_5
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 1346
1272 1347
1273 void Assembler::ldr_pc_thumb(Register dst, const Operand& src) { 1348 void Assembler::ldr_pc_thumb(Register dst, const Operand& src) {
1274 RecordRelocInfo(src.rmode_, src.imm32_, USE_CONSTANT_POOL); 1349 RecordRelocInfo(src.rmode_, src.imm32_, USE_CONSTANT_POOL);
1275 ldr_thumb(dst, MemOperand(pc, 0)); 1350 ldr_thumb(dst, MemOperand(pc, 0));
1276 } 1351 }
1277 1352
1278 } } // namespace v8::internal 1353 } } // namespace v8::internal
1279 1354
1280 #endif // V8_TARGET_ARCH_ARM 1355 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/constants-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698