OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <functional> | 5 #include <functional> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 4224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4235 double input = -1.0; | 4235 double input = -1.0; |
4236 RawMachineAssemblerTester<int32_t> m; | 4236 RawMachineAssemblerTester<int32_t> m; |
4237 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); | 4237 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); |
4238 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4238 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4239 input = kValues[i].from; | 4239 input = kValues[i].from; |
4240 uint64_t expected = static_cast<int64_t>(kValues[i].raw); | 4240 uint64_t expected = static_cast<int64_t>(kValues[i].raw); |
4241 CHECK_EQ(static_cast<int>(expected), m.Call()); | 4241 CHECK_EQ(static_cast<int>(expected), m.Call()); |
4242 } | 4242 } |
4243 } | 4243 } |
4244 | 4244 |
| 4245 |
| 4246 TEST(RunChangeFloat32ToFloat64) { |
| 4247 double actual = 0.0f; |
| 4248 float expected = 0.0; |
| 4249 RawMachineAssemblerTester<int32_t> m; |
| 4250 m.StoreToPointer( |
| 4251 &actual, kMachFloat64, |
| 4252 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); |
| 4253 m.Return(m.Int32Constant(0)); |
| 4254 FOR_FLOAT32_INPUTS(i) { |
| 4255 expected = *i; |
| 4256 CHECK_EQ(0, m.Call()); |
| 4257 CHECK_EQ(expected, actual); |
| 4258 } |
| 4259 } |
| 4260 |
| 4261 |
| 4262 TEST(RunTruncateFloat64ToFloat32) { |
| 4263 float actual = 0.0f; |
| 4264 double input = 0.0; |
| 4265 RawMachineAssemblerTester<int32_t> m; |
| 4266 m.StoreToPointer( |
| 4267 &actual, kMachFloat32, |
| 4268 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); |
| 4269 m.Return(m.Int32Constant(0)); |
| 4270 FOR_FLOAT64_INPUTS(i) { |
| 4271 input = *i; |
| 4272 volatile double expected = DoubleToFloat32(input); |
| 4273 CHECK_EQ(0, m.Call()); |
| 4274 CHECK_EQ(expected, actual); |
| 4275 } |
| 4276 } |
| 4277 |
4245 #endif // V8_TURBOFAN_TARGET | 4278 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |