4 // Rodrigo Kumpera (rkumpera@novell.com)
6 // (C) 2008 Novell, Inc. (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System.Runtime.InteropServices;
32 [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)]
34 public struct Vector16sb
69 public Vector16sb (sbyte v0, sbyte v1, sbyte v2, sbyte v3, sbyte v4, sbyte v5, sbyte v6, sbyte v7, sbyte v8, sbyte v9, sbyte v10, sbyte v11, sbyte v12, sbyte v13, sbyte v14, sbyte v15)
89 public Vector16sb (sbyte sb)
109 public sbyte V0 { get { return v0; } set { v0 = value; } }
110 public sbyte V1 { get { return v1; } set { v1 = value; } }
111 public sbyte V2 { get { return v2; } set { v2 = value; } }
112 public sbyte V3 { get { return v3; } set { v3 = value; } }
113 public sbyte V4 { get { return v4; } set { v4 = value; } }
114 public sbyte V5 { get { return v5; } set { v5 = value; } }
115 public sbyte V6 { get { return v6; } set { v6 = value; } }
116 public sbyte V7 { get { return v7; } set { v7 = value; } }
117 public sbyte V8 { get { return v8; } set { v8 = value; } }
118 public sbyte V9 { get { return v9; } set { v9 = value; } }
119 public sbyte V10 { get { return v10; } set { v10 = value; } }
120 public sbyte V11 { get { return v11; } set { v11 = value; } }
121 public sbyte V12 { get { return v12; } set { v12 = value; } }
122 public sbyte V13 { get { return v13; } set { v13 = value; } }
123 public sbyte V14 { get { return v14; } set { v14 = value; } }
124 public sbyte V15 { get { return v15; } set { v15 = value; } }
126 public static Vector16sb One
128 get { return new Vector16sb (1); }
131 public static Vector16sb Zero
133 get { return new Vector16sb (0); }
136 public static Vector16sb MinusOne
138 get { return new Vector16sb (-1); }
141 [System.Runtime.CompilerServices.IndexerName ("Component")]
142 public unsafe sbyte this [int index]
145 if ((index | 0xF) != 0xF) //index < 0 || index > 15
146 throw new ArgumentOutOfRangeException ("index");
147 fixed (sbyte *v = &v0) {
152 if ( (index | 0xF) != 0xF) //index < 0 || index > 15
153 throw new ArgumentOutOfRangeException ("index");
154 fixed (sbyte *v = &v0) {
155 *(v + index) = value;
160 [Acceleration (AccelMode.SSE2)]
161 public static unsafe Vector16sb operator + (Vector16sb va, Vector16sb vb)
163 Vector16sb res = new Vector16sb ();
167 for (int i = 0; i < 16; ++i)
168 *c++ = (sbyte)(*a++ + *b++);
172 [Acceleration (AccelMode.SSE2)]
173 public static unsafe Vector16sb operator - (Vector16sb va, Vector16sb vb)
175 Vector16sb res = new Vector16sb ();
179 for (int i = 0; i < 16; ++i)
180 *c++ = (sbyte)(*a++ - *b++);
184 [Acceleration (AccelMode.SSE2)]
185 public static unsafe Vector16sb operator & (Vector16sb va, Vector16sb vb)
187 Vector16sb res = new Vector16sb ();
188 uint *a = (uint*) &va.v0;
189 uint *b = (uint*) &vb.v0;
190 uint *c = (uint*) &res.v0;
198 [Acceleration (AccelMode.SSE2)]
199 public static unsafe Vector16sb operator | (Vector16sb va, Vector16sb vb)
201 Vector16sb res = new Vector16sb ();
202 uint *a = (uint*) &va.v0;
203 uint *b = (uint*) &vb.v0;
204 uint *c = (uint*) &res.v0;
212 [Acceleration (AccelMode.SSE2)]
213 public static unsafe Vector16sb operator ^ (Vector16sb va, Vector16sb vb)
215 Vector16sb res = new Vector16sb ();
216 uint *a = (uint*) &va.v0;
217 uint *b = (uint*) &vb.v0;
218 uint *c = (uint*) &res.v0;
226 [Acceleration (AccelMode.SSE2)]
227 public unsafe static bool operator ==(Vector16sb va, Vector16sb vb)
231 for (int i = 0; i < 16; ++i)
237 [Acceleration (AccelMode.SSE2)]
238 public unsafe static bool operator !=(Vector16sb va, Vector16sb vb)
242 for (int i = 0; i < 16; ++i)
248 [Acceleration (AccelMode.SSE1)]
249 public static unsafe explicit operator Vector2d (Vector16sb v)
251 Vector2d* p = (Vector2d*)&v;
255 [Acceleration (AccelMode.SSE1)]
256 public static unsafe explicit operator Vector4f (Vector16sb v)
258 Vector4f* p = (Vector4f*)&v;
262 [Acceleration (AccelMode.SSE1)]
263 public static unsafe explicit operator Vector2l (Vector16sb v)
265 Vector2l* p = (Vector2l*)&v;
269 [Acceleration (AccelMode.SSE1)]
270 public static unsafe explicit operator Vector2ul (Vector16sb v)
272 Vector2ul* p = (Vector2ul*)&v;
276 [Acceleration (AccelMode.SSE1)]
277 public static unsafe explicit operator Vector4i (Vector16sb v)
279 Vector4i* p = (Vector4i*)&v;
283 [Acceleration (AccelMode.SSE1)]
284 public static unsafe explicit operator Vector4ui (Vector16sb v)
286 Vector4ui* p = (Vector4ui*)&v;
290 [Acceleration (AccelMode.SSE1)]
291 public static unsafe explicit operator Vector8s (Vector16sb v)
293 Vector8s* p = (Vector8s*)&v;
297 [Acceleration (AccelMode.SSE1)]
298 public static unsafe explicit operator Vector8us (Vector16sb v)
300 Vector8us* p = (Vector8us*)&v;
304 [Acceleration (AccelMode.SSE1)]
305 public static unsafe explicit operator Vector16b (Vector16sb v)
307 Vector16b* p = (Vector16b*)&v;
311 [Acceleration (AccelMode.SSE1)]
312 public static Vector16sb LoadAligned (ref Vector16sb v)
317 [Acceleration (AccelMode.SSE1)]
318 public static void StoreAligned (ref Vector16sb res, Vector16sb val)
323 [Acceleration (AccelMode.SSE1)]
324 public static unsafe Vector16sb LoadAligned (Vector16sb *v)
329 [Acceleration (AccelMode.SSE1)]
330 public static unsafe void StoreAligned (Vector16sb *res, Vector16sb val)
335 [Acceleration (AccelMode.SSE1)]
336 [CLSCompliant(false)]
337 public static void PrefetchTemporalAllCacheLevels (ref Vector16sb res)
341 [Acceleration (AccelMode.SSE1)]
342 [CLSCompliant(false)]
343 public static void PrefetchTemporal1stLevelCache (ref Vector16sb res)
347 [Acceleration (AccelMode.SSE1)]
348 [CLSCompliant(false)]
349 public static void PrefetchTemporal2ndLevelCache (ref Vector16sb res)
353 [Acceleration (AccelMode.SSE1)]
354 [CLSCompliant(false)]
355 public static void PrefetchNonTemporal (ref Vector16sb res)
359 [Acceleration (AccelMode.SSE1)]
360 [CLSCompliant(false)]
361 public static unsafe void PrefetchTemporalAllCacheLevels (Vector16sb *res)
365 [Acceleration (AccelMode.SSE1)]
366 [CLSCompliant(false)]
367 public static unsafe void PrefetchTemporal1stLevelCache (Vector16sb *res)
371 [Acceleration (AccelMode.SSE1)]
372 [CLSCompliant(false)]
373 public static unsafe void PrefetchTemporal2ndLevelCache (Vector16sb *res)
377 [Acceleration (AccelMode.SSE1)]
378 [CLSCompliant(false)]
379 public static unsafe void PrefetchNonTemporal (Vector16sb *res)
383 public override string ToString()
385 return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
386 v4 + ", " + v5 + ", " + v6 + ", " + v7 + ", " +
387 + v8 + ", " + v9 + ", " + v10 + ", " + v11 + ", " +
388 v12 + ", " + v13 + ", " + v14 + ", " + v15 + ">";