OLD | NEW |
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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 3019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 ASSEMBLER_TEST_RUN(Vsqrtd, test) { | 3030 ASSEMBLER_TEST_RUN(Vsqrtd, test) { |
3031 typedef double (*DoubleReturn)() DART_UNUSED; | 3031 typedef double (*DoubleReturn)() DART_UNUSED; |
3032 EXPECT_EQ(15.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 3032 EXPECT_EQ(15.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
3033 } | 3033 } |
3034 | 3034 |
3035 | 3035 |
3036 // This is the same function as in the Simulator. | 3036 // This is the same function as in the Simulator. |
3037 static float arm_recip_estimate(float a) { | 3037 static float arm_recip_estimate(float a) { |
3038 // From the ARM Architecture Reference Manual A2-85. | 3038 // From the ARM Architecture Reference Manual A2-85. |
3039 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3039 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
3040 else if (a == 0.0) return INFINITY; | 3040 else if (a == 0.0) return kPosInfinity; |
3041 else if (isnan(a)) return a; | 3041 else if (isnan(a)) return a; |
3042 | 3042 |
3043 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3043 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3044 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) | 3044 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) |
3045 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 3045 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
3046 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3046 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3047 // result_exp = 253 - UInt(a<30:23>) | 3047 // result_exp = 253 - UInt(a<30:23>) |
3048 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); | 3048 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); |
3049 ASSERT((result_exp >= 1) && (result_exp <= 252)); | 3049 ASSERT((result_exp >= 1) && (result_exp <= 252)); |
3050 | 3050 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3139 ASSEMBLER_TEST_RUN(VRecps, test) { | 3139 ASSEMBLER_TEST_RUN(VRecps, test) { |
3140 typedef double (*DoubleReturn)() DART_UNUSED; | 3140 typedef double (*DoubleReturn)() DART_UNUSED; |
3141 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); | 3141 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); |
3142 EXPECT_FLOAT_EQ(42.0, res, 0.0001); | 3142 EXPECT_FLOAT_EQ(42.0, res, 0.0001); |
3143 } | 3143 } |
3144 | 3144 |
3145 | 3145 |
3146 static float arm_reciprocal_sqrt_estimate(float a) { | 3146 static float arm_reciprocal_sqrt_estimate(float a) { |
3147 // From the ARM Architecture Reference Manual A2-87. | 3147 // From the ARM Architecture Reference Manual A2-87. |
3148 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3148 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
3149 else if (a == 0.0) return INFINITY; | 3149 else if (a == 0.0) return kPosInfinity; |
3150 else if (isnan(a)) return a; | 3150 else if (isnan(a)) return a; |
3151 | 3151 |
3152 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3152 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3153 uint64_t scaled; | 3153 uint64_t scaled; |
3154 if (((a_bits >> 23) & 1) != 0) { | 3154 if (((a_bits >> 23) & 1) != 0) { |
3155 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) | 3155 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) |
3156 scaled = (static_cast<uint64_t>(0x3fd) << 52) | | 3156 scaled = (static_cast<uint64_t>(0x3fd) << 52) | |
3157 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3157 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3158 } else { | 3158 } else { |
3159 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) | 3159 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3272 __ Pop(LR); | 3272 __ Pop(LR); |
3273 __ Pop(CTX); | 3273 __ Pop(CTX); |
3274 __ PopAndUntagPP(); | 3274 __ PopAndUntagPP(); |
3275 __ mov(CSP, SP); | 3275 __ mov(CSP, SP); |
3276 __ ret(); | 3276 __ ret(); |
3277 } | 3277 } |
3278 | 3278 |
3279 } // namespace dart | 3279 } // namespace dart |
3280 | 3280 |
3281 #endif // defined(TARGET_ARCH_ARM64) | 3281 #endif // defined(TARGET_ARCH_ARM64) |
OLD | NEW |