Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: runtime/platform/globals.h

Issue 12871015: SIMD plumbing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: s/materialize/Materialize Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/byte_array.cc ('k') | runtime/vm/code_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #elif defined(__linux__) || defined(__FreeBSD__) 65 #elif defined(__linux__) || defined(__FreeBSD__)
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 {
76 float storage[4];
77 simd128_value_t& readFrom(const float* v) {
78 storage[0] = v[0];
79 storage[1] = v[1];
80 storage[2] = v[2];
81 storage[3] = v[3];
82 return *this;
83 }
84 simd128_value_t& readFrom(const uint32_t* v) {
85 const float* vv = reinterpret_cast<const float*>(v);
86 storage[0] = vv[0];
87 storage[1] = vv[1];
88 storage[2] = vv[2];
89 storage[3] = vv[3];
90 return *this;
91 }
92 simd128_value_t& readFrom(const simd128_value_t* v) {
93 *this = *v;
94 return *this;
95 }
96 void writeTo(float* v) {
97 v[0] = storage[0];
98 v[1] = storage[1];
99 v[2] = storage[2];
100 v[3] = storage[3];
101 }
102 void writeTo(uint32_t* v) {
103 float* vv = reinterpret_cast<float*>(v);
104 vv[0] = storage[0];
105 vv[1] = storage[1];
106 vv[2] = storage[2];
107 vv[3] = storage[3];
108 }
109 void writeTo(simd128_value_t* v) {
110 *v = *this;
111 }
112 };
113
75 // Processor architecture detection. For more info on what's defined, see: 114 // Processor architecture detection. For more info on what's defined, see:
76 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 115 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
77 // http://www.agner.org/optimize/calling_conventions.pdf 116 // http://www.agner.org/optimize/calling_conventions.pdf
78 // or with gcc, run: "echo | gcc -E -dM -" 117 // or with gcc, run: "echo | gcc -E -dM -"
79 #if defined(_M_X64) || defined(__x86_64__) 118 #if defined(_M_X64) || defined(__x86_64__)
80 #define HOST_ARCH_X64 1 119 #define HOST_ARCH_X64 1
81 #define ARCH_IS_64_BIT 1 120 #define ARCH_IS_64_BIT 1
82 #include <xmmintrin.h> // NOLINT
83 #define kFpuRegisterSize 16 121 #define kFpuRegisterSize 16
84 typedef __m128 fpu_register_t; 122 typedef simd128_value_t fpu_register_t;
85 typedef __m128 simd_value_t;
86 // Unaligned load.
87 #define simd_value_safe_load(addr) \
88 _mm_loadu_ps(reinterpret_cast<const float*>(addr))
89 // Unaligned store.
90 #define simd_value_safe_store(addr, value) \
91 _mm_storeu_ps(reinterpret_cast<float*>(addr), value)
92 #elif defined(_M_IX86) || defined(__i386__) 123 #elif defined(_M_IX86) || defined(__i386__)
93 #define HOST_ARCH_IA32 1 124 #define HOST_ARCH_IA32 1
94 #define ARCH_IS_32_BIT 1 125 #define ARCH_IS_32_BIT 1
95 #include <xmmintrin.h> // NOLINT
96 #define kFpuRegisterSize 16 126 #define kFpuRegisterSize 16
97 typedef __m128 fpu_register_t; 127 typedef simd128_value_t fpu_register_t;
98 typedef __m128 simd_value_t;
99 // Unaligned load.
100 #define simd_value_safe_load(addr) \
101 _mm_loadu_ps(reinterpret_cast<const float*>(addr))
102 // Unaligned store.
103 #define simd_value_safe_store(addr, value) \
104 _mm_storeu_ps(reinterpret_cast<float*>(addr), value)
105 #elif defined(__ARMEL__) 128 #elif defined(__ARMEL__)
106 #define HOST_ARCH_ARM 1 129 #define HOST_ARCH_ARM 1
107 #define ARCH_IS_32_BIT 1 130 #define ARCH_IS_32_BIT 1
108 #define kFpuRegisterSize 8 131 #define kFpuRegisterSize 8
109 typedef double fpu_register_t; 132 typedef double fpu_register_t;
110 // TODO(johnmccutchan): ARM simd type.
111 typedef struct {
112 uint32_t data_[4];
113 } simd_value_t;
114 #elif defined(__MIPSEL__) 133 #elif defined(__MIPSEL__)
115 #define HOST_ARCH_MIPS 1 134 #define HOST_ARCH_MIPS 1
116 #define ARCH_IS_32_BIT 1 135 #define ARCH_IS_32_BIT 1
117 #define kFpuRegisterSize 8 136 #define kFpuRegisterSize 8
118 typedef double fpu_register_t; 137 typedef double fpu_register_t;
119 // TODO(johnmccutchan): MIPS simd type.
120 typedef struct {
121 uint32_t data_[4];
122 } simd_value_t;
123 #else 138 #else
124 #error Architecture was not detected as supported by Dart. 139 #error Architecture was not detected as supported by Dart.
125 #endif 140 #endif
126 141
127 // DART_FORCE_INLINE strongly hints to the compiler that a function should 142 // DART_FORCE_INLINE strongly hints to the compiler that a function should
128 // be inlined. Your function is not guaranteed to be inlined but this is 143 // be inlined. Your function is not guaranteed to be inlined but this is
129 // stronger than just using "inline". 144 // stronger than just using "inline".
130 // See: http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx for an 145 // See: http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx for an
131 // explanation of some the cases when a function can never be inlined. 146 // explanation of some the cases when a function can never be inlined.
132 #ifdef _MSC_VER 147 #ifdef _MSC_VER
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 223
209 // Types for native machine words. Guaranteed to be able to hold pointers and 224 // Types for native machine words. Guaranteed to be able to hold pointers and
210 // integers. 225 // integers.
211 typedef intptr_t word; 226 typedef intptr_t word;
212 typedef uintptr_t uword; 227 typedef uintptr_t uword;
213 228
214 // Byte sizes. 229 // Byte sizes.
215 const int kWordSize = sizeof(word); 230 const int kWordSize = sizeof(word);
216 const int kDoubleSize = sizeof(double); // NOLINT 231 const int kDoubleSize = sizeof(double); // NOLINT
217 const int kFloatSize = sizeof(float); // NOLINT 232 const int kFloatSize = sizeof(float); // NOLINT
218 const int kSimd128Size = 16; 233 const int kSimd128Size = sizeof(simd128_value_t); // NOLINT
219 #ifdef ARCH_IS_32_BIT 234 #ifdef ARCH_IS_32_BIT
220 const int kWordSizeLog2 = 2; 235 const int kWordSizeLog2 = 2;
221 const uword kUwordMax = kMaxUint32; 236 const uword kUwordMax = kMaxUint32;
222 #else 237 #else
223 const int kWordSizeLog2 = 3; 238 const int kWordSizeLog2 = 3;
224 const uword kUwordMax = kMaxUint64; 239 const uword kUwordMax = kMaxUint64;
225 #endif 240 #endif
226 241
227 // Bit sizes. 242 // Bit sizes.
228 const int kBitsPerByte = 8; 243 const int kBitsPerByte = 8;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods 448 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods
434 // have an implicit 'this' argument, the arguments of such methods 449 // have an implicit 'this' argument, the arguments of such methods
435 // should be counted from two, not one." 450 // should be counted from two, not one."
436 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ 451 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \
437 __attribute__((__format__(__printf__, string_index, first_to_check))) 452 __attribute__((__format__(__printf__, string_index, first_to_check)))
438 #else 453 #else
439 #define PRINTF_ATTRIBUTE(string_index, first_to_check) 454 #define PRINTF_ATTRIBUTE(string_index, first_to_check)
440 #endif 455 #endif
441 456
442 #endif // PLATFORM_GLOBALS_H_ 457 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « runtime/lib/byte_array.cc ('k') | runtime/vm/code_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698