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 5983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5994 m.Return(m.BitcastFloat32ToInt32( | 5994 m.Return(m.BitcastFloat32ToInt32( |
5995 m.LoadFromPointer(&input, MachineType::Float32()))); | 5995 m.LoadFromPointer(&input, MachineType::Float32()))); |
5996 FOR_FLOAT32_INPUTS(i) { | 5996 FOR_FLOAT32_INPUTS(i) { |
5997 input = *i; | 5997 input = *i; |
5998 int32_t expected = bit_cast<int32_t>(input); | 5998 int32_t expected = bit_cast<int32_t>(input); |
5999 CHECK_EQ(expected, m.Call()); | 5999 CHECK_EQ(expected, m.Call()); |
6000 } | 6000 } |
6001 } | 6001 } |
6002 | 6002 |
6003 | 6003 |
| 6004 TEST(RunRoundInt32ToFloat32) { |
| 6005 BufferedRawMachineAssemblerTester<float> m(MachineType::Int32()); |
| 6006 m.Return(m.RoundInt32ToFloat32(m.Parameter(0))); |
| 6007 FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } |
| 6008 } |
| 6009 |
| 6010 |
6004 TEST(RunBitcastInt32ToFloat32) { | 6011 TEST(RunBitcastInt32ToFloat32) { |
6005 int32_t input = 1; | 6012 int32_t input = 1; |
6006 float output = 0.0; | 6013 float output = 0.0; |
6007 RawMachineAssemblerTester<int32_t> m; | 6014 RawMachineAssemblerTester<int32_t> m; |
6008 m.StoreToPointer( | 6015 m.StoreToPointer( |
6009 &output, MachineRepresentation::kFloat32, | 6016 &output, MachineRepresentation::kFloat32, |
6010 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); | 6017 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); |
6011 m.Return(m.Int32Constant(11)); | 6018 m.Return(m.Int32Constant(11)); |
6012 FOR_INT32_INPUTS(i) { | 6019 FOR_INT32_INPUTS(i) { |
6013 input = *i; | 6020 input = *i; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6064 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6071 Node* call = r.AddNode(r.common()->Call(desc), phi); |
6065 r.Return(call); | 6072 r.Return(call); |
6066 | 6073 |
6067 CHECK_EQ(33, r.Call(1)); | 6074 CHECK_EQ(33, r.Call(1)); |
6068 CHECK_EQ(44, r.Call(0)); | 6075 CHECK_EQ(44, r.Call(0)); |
6069 } | 6076 } |
6070 | 6077 |
6071 } // namespace compiler | 6078 } // namespace compiler |
6072 } // namespace internal | 6079 } // namespace internal |
6073 } // namespace v8 | 6080 } // namespace v8 |
OLD | NEW |