Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PLATFORM_GLOBALS_H_ | 5 #ifndef PLATFORM_GLOBALS_H_ |
| 6 #define PLATFORM_GLOBALS_H_ | 6 #define PLATFORM_GLOBALS_H_ |
| 7 | 7 |
| 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to | 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to |
| 9 // enable platform independent printf format specifiers. | 9 // enable platform independent printf format specifiers. |
| 10 #ifndef __STDC_FORMAT_MACROS | 10 #ifndef __STDC_FORMAT_MACROS |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 #define TARGET_OS_LINUX 1 | 66 #define TARGET_OS_LINUX 1 |
| 67 #elif defined(__APPLE__) | 67 #elif defined(__APPLE__) |
| 68 #define TARGET_OS_MACOS 1 | 68 #define TARGET_OS_MACOS 1 |
| 69 #elif defined(_WIN32) | 69 #elif defined(_WIN32) |
| 70 #define TARGET_OS_WINDOWS 1 | 70 #define TARGET_OS_WINDOWS 1 |
| 71 #else | 71 #else |
| 72 #error Automatic target os detection failed. | 72 #error Automatic target os detection failed. |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 struct simd128_value_t { | 75 struct simd128_value_t { |
| 76 float storage[4]; | 76 union { |
| 77 float storage[4]; | |
|
kasperl
2014/01/29 14:07:50
Rename to float_storage?
Anders Johnsen
2014/01/29 14:21:20
Done.
| |
| 78 int32_t int_storage[4]; | |
| 79 }; | |
| 77 simd128_value_t& readFrom(const float* v) { | 80 simd128_value_t& readFrom(const float* v) { |
| 78 storage[0] = v[0]; | 81 storage[0] = v[0]; |
| 79 storage[1] = v[1]; | 82 storage[1] = v[1]; |
| 80 storage[2] = v[2]; | 83 storage[2] = v[2]; |
| 81 storage[3] = v[3]; | 84 storage[3] = v[3]; |
| 82 return *this; | 85 return *this; |
| 83 } | 86 } |
| 84 simd128_value_t& readFrom(const int32_t* v) { | 87 simd128_value_t& readFrom(const int32_t* v) { |
| 85 const float* vv = reinterpret_cast<const float*>(v); | 88 int_storage[0] = v[0]; |
| 86 storage[0] = vv[0]; | 89 int_storage[1] = v[1]; |
| 87 storage[1] = vv[1]; | 90 int_storage[2] = v[2]; |
| 88 storage[2] = vv[2]; | 91 int_storage[3] = v[3]; |
| 89 storage[3] = vv[3]; | |
| 90 return *this; | 92 return *this; |
| 91 } | 93 } |
| 92 simd128_value_t& readFrom(const simd128_value_t* v) { | 94 simd128_value_t& readFrom(const simd128_value_t* v) { |
| 93 *this = *v; | 95 *this = *v; |
| 94 return *this; | 96 return *this; |
| 95 } | 97 } |
| 96 void writeTo(float* v) { | 98 void writeTo(float* v) { |
| 97 v[0] = storage[0]; | 99 v[0] = storage[0]; |
| 98 v[1] = storage[1]; | 100 v[1] = storage[1]; |
| 99 v[2] = storage[2]; | 101 v[2] = storage[2]; |
| 100 v[3] = storage[3]; | 102 v[3] = storage[3]; |
| 101 } | 103 } |
| 102 void writeTo(int32_t* v) { | 104 void writeTo(int32_t* v) { |
| 103 float* vv = reinterpret_cast<float*>(v); | 105 v[0] = int_storage[0]; |
| 104 vv[0] = storage[0]; | 106 v[1] = int_storage[1]; |
| 105 vv[1] = storage[1]; | 107 v[2] = int_storage[2]; |
| 106 vv[2] = storage[2]; | 108 v[3] = int_storage[3]; |
| 107 vv[3] = storage[3]; | |
| 108 } | 109 } |
| 109 void writeTo(simd128_value_t* v) { | 110 void writeTo(simd128_value_t* v) { |
| 110 *v = *this; | 111 *v = *this; |
| 111 } | 112 } |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 // Processor architecture detection. For more info on what's defined, see: | 115 // Processor architecture detection. For more info on what's defined, see: |
| 115 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 116 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 116 // http://www.agner.org/optimize/calling_conventions.pdf | 117 // http://www.agner.org/optimize/calling_conventions.pdf |
| 117 // or with gcc, run: "echo | gcc -E -dM -" | 118 // or with gcc, run: "echo | gcc -E -dM -" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods | 490 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods |
| 490 // have an implicit 'this' argument, the arguments of such methods | 491 // have an implicit 'this' argument, the arguments of such methods |
| 491 // should be counted from two, not one." | 492 // should be counted from two, not one." |
| 492 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ | 493 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
| 493 __attribute__((__format__(__printf__, string_index, first_to_check))) | 494 __attribute__((__format__(__printf__, string_index, first_to_check))) |
| 494 #else | 495 #else |
| 495 #define PRINTF_ATTRIBUTE(string_index, first_to_check) | 496 #define PRINTF_ATTRIBUTE(string_index, first_to_check) |
| 496 #endif | 497 #endif |
| 497 | 498 |
| 498 #endif // PLATFORM_GLOBALS_H_ | 499 #endif // PLATFORM_GLOBALS_H_ |
| OLD | NEW |