[tests] Separate MONO_PATH directories by PLATFORM_PATH_SEPARATOR
[mono.git] / mcs / class / Mono.Simd / Mono.Simd / Vector16sb.cs
1 // Vector16sb.cs
2 //
3 // Author:
4 //   Rodrigo Kumpera (rkumpera@novell.com)
5 //
6 // (C) 2008 Novell, Inc. (http://www.novell.com)
7 //
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:
15 //
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 //
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.
26 //
27 using System;
28 using System.Runtime.InteropServices;
29
30 namespace Mono.Simd
31 {
32         [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)]
33         [CLSCompliant(false)]
34         public struct Vector16sb
35         {
36                 [ FieldOffset(0) ]
37                 internal sbyte v0;
38                 [ FieldOffset(1) ]
39                 internal sbyte v1;
40                 [ FieldOffset(2) ]
41                 internal sbyte v2;
42                 [ FieldOffset(3) ]
43                 internal sbyte v3;
44                 [ FieldOffset(4) ]
45                 internal sbyte v4;
46                 [ FieldOffset(5) ]
47                 internal sbyte v5;
48                 [ FieldOffset(6) ]
49                 internal sbyte v6;
50                 [ FieldOffset(7) ]
51                 internal sbyte v7;
52                 [ FieldOffset(8) ]
53                 internal sbyte v8;
54                 [ FieldOffset(9) ]
55                 internal sbyte v9;
56                 [ FieldOffset(10) ]
57                 internal sbyte v10;
58                 [ FieldOffset(11) ]
59                 internal sbyte v11;
60                 [ FieldOffset(12) ]
61                 internal sbyte v12;
62                 [ FieldOffset(13) ]
63                 internal sbyte v13;
64                 [ FieldOffset(14) ]
65                 internal sbyte v14;
66                 [ FieldOffset(15) ]
67                 internal sbyte v15;
68                 
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)
70                 {
71                         this.v0 = v0;
72                         this.v1 = v1;
73                         this.v2 = v2;
74                         this.v3 = v3;
75                         this.v4 = v4;
76                         this.v5 = v5;
77                         this.v6 = v6;
78                         this.v7 = v7;
79                         this.v8 = v8;
80                         this.v9 = v9;
81                         this.v10 = v10;
82                         this.v11 = v11;
83                         this.v12 = v12;
84                         this.v13 = v13;
85                         this.v14 = v14;
86                         this.v15 = v15;
87                 }
88                 
89                 public Vector16sb (sbyte sb)
90                 {
91                         this.v0 = sb;
92                         this.v1 = sb;
93                         this.v2 = sb;
94                         this.v3 = sb;
95                         this.v4 = sb;
96                         this.v5 = sb;
97                         this.v6 = sb;
98                         this.v7 = sb;
99                         this.v8 = sb;
100                         this.v9 = sb;
101                         this.v10 = sb;
102                         this.v11 = sb;
103                         this.v12 = sb;
104                         this.v13 = sb;
105                         this.v14 = sb;
106                         this.v15 = sb;
107                 }
108
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; } }
125
126                 public static Vector16sb One
127                 {
128                         get { return new Vector16sb (1); }
129                 }
130
131                 public static Vector16sb Zero
132                 {
133                         get { return new Vector16sb (0); }
134                 }
135
136                 public static Vector16sb MinusOne
137                 {
138                         get { return new Vector16sb (-1); }
139                 }
140
141                 [System.Runtime.CompilerServices.IndexerName ("Component")]
142                 public unsafe sbyte this [int index]
143                 {
144                         get {
145                                 if ((index | 0xF) != 0xF) //index < 0 || index > 15
146                                         throw new ArgumentOutOfRangeException ("index");
147                                 fixed (sbyte *v = &v0) {
148                                         return *(v + index);
149                                 }
150                         }
151                         set {
152                                 if ( (index | 0xF) != 0xF) //index < 0 || index > 15
153                                         throw new ArgumentOutOfRangeException ("index");
154                                 fixed (sbyte *v = &v0) {
155                                         *(v + index) = value;
156                                 }
157                         }
158                 }
159
160                 [Acceleration (AccelMode.SSE2)]
161                 public static unsafe Vector16sb operator + (Vector16sb va, Vector16sb vb)
162                 {
163                         Vector16sb res = new Vector16sb ();
164                         sbyte *a = &va.v0;
165                         sbyte *b = &vb.v0;
166                         sbyte *c = &res.v0;
167                         for (int i = 0; i < 16; ++i)
168                                 *c++ = (sbyte)(*a++ + *b++);
169                         return res;
170                 }
171
172                 [Acceleration (AccelMode.SSE2)]
173                 public static unsafe Vector16sb operator - (Vector16sb va, Vector16sb vb)
174                 {
175                         Vector16sb res = new Vector16sb ();
176                         sbyte *a = &va.v0;
177                         sbyte *b = &vb.v0;
178                         sbyte *c = &res.v0;
179                         for (int i = 0; i < 16; ++i)
180                                 *c++ = (sbyte)(*a++ - *b++);
181                         return res;
182                 }
183
184                 [Acceleration (AccelMode.SSE2)]
185                 public static unsafe Vector16sb operator & (Vector16sb va, Vector16sb vb)
186                 {
187                         Vector16sb res = new Vector16sb ();
188                         uint *a = (uint*) &va.v0;
189                         uint *b = (uint*) &vb.v0;
190                         uint *c = (uint*) &res.v0;
191                         *c++ = *a++ & *b++;
192                         *c++ = *a++ & *b++;
193                         *c++ = *a++ & *b++;
194                         *c = *a & *b;
195                         return res;
196                 }
197
198                 [Acceleration (AccelMode.SSE2)]
199                 public static unsafe Vector16sb operator | (Vector16sb va, Vector16sb vb)
200                 {
201                         Vector16sb res = new Vector16sb ();
202                         uint *a = (uint*) &va.v0;
203                         uint *b = (uint*) &vb.v0;
204                         uint *c = (uint*) &res.v0;
205                         *c++ = *a++ | *b++;
206                         *c++ = *a++ | *b++;
207                         *c++ = *a++ | *b++;
208                         *c = *a | *b;
209                         return res;
210                 }
211
212                 [Acceleration (AccelMode.SSE2)]
213                 public static unsafe Vector16sb operator ^ (Vector16sb va, Vector16sb vb)
214                 {
215                         Vector16sb res = new Vector16sb ();
216                         uint *a = (uint*) &va.v0;
217                         uint *b = (uint*) &vb.v0;
218                         uint *c = (uint*) &res.v0;
219                         *c++ = *a++ ^ *b++;
220                         *c++ = *a++ ^ *b++;
221                         *c++ = *a++ ^ *b++;
222                         *c = *a ^ *b;
223                         return res;
224                 }
225
226                 [Acceleration (AccelMode.SSE2)]
227                 public unsafe static bool operator ==(Vector16sb va, Vector16sb vb)
228                 {
229                         sbyte *a = &va.v0;
230                         sbyte *b = &vb.v0;
231                         for (int i = 0; i < 16; ++i)
232                                 if (*a++ != *b++)
233                                         return false;
234                         return true;
235                 }
236
237                 [Acceleration (AccelMode.SSE2)]
238                 public unsafe static bool operator !=(Vector16sb va, Vector16sb vb)
239                 {
240                         sbyte *a = &va.v0;
241                         sbyte *b = &vb.v0;
242                         for (int i = 0; i < 16; ++i)
243                                 if (*a++ != *b++)
244                                         return true;
245                         return false;
246                 }
247
248                 [Acceleration (AccelMode.SSE1)]
249                 public static unsafe explicit operator Vector2d (Vector16sb v)
250                 {
251                         Vector2d* p = (Vector2d*)&v;
252                         return *p;
253                 }
254
255                 [Acceleration (AccelMode.SSE1)]
256                 public static unsafe explicit operator Vector4f (Vector16sb v)
257                 {
258                         Vector4f* p = (Vector4f*)&v;
259                         return *p;
260                 }
261
262                 [Acceleration (AccelMode.SSE1)]
263                 public static unsafe explicit operator Vector2l (Vector16sb v)
264                 {
265                         Vector2l* p = (Vector2l*)&v;
266                         return *p;
267                 }
268
269                 [Acceleration (AccelMode.SSE1)]
270                 public static unsafe explicit operator Vector2ul (Vector16sb v)
271                 {
272                         Vector2ul* p = (Vector2ul*)&v;
273                         return *p;
274                 }
275
276                 [Acceleration (AccelMode.SSE1)]
277                 public static unsafe explicit operator Vector4i (Vector16sb v)
278                 {
279                         Vector4i* p = (Vector4i*)&v;
280                         return *p;
281                 }
282
283                 [Acceleration (AccelMode.SSE1)]
284                 public static unsafe explicit operator Vector4ui (Vector16sb v)
285                 {
286                         Vector4ui* p = (Vector4ui*)&v;
287                         return *p;
288                 }
289
290                 [Acceleration (AccelMode.SSE1)]
291                 public static unsafe explicit operator Vector8s (Vector16sb v)
292                 {
293                         Vector8s* p = (Vector8s*)&v;
294                         return *p;
295                 }
296
297                 [Acceleration (AccelMode.SSE1)]
298                 public static unsafe explicit operator Vector8us (Vector16sb v)
299                 {
300                         Vector8us* p = (Vector8us*)&v;
301                         return *p;
302                 }
303
304                 [Acceleration (AccelMode.SSE1)]
305                 public static unsafe explicit operator Vector16b (Vector16sb v)
306                 {
307                         Vector16b* p = (Vector16b*)&v;
308                         return *p;
309                 }
310
311                 [Acceleration (AccelMode.SSE1)]
312                 public static Vector16sb LoadAligned (ref Vector16sb v)
313                 {
314                         return v;
315                 }
316
317                 [Acceleration (AccelMode.SSE1)]
318                 public static void StoreAligned (ref Vector16sb res, Vector16sb val)
319                 {
320                         res = val;
321                 }
322
323                 [Acceleration (AccelMode.SSE1)]
324                 public static unsafe Vector16sb LoadAligned (Vector16sb *v)
325                 {
326                         return *v;
327                 }
328
329                 [Acceleration (AccelMode.SSE1)]
330                 public static unsafe void StoreAligned (Vector16sb *res, Vector16sb val)
331                 {
332                         *res = val;
333                 }
334
335                 [Acceleration (AccelMode.SSE1)]
336                 [CLSCompliant(false)]
337                 public static void PrefetchTemporalAllCacheLevels (ref Vector16sb res)
338                 {
339                 }
340
341                 [Acceleration (AccelMode.SSE1)]
342                 [CLSCompliant(false)]
343                 public static void PrefetchTemporal1stLevelCache (ref Vector16sb res)
344                 {
345                 }
346
347                 [Acceleration (AccelMode.SSE1)]
348                 [CLSCompliant(false)]
349                 public static void PrefetchTemporal2ndLevelCache (ref Vector16sb res)
350                 {
351                 }
352
353                 [Acceleration (AccelMode.SSE1)]
354                 [CLSCompliant(false)]
355                 public static void PrefetchNonTemporal (ref Vector16sb res)
356                 {
357                 }
358
359                 [Acceleration (AccelMode.SSE1)]
360                 [CLSCompliant(false)]
361                 public static unsafe void PrefetchTemporalAllCacheLevels (Vector16sb *res)
362                 {
363                 }
364
365                 [Acceleration (AccelMode.SSE1)]
366                 [CLSCompliant(false)]
367                 public static unsafe void PrefetchTemporal1stLevelCache (Vector16sb *res)
368                 {
369                 }
370
371                 [Acceleration (AccelMode.SSE1)]
372                 [CLSCompliant(false)]
373                 public static unsafe void PrefetchTemporal2ndLevelCache (Vector16sb *res)
374                 {
375                 }
376
377                 [Acceleration (AccelMode.SSE1)]
378                 [CLSCompliant(false)]
379                 public static unsafe void PrefetchNonTemporal (Vector16sb *res)
380                 {
381                 }
382                 
383                 public override string ToString()
384                 {
385                         return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
386                                         v4 + ", " + v5 + ", " + v6 + ", " + v7 + ", " + 
387                                         + v8 + ", " + v9 + ", " + v10 + ", " + v11 + ", " +
388                                         v12 + ", " + v13 + ", " + v14 + ", " + v15 + ">"; 
389                 }
390         }
391 }