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 4289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4300 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); | 4300 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); |
4301 m.Return(m.Int32Constant(0)); | 4301 m.Return(m.Int32Constant(0)); |
4302 FOR_FLOAT32_INPUTS(i) { | 4302 FOR_FLOAT32_INPUTS(i) { |
4303 expected = *i; | 4303 expected = *i; |
4304 CHECK_EQ(0, m.Call()); | 4304 CHECK_EQ(0, m.Call()); |
4305 CHECK_EQ(expected, actual); | 4305 CHECK_EQ(expected, actual); |
4306 } | 4306 } |
4307 } | 4307 } |
4308 | 4308 |
4309 | 4309 |
| 4310 TEST(RunChangeFloat32ToFloat64_spilled) { |
| 4311 RawMachineAssemblerTester<int32_t> m; |
| 4312 const int kNumInputs = 32; |
| 4313 int32_t magic = 0x786234; |
| 4314 float input[kNumInputs]; |
| 4315 double result[kNumInputs]; |
| 4316 Node* input_node[kNumInputs]; |
| 4317 |
| 4318 for (int i = 0; i < kNumInputs; i++) { |
| 4319 input_node[i] = |
| 4320 m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4)); |
| 4321 } |
| 4322 |
| 4323 for (int i = 0; i < kNumInputs; i++) { |
| 4324 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8), |
| 4325 m.ChangeFloat32ToFloat64(input_node[i])); |
| 4326 } |
| 4327 |
| 4328 m.Return(m.Int32Constant(magic)); |
| 4329 |
| 4330 for (int i = 0; i < kNumInputs; i++) { |
| 4331 input[i] = 100.9f + i; |
| 4332 } |
| 4333 |
| 4334 CHECK_EQ(magic, m.Call()); |
| 4335 |
| 4336 for (int i = 0; i < kNumInputs; i++) { |
| 4337 CHECK_EQ(result[i], static_cast<double>(input[i])); |
| 4338 } |
| 4339 } |
| 4340 |
| 4341 |
4310 TEST(RunTruncateFloat64ToFloat32) { | 4342 TEST(RunTruncateFloat64ToFloat32) { |
4311 float actual = 0.0f; | 4343 float actual = 0.0f; |
4312 double input = 0.0; | 4344 double input = 0.0; |
4313 RawMachineAssemblerTester<int32_t> m; | 4345 RawMachineAssemblerTester<int32_t> m; |
4314 m.StoreToPointer( | 4346 m.StoreToPointer( |
4315 &actual, kMachFloat32, | 4347 &actual, kMachFloat32, |
4316 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); | 4348 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); |
4317 m.Return(m.Int32Constant(0)); | 4349 m.Return(m.Int32Constant(0)); |
4318 FOR_FLOAT64_INPUTS(i) { | 4350 FOR_FLOAT64_INPUTS(i) { |
4319 input = *i; | 4351 input = *i; |
(...skipping 10 matching lines...) Expand all Loading... |
4330 float actual = *i; | 4362 float actual = *i; |
4331 RawMachineAssemblerTester<int32_t> m; | 4363 RawMachineAssemblerTester<int32_t> m; |
4332 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); | 4364 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); |
4333 m.Return(m.Int32Constant(0)); | 4365 m.Return(m.Int32Constant(0)); |
4334 CHECK_EQ(0, m.Call()); | 4366 CHECK_EQ(0, m.Call()); |
4335 CHECK_EQ(expected, actual); | 4367 CHECK_EQ(expected, actual); |
4336 } | 4368 } |
4337 } | 4369 } |
4338 | 4370 |
4339 #endif // V8_TURBOFAN_TARGET | 4371 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |