OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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. | |
6 #include <setjmp.h> | 5 #include <setjmp.h> |
7 #include <stdlib.h> | 6 #include <stdlib.h> |
8 | 7 |
9 #include "vm/globals.h" | 8 #include "vm/globals.h" |
10 #if defined(TARGET_ARCH_ARM64) | 9 #if defined(TARGET_ARCH_ARM64) |
11 | 10 |
12 // Only build the simulator if not compiling for real ARM hardware. | 11 // Only build the simulator if not compiling for real ARM hardware. |
13 #if !defined(HOST_ARCH_ARM64) | 12 #if !defined(HOST_ARCH_ARM64) |
14 | 13 |
15 #include "vm/simulator.h" | 14 #include "vm/simulator.h" |
(...skipping 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2437 return; | 2436 return; |
2438 } | 2437 } |
2439 set_vregisterd(vd, idx, res); | 2438 set_vregisterd(vd, idx, res); |
2440 } | 2439 } |
2441 } | 2440 } |
2442 } | 2441 } |
2443 | 2442 |
2444 | 2443 |
2445 static float arm_reciprocal_sqrt_estimate(float a) { | 2444 static float arm_reciprocal_sqrt_estimate(float a) { |
2446 // From the ARM Architecture Reference Manual A2-87. | 2445 // From the ARM Architecture Reference Manual A2-87. |
2447 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 2446 if (std::isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
koda
2014/06/30 20:50:40
It looks slightly odd to have only one of these in
siva
2014/06/30 20:59:34
I agree too, it does seem odd.
I am wondering if
zra
2014/06/30 20:59:44
Yah, it does look strange, but hopefully it will m
zra
2014/06/30 22:14:33
Done.
| |
2448 else if (a == 0.0) return INFINITY; | 2447 else if (a == 0.0) return INFINITY; |
2449 else if (isnan(a)) return a; | 2448 else if (std::isnan(a)) return a; |
2450 | 2449 |
2451 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 2450 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
2452 uint64_t scaled; | 2451 uint64_t scaled; |
2453 if (((a_bits >> 23) & 1) != 0) { | 2452 if (((a_bits >> 23) & 1) != 0) { |
2454 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) | 2453 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) |
2455 scaled = (static_cast<uint64_t>(0x3fd) << 52) | | 2454 scaled = (static_cast<uint64_t>(0x3fd) << 52) | |
2456 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 2455 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
2457 } else { | 2456 } else { |
2458 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) | 2457 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) |
2459 scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 2458 scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
(...skipping 28 matching lines...) Expand all Loading... | |
2488 | 2487 |
2489 // result = 0 : result_exp<7:0> : estimate<51:29> | 2488 // result = 0 : result_exp<7:0> : estimate<51:29> |
2490 int32_t result_bits = ((result_exp & 0xff) << 23) | | 2489 int32_t result_bits = ((result_exp & 0xff) << 23) | |
2491 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); | 2490 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); |
2492 return bit_cast<float, int32_t>(result_bits); | 2491 return bit_cast<float, int32_t>(result_bits); |
2493 } | 2492 } |
2494 | 2493 |
2495 | 2494 |
2496 static float arm_recip_estimate(float a) { | 2495 static float arm_recip_estimate(float a) { |
2497 // From the ARM Architecture Reference Manual A2-85. | 2496 // From the ARM Architecture Reference Manual A2-85. |
2498 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 2497 if (std::isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
2499 else if (a == 0.0) return INFINITY; | 2498 else if (a == 0.0) return INFINITY; |
2500 else if (isnan(a)) return a; | 2499 else if (std::isnan(a)) return a; |
2501 | 2500 |
2502 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 2501 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
2503 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) | 2502 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) |
2504 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 2503 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
2505 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 2504 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
2506 // result_exp = 253 - UInt(a<30:23>) | 2505 // result_exp = 253 - UInt(a<30:23>) |
2507 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); | 2506 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); |
2508 ASSERT((result_exp >= 1) && (result_exp <= 252)); | 2507 ASSERT((result_exp >= 1) && (result_exp <= 252)); |
2509 | 2508 |
2510 double scaled_d = bit_cast<double, uint64_t>(scaled); | 2509 double scaled_d = bit_cast<double, uint64_t>(scaled); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2813 } else { | 2812 } else { |
2814 UnimplementedInstruction(instr); | 2813 UnimplementedInstruction(instr); |
2815 return; | 2814 return; |
2816 } | 2815 } |
2817 | 2816 |
2818 n_flag_ = false; | 2817 n_flag_ = false; |
2819 z_flag_ = false; | 2818 z_flag_ = false; |
2820 c_flag_ = false; | 2819 c_flag_ = false; |
2821 v_flag_ = false; | 2820 v_flag_ = false; |
2822 | 2821 |
2823 if (isnan(vn_val) || isnan(vm_val)) { | 2822 if (std::isnan(vn_val) || std::isnan(vm_val)) { |
2824 c_flag_ = true; | 2823 c_flag_ = true; |
2825 v_flag_ = true; | 2824 v_flag_ = true; |
2826 } else if (vn_val == vm_val) { | 2825 } else if (vn_val == vm_val) { |
2827 z_flag_ = true; | 2826 z_flag_ = true; |
2828 c_flag_ = true; | 2827 c_flag_ = true; |
2829 } else if (vn_val < vm_val) { | 2828 } else if (vn_val < vm_val) { |
2830 n_flag_ = true; | 2829 n_flag_ = true; |
2831 } else { | 2830 } else { |
2832 c_flag_ = true; | 2831 c_flag_ = true; |
2833 } | 2832 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3054 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3053 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
3055 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3054 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
3056 buf->Longjmp(); | 3055 buf->Longjmp(); |
3057 } | 3056 } |
3058 | 3057 |
3059 } // namespace dart | 3058 } // namespace dart |
3060 | 3059 |
3061 #endif // !defined(HOST_ARCH_ARM64) | 3060 #endif // !defined(HOST_ARCH_ARM64) |
3062 | 3061 |
3063 #endif // defined TARGET_ARCH_ARM64 | 3062 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |