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

Unified Diff: runtime/lib/simd128.dart

Issue 12303013: Simd128Float32, Simd128Mask, and Simd128Float32List additions for dart:scalarlist (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
Index: runtime/lib/simd128.dart
diff --git a/runtime/lib/simd128.dart b/runtime/lib/simd128.dart
new file mode 100644
index 0000000000000000000000000000000000000000..caca5b97daa66885e7e7165b78186e23ac4ae31f
--- /dev/null
+++ b/runtime/lib/simd128.dart
@@ -0,0 +1,734 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+patch class Simd128Float32 {
+ /* patch */ factory Simd128Float32(double x, double y, double z, double w) {
+ //return new _Simd128Float32Dart(x, y, z, w);
+ return new _Simd128Float32(x, y, z, w);
+ }
+ /* patch */ factory Simd128Float32.zero() {
+ //return new _Simd128Float32Dart.zero();
+ return new _Simd128Float32.zero();
+ }
+}
+
+patch class Simd128Mask {
+ /* patch */ factory Simd128Mask(int x, int y, int z, int w) {
+ //return new _Simd128MaskDart(x, y, z, w);
+ return new _Simd128Mask(x, y, z, w);
+ }
+ /* patch */ factory Simd128Mask.bool(bool x, bool y, bool z, bool w) {
+ //return new _Simd128MaskDart.bool(x, y, z, w);
+ return new _Simd128Mask.bool(x, y, z, w);
+ }
+}
+
+
+patch class Simd128Float32List {
+ /* patch */ factory Simd128Float32List(int length) {
+ return new _Simd128Float32Array(length);
+ }
+
+ /* patch */ factory Simd128Float32List.transferable(int length) {
+ return _newTransferable(length);
+ }
+
+ /* patch */ factory Simd128Float32List.view(ByteArray array,
+ [int start = 0, int length]) {
+ return new _Simd128Float32ArrayView(array, start, length);
+ }
+
+ static _ExternalSimd128Float32Array _newTransferable(int length)
+ native "Simd128Float32List_newTransferable";
+}
+
+
+// Expose native square root.
+double _sqrt(double x) native "Math_sqrt";
+class _Simd128Float32Dart implements Simd128Float32 {
+ final Float32List storage = new Float32List(4);
sra1 2013/02/19 01:13:45 Should storage be public?
+ _Simd128Float32Dart.empty() {
+ }
+ _Simd128Float32Dart.copy(Float32List other) {
+ storage[0] = other.storage[0];
+ storage[1] = other.storage[1];
+ storage[2] = other.storage[2];
+ storage[3] = other.storage[3];
+ }
+ factory _Simd128Float32Dart(double x, double y, double z, double w) {
+ var instance = new _Simd128Float32Dart.empty();
+ instance.storage[0] = x;
+ instance.storage[1] = y;
+ instance.storage[2] = z;
+ instance.storage[3] = w;
+ return instance;
+ }
+ factory _Simd128Float32Dart.zero() {
+ var instance = new _Simd128Float32Dart.empty();
+ return instance;
+ }
+ Simd128Float32 operator+(Simd128Float32 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] += other.storage[0];
+ instance.storage[1] += other.storage[1];
+ instance.storage[2] += other.storage[2];
+ instance.storage[3] += other.storage[3];
+ return instance;
+ }
+ Simd128Float32 operator-() {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] *= -1.0;
+ instance.storage[1] *= -1.0;
+ instance.storage[2] *= -1.0;
+ instance.storage[3] *= -1.0;
+ return instance;
+ }
+ Simd128Float32 operator-(Simd128Float32 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] -= other.storage[0];
+ instance.storage[1] -= other.storage[1];
+ instance.storage[2] -= other.storage[2];
+ instance.storage[3] -= other.storage[3];
+ return instance;
+ }
+ Simd128Float32 operator*(Simd128Float32 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] *= other.storage[0];
+ instance.storage[1] *= other.storage[1];
+ instance.storage[2] *= other.storage[2];
+ instance.storage[3] *= other.storage[3];
+ return instance;
+ }
+ Simd128Float32 operator/(Simd128Float32 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] /= other.storage[0];
+ instance.storage[1] /= other.storage[1];
+ instance.storage[2] /= other.storage[2];
+ instance.storage[3] /= other.storage[3];
+ return instance;
+ }
+ Simd128Mask operator<(Simd128Float32 other) {
sra1 2013/02/19 01:13:45 I'm a little nervous about a comparison operations
+ bool _x = storage[0] < other.storage[0];
+ bool _y = storage[1] < other.storage[1];
+ bool _z = storage[2] < other.storage[2];
+ bool _w = storage[3] < other.storage[3];
+ return new Simd128Mask.bool(_x, _y, _z, _w);
+ }
+ Simd128Mask operator<=(Simd128Float32 other) {
+ bool _x = storage[0] <= other.storage[0];
+ bool _y = storage[1] <= other.storage[1];
+ bool _z = storage[2] <= other.storage[2];
+ bool _w = storage[3] <= other.storage[3];
+ return new Simd128Mask.bool(_x, _y, _z, _w);
+ }
+ Simd128Mask operator>(Simd128Float32 other) {
+ bool _x = storage[0] > other.storage[0];
+ bool _y = storage[1] > other.storage[1];
+ bool _z = storage[2] > other.storage[2];
+ bool _w = storage[3] > other.storage[3];
+ return new Simd128Mask.bool(_x, _y, _z, _w);
+ }
+ Simd128Mask operator>=(Simd128Float32 other) {
+ bool _x = storage[0] >= other.storage[0];
+ bool _y = storage[1] >= other.storage[1];
+ bool _z = storage[2] >= other.storage[2];
+ bool _w = storage[3] >= other.storage[3];
+ return new Simd128Mask.bool(_x, _y, _z, _w);
+ }
+ Simd128Mask operator==(Simd128Float32 other) {
+ bool _x = storage[0] == other.storage[0];
+ bool _y = storage[1] == other.storage[1];
+ bool _z = storage[2] == other.storage[2];
+ bool _w = storage[3] == other.storage[3];
+ return new Simd128Mask.bool(_x, _y, _z, _w);
+ }
+ Simd128Float32 scale(double s) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] *= s;
+ instance.storage[1] *= s;
+ instance.storage[2] *= s;
+ instance.storage[3] *= s;
+ return instance;
+ }
+ Simd128Float32 abs() {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = instance.storage[0].abs();
+ instance.storage[1] = instance.storage[1].abs();
+ instance.storage[2] = instance.storage[2].abs();
+ instance.storage[3] = instance.storage[3].abs();
+ return instance;
+ }
+ Simd128Float32 clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ if (instance.storage[0] > upperLimit.storage[0]) {
+ instance.storage[0] = upperLimit.storage[0];
+ }
+ if (instance.storage[1] > upperLimit.storage[1]) {
+ instance.storage[1] = upperLimit.storage[1];
+ }
+ if (instance.storage[2] > upperLimit.storage[2]) {
+ instance.storage[2] = upperLimit.storage[2];
+ }
+ if (instance.storage[3] > upperLimit.storage[3]) {
+ instance.storage[3] = upperLimit.storage[3];
+ }
+ if (instance.storage[0] < lowerLimit.storage[0]) {
+ instance.storage[0] = lowerLimit.storage[0];
+ }
+ if (instance.storage[1] < lowerLimit.storage[1]) {
+ instance.storage[1] = lowerLimit.storage[1];
+ }
+ if (instance.storage[2] < lowerLimit.storage[2]) {
+ instance.storage[2] = lowerLimit.storage[2];
+ }
+ if (instance.storage[3] < lowerLimit.storage[3]) {
+ instance.storage[3] = lowerLimit.storage[3];
+ }
+ return instance;
+ }
+ double get x => storage[0];
+ double get y => storage[1];
+ double get z => storage[2];
+ double get w => storage[3];
+ Simd128Float32 get xxxx {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[1] = instance.storage[0];
+ instance.storage[2] = instance.storage[0];
+ instance.storage[3] = instance.storage[0];
+ return instance;
+ }
+ Simd128Float32 get yyyy {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = instance.storage[1];
+ instance.storage[2] = instance.storage[1];
+ instance.storage[3] = instance.storage[1];
+ return instance;
+ }
+ Simd128Float32 get zzzz {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = instance.storage[2];
+ instance.storage[1] = instance.storage[2];
+ instance.storage[3] = instance.storage[2];
+ return instance;
+ }
+ Simd128Float32 get wwww {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = instance.storage[3];
+ instance.storage[1] = instance.storage[3];
+ instance.storage[2] = instance.storage[3];
+ return instance;
+ }
+ Simd128Float32 setX(double x) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = x;
+ return instance;
+ }
+ Simd128Float32 setY(double y) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[1] = y;
+ return instance;
+ }
+ Simd128Float32 setZ(double z) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[2] = z;
+ return instance;
+ }
+ Simd128Float32 setW(double w) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[3] = w;
+ return instance;
+ }
+ Simd128Float32 min(Simd128 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ if (instance.storage[0] > other.storage[0]) {
+ instance.storage[0] = other.storage[0];
+ }
+ if (instance.storage[1] > other.storage[1]) {
+ instance.storage[1] = other.storage[1];
+ }
+ if (instance.storage[2] > other.storage[2]) {
+ instance.storage[2] = other.storage[2];
+ }
+ if (instance.storage[3] > other.storage[3]) {
+ instance.storage[3] = other.storage[3];
+ }
+ return instance;
+ }
+ Simd128Float32 max(Simd128 other) {
+ var instance = new _Simd128Float32Dart.copy(this);
+ if (instance.storage[0] < other.storage[0]) {
+ instance.storage[0] = other.storage[0];
+ }
+ if (instance.storage[1] < other.storage[1]) {
+ instance.storage[1] = other.storage[1];
+ }
+ if (instance.storage[2] < other.storage[2]) {
+ instance.storage[2] = other.storage[2];
+ }
+ if (instance.storage[3] < other.storage[3]) {
+ instance.storage[3] = other.storage[3];
+ }
+ return instance;
+ }
+ Simd128Float32 sqrt() {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = _sqrt(instance.storage[0]);
+ instance.storage[1] = _sqrt(instance.storage[1]);
+ instance.storage[2] = _sqrt(instance.storage[2]);
+ instance.storage[3] = _sqrt(instance.storage[3]);
+ return instance;
+ }
+ Simd128Float32 reciprocal() {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = (1.0 / instance.storage[0]);
+ instance.storage[1] = (1.0 / instance.storage[1]);
+ instance.storage[2] = (1.0 / instance.storage[2]);
+ instance.storage[3] = (1.0 / instance.storage[3]);
+ return instance;
+ }
+ Simd128Float32 reciprocalSqrt() {
+ var instance = new _Simd128Float32Dart.copy(this);
+ instance.storage[0] = _sqrt(1.0 / instance.storage[0]);
+ instance.storage[1] = _sqrt(1.0 / instance.storage[1]);
+ instance.storage[2] = _sqrt(1.0 / instance.storage[2]);
+ instance.storage[3] = _sqrt(1.0 / instance.storage[3]);
+ return instance;
+ }
+ Simd128Mask toSimd128Mask() {
+ Uint32List view = new Uint32List.view(storage.asByteArray());
+ return new Simd128Mask(view[0], view[1], view[2], view[3]);
+ }
+}
+
+class _Simd128MaskDart implements Simd128Mask {
+ final Uint32List storage = new Uint32List(4);
+ _Simd128MaskDart.empty() {
+ }
+ _Simd128MaskDart.copy(_Simd128MaskDart other) {
+ storage[0] = other.storage[0];
+ storage[1] = other.storage[1];
+ storage[2] = other.storage[2];
+ storage[3] = other.storage[3];
+ }
+ factory _Simd128MaskDart(int x, int y, int z, int w) {
+ var instance = new _Simd128MaskDart.empty();
+ instance.storage[0] = x;
+ instance.storage[1] = y;
+ instance.storage[2] = z;
+ instance.storage[3] = w;
+ return instance;
+ }
+ factory _Simd128MaskDart.bool(bool x, bool y, bool z, bool w) {
+ var instance = new _Simd128MaskDart.empty();
+ instance.storage[0] = x ? 0xFFFFFFFF : 0x0;
+ instance.storage[1] = y ? 0xFFFFFFFF : 0x0;
+ instance.storage[2] = z ? 0xFFFFFFFF : 0x0;
+ instance.storage[3] = w ? 0xFFFFFFFF : 0x0;
+ return instance;
+ }
+ Simd128Mask operator|(Simd128Mask other) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[0] |= other.storage[0];
+ instance.storage[1] |= other.storage[1];
+ instance.storage[2] |= other.storage[2];
+ instance.storage[3] |= other.storage[3];
+ return instance;
+ }
+ Simd128Mask operator&(Simd128Mask other) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[0] &= other.storage[0];
+ instance.storage[1] &= other.storage[1];
+ instance.storage[2] &= other.storage[2];
+ instance.storage[3] &= other.storage[3];
+ return instance;
+ }
+ Simd128Mask operator^(Simd128Mask other) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[0] ^= other.storage[0];
+ instance.storage[1] ^= other.storage[1];
+ instance.storage[2] ^= other.storage[2];
+ instance.storage[3] ^= other.storage[3];
+ return instance;
+ }
+ int get x => storage[0];
+ int get y => storage[1];
+ int get z => storage[2];
+ int get w => storage[3];
+ Simd128Mask setX(int x) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[0] = x & 0xFFFFFFFF;
+ return instance;
+ }
+ Simd128Mask setY(int y) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[1] = y & 0xFFFFFFFF;
+ return instance;
+ }
+ Simd128Mask setZ(int z) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[2] = z & 0xFFFFFFFF;
+ return instance;
+ }
+ Simd128Mask setW(int w) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[3] = w & 0xFFFFFFFF;
+ return instance;
+ }
+ bool get flagX => storage[0] != 0x0;
+ bool get flagY => storage[1] != 0x0;
+ bool get flagZ => storage[2] != 0x0;
+ bool get flagW => storage[3] != 0x0;
+ Simd128Mask setFlagX(bool x) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[0] = x ? 0xFFFFFFFF : 0x0;
+ return instance;
+ }
+ Simd128Mask setFlagY(bool y) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[1] = y ? 0xFFFFFFFF : 0x0;
+ return instance;
+ }
+ Simd128Mask setFlagZ(bool z) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[2] = z ? 0xFFFFFFFF : 0x0;
+ return instance;
+ }
+ Simd128Mask setFlagW(bool w) {
+ var instance = new _Simd128MaskDart.copy(this);
+ instance.storage[3] = w ? 0xFFFFFFFF : 0x0;
+ return instance;
+ }
+ Simd128Float32 select(Simd128Float32 trueValue, Simd128Float32 falseValue) {
+ Simd128Mask trueMask = trueValue.toSimd128Mask();
sra1 2013/02/19 01:13:45 These are not so much masks as raw 'bits' or 'byte
+ Simd128Mask falseMask = falseValue.toSimd128Mask();
+ var instance = new _Simd128MaskDart.empty();
+ instance.storage[0] = (storage[0] & trueMask.storage[0]);
+ instance.storage[1] = (storage[1] & trueMask.storage[1]);
+ instance.storage[2] = (storage[2] & trueMask.storage[2]);
+ instance.storage[3] = (storage[3] & trueMask.storage[3]);
+ instance.storage[0] |= (~storage[0] & falseMask.storage[0]);
+ instance.storage[1] |= (~storage[1] & falseMask.storage[1]);
+ instance.storage[2] |= (~storage[2] & falseMask.storage[2]);
+ instance.storage[3] |= (~storage[3] & falseMask.storage[3]);
+ return instance.toSimd128Float32();
+ }
+ Simd128Float32 toSimd128Float32() {
+ Float32List view = new Float32List.view(storage.asByteArray());
+ return new Simd128Float32(view[0], view[1], view[2], view[3]);
+ }
+}
+
+class _Simd128Float32 implements Simd128Float32 {
+ factory _Simd128Float32(double x, double y, double z, double w)
+ native "Simd128Float32_fromDoubles";
+ factory _Simd128Float32.zero() native "Simd128Float32_zero";
+ Simd128Float32 operator+(Simd128Float32 other) {
+ return _add(other);
+ }
+ Simd128Float32 _add(Simd128Float32 other) native "Simd128Float32_add";
+ Simd128Float32 operator-() {
+ return _negate();
+ }
+ Simd128Float32 _negate() native "Simd128Float32_negate";
+ Simd128Float32 operator-(Simd128Float32 other) {
+ return _sub(other);
+ }
+ Simd128Float32 _sub(Simd128Float32 other) native "Simd128Float32_sub";
+ Simd128Float32 operator*(Simd128Float32 other) {
+ return _mul(other);
+ }
+ Simd128Float32 _mul(Simd128Float32 other) native "Simd128Float32_mul";
+ Simd128Float32 operator/(Simd128Float32 other) {
+ return _div(other);
+ }
+ Simd128Float32 _div(Simd128Float32 other) native "Simd128Float32_div";
+ Simd128Mask operator<(Simd128Float32 other) {
+ return _cmplt(other);
+ }
+ Simd128Mask _cmplt(Simd128Float32 other) native "Simd128Float32_cmplt";
+ Simd128Mask operator<=(Simd128Float32 other) {
+ return _cmplte(other);
+ }
+ Simd128Mask _cmplte(Simd128Float32 other) native "Simd128Float32_cmplte";
+ Simd128Mask operator>(Simd128Float32 other) {
+ return _cmpgt(other);
+ }
+ Simd128Mask _cmpgt(Simd128Float32 other) native "Simd128Float32_cmpgt";
+ Simd128Mask operator>=(Simd128Float32 other) {
+ return _cmpgte(other);
+ }
+ Simd128Mask _cmpgte(Simd128Float32 other) native "Simd128Float32_cmpgte";
+ Simd128Mask operator==(Simd128Float32 other) {
+ return _cmpequal(other);
+ }
+ Simd128Mask _cmpequal(Simd128Float32 other) native "Simd128Float32_cmpequal";
+ Simd128Float32 scale(double s) {
+ return _scale(s);
+ }
+ Simd128Float32 _scale(double s) native "Simd128Float32_scale";
+ Simd128Float32 abs() {
+ return _abs();
+ }
+ Simd128Float32 _abs() native "Simd128Float32_abs";
+ Simd128Float32 clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit) {
+ return _clamp(lowerLimit, upperLimit);
+ }
+ Simd128Float32 _clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit)
+ native "Simd128Float32_clamp";
+ double get x native "Simd128Float32_getX";
+ double get y native "Simd128Float32_getY";
+ double get z native "Simd128Float32_getZ";
+ double get w native "Simd128Float32_getW";
+ Simd128Float32 get xxxx native "Simd128Float32_getXXXX";
+ Simd128Float32 get yyyy native "Simd128Float32_getYYYY";
+ Simd128Float32 get zzzz native "Simd128Float32_getZZZZ";
+ Simd128Float32 get wwww native "Simd128Float32_getWWWW";
+ Simd128Float32 setX(double x) native "Simd128Float32_setX";
+ Simd128Float32 setY(double y) native "Simd128Float32_setY";
+ Simd128Float32 setZ(double z) native "Simd128Float32_setZ";
+ Simd128Float32 setW(double w) native "Simd128Float32_setW";
+ Simd128Float32 min(Simd128 other) {
+ return _min(other);
+ }
+ Simd128Float32 _min(Simd128Float32 other) native "Simd128Float32_min";
+ Simd128Float32 max(Simd128 other) {
+ return _max(other);
+ }
+ Simd128Float32 _max(Simd128Float32 other) native "Simd128Float32_max";
+ Simd128Float32 sqrt() {
+ return _sqrt();
+ }
+ Simd128Float32 _sqrt() native "Simd128Float32_sqrt";
+ Simd128Float32 reciprocal() {
+ return _reciprocal();
+ }
+ Simd128Float32 _reciprocal() native "Simd128Float32_reciprocal";
+ Simd128Float32 reciprocalSqrt() {
+ return _reciprocalSqrt();
+ }
+ Simd128Float32 _reciprocalSqrt() native "Simd128Float32_reciprocalSqrt";
+ Simd128Mask toSimd128Mask() {
+ return _toSimd128Mask();
+ }
+ Simd128Mask _toSimd128Mask() native "Simd128Float32_toSimd128Mask";
+}
+
+class _Simd128Mask implements Simd128Mask {
+ factory _Simd128Mask(int x, int y, int z, int w)
+ native "Simd128Mask_fromInts";
+ factory _Simd128Mask.bool(bool x, bool y, bool z, bool w)
+ native "Simd128Mask_fromBools";
+ Simd128Mask operator|(Simd128Mask other) {
+ return _or(other);
+ }
+ Simd128Mask _or(Simd128Mask other) native "Simd128Mask_or";
+ Simd128Mask operator&(Simd128Mask other) {
+ return _and(other);
+ }
+ Simd128Mask _and(Simd128Mask other) native "Simd128Mask_and";
+ Simd128Mask operator^(Simd128Mask other) {
+ return _xor(other);
+ }
+ Simd128Mask _xor(Simd128Mask other) native "Simd128Mask_xor";
+ int get x native "Simd128Mask_getX";
+ int get y native "Simd128Mask_getY";
+ int get z native "Simd128Mask_getZ";
+ int get w native "Simd128Mask_getW";
+ Simd128Mask setX(int x) native "Simd128Mask_setX";
+ Simd128Mask setY(int y) native "Simd128Mask_setY";
+ Simd128Mask setZ(int z) native "Simd128Mask_setZ";
+ Simd128Mask setW(int w) native "Simd128Mask_setW";
+ bool get flagX native "Simd128Mask_getFlagX";
+ bool get flagY native "Simd128Mask_getFlagY";
+ bool get flagZ native "Simd128Mask_getFlagZ";
+ bool get flagW native "Simd128Mask_getFlagW";
+ Simd128Mask setFlagX(bool x) native "Simd128Mask_setFlagX";
+ Simd128Mask setFlagY(bool y) native "Simd128Mask_setFlagY";
+ Simd128Mask setFlagZ(bool z) native "Simd128Mask_setFlagZ";
+ Simd128Mask setFlagW(bool w) native "Simd128Mask_setFlagW";
+ Simd128Float32 select(Simd128Float32 trueValue, Simd128Float32 falseValue) {
+ return _select(trueValue, falseValue);
+ }
+ Simd128Float32 _select(Simd128Float32 trueValue, Simd128Float32 falseValue)
+ native "Simd128Mask_select";
+ Simd128Float32 toSimd128Float32() {
+ return _toSimd128Float32();
+ }
+ Simd128Float32 _toSimd128Float32() native "Simd128Mask_toSimd128Float32";
+}
+
+
+class _Simd128Float32Array extends _ByteArrayBase implements Simd128Float32List {
+ factory _Simd128Float32Array(int length) {
+ return _new(length);
+ }
+ factory _Simd128Float32Array.view(ByteArray array,
+ [int start = 0, int length]) {
+ if (length == null) {
+ length = (array.lengthInBytes() - start) ~/ _BYTES_PER_ELEMENT;
+ }
+ return new _Simd128Float32ArrayView(array, start, length);
+ }
+ Simd128Float32 operator[](int index) {
+ return _getIndexed(index);
+ }
+ int operator[]=(int index, Simd128Float32 value) {
+ _setIndexed(index, value);
+ }
+ Iterator<Simd128Float32> get iterator {
+ return new _ByteArrayIterator<Simd128Float32>(this);
+ }
+ List<Simd128Float32> getRange(int start, int length) {
+ _rangeCheck(this.length, start, length);
+ List<Simd128Float32> result = _new(length);
+ result.setRange(0, length, this, start);
+ return result;
+ }
+ void setRange(int start, int length, List<Simd128Float32> from,
+ [int startFrom = 0]) {
+ if (from is _Simd128Float32Array) {
+ _setRange(start * _BYTES_PER_ELEMENT,
+ length * _BYTES_PER_ELEMENT,
+ from,
+ startFrom * _BYTES_PER_ELEMENT);
+ } else {
+ Arrays.copy(from, startFrom, this, start, length);
+ }
+ }
+ String toString() {
+ return Collections.collectionToString(this);
+ }
+ int bytesPerElement() {
+ return _BYTES_PER_ELEMENT;
+ }
+ int lengthInBytes() {
+ return _length() * _BYTES_PER_ELEMENT;
+ }
+ static const int _BYTES_PER_ELEMENT = 16;
+ static _Simd128Float32Array _new(int length) native "Simd128Float32Array_new";
+ Simd128Float32 _getIndexed(int index) native "Simd128Float32Array_getIndexed";
+ int _setIndexed(int index, Simd128Float32 value)
+ native "Simd128Float32Array_setIndexed";
+}
+
+
+class _Simd128Float32ArrayView extends _ByteArrayViewBase
+ implements Simd128Float32List {
+ _Simd128Float32ArrayView(ByteArray array,
+ [int offsetInBytes = 0, int _length])
+ : super(array, _requireInteger(offsetInBytes),
+ _requireIntegerOrNull(
+ _length,
+ ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
+ _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
+ }
+
+ Simd128Float32 operator[](int index) {
+ if (index < 0 || index >= length) {
+ String message = "$index must be in the range [0..$length)";
+ throw new RangeError(message);
+ }
+ return _array.getSimd128Float32(_offset + (index * _BYTES_PER_ELEMENT));
+ }
+
+ void operator[]=(int index, Simd128Float32 value) {
+ if (index < 0 || index >= length) {
+ String message = "$index must be in the range [0..$length)";
+ throw new RangeError(message);
+ }
+ _array.setSimd128Float32(_offset + (index * _BYTES_PER_ELEMENT), value);
+ }
+
+ Iterator<Simd128Float32> get iterator {
+ return new _ByteArrayIterator<Simd128Float32>(this);
+ }
+
+ List<Simd128Float32> getRange(int start, int length) {
+ _rangeCheck(this.length, start, length);
+ List<Simd128Float32> result = new Float32List(length);
+ result.setRange(0, length, this, start);
+ return result;
+ }
+
+ void setRange(int start, int length, List<Simd128Float32> from,
+ [int startFrom = 0]) {
+ Arrays.copy(from, startFrom, this, start, length);
+ }
+
+ String toString() {
+ return Collections.collectionToString(this);
+ }
+
+ int bytesPerElement() {
+ return _BYTES_PER_ELEMENT;
+ }
+
+ int lengthInBytes() {
+ return length * _BYTES_PER_ELEMENT;
+ }
+
+ ByteArray asByteArray([int start = 0, int length]) {
+ if (length == null) {
+ length = this.lengthInBytes();
+ }
+ _rangeCheck(this.length, start, length);
+ return _array.subByteArray(_offset + start, length);
+ }
+
+ static const int _BYTES_PER_ELEMENT = 16;
+}
+
+
+class _ExternalSimd128Float32Array extends _ByteArrayBase
+ implements Simd128Float32List {
+ Simd128Float32 operator[](int index) {
+ return _getIndexed(index);
+ }
+
+ int operator[]=(int index, Simd128Float32 value) {
+ _setIndexed(index, value);
+ }
+
+ Iterator<Simd128Float32> get iterator {
+ return new _ByteArrayIterator<Simd128Float32>(this);
+ }
+
+ List<Simd128Float32> getRange(int start, int length) {
+ _rangeCheck(this.length, start, length);
+ List<Simd128Float32> result = new Simd128Float32List(length);
+ result.setRange(0, length, this, start);
+ return result;
+ }
+
+ void setRange(int start, int length, List<Simd128Float32> from,
+ [int startFrom = 0]) {
+ if (from is _ExternalSimd128Float32Array) {
+ _setRange(start * _BYTES_PER_ELEMENT,
+ length * _BYTES_PER_ELEMENT,
+ from,
+ startFrom * _BYTES_PER_ELEMENT);
+ } else {
+ Arrays.copy(from, startFrom, this, start, length);
+ }
+ }
+
+ String toString() {
+ return Collections.collectionToString(this);
+ }
+
+ int bytesPerElement() {
+ return _BYTES_PER_ELEMENT;
+ }
+
+ int lengthInBytes() {
+ return _length() * _BYTES_PER_ELEMENT;
+ }
+
+ static const int _BYTES_PER_ELEMENT = 16;
+
+ Simd128Float32 _getIndexed(int index)
+ native "ExternalSimd128Float32Array_getIndexed";
+ int _setIndexed(int index, Simd128Float32 value)
+ native "ExternalSimd128Float32Array_setIndexed";
+}

Powered by Google App Engine
This is Rietveld 408576698