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/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3597 MachineType::Float32()); | 3597 MachineType::Float32()); |
3598 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); | 3598 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); |
3599 | 3599 |
3600 FOR_FLOAT32_INPUTS(i) { | 3600 FOR_FLOAT32_INPUTS(i) { |
3601 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*i, *j)); } | 3601 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*i, *j)); } |
3602 } | 3602 } |
3603 } | 3603 } |
3604 | 3604 |
3605 TEST(RunFloat32Neg) { | 3605 TEST(RunFloat32Neg) { |
3606 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); | 3606 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); |
3607 if (!m.machine()->Float32Neg().IsSupported()) return; | 3607 m.Return(m.AddNode(m.machine()->Float32Neg(), m.Parameter(0))); |
3608 m.Return(m.AddNode(m.machine()->Float32Neg().op(), m.Parameter(0))); | |
3609 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(-0.0f - *i, m.Call(*i)); } | 3608 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(-0.0f - *i, m.Call(*i)); } |
3610 } | 3609 } |
3611 | 3610 |
3612 TEST(RunFloat32Mul) { | 3611 TEST(RunFloat32Mul) { |
3613 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), | 3612 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), |
3614 MachineType::Float32()); | 3613 MachineType::Float32()); |
3615 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); | 3614 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); |
3616 | 3615 |
3617 FOR_FLOAT32_INPUTS(i) { | 3616 FOR_FLOAT32_INPUTS(i) { |
3618 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*i, *j)); } | 3617 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*i, *j)); } |
(...skipping 28 matching lines...) Expand all Loading... |
3647 MachineType::Float64()); | 3646 MachineType::Float64()); |
3648 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); | 3647 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); |
3649 | 3648 |
3650 FOR_FLOAT64_INPUTS(i) { | 3649 FOR_FLOAT64_INPUTS(i) { |
3651 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i - *j, m.Call(*i, *j)); } | 3650 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i - *j, m.Call(*i, *j)); } |
3652 } | 3651 } |
3653 } | 3652 } |
3654 | 3653 |
3655 TEST(RunFloat64Neg) { | 3654 TEST(RunFloat64Neg) { |
3656 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); | 3655 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
3657 if (!m.machine()->Float64Neg().IsSupported()) return; | 3656 m.Return(m.AddNode(m.machine()->Float64Neg(), m.Parameter(0))); |
3658 m.Return(m.AddNode(m.machine()->Float64Neg().op(), m.Parameter(0))); | |
3659 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(-0.0 - *i, m.Call(*i)); } | 3657 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(-0.0 - *i, m.Call(*i)); } |
3660 } | 3658 } |
3661 | 3659 |
3662 TEST(RunFloat64Mul) { | 3660 TEST(RunFloat64Mul) { |
3663 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), | 3661 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), |
3664 MachineType::Float64()); | 3662 MachineType::Float64()); |
3665 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); | 3663 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); |
3666 | 3664 |
3667 FOR_FLOAT64_INPUTS(i) { | 3665 FOR_FLOAT64_INPUTS(i) { |
3668 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i * *j, m.Call(*i, *j)); } | 3666 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i * *j, m.Call(*i, *j)); } |
(...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6567 r.Goto(&merge); | 6565 r.Goto(&merge); |
6568 r.Bind(&merge); | 6566 r.Bind(&merge); |
6569 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6567 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6570 r.Return(phi); | 6568 r.Return(phi); |
6571 CHECK_EQ(1, r.Call(1)); | 6569 CHECK_EQ(1, r.Call(1)); |
6572 } | 6570 } |
6573 | 6571 |
6574 } // namespace compiler | 6572 } // namespace compiler |
6575 } // namespace internal | 6573 } // namespace internal |
6576 } // namespace v8 | 6574 } // namespace v8 |
OLD | NEW |