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

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

Issue 18684008: Begins implementation of ARM neon instructions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
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 <math.h> // for isnan. 5 #include <math.h> // for isnan.
6 #include <setjmp.h> 6 #include <setjmp.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #if defined(TARGET_ARCH_ARM) 10 #if defined(TARGET_ARCH_ARM)
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 dregisters_[reg] = bit_cast<int64_t, double>(value); 916 dregisters_[reg] = bit_cast<int64_t, double>(value);
917 } 917 }
918 918
919 919
920 double Simulator::get_dregister(DRegister reg) const { 920 double Simulator::get_dregister(DRegister reg) const {
921 ASSERT((reg >= 0) && (reg < kNumberOfDRegisters)); 921 ASSERT((reg >= 0) && (reg < kNumberOfDRegisters));
922 return bit_cast<double, int64_t>(dregisters_[reg]); 922 return bit_cast<double, int64_t>(dregisters_[reg]);
923 } 923 }
924 924
925 925
926 void Simulator::set_qregister(QRegister reg, simd_value_t value) {
927 ASSERT((reg >= 0) && (reg < kNumberOfQRegisters));
928 qregisters_[reg].data_[0] = value.data_[0];
929 qregisters_[reg].data_[1] = value.data_[1];
930 qregisters_[reg].data_[2] = value.data_[2];
931 qregisters_[reg].data_[3] = value.data_[3];
932 }
933
934
935 simd_value_t Simulator::get_qregister(QRegister reg) const {
936 ASSERT((reg >= 0) && (reg < kNumberOfQRegisters));
937 return qregisters_[reg];
938 }
939
940
926 void Simulator::set_sregister_bits(SRegister reg, int32_t value) { 941 void Simulator::set_sregister_bits(SRegister reg, int32_t value) {
927 ASSERT((reg >= 0) && (reg < kNumberOfSRegisters)); 942 ASSERT((reg >= 0) && (reg < kNumberOfSRegisters));
928 sregisters_[reg] = value; 943 sregisters_[reg] = value;
929 } 944 }
930 945
931 946
932 int32_t Simulator::get_sregister_bits(SRegister reg) const { 947 int32_t Simulator::get_sregister_bits(SRegister reg) const {
933 ASSERT((reg >= 0) && (reg < kNumberOfSRegisters)); 948 ASSERT((reg >= 0) && (reg < kNumberOfSRegisters));
934 return sregisters_[reg]; 949 return sregisters_[reg];
935 } 950 }
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 } else { 2894 } else {
2880 UnimplementedInstruction(instr); 2895 UnimplementedInstruction(instr);
2881 } 2896 }
2882 } 2897 }
2883 } else { 2898 } else {
2884 UnimplementedInstruction(instr); 2899 UnimplementedInstruction(instr);
2885 } 2900 }
2886 } 2901 }
2887 2902
2888 2903
2904 void Simulator::DecodeSIMDDataProcessing(Instr* instr) {
2905 ASSERT(instr->ConditionField() == kSpecialCondition);
2906
2907 if (instr->Bit(6) == 1) {
2908 // Q = 1, Using 128-bit Q registers.
2909 const QRegister qd = instr->QdField();
2910 const QRegister qn = instr->QnField();
2911 const QRegister qm = instr->QmField();
2912 simd_value_t s8d;
2913 simd_value_t s8n = get_qregister(qn);
2914 simd_value_t s8m = get_qregister(qm);
2915 int8_t* s8d_8 = reinterpret_cast<int8_t*>(&s8d);
2916 int8_t* s8n_8 = reinterpret_cast<int8_t*>(&s8n);
2917 int8_t* s8m_8 = reinterpret_cast<int8_t*>(&s8m);
2918 int16_t* s8d_16 = reinterpret_cast<int16_t*>(&s8d);
2919 int16_t* s8n_16 = reinterpret_cast<int16_t*>(&s8n);
2920 int16_t* s8m_16 = reinterpret_cast<int16_t*>(&s8m);
2921 int64_t* s8d_64 = reinterpret_cast<int64_t*>(&s8d);
2922 int64_t* s8n_64 = reinterpret_cast<int64_t*>(&s8n);
2923 int64_t* s8m_64 = reinterpret_cast<int64_t*>(&s8m);
2924
2925 if ((instr->Bits(8, 4) == 8) && (instr->Bit(4) == 0) &&
2926 (instr->Bit(24) == 0)) {
2927 // Uses q registers.
2928 // Format(instr, "vadd.'sz 'qd, 'qn, 'qm");
2929 const int size = instr->Bits(20, 2);
2930 if (size == 0) {
2931 for (int i = 0; i < 16; i++) {
2932 s8d_8[i] = s8n_8[i] + s8m_8[i];
2933 }
2934 } else if (size == 1) {
2935 for (int i = 0; i < 8; i++) {
2936 s8d_16[i] = s8n_16[i] + s8m_16[i];
2937 }
2938 } else if (size == 2) {
2939 for (int i = 0; i < 4; i++) {
2940 s8d.data_[i].u = s8n.data_[i].u + s8m.data_[i].u;
2941 }
2942 } else if (size == 3) {
2943 for (int i = 0; i < 2; i++) {
2944 s8d_64[i] = s8n_64[i] + s8m_64[i];
2945 }
2946 } else {
2947 UNREACHABLE();
2948 }
2949 } else if ((instr->Bits(8, 4) == 13) && (instr->Bit(4) == 0) &&
2950 (instr->Bit(24) == 0)) {
2951 // Format(instr, "vadd.F32 'qd, 'qn, 'qm");
2952 for (int i = 0; i < 4; i++) {
2953 s8d.data_[i].f = s8n.data_[i].f + s8m.data_[i].f;
2954 }
2955 } else {
2956 UnimplementedInstruction(instr);
2957 }
2958
2959 set_qregister(qd, s8d);
2960 } else {
2961 // Q == 0, Uses 64-bit D registers.
2962 UnimplementedInstruction(instr);
2963 }
2964 }
2965
2966
2889 // Executes the current instruction. 2967 // Executes the current instruction.
2890 void Simulator::InstructionDecode(Instr* instr) { 2968 void Simulator::InstructionDecode(Instr* instr) {
2891 pc_modified_ = false; 2969 pc_modified_ = false;
2892 if (FLAG_trace_sim) { 2970 if (FLAG_trace_sim) {
2893 const uword start = reinterpret_cast<uword>(instr); 2971 const uword start = reinterpret_cast<uword>(instr);
2894 const uword end = start + Instr::kInstrSize; 2972 const uword end = start + Instr::kInstrSize;
2895 Disassembler::Disassemble(start, end); 2973 Disassembler::Disassemble(start, end);
2896 } 2974 }
2897 if (instr->ConditionField() == kSpecialCondition) { 2975 if (instr->ConditionField() == kSpecialCondition) {
2898 if (instr->InstructionBits() == static_cast<int32_t>(0xf57ff01f)) { 2976 if (instr->InstructionBits() == static_cast<int32_t>(0xf57ff01f)) {
2899 // Format(instr, "clrex"); 2977 // Format(instr, "clrex");
2900 ClearExclusive(); 2978 ClearExclusive();
2901 } else { 2979 } else {
2902 UnimplementedInstruction(instr); 2980 if (instr->IsSIMDDataProcessing()) {
2981 DecodeSIMDDataProcessing(instr);
2982 } else {
2983 UnimplementedInstruction(instr);
2984 }
2903 } 2985 }
2904 } else if (ConditionallyExecute(instr)) { 2986 } else if (ConditionallyExecute(instr)) {
2905 switch (instr->TypeField()) { 2987 switch (instr->TypeField()) {
2906 case 0: 2988 case 0:
2907 case 1: { 2989 case 1: {
2908 DecodeType01(instr); 2990 DecodeType01(instr);
2909 break; 2991 break;
2910 } 2992 }
2911 case 2: { 2993 case 2: {
2912 DecodeType2(instr); 2994 DecodeType2(instr);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); 3198 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception));
3117 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); 3199 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace));
3118 buf->Longjmp(); 3200 buf->Longjmp();
3119 } 3201 }
3120 3202
3121 } // namespace dart 3203 } // namespace dart
3122 3204
3123 #endif // !defined(HOST_ARCH_ARM) 3205 #endif // !defined(HOST_ARCH_ARM)
3124 3206
3125 #endif // defined TARGET_ARCH_ARM 3207 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698