OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 vfp_register[sreg] = value; | 938 vfp_register[sreg] = value; |
939 } | 939 } |
940 | 940 |
941 | 941 |
942 unsigned int Simulator::get_s_register(int sreg) const { | 942 unsigned int Simulator::get_s_register(int sreg) const { |
943 ASSERT((sreg >= 0) && (sreg < num_s_registers)); | 943 ASSERT((sreg >= 0) && (sreg < num_s_registers)); |
944 return vfp_register[sreg]; | 944 return vfp_register[sreg]; |
945 } | 945 } |
946 | 946 |
947 | 947 |
948 void Simulator::set_s_register_from_float(int sreg, const float flt) { | 948 template<class InputType, int register_size> |
949 ASSERT((sreg >= 0) && (sreg < num_s_registers)); | 949 void Simulator::SetVFPRegister(int reg_index, const InputType& value) { |
950 // Read the bits from the single precision floating point value | 950 ASSERT(reg_index >= 0); |
951 // into the unsigned integer element of vfp_register[] given by index=sreg. | 951 if (register_size == 1) ASSERT(reg_index < num_s_registers); |
952 char buffer[sizeof(vfp_register[0])]; | 952 if (register_size == 2) ASSERT(reg_index < num_d_registers); |
953 memcpy(buffer, &flt, sizeof(vfp_register[0])); | 953 |
954 memcpy(&vfp_register[sreg], buffer, sizeof(vfp_register[0])); | 954 char buffer[register_size * sizeof(vfp_register[0])]; |
| 955 memcpy(buffer, &value, register_size * sizeof(vfp_register[0])); |
| 956 memcpy(&vfp_register[reg_index * register_size], buffer, |
| 957 register_size * sizeof(vfp_register[0])); |
955 } | 958 } |
956 | 959 |
957 | 960 |
958 void Simulator::set_s_register_from_sinteger(int sreg, const int sint) { | 961 template<class ReturnType, int register_size> |
959 ASSERT((sreg >= 0) && (sreg < num_s_registers)); | 962 ReturnType Simulator::GetFromVFPRegister(int reg_index) { |
960 // Read the bits from the integer value into the unsigned integer element of | 963 ASSERT(reg_index >= 0); |
961 // vfp_register[] given by index=sreg. | 964 if (register_size == 1) ASSERT(reg_index < num_s_registers); |
962 char buffer[sizeof(vfp_register[0])]; | 965 if (register_size == 2) ASSERT(reg_index < num_d_registers); |
963 memcpy(buffer, &sint, sizeof(vfp_register[0])); | 966 |
964 memcpy(&vfp_register[sreg], buffer, sizeof(vfp_register[0])); | 967 ReturnType value = 0; |
| 968 char buffer[register_size * sizeof(vfp_register[0])]; |
| 969 memcpy(buffer, &vfp_register[register_size * reg_index], |
| 970 register_size * sizeof(vfp_register[0])); |
| 971 memcpy(&value, buffer, register_size * sizeof(vfp_register[0])); |
| 972 return value; |
965 } | 973 } |
966 | 974 |
967 | 975 |
968 void Simulator::set_d_register_from_double(int dreg, const double& dbl) { | |
969 ASSERT((dreg >= 0) && (dreg < num_d_registers)); | |
970 // Read the bits from the double precision floating point value into the two | |
971 // consecutive unsigned integer elements of vfp_register[] given by index | |
972 // 2*sreg and 2*sreg+1. | |
973 char buffer[2 * sizeof(vfp_register[0])]; | |
974 memcpy(buffer, &dbl, 2 * sizeof(vfp_register[0])); | |
975 memcpy(&vfp_register[dreg * 2], buffer, 2 * sizeof(vfp_register[0])); | |
976 } | |
977 | |
978 | |
979 float Simulator::get_float_from_s_register(int sreg) { | |
980 ASSERT((sreg >= 0) && (sreg < num_s_registers)); | |
981 | |
982 float sm_val = 0.0; | |
983 // Read the bits from the unsigned integer vfp_register[] array | |
984 // into the single precision floating point value and return it. | |
985 char buffer[sizeof(vfp_register[0])]; | |
986 memcpy(buffer, &vfp_register[sreg], sizeof(vfp_register[0])); | |
987 memcpy(&sm_val, buffer, sizeof(vfp_register[0])); | |
988 return(sm_val); | |
989 } | |
990 | |
991 | |
992 int Simulator::get_sinteger_from_s_register(int sreg) { | |
993 ASSERT((sreg >= 0) && (sreg < num_s_registers)); | |
994 | |
995 int sm_val = 0; | |
996 // Read the bits from the unsigned integer vfp_register[] array | |
997 // into the single precision floating point value and return it. | |
998 char buffer[sizeof(vfp_register[0])]; | |
999 memcpy(buffer, &vfp_register[sreg], sizeof(vfp_register[0])); | |
1000 memcpy(&sm_val, buffer, sizeof(vfp_register[0])); | |
1001 return(sm_val); | |
1002 } | |
1003 | |
1004 | |
1005 double Simulator::get_double_from_d_register(int dreg) { | |
1006 ASSERT((dreg >= 0) && (dreg < num_d_registers)); | |
1007 | |
1008 double dm_val = 0.0; | |
1009 // Read the bits from the unsigned integer vfp_register[] array | |
1010 // into the double precision floating point value and return it. | |
1011 char buffer[2 * sizeof(vfp_register[0])]; | |
1012 memcpy(buffer, &vfp_register[2 * dreg], 2 * sizeof(vfp_register[0])); | |
1013 memcpy(&dm_val, buffer, 2 * sizeof(vfp_register[0])); | |
1014 return(dm_val); | |
1015 } | |
1016 | |
1017 | |
1018 // For use in calls that take two double values, constructed either | 976 // For use in calls that take two double values, constructed either |
1019 // from r0-r3 or d0 and d1. | 977 // from r0-r3 or d0 and d1. |
1020 void Simulator::GetFpArgs(double* x, double* y) { | 978 void Simulator::GetFpArgs(double* x, double* y) { |
1021 if (use_eabi_hardfloat()) { | 979 if (use_eabi_hardfloat()) { |
1022 *x = vfp_register[0]; | 980 *x = vfp_register[0]; |
1023 *y = vfp_register[1]; | 981 *y = vfp_register[1]; |
1024 } else { | 982 } else { |
1025 // We use a char buffer to get around the strict-aliasing rules which | 983 // We use a char buffer to get around the strict-aliasing rules which |
1026 // otherwise allow the compiler to optimize away the copy. | 984 // otherwise allow the compiler to optimize away the copy. |
1027 char buffer[sizeof(*x)]; | 985 char buffer[sizeof(*x)]; |
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3426 uintptr_t address = *stack_slot; | 3384 uintptr_t address = *stack_slot; |
3427 set_register(sp, current_sp + sizeof(uintptr_t)); | 3385 set_register(sp, current_sp + sizeof(uintptr_t)); |
3428 return address; | 3386 return address; |
3429 } | 3387 } |
3430 | 3388 |
3431 } } // namespace v8::internal | 3389 } } // namespace v8::internal |
3432 | 3390 |
3433 #endif // USE_SIMULATOR | 3391 #endif // USE_SIMULATOR |
3434 | 3392 |
3435 #endif // V8_TARGET_ARCH_ARM | 3393 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |