OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include <cmath> | 5 #include <cmath> |
6 #include <functional> | 6 #include <functional> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 4183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4194 | 4194 |
4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); | 4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); |
4196 | 4196 |
4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); } | 4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); } |
4198 } | 4198 } |
4199 | 4199 |
4200 uint64_t ToInt64(uint32_t low, uint32_t high) { | 4200 uint64_t ToInt64(uint32_t low, uint32_t high) { |
4201 return (static_cast<uint64_t>(high) << 32) | static_cast<uint64_t>(low); | 4201 return (static_cast<uint64_t>(high) << 32) | static_cast<uint64_t>(low); |
4202 } | 4202 } |
4203 | 4203 |
4204 #if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_X87 | 4204 #if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_X87 |
4205 TEST(RunInt32PairAdd) { | 4205 TEST(RunInt32PairAdd) { |
4206 BufferedRawMachineAssemblerTester<int32_t> m( | 4206 BufferedRawMachineAssemblerTester<int32_t> m( |
4207 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(), | 4207 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(), |
4208 MachineType::Uint32()); | 4208 MachineType::Uint32()); |
4209 | 4209 |
4210 uint32_t high; | 4210 uint32_t high; |
4211 uint32_t low; | 4211 uint32_t low; |
4212 | 4212 |
4213 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2), | 4213 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2), |
4214 m.Parameter(3)); | 4214 m.Parameter(3)); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4442 } | 4442 } |
4443 } | 4443 } |
4444 | 4444 |
4445 TEST(RunWord32PairShlWithSharedInput) { | 4445 TEST(RunWord32PairShlWithSharedInput) { |
4446 TestWord32PairShlWithSharedInput(0, 0); | 4446 TestWord32PairShlWithSharedInput(0, 0); |
4447 TestWord32PairShlWithSharedInput(0, 1); | 4447 TestWord32PairShlWithSharedInput(0, 1); |
4448 TestWord32PairShlWithSharedInput(1, 0); | 4448 TestWord32PairShlWithSharedInput(1, 0); |
4449 TestWord32PairShlWithSharedInput(1, 1); | 4449 TestWord32PairShlWithSharedInput(1, 1); |
4450 } | 4450 } |
4451 | 4451 |
| 4452 TEST(RunWord32PairShr) { |
| 4453 BufferedRawMachineAssemblerTester<int32_t> m( |
| 4454 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); |
| 4455 |
| 4456 uint32_t high; |
| 4457 uint32_t low; |
| 4458 |
| 4459 Node* PairAdd = |
| 4460 m.Word32PairShr(m.Parameter(0), m.Parameter(1), m.Parameter(2)); |
| 4461 |
| 4462 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4463 m.Projection(0, PairAdd)); |
| 4464 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4465 m.Projection(1, PairAdd)); |
| 4466 m.Return(m.Int32Constant(74)); |
| 4467 |
| 4468 FOR_UINT64_INPUTS(i) { |
| 4469 for (uint32_t j = 0; j < 64; j++) { |
| 4470 m.Call(static_cast<uint32_t>(*i & 0xffffffff), |
| 4471 static_cast<uint32_t>(*i >> 32), j); |
| 4472 CHECK_EQ(*i >> j, ToInt64(low, high)); |
| 4473 } |
| 4474 } |
| 4475 } |
| 4476 |
| 4477 TEST(RunWord32PairSar) { |
| 4478 BufferedRawMachineAssemblerTester<int32_t> m( |
| 4479 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); |
| 4480 |
| 4481 uint32_t high; |
| 4482 uint32_t low; |
| 4483 |
| 4484 Node* PairAdd = |
| 4485 m.Word32PairSar(m.Parameter(0), m.Parameter(1), m.Parameter(2)); |
| 4486 |
| 4487 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4488 m.Projection(0, PairAdd)); |
| 4489 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4490 m.Projection(1, PairAdd)); |
| 4491 m.Return(m.Int32Constant(74)); |
| 4492 |
| 4493 FOR_INT64_INPUTS(i) { |
| 4494 for (uint32_t j = 0; j < 64; j++) { |
| 4495 m.Call(static_cast<uint32_t>(*i & 0xffffffff), |
| 4496 static_cast<uint32_t>(*i >> 32), j); |
| 4497 CHECK_EQ(*i >> j, ToInt64(low, high)); |
| 4498 } |
| 4499 } |
| 4500 } |
| 4501 |
4452 #endif | 4502 #endif |
4453 | 4503 |
4454 TEST(RunDeadChangeFloat64ToInt32) { | 4504 TEST(RunDeadChangeFloat64ToInt32) { |
4455 RawMachineAssemblerTester<int32_t> m; | 4505 RawMachineAssemblerTester<int32_t> m; |
4456 const int magic = 0x88abcda4; | 4506 const int magic = 0x88abcda4; |
4457 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); | 4507 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); |
4458 m.Return(m.Int32Constant(magic)); | 4508 m.Return(m.Int32Constant(magic)); |
4459 CHECK_EQ(magic, m.Call()); | 4509 CHECK_EQ(magic, m.Call()); |
4460 } | 4510 } |
4461 | 4511 |
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6380 r.Goto(&merge); | 6430 r.Goto(&merge); |
6381 r.Bind(&merge); | 6431 r.Bind(&merge); |
6382 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6432 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6383 r.Return(phi); | 6433 r.Return(phi); |
6384 CHECK_EQ(1, r.Call(1)); | 6434 CHECK_EQ(1, r.Call(1)); |
6385 } | 6435 } |
6386 | 6436 |
6387 } // namespace compiler | 6437 } // namespace compiler |
6388 } // namespace internal | 6438 } // namespace internal |
6389 } // namespace v8 | 6439 } // namespace v8 |
OLD | NEW |