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

Side by Side Diff: runtime/vm/intrinsifier_mips.cc

Issue 1121613003: Implement bigint shift intrinsics on MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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 | « runtime/vm/intrinsifier_arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/globals.h" // Needed here to get TARGET_ARCH_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 __ delay_slot()->addiu(V0, V0, Immediate(-1)); // Remove inverted smi-tag. 786 __ delay_slot()->addiu(V0, V0, Immediate(-1)); // Remove inverted smi-tag.
787 } 787 }
788 788
789 789
790 void Intrinsifier::Smi_bitLength(Assembler* assembler) { 790 void Intrinsifier::Smi_bitLength(Assembler* assembler) {
791 // TODO(sra): Implement. 791 // TODO(sra): Implement.
792 } 792 }
793 793
794 794
795 void Intrinsifier::Bigint_lsh(Assembler* assembler) { 795 void Intrinsifier::Bigint_lsh(Assembler* assembler) {
796 // TODO(regis): Implement. 796 // static void _lsh(Uint32List x_digits, int x_used, int n,
797 // Uint32List r_digits)
798
799 // T2 = x_used, T3 = x_digits, x_used > 0, x_used is Smi.
800 __ lw(T2, Address(SP, 2 * kWordSize));
801 __ lw(T3, Address(SP, 3 * kWordSize));
802 // T4 = r_digits, T5 = n, n is Smi, n % _DIGIT_BITS != 0.
803 __ lw(T4, Address(SP, 0 * kWordSize));
804 __ lw(T5, Address(SP, 1 * kWordSize));
805 __ SmiUntag(T5);
806 // T0 = n ~/ _DIGIT_BITS
807 __ sra(T0, T5, 5);
808 // T6 = &x_digits[0]
809 __ addiu(T6, T3, Immediate(TypedData::data_offset() - kHeapObjectTag));
810 // V0 = &x_digits[x_used]
811 __ sll(T2, T2, 1);
812 __ addu(V0, T6, T2);
813 // V1 = &r_digits[1]
814 __ addiu(V1, T4, Immediate(TypedData::data_offset() - kHeapObjectTag +
815 Bigint::kBytesPerDigit));
816 // V1 = &r_digits[x_used + n ~/ _DIGIT_BITS + 1]
817 __ addu(V1, V1, T2);
818 __ sll(T1, T0, 2);
819 __ addu(V1, V1, T1);
820 // T3 = n % _DIGIT_BITS
821 __ andi(T3, T5, Immediate(31));
822 // T2 = 32 - T3
823 __ subu(T2, ZR, T3);
824 __ addiu(T2, T2, Immediate(32));
825 __ mov(T1, ZR);
826 Label loop;
827 __ Bind(&loop);
828 __ addiu(V0, V0, Immediate(-Bigint::kBytesPerDigit));
829 __ lw(T0, Address(V0, 0));
830 __ srlv(AT, T0, T2);
831 __ or_(T1, T1, AT);
832 __ addiu(V1, V1, Immediate(-Bigint::kBytesPerDigit));
833 __ sw(T1, Address(V1, 0));
834 __ bne(V0, T6, &loop);
835 __ delay_slot()->sllv(T1, T0, T3);
836 __ sw(T1, Address(V1, -Bigint::kBytesPerDigit));
837 // Returning Object::null() is not required, since this method is private.
838 __ Ret();
797 } 839 }
798 840
799 841
800 void Intrinsifier::Bigint_rsh(Assembler* assembler) { 842 void Intrinsifier::Bigint_rsh(Assembler* assembler) {
801 // TODO(regis): Implement. 843 // static void _lsh(Uint32List x_digits, int x_used, int n,
844 // Uint32List r_digits)
845
846 // T2 = x_used, T3 = x_digits, x_used > 0, x_used is Smi.
847 __ lw(T2, Address(SP, 2 * kWordSize));
848 __ lw(T3, Address(SP, 3 * kWordSize));
849 // T4 = r_digits, T5 = n, n is Smi, n % _DIGIT_BITS != 0.
850 __ lw(T4, Address(SP, 0 * kWordSize));
851 __ lw(T5, Address(SP, 1 * kWordSize));
852 __ SmiUntag(T5);
853 // T0 = n ~/ _DIGIT_BITS
854 __ sra(T0, T5, 5);
855 // V1 = &r_digits[0]
856 __ addiu(V1, T4, Immediate(TypedData::data_offset() - kHeapObjectTag));
857 // V0 = &x_digits[n ~/ _DIGIT_BITS]
858 __ addiu(V0, T3, Immediate(TypedData::data_offset() - kHeapObjectTag));
859 __ sll(T1, T0, 2);
860 __ addu(V0, V0, T1);
861 // T6 = &r_digits[x_used - n ~/ _DIGIT_BITS - 1]
862 __ sll(T2, T2, 1);
863 __ addu(T6, V1, T2);
864 __ subu(T6, T6, T1);
865 __ addiu(T6, T6, Immediate(-4));
866 // T3 = n % _DIGIT_BITS
867 __ andi(T3, T5, Immediate(31));
868 // T2 = 32 - T3
869 __ subu(T2, ZR, T3);
870 __ addiu(T2, T2, Immediate(32));
871 Label loop_exit;
872 __ beq(V1, T6, &loop_exit);
873 __ delay_slot()->mov(T1, ZR);
874 Label loop;
875 __ Bind(&loop);
876 __ lw(T0, Address(V0, 0));
877 __ addiu(V0, V0, Immediate(Bigint::kBytesPerDigit));
878 __ sllv(AT, T0, T2);
879 __ or_(T1, T1, AT);
880 __ sw(T1, Address(V1, 0));
881 __ addiu(V1, V1, Immediate(Bigint::kBytesPerDigit));
882 __ bne(V1, T6, &loop);
883 __ delay_slot()->srlv(T1, T0, T3);
884 __ Bind(&loop_exit);
885 __ sw(T1, Address(V1, 0));
886 // Returning Object::null() is not required, since this method is private.
887 __ Ret();
802 } 888 }
803 889
804 890
805 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { 891 void Intrinsifier::Bigint_absAdd(Assembler* assembler) {
806 // static void _absAdd(Uint32List digits, int used, 892 // static void _absAdd(Uint32List digits, int used,
807 // Uint32List a_digits, int a_used, 893 // Uint32List a_digits, int a_used,
808 // Uint32List r_digits) 894 // Uint32List r_digits)
809 895
810 // T2 = used, T3 = digits 896 // T2 = used, T3 = digits
811 __ lw(T2, Address(SP, 3 * kWordSize)); 897 __ lw(T2, Address(SP, 3 * kWordSize));
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 Isolate* isolate = Isolate::Current(); 2132 Isolate* isolate = Isolate::Current();
2047 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate)); 2133 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate));
2048 // Set return value. 2134 // Set return value.
2049 __ Ret(); 2135 __ Ret();
2050 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); 2136 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset()));
2051 } 2137 }
2052 2138
2053 } // namespace dart 2139 } // namespace dart
2054 2140
2055 #endif // defined TARGET_ARCH_MIPS 2141 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698