[tests] Separate MONO_PATH directories by PLATFORM_PATH_SEPARATOR
[mono.git] / mcs / class / Mono.Simd / Mono.Simd / Vector2l.cs
1 // Vector2l.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 = 0, Size = 16)]
33         public struct Vector2l
34         {
35                 [ FieldOffset(0) ]
36                 internal long x;
37                 [ FieldOffset(8) ]
38                 internal long y;
39
40                 public long X { get { return x; } set { x = value; } }
41                 public long Y { get { return y; } set { y = value; } }
42
43                 public static Vector2l One
44                 {
45                         get { return new Vector2l (1); }
46                 }
47
48                 public static Vector2l Zero
49                 {
50                         get { return new Vector2l (0); }
51                 }
52
53                 public static Vector2l MinusOne
54                 {
55                         get { return new Vector2l (-1); }
56                 }
57
58                 [System.Runtime.CompilerServices.IndexerName ("Component")]
59                 public unsafe long this [int index]
60                 {
61                         get {
62                                 if ((index | 0x1) != 0x1) //index < 0 || index > 1
63                                         throw new ArgumentOutOfRangeException ("index");
64                                 fixed (long *v = &x) {
65                                         return * (v + index);
66                                 }
67                         }
68                         set {
69                                 if ( (index | 0x1) != 0x1) //index < 0 || index > 1
70                                         throw new ArgumentOutOfRangeException ("index");
71                                 fixed (long *v = &x) {
72                                         * (v + index) = value;
73                                 }
74                         }
75                 }
76
77                 public Vector2l (long x, long y)
78                 {
79                         this.x = x;
80                         this.y = y;
81                 }
82
83                 public Vector2l (long l)
84                 {
85                         this.x = l;
86                         this.y = l;
87                 }
88
89                 [Acceleration (AccelMode.SSE2)]
90                 public static Vector2l operator + (Vector2l v1, Vector2l v2)
91                 {
92                         return new Vector2l (v1.x + v2.x, v1.y + v2.y);
93                 }
94
95                 [Acceleration (AccelMode.SSE2)]
96                 public static Vector2l operator - (Vector2l v1, Vector2l v2)
97                 {
98                         return new Vector2l (v1.x - v2.x, v1.y - v2.y);
99                 }
100
101                 [Acceleration (AccelMode.SSE2)]
102                 public static unsafe Vector2l operator << (Vector2l v1, int amount)
103                 {
104                         return new Vector2l (v1.x << amount, v1.y << amount);
105                 }
106
107                 [Acceleration (AccelMode.SSE2)]
108                 public static Vector2l operator & (Vector2l v1, Vector2l v2)
109                 {
110                         return new Vector2l (v1.x & v2.x, v1.y & v2.y);
111                 }
112
113                 [Acceleration (AccelMode.SSE2)]
114                 public static Vector2l operator | (Vector2l v1, Vector2l v2)
115                 {
116                         return new Vector2l (v1.x | v2.x, v1.y | v2.y);
117                 }
118
119                 [Acceleration (AccelMode.SSE2)]
120                 public static Vector2l operator ^ (Vector2l v1, Vector2l v2)
121                 {
122                         return new Vector2l (v1.x ^ v2.x, v1.y ^ v2.y);
123                 }
124
125                 [Acceleration (AccelMode.SSE1)]
126                 public static unsafe explicit operator Vector2d (Vector2l v)
127                 {
128                         Vector2d* p = (Vector2d*)&v;
129                         return *p;
130                 }
131
132                 [Acceleration (AccelMode.SSE1)]
133                 public static unsafe explicit operator Vector4f (Vector2l v)
134                 {
135                         Vector4f* p = (Vector4f*)&v;
136                         return *p;
137                 }
138
139                 [Acceleration (AccelMode.SSE1)]
140                 [CLSCompliant(false)]
141                 public static unsafe explicit operator Vector2ul (Vector2l v)
142                 {
143                         Vector2ul* p = (Vector2ul*)&v;
144                         return *p;
145                 }
146
147                 [Acceleration (AccelMode.SSE1)]
148                 public static unsafe explicit operator Vector4i (Vector2l v)
149                 {
150                         Vector4i* p = (Vector4i*)&v;
151                         return *p;
152                 }
153
154                 [Acceleration (AccelMode.SSE1)]
155                 [CLSCompliant(false)]
156                 public static unsafe explicit operator Vector4ui (Vector2l v)
157                 {
158                         Vector4ui* p = (Vector4ui*)&v;
159                         return *p;
160                 }
161
162                 [Acceleration (AccelMode.SSE1)]
163                 public static unsafe explicit operator Vector8s (Vector2l v)
164                 {
165                         Vector8s* p = (Vector8s*)&v;
166                         return *p;
167                 }
168
169                 [Acceleration (AccelMode.SSE1)]
170                 [CLSCompliant(false)]
171                 public static unsafe explicit operator Vector8us (Vector2l v)
172                 {
173                         Vector8us* p = (Vector8us*)&v;
174                         return *p;
175                 }
176
177                 [Acceleration (AccelMode.SSE1)]
178                 [CLSCompliant(false)]
179                 public static unsafe explicit operator Vector16sb (Vector2l v)
180                 {
181                         Vector16sb* p = (Vector16sb*)&v;
182                         return *p;
183                 }
184
185                 [Acceleration (AccelMode.SSE1)]
186                 public static unsafe explicit operator Vector16b (Vector2l v)
187                 {
188                         Vector16b* p = (Vector16b*)&v;
189                         return *p;
190                 }
191
192                 [Acceleration (AccelMode.SSE1)]
193                 public static Vector2l LoadAligned (ref Vector2l v)
194                 {
195                         return v;
196                 }
197
198                 [Acceleration (AccelMode.SSE1)]
199                 public static void StoreAligned (ref Vector2l res, Vector2l val)
200                 {
201                         res = val;
202                 }
203
204                 [CLSCompliant(false)]
205                 [Acceleration (AccelMode.SSE1)]
206                 public static unsafe Vector2l LoadAligned (Vector2l *v)
207                 {
208                         return *v;
209                 }
210
211                 [CLSCompliant(false)]
212                 [Acceleration (AccelMode.SSE1)]
213                 public static unsafe void StoreAligned (Vector2l *res, Vector2l val)
214                 {
215                         *res = val;
216                 }
217
218                 [Acceleration (AccelMode.SSE1)]
219                 [CLSCompliant(false)]
220                 public static void PrefetchTemporalAllCacheLevels (ref Vector2l res)
221                 {
222                 }
223
224                 [Acceleration (AccelMode.SSE1)]
225                 [CLSCompliant(false)]
226                 public static void PrefetchTemporal1stLevelCache (ref Vector2l res)
227                 {
228                 }
229
230                 [Acceleration (AccelMode.SSE1)]
231                 [CLSCompliant(false)]
232                 public static void PrefetchTemporal2ndLevelCache (ref Vector2l res)
233                 {
234                 }
235
236                 [Acceleration (AccelMode.SSE1)]
237                 [CLSCompliant(false)]
238                 public static void PrefetchNonTemporal (ref Vector2l res)
239                 {
240                 }
241
242                 [Acceleration (AccelMode.SSE1)]
243                 [CLSCompliant(false)]
244                 public static unsafe void PrefetchTemporalAllCacheLevels (Vector2l *res)
245                 {
246                 }
247
248                 [Acceleration (AccelMode.SSE1)]
249                 [CLSCompliant(false)]
250                 public static unsafe void PrefetchTemporal1stLevelCache (Vector2l *res)
251                 {
252                 }
253
254                 [Acceleration (AccelMode.SSE1)]
255                 [CLSCompliant(false)]
256                 public static unsafe void PrefetchTemporal2ndLevelCache (Vector2l *res)
257                 {
258                 }
259
260                 [Acceleration (AccelMode.SSE1)]
261                 [CLSCompliant(false)]
262                 public static unsafe void PrefetchNonTemporal (Vector2l *res)
263                 {
264                 }
265                 
266                 public override string ToString()
267                 {
268                         return "<" + x + ", " + y + ">"; 
269                 }
270         }
271 }