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 #ifndef V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 5 #ifndef V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
6 #define V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 6 #define V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 | 294 |
295 static const std::vector<double> nan_vector(size_t limit = 0) { | 295 static const std::vector<double> nan_vector(size_t limit = 0) { |
296 static const double nan = std::numeric_limits<double>::quiet_NaN(); | 296 static const double nan = std::numeric_limits<double>::quiet_NaN(); |
297 static const double values[] = {-nan, -V8_INFINITY * -0.0, | 297 static const double values[] = {-nan, -V8_INFINITY * -0.0, |
298 -V8_INFINITY * 0.0, V8_INFINITY * -0.0, | 298 -V8_INFINITY * 0.0, V8_INFINITY * -0.0, |
299 V8_INFINITY * 0.0, nan}; | 299 V8_INFINITY * 0.0, nan}; |
300 return std::vector<double>(&values[0], &values[arraysize(values)]); | 300 return std::vector<double>(&values[0], &values[arraysize(values)]); |
301 } | 301 } |
302 | 302 |
| 303 static const std::vector<int16_t> int16_vector() { |
| 304 static const int16_t kValues[] = { |
| 305 0, 1, 2, INT16_MAX - 1, INT16_MAX, INT16_MIN, INT16_MIN + 1, -2, -1}; |
| 306 return std::vector<int16_t>(&kValues[0], &kValues[arraysize(kValues)]); |
| 307 } |
| 308 |
| 309 static const std::vector<int8_t> int8_vector() { |
| 310 static const int8_t kValues[] = { |
| 311 0, 1, 2, INT8_MAX - 1, INT8_MAX, INT8_MIN, INT8_MIN + 1, -2, -1}; |
| 312 return std::vector<int8_t>(&kValues[0], &kValues[arraysize(kValues)]); |
| 313 } |
| 314 |
303 static const std::vector<uint32_t> ror_vector() { | 315 static const std::vector<uint32_t> ror_vector() { |
304 static const uint32_t kValues[31] = { | 316 static const uint32_t kValues[31] = { |
305 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | 317 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
306 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; | 318 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; |
307 return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); | 319 return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); |
308 } | 320 } |
309 }; | 321 }; |
310 | 322 |
311 // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } | 323 // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } |
312 // Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL. | 324 // Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL. |
313 #define FOR_INPUTS(ctype, itype, var) \ | 325 #define FOR_INPUTS(ctype, itype, var) \ |
314 std::vector<ctype> var##_vec = ValueHelper::itype##_vector(); \ | 326 std::vector<ctype> var##_vec = ValueHelper::itype##_vector(); \ |
315 for (std::vector<ctype>::iterator var = var##_vec.begin(); \ | 327 for (std::vector<ctype>::iterator var = var##_vec.begin(); \ |
316 var != var##_vec.end(); ++var) | 328 var != var##_vec.end(); ++var) |
317 | 329 |
318 #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) | 330 #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) |
319 #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) | 331 #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) |
| 332 #define FOR_INT16_INPUTS(var) FOR_INPUTS(int16_t, int16, var) |
| 333 #define FOR_INT8_INPUTS(var) FOR_INPUTS(int8_t, int8, var) |
320 #define FOR_INT64_INPUTS(var) FOR_INPUTS(int64_t, int64, var) | 334 #define FOR_INT64_INPUTS(var) FOR_INPUTS(int64_t, int64, var) |
321 #define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var) | 335 #define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var) |
322 #define FOR_FLOAT32_INPUTS(var) FOR_INPUTS(float, float32, var) | 336 #define FOR_FLOAT32_INPUTS(var) FOR_INPUTS(float, float32, var) |
323 #define FOR_FLOAT64_INPUTS(var) FOR_INPUTS(double, float64, var) | 337 #define FOR_FLOAT64_INPUTS(var) FOR_INPUTS(double, float64, var) |
324 | 338 |
325 #define FOR_INT32_SHIFTS(var) for (int32_t var = 0; var < 32; var++) | 339 #define FOR_INT32_SHIFTS(var) for (int32_t var = 0; var < 32; var++) |
326 | 340 |
327 #define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) | 341 #define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) |
328 | 342 |
329 // TODO(bmeurer): Drop this crap once we switch to GTest/Gmock. | 343 // TODO(bmeurer): Drop this crap once we switch to GTest/Gmock. |
(...skipping 25 matching lines...) Expand all Loading... |
355 do { \ | 369 do { \ |
356 volatile double tmp = lhs; \ | 370 volatile double tmp = lhs; \ |
357 CheckDoubleEq(tmp, rhs); \ | 371 CheckDoubleEq(tmp, rhs); \ |
358 } while (0) | 372 } while (0) |
359 | 373 |
360 } // namespace compiler | 374 } // namespace compiler |
361 } // namespace internal | 375 } // namespace internal |
362 } // namespace v8 | 376 } // namespace v8 |
363 | 377 |
364 #endif // V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 378 #endif // V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
OLD | NEW |