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 <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/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 3194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3205 | 3205 |
3206 FOR_FLOAT32_INPUTS(pl) { | 3206 FOR_FLOAT32_INPUTS(pl) { |
3207 FOR_FLOAT32_INPUTS(pr) { | 3207 FOR_FLOAT32_INPUTS(pr) { |
3208 float expected = *pl - *pr; | 3208 float expected = *pl - *pr; |
3209 CheckFloatEq(expected, bt.call(*pl, *pr)); | 3209 CheckFloatEq(expected, bt.call(*pl, *pr)); |
3210 } | 3210 } |
3211 } | 3211 } |
3212 } | 3212 } |
3213 | 3213 |
3214 | 3214 |
| 3215 TEST(RunFloat32SubImm1) { |
| 3216 float input = 0.0f; |
| 3217 float output = 0.0f; |
| 3218 |
| 3219 FOR_FLOAT32_INPUTS(i) { |
| 3220 RawMachineAssemblerTester<int32_t> m; |
| 3221 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); |
| 3222 Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0); |
| 3223 m.StoreToPointer(&output, kMachFloat32, t1); |
| 3224 m.Return(m.Int32Constant(0)); |
| 3225 FOR_FLOAT32_INPUTS(j) { |
| 3226 input = *j; |
| 3227 float expected = *i - input; |
| 3228 CHECK_EQ(0, m.Call()); |
| 3229 CheckFloatEq(expected, output); |
| 3230 } |
| 3231 } |
| 3232 } |
| 3233 |
| 3234 |
| 3235 TEST(RunFloat32SubImm2) { |
| 3236 float input = 0.0f; |
| 3237 float output = 0.0f; |
| 3238 |
| 3239 FOR_FLOAT32_INPUTS(i) { |
| 3240 RawMachineAssemblerTester<int32_t> m; |
| 3241 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); |
| 3242 Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i)); |
| 3243 m.StoreToPointer(&output, kMachFloat32, t1); |
| 3244 m.Return(m.Int32Constant(0)); |
| 3245 FOR_FLOAT32_INPUTS(j) { |
| 3246 input = *j; |
| 3247 float expected = input - *i; |
| 3248 CHECK_EQ(0, m.Call()); |
| 3249 CheckFloatEq(expected, output); |
| 3250 } |
| 3251 } |
| 3252 } |
| 3253 |
| 3254 |
3215 TEST(RunFloat64SubP) { | 3255 TEST(RunFloat64SubP) { |
3216 RawMachineAssemblerTester<int32_t> m; | 3256 RawMachineAssemblerTester<int32_t> m; |
3217 Float64BinopTester bt(&m); | 3257 Float64BinopTester bt(&m); |
3218 | 3258 |
3219 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); | 3259 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); |
3220 | 3260 |
3221 FOR_FLOAT64_INPUTS(pl) { | 3261 FOR_FLOAT64_INPUTS(pl) { |
3222 FOR_FLOAT64_INPUTS(pr) { | 3262 FOR_FLOAT64_INPUTS(pr) { |
3223 double expected = *pl - *pr; | 3263 double expected = *pl - *pr; |
3224 CheckDoubleEq(expected, bt.call(*pl, *pr)); | 3264 CheckDoubleEq(expected, bt.call(*pl, *pr)); |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5069 m.Return(m.Int32Constant(0)); | 5109 m.Return(m.Int32Constant(0)); |
5070 for (size_t i = 0; i < arraysize(kValues); ++i) { | 5110 for (size_t i = 0; i < arraysize(kValues); ++i) { |
5071 input = kValues[i]; | 5111 input = kValues[i]; |
5072 CHECK_EQ(0, m.Call()); | 5112 CHECK_EQ(0, m.Call()); |
5073 double expected = round(kValues[i]); | 5113 double expected = round(kValues[i]); |
5074 CHECK_EQ(expected, result); | 5114 CHECK_EQ(expected, result); |
5075 } | 5115 } |
5076 } | 5116 } |
5077 | 5117 |
5078 #endif // V8_TURBOFAN_TARGET | 5118 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |