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

Unified Diff: runtime/platform/globals.h

Issue 138203003: Mark simd128_value_t as able to containing both float and int32_t. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: storage->float_storage Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index 9e27506dd2b77ee001cd26958b8115a8b7753345..52adc16c79a292a586e918f525a852a65ddf28d3 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -73,20 +73,22 @@
#endif
struct simd128_value_t {
- float storage[4];
+ union {
+ float float_storage[4];
+ int32_t int_storage[4];
+ };
simd128_value_t& readFrom(const float* v) {
- storage[0] = v[0];
- storage[1] = v[1];
- storage[2] = v[2];
- storage[3] = v[3];
+ float_storage[0] = v[0];
+ float_storage[1] = v[1];
+ float_storage[2] = v[2];
+ float_storage[3] = v[3];
return *this;
}
simd128_value_t& readFrom(const int32_t* v) {
- const float* vv = reinterpret_cast<const float*>(v);
- storage[0] = vv[0];
- storage[1] = vv[1];
- storage[2] = vv[2];
- storage[3] = vv[3];
+ int_storage[0] = v[0];
+ int_storage[1] = v[1];
+ int_storage[2] = v[2];
+ int_storage[3] = v[3];
return *this;
}
simd128_value_t& readFrom(const simd128_value_t* v) {
@@ -94,17 +96,16 @@ struct simd128_value_t {
return *this;
}
void writeTo(float* v) {
- v[0] = storage[0];
- v[1] = storage[1];
- v[2] = storage[2];
- v[3] = storage[3];
+ v[0] = float_storage[0];
+ v[1] = float_storage[1];
+ v[2] = float_storage[2];
+ v[3] = float_storage[3];
}
void writeTo(int32_t* v) {
- float* vv = reinterpret_cast<float*>(v);
- vv[0] = storage[0];
- vv[1] = storage[1];
- vv[2] = storage[2];
- vv[3] = storage[3];
+ v[0] = int_storage[0];
+ v[1] = int_storage[1];
+ v[2] = int_storage[2];
+ v[3] = int_storage[3];
}
void writeTo(simd128_value_t* v) {
*v = *this;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698