2008-10-28 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 28 Oct 2008 19:24:46 +0000 (19:24 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 28 Oct 2008 19:24:46 +0000 (19:24 -0000)
* Mono.Simd.dll.sources: Added Vector2l.cs.

2008-10-28  Rodrigo Kumpera  <rkumpera@novell.com>

* Vector2l.cs: New vector type.

svn path=/trunk/mcs/; revision=117295

mcs/class/Mono.Simd/Changelog
mcs/class/Mono.Simd/Mono.Simd.dll.sources
mcs/class/Mono.Simd/Mono.Simd/Changelog
mcs/class/Mono.Simd/Mono.Simd/Vector2l.cs [new file with mode: 0644]

index 4264075eceb97533617ac53b7df724b76fe5e838..d173eb387a760664af64c1fa5ad528cdf80fa161 100644 (file)
@@ -1,3 +1,7 @@
+2008-10-28  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Mono.Simd.dll.sources: Added Vector2l.cs.
+
 2008-10-27  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * Mono.Simd.dll.sources: Added Vector2d.cs.
index 065610951834a7b7f5b04fa7080de4df13ae3694..431c945c179b937af1138632e17a04852064d0c8 100644 (file)
@@ -2,6 +2,7 @@
 ../../build/common/Locale.cs
 Assembly/AssemblyInfo.cs
 Mono.Simd/Vector2d.cs
+Mono.Simd/Vector2l.cs
 Mono.Simd/Vector4f.cs
 Mono.Simd/Vector4ui.cs
 Mono.Simd/Vector4i.cs
index e553dafd5c99ab47bb9754b4e0b852e72b09a9bb..2bc01fe655afbfa2f66a7b8738daf0075522b0fe 100644 (file)
@@ -1,3 +1,7 @@
+2008-10-28  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Vector2l.cs: New vector type.
+
 2008-10-27  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * Vector2d.cs: New vector type.
diff --git a/mcs/class/Mono.Simd/Mono.Simd/Vector2l.cs b/mcs/class/Mono.Simd/Mono.Simd/Vector2l.cs
new file mode 100644 (file)
index 0000000..e36a8c3
--- /dev/null
@@ -0,0 +1,161 @@
+// Vector2l.cs
+//
+// Author:
+//   Rodrigo Kumpera (rkumpera@novell.com)
+//
+// (C) 2008 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.Simd\r
+{\r
+       [StructLayout(LayoutKind.Sequential, Pack = 0, Size = 16)]\r
+       public struct Vector2l\r
+       {\r
+               private long x;\r
+               private long y;\r
+\r
+               public long X { get { return x; } set { x = value; } }\r
+               public long Y { get { return y; } set { y = value; } }\r
+\r
+               public Vector2l (long x, long y)\r
+               {\r
+                       this.x = x;\r
+                       this.y = y;\r
+               }
+
+               //PADDQ
+               public static Vector2l operator + (Vector2l v1, Vector2l v2)\r
+               {\r
+                       return new Vector2l (v1.x + v2.x, v1.y + v2.y);\r
+               }
+
+               //PSUBQ
+               public static Vector2l operator - (Vector2l v1, Vector2l v2)\r
+               {\r
+                       return new Vector2l (v1.x - v2.x, v1.y - v2.y);\r
+               }
+
+               public static unsafe Vector2l operator << (Vector2l v1, int amount)\r
+               {\r
+                       return new Vector2l (v1.x << amount, v1.y << amount);\r
+               }
+
+               public static Vector2l operator & (Vector2l v1, Vector2l v2)\r
+               {\r
+                       return new Vector2l (v1.x & v2.x, v1.y & v2.y);\r
+               }
+
+               public static Vector2l operator | (Vector2l v1, Vector2l v2)\r
+               {\r
+                       return new Vector2l (v1.x | v2.x, v1.y | v2.y);\r
+               }\r
+\r
+               public static Vector2l operator ^ (Vector2l v1, Vector2l v2)\r
+               {\r
+                       return new Vector2l (v1.x ^ v2.x, v1.y ^ v2.y);\r
+               }\r
+
+               public static Vector2l UnpackLow (Vector2l v1, Vector2l v2)
+               {
+                       return new Vector2l (v1.x, v2.x);
+               }
+
+               public static Vector2l UnpackHigh (Vector2l v1, Vector2l v2)
+               {
+                       return new Vector2l (v1.y, v2.y);
+               }
+
+               public static unsafe Vector2l ShiftRightLogic (Vector2l v1, int amount)\r
+               {\r
+                       Vector2l res = new Vector2l ();
+                       long *a = &v1.x;
+                       long *b = &res.x;
+                       for (int i = 0; i < 4; ++i)
+                               *b++ = (long)((ulong)(*a++) >> amount);
+                       return res;\r
+               }
+
+               public static unsafe long ExtractByteMask (Vector2l va) {
+                       int res = 0;
+                       byte *a = (byte*)&va;
+                       for (int i = 0; i < 16; ++i)
+                               res |= (*a++ & 0x80) >> 7 << i;
+                       return res;
+               }
+
+               /*Requires SSE 4.1*/
+               public static Vector2l CompareEqual (Vector2l v1, Vector2l v2)
+               {
+                       return new Vector2l ((long)(v1.x ==  v2.x ? -1 : 0), (long)(v1.y ==  v2.y ? -1 : 0));
+               }
+
+               /*Requires SSE 4.1*/
+               public static Vector2l CompareGreaterThan (Vector2l v1, Vector2l v2)
+               {
+                       return new Vector2l ((long)(v1.x > v2.x ? -1 : 0), (long)(v1.y >  v2.y ? -1 : 0));
+               }
+
+               public static unsafe explicit operator Vector4f (Vector2l v1)\r
+               {\r
+                       Vector4f* p = (Vector4f*)&v1;\r
+                       return *p;\r
+               }
+
+               [CLSCompliant(false)]\r
+               public static unsafe explicit operator Vector8us (Vector2l v1)\r
+               {\r
+                       Vector8us* p = (Vector8us*)&v1;\r
+                       return *p;\r
+               }
+
+               [CLSCompliant(false)]\r
+               public static unsafe explicit operator Vector16b (Vector2l v1)\r
+               {\r
+                       Vector16b* p = (Vector16b*)&v1;\r
+                       return *p;\r
+               }
+
+               public static Vector2l LoadAligned (ref Vector2l v)\r
+               {\r
+                       return v;\r
+               }\r
+\r
+               public static void StoreAligned (ref Vector2l res, Vector2l val)\r
+               {\r
+                       res = val;\r
+               }
+
+               [CLSCompliant(false)]\r
+               public static unsafe Vector2l LoadAligned (Vector2l *v)\r
+               {\r
+                       return *v;\r
+               }\r
+\r
+               [CLSCompliant(false)]\r
+               public static unsafe void StoreAligned (Vector2l *res, Vector2l val)\r
+               {\r
+                       *res = val;\r
+               }
+       }\r
+}\r