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

Side by Side Diff: sdk/lib/scalarlist/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 part of dart.scalarlist;
6
7 /**
8 * Interface of Dart Simd128Float32 and operations.
9 * Simd128Float32 stores 4 32-bit floating point values in "lanes".
sra1 2013/02/19 01:13:45 Why not call it Float32x4 ?
10 * The lanes are "x", "y", "z", and "w" respectively.
11 */
12 abstract class Simd128Float32 {
13 external factory Simd128Float32(double x, double y, double z, double w);
14 external factory Simd128Float32.zero();
15
16 /// Addition operator.
17 Simd128Float32 operator+(Simd128Float32 other);
18 /// Negate operator.
19 Simd128Float32 operator-();
20 /// Subtraction operator.
21 Simd128Float32 operator-(Simd128Float32 other);
22 /// Multiplication operator.
23 Simd128Float32 operator*(Simd128Float32 other);
24 /// Division operator.
25 Simd128Float32 operator/(Simd128Float32 other);
26
27 /// Relational less than operator.
28 Simd128Mask operator<(Simd128Float32 other);
29 /// Relational less than or equal operator.
30 Simd128Mask operator<=(Simd128Float32 other);
31 /// Relational greater than operator.
32 Simd128Mask operator>(Simd128Float32 other);
33 /// Relational greater than or equal operator.
34 Simd128Mask operator>=(Simd128Float32 other);
35 /// Relational equal operator.
36 Simd128Mask operator==(Simd128Float32 other);
37
38 /// Returns a copy of [this] each lane being scaled by [s].
39 Simd128Float32 scale(double s);
40 /// Returns the absolute value of this [Simd128Float32].
41 Simd128Float32 abs();
42 /// Clamps [this] to be in the range [lowerLimit]-[upperLimit].
43 Simd128Float32 clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit);
44
45 /// Extracted x value.
46 double get x;
47 /// Extracted y value.
48 double get y;
49 /// Extracted z value.
50 double get z;
51 /// Extracted w value.
52 double get w;
53
54 /// Returns a new [Simd128Float32] with [this]' x value in all four lanes.
55 Simd128Float32 get xxxx;
56 /// Returns a new [Simd128Float32] with [this]' y value in all four lanes.
57 Simd128Float32 get yyyy;
58 /// Returns a new [Simd128Float32] with [this]' z value in all four lanes.
59 Simd128Float32 get zzzz;
60 /// Returns a new [Simd128Float32] with [this]' w value in all four lanes.
61 Simd128Float32 get wwww;
62 // TODO(johnmccutchan): Add all 256 possible combinations.
63
64 /// Returns a new [Simd128Float32] copied from [this] with a new x value.
65 Simd128Float32 setX(double x);
66 /// Returns a new [Simd128Float32] copied from [this] with a new y value.
67 Simd128Float32 setY(double y);
68 /// Returns a new [Simd128Float32] copied from [this] with a new z value.
69 Simd128Float32 setZ(double z);
70 /// Returns a new [Simd128Float32] copied from [this] with a new w value.
71 Simd128Float32 setW(double w);
72
73 /// Returns the lane-wise minimum value in [this] or [other].
74 Simd128Float32 min(Simd128 other);
75
76 /// Returns the lane-wise maximum value in [this] or [other].
77 Simd128Float32 max(Simd128 other);
78
79 /// Returns the square root of [this].
80 Simd128Float32 sqrt();
81
82 /// Returns the reciprocal of [this].
83 Simd128Float32 reciprocal();
84
85 /// Returns the square root of the reciprocal of [this].
86 Simd128Float32 reciprocalSqrt();
87
88 /// Returns a copy of [this] as a [Simd128Mask].
89 Simd128Mask toSimd128Mask();
90 }
91
92 /**
93 * Interface of Dart Simd128Mask and operations.
94 * Simd128Mask stores 4 32-bit bit-masks in "lanes".
95 * The lanes are "x", "y", "z", and "w" respectively.
96 */
97 abstract class Simd128Mask {
98 external factory Simd128Mask(int x, int y, int z, int w);
99 external factory Simd128Mask.bool(bool x, bool y, bool z, bool w);
100
101 /// The bit-wise or operator.
102 Simd128Mask operator|(Simd128Mask other);
103 /// The bit-wise and operator.
104 Simd128Mask operator&(Simd128Mask other);
105 /// The bit-wise xor operator.
106 Simd128Mask operator^(Simd128Mask other);
107
108 /// Extract 32-bit mask from x lane.
109 int get x;
110 /// Extract 32-bit mask from y lane.
111 int get y;
112 /// Extract 32-bit mask from z lane.
113 int get z;
114 /// Extract 32-bit mask from w lane.
115 int get w;
116
117 /// Returns a new [Simd128Mask] copied from [this] with a new x value.
118 Simd128Mask setX(int x);
119 /// Returns a new [Simd128Mask] copied from [this] with a new y value.
120 Simd128Mask setY(int y);
121 /// Returns a new [Simd128Mask] copied from [this] with a new z value.
122 Simd128Mask setZ(int z);
123 /// Returns a new [Simd128Mask] copied from [this] with a new w value.
124 Simd128Mask setW(int w);
125
126 /// Extracted x value. Returns false for 0, true for any other value.
127 bool get flagX;
128 /// Extracted y value. Returns false for 0, true for any other value.
129 bool get flagY;
130 /// Extracted z value. Returns false for 0, true for any other value.
131 bool get flagZ;
132 /// Extracted w value. Returns false for 0, true for any other value.
133 bool get flagW;
134
135 /// Returns a new [Simd128Mask] copied from [this] with a new x value.
136 Simd128Mask setFlagX(bool x);
sra1 2013/02/19 01:13:45 Nothing is modified, so perhaps withFlagX would be
137 /// Returns a new [Simd128Mask] copied from [this] with a new y value.
138 Simd128Mask setFlagY(bool y);
139 /// Returns a new [Simd128Mask] copied from [this] with a new z value.
140 Simd128Mask setFlagZ(bool z);
141 /// Returns a new [Simd128Mask] copied from [this] with a new w value.
142 Simd128Mask setFlagW(bool w);
143
144 /// Merge [trueValue] and [falseValue] based on [this]' bit mask:
145 /// Select bit from [trueValue] when bit in [this] is on.
146 /// Select bit from [falseValue] when bit in [this] is off.
147 Simd128Float32 select(Simd128Float32 trueValue, Simd128Float32 falseValue);
148
149 /// Returns a copy of [this] as a [Simd128Float32].
sra1 2013/02/19 01:13:45 Converting from int to float32 or bitwise copy?
150 Simd128Float32 toSimd128Float32();
151 }
152
153 /**
154 * A fixed-length list of Simd128Float32 numbers that is viewable as a
155 * [ByteArray]. For long lists, this
156 * implementation will be considerably more space- and time-efficient than
157 * the default [List] implementation.
158 */
159 abstract class Simd128Float32List implements List<Simd128Float32>,
160 ByteArrayViewable {
161 /**
162 * Creates a [Simd128Float32List] of the specified length (in elements),
163 * all of whose elements are initially zero.
164 */
165 external factory Simd128Float32List(int length);
166
167 /**
168 * Creates a [Simd128Float32List] _view_ of the specified region in the
169 * specified byte [array]. Changes in the [Simd128Float32List] will be visible
170 * in the byte array and vice versa. If the [start] index of the region is
171 * not specified,
172 * it defaults to zero (the first byte in the byte array). If the length is
173 * not specified, it defaults to null, which indicates that the view extends
174 * to the end of the byte array.
175 *
176 * Throws [ArgumentError] if the length of the specified region
177 * is not divisible by 16 (the size of a "Simd128Float32" in bytes), or if the
178 * [start] of the region is not divisible by 16. If, however, [array]
179 * is a view of another byte array, this constructor will throw
180 * [ArgumentError] if the implicit starting position in the
181 * "ultimately backing" byte array is not divisible by 16. In plain terms,
182 * this constructor throws [ArgumentError] if the specified
183 * region does not contain an integral number of "Simd128Float32s," or if it
184 * is not "Simd128Float32-aligned."
185 */
186 external factory Simd128Float32List.view(ByteArray array,
187 [int start = 0, int length]);
188 }
OLDNEW
« runtime/lib/simd128.dart ('K') | « sdk/lib/scalarlist/scalarlist_sources.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698