using System; using System.Diagnostics; namespace Unity.Burst.Intrinsics { public unsafe static partial class X86 { /// /// SSE intrinsics /// public static class Sse { /// /// Evaluates to true at compile time if SSE intrinsics are supported. /// public static bool IsSseSupported { get { return false; } } /// /// Load 128-bits (composed of 4 packed single-precision (32-bit) /// floating-point elements) from memory into dst. /// /// /// Burst will always generate unaligned loads. /// /// Pointer /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 load_ps(void* ptr) { return GenericCSharpLoad(ptr); } /// /// Load 128-bits (composed of 4 packed single-precision (32-bit) /// floating-point elements) from memory into dst. mem_addr does /// not need to be aligned on any particular boundary. /// /// Pointer /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 loadu_ps(void* ptr) { return GenericCSharpLoad(ptr); } /// /// Store 128-bits (composed of 4 packed single-precision (32-bit) /// floating-point elements) from a into memory. /// /// /// Burst will always generate unaligned stores. /// /// Pointer /// Value vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static void store_ps(void* ptr, v128 val) { GenericCSharpStore(ptr, val); } /// /// Store 128-bits (composed of 4 packed single-precision (32-bit) /// floating-point elements) from a into memory. mem_addr does not /// need to be aligned on any particular boundary. /// /// Pointer /// Value vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static void storeu_ps(void* ptr, v128 val) { GenericCSharpStore(ptr, val); } /// /// Store 128-bits (composed of 4 packed single-precision (32-bit) floating-point elements) from "a" into memory using a non-temporal memory hint. "mem_addr" must be aligned on a 16-byte boundary or a general-protection exception will be generated. /// /// Memory address /// Vector a [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static void stream_ps(void* mem_addr, v128 a) { GenericCSharpStore(mem_addr, a); } // _mm_cvtsi32_ss /// Convert the 32-bit integer "b" to a single-precision (32-bit) floating-point element, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// 32-bit integer /// Vector [DebuggerStepThrough] public static v128 cvtsi32_ss(v128 a, int b) { v128 dst = a; dst.Float0 = b; return dst; } // _mm_cvtsi64_ss /// Convert the 64-bit integer "b" to a single-precision (32-bit) floating-point element, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// 64-bit integer /// Vector [DebuggerStepThrough] public static v128 cvtsi64_ss(v128 a, long b) { v128 dst = a; dst.Float0 = b; return dst; } // _mm_add_ss /// Add the lower single-precision (32-bit) floating-point element in "a" and "b", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 add_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = dst.Float0 + b.Float0; return dst; } // _mm_add_ps /// Add packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 add_ps(v128 a, v128 b) { v128 dst = a; dst.Float0 += b.Float0; dst.Float1 += b.Float1; dst.Float2 += b.Float2; dst.Float3 += b.Float3; return dst; } // _mm_sub_ss /// Subtract the lower single-precision (32-bit) floating-point element in "b" from the lower single-precision (32-bit) floating-point element in "a", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 sub_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = a.Float0 - b.Float0; return dst; } // _mm_sub_ps /// Subtract packed single-precision (32-bit) floating-point elements in "b" from packed single-precision (32-bit) floating-point elements in "a", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 sub_ps(v128 a, v128 b) { v128 dst = a; dst.Float0 -= b.Float0; dst.Float1 -= b.Float1; dst.Float2 -= b.Float2; dst.Float3 -= b.Float3; return dst; } // _mm_mul_ss /// Multiply the lower single-precision (32-bit) floating-point element in "a" and "b", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 mul_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = a.Float0 * b.Float0; return dst; } // _mm_mul_ps /// Multiply packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 mul_ps(v128 a, v128 b) { v128 dst = a; dst.Float0 *= b.Float0; dst.Float1 *= b.Float1; dst.Float2 *= b.Float2; dst.Float3 *= b.Float3; return dst; } // _mm_div_ss /// Divide the lower single-precision (32-bit) floating-point element in "a" by the lower single-precision (32-bit) floating-point element in "b", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 div_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = a.Float0 / b.Float0; return dst; } // _mm_div_ps /// Divide packed single-precision (32-bit) floating-point elements in "a" by packed elements in "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 div_ps(v128 a, v128 b) { v128 dst = a; dst.Float0 /= b.Float0; dst.Float1 /= b.Float1; dst.Float2 /= b.Float2; dst.Float3 /= b.Float3; return dst; } // _mm_sqrt_ss /// Compute the square root of the lower single-precision (32-bit) floating-point element in "a", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector [DebuggerStepThrough] public static v128 sqrt_ss(v128 a) { v128 dst = a; dst.Float0 = (float)Math.Sqrt(a.Float0); return dst; } // _mm_sqrt_ps /// Compute the square root of packed single-precision (32-bit) floating-point elements in "a", and store the results in "dst". /// Vector a /// Vector [DebuggerStepThrough] public static v128 sqrt_ps(v128 a) { v128 dst = default(v128); dst.Float0 = (float)Math.Sqrt(a.Float0); dst.Float1 = (float)Math.Sqrt(a.Float1); dst.Float2 = (float)Math.Sqrt(a.Float2); dst.Float3 = (float)Math.Sqrt(a.Float3); return dst; } // _mm_rcp_ss /// Compute the approximate reciprocal of the lower single-precision (32-bit) floating-point element in "a", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". The maximum relative error for this approximation is less than 1.5*2^-12. /// Vector a /// Vector [DebuggerStepThrough] public static v128 rcp_ss(v128 a) { v128 dst = a; dst.Float0 = 1.0f / a.Float0; return dst; } // _mm_rcp_ps /// Compute the approximate reciprocal of packed single-precision (32-bit) floating-point elements in "a", and store the results in "dst". The maximum relative error for this approximation is less than 1.5*2^-12. /// Vector a /// Vector [DebuggerStepThrough] public static v128 rcp_ps(v128 a) { v128 dst = default(v128); dst.Float0 = 1.0f / a.Float0; dst.Float1 = 1.0f / a.Float1; dst.Float2 = 1.0f / a.Float2; dst.Float3 = 1.0f / a.Float3; return dst; } // _mm_rsqrt_ss /// Compute the approximate reciprocal square root of the lower single-precision (32-bit) floating-point element in "a", store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". The maximum relative error for this approximation is less than 1.5*2^-12. /// Vector a /// Vector [DebuggerStepThrough] public static v128 rsqrt_ss(v128 a) { v128 dst = a; dst.Float0 = 1.0f / (float)Math.Sqrt(a.Float0); return dst; } // _mm_rsqrt_ps /// Compute the approximate reciprocal square root of packed single-precision (32-bit) floating-point elements in "a", and store the results in "dst". The maximum relative error for this approximation is less than 1.5*2^-12. /// Vector a /// Vector [DebuggerStepThrough] public static v128 rsqrt_ps(v128 a) { v128 dst = default(v128); dst.Float0 = 1.0f / (float)Math.Sqrt(a.Float0); dst.Float1 = 1.0f / (float)Math.Sqrt(a.Float1); dst.Float2 = 1.0f / (float)Math.Sqrt(a.Float2); dst.Float3 = 1.0f / (float)Math.Sqrt(a.Float3); return dst; } // _mm_min_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b", store the minimum value in the lower element of "dst", and copy the upper element from "a" to the upper element of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 min_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = Math.Min(a.Float0, b.Float0); return dst; } // _mm_min_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b", and store packed minimum values in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 min_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = Math.Min(a.Float0, b.Float0); dst.Float1 = Math.Min(a.Float1, b.Float1); dst.Float2 = Math.Min(a.Float2, b.Float2); dst.Float3 = Math.Min(a.Float3, b.Float3); return dst; } // _mm_max_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b", store the maximum value in the lower element of "dst", and copy the upper element from "a" to the upper element of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 max_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = Math.Max(a.Float0, b.Float0); return dst; } // _mm_max_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b", and store packed maximum values in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 max_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = Math.Max(a.Float0, b.Float0); dst.Float1 = Math.Max(a.Float1, b.Float1); dst.Float2 = Math.Max(a.Float2, b.Float2); dst.Float3 = Math.Max(a.Float3, b.Float3); return dst; } // _mm_and_ps /// Compute the bitwise AND of packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 and_ps(v128 a, v128 b) { v128 dst = a; dst.UInt0 &= b.UInt0; dst.UInt1 &= b.UInt1; dst.UInt2 &= b.UInt2; dst.UInt3 &= b.UInt3; return dst; } // _mm_andnot_ps /// Compute the bitwise NOT of packed single-precision (32-bit) floating-point elements in "a" and then AND with "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 andnot_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = (~a.UInt0) & b.UInt0; dst.UInt1 = (~a.UInt1) & b.UInt1; dst.UInt2 = (~a.UInt2) & b.UInt2; dst.UInt3 = (~a.UInt3) & b.UInt3; return dst; } // _mm_or_ps /// Compute the bitwise OR of packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 or_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.UInt0 | b.UInt0; dst.UInt1 = a.UInt1 | b.UInt1; dst.UInt2 = a.UInt2 | b.UInt2; dst.UInt3 = a.UInt3 | b.UInt3; return dst; } // _mm_xor_ps /// Compute the bitwise XOR of packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 xor_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.UInt0 ^ b.UInt0; dst.UInt1 = a.UInt1 ^ b.UInt1; dst.UInt2 = a.UInt2 ^ b.UInt2; dst.UInt3 = a.UInt3 ^ b.UInt3; return dst; } // _mm_cmpeq_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for equality, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpeq_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = a.Float0 == b.Float0 ? ~0u : 0; return dst; } // _mm_cmpeq_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for equality, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpeq_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.Float0 == b.Float0 ? ~0u : 0; dst.UInt1 = a.Float1 == b.Float1 ? ~0u : 0; dst.UInt2 = a.Float2 == b.Float2 ? ~0u : 0; dst.UInt3 = a.Float3 == b.Float3 ? ~0u : 0; return dst; } // _mm_cmplt_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for less-than, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmplt_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = a.Float0 < b.Float0 ? ~0u : 0u; return dst; } // _mm_cmplt_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for less-than, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmplt_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.Float0 < b.Float0 ? ~0u : 0u; dst.UInt1 = a.Float1 < b.Float1 ? ~0u : 0u; dst.UInt2 = a.Float2 < b.Float2 ? ~0u : 0u; dst.UInt3 = a.Float3 < b.Float3 ? ~0u : 0u; return dst; } // _mm_cmple_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for less-than-or-equal, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmple_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = a.Float0 <= b.Float0 ? ~0u : 0; return dst; } // _mm_cmple_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for less-than-or-equal, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmple_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.Float0 <= b.Float0 ? ~0u : 0u; dst.UInt1 = a.Float1 <= b.Float1 ? ~0u : 0u; dst.UInt2 = a.Float2 <= b.Float2 ? ~0u : 0u; dst.UInt3 = a.Float3 <= b.Float3 ? ~0u : 0u; return dst; } // _mm_cmpgt_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for greater-than, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpgt_ss(v128 a, v128 b) { return cmplt_ss(b, a); } // _mm_cmpgt_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for greater-than, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpgt_ps(v128 a, v128 b) { return cmplt_ps(b, a); } // _mm_cmpge_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for greater-than-or-equal, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpge_ss(v128 a, v128 b) { return cmple_ss(b, a); } // _mm_cmpge_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for greater-than-or-equal, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpge_ps(v128 a, v128 b) { return cmple_ps(b, a); } // _mm_cmpneq_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for not-equal, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpneq_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = a.Float0 != b.Float0 ? ~0u : 0u; return dst; } // _mm_cmpneq_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for not-equal, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpneq_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = a.Float0 != b.Float0 ? ~0u : 0u; dst.UInt1 = a.Float1 != b.Float1 ? ~0u : 0u; dst.UInt2 = a.Float2 != b.Float2 ? ~0u : 0u; dst.UInt3 = a.Float3 != b.Float3 ? ~0u : 0u; return dst; } // _mm_cmpnlt_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for not-less-than, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpnlt_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = !(a.Float0 < b.Float0) ? ~0u : 0u; return dst; } // _mm_cmpnlt_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for not-less-than, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpnlt_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = !(a.Float0 < b.Float0) ? ~0u : 0u; dst.UInt1 = !(a.Float1 < b.Float1) ? ~0u : 0u; dst.UInt2 = !(a.Float2 < b.Float2) ? ~0u : 0u; dst.UInt3 = !(a.Float3 < b.Float3) ? ~0u : 0u; return dst; } // _mm_cmpnle_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for not-less-than-or-equal, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpnle_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = !(a.Float0 <= b.Float0) ? ~0u : 0u; return dst; } // _mm_cmpnle_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for not-less-than-or-equal, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpnle_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = !(a.Float0 <= b.Float0) ? ~0u : 0u; dst.UInt1 = !(a.Float1 <= b.Float1) ? ~0u : 0u; dst.UInt2 = !(a.Float2 <= b.Float2) ? ~0u : 0u; dst.UInt3 = !(a.Float3 <= b.Float3) ? ~0u : 0u; return dst; } // _mm_cmpngt_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for not-greater-than, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpngt_ss(v128 a, v128 b) { return cmpnlt_ss(b, a); } // _mm_cmpngt_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for not-greater-than, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpngt_ps(v128 a, v128 b) { return cmpnlt_ps(b, a); } // _mm_cmpnge_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" for not-greater-than-or-equal, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpnge_ss(v128 a, v128 b) { return cmpnle_ss(b, a); } // _mm_cmpnge_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" for not-greater-than-or-equal, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 cmpnge_ps(v128 a, v128 b) { return cmpnle_ps(b, a); } // _mm_cmpord_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" to see if neither is NaN, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpord_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = IsNaN(a.UInt0) || IsNaN(b.UInt0) ? 0 : ~0u; return dst; } // _mm_cmpord_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" to see if neither is NaN, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpord_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = IsNaN(a.UInt0) || IsNaN(b.UInt0) ? 0 : ~0u; dst.UInt1 = IsNaN(a.UInt1) || IsNaN(b.UInt1) ? 0 : ~0u; dst.UInt2 = IsNaN(a.UInt2) || IsNaN(b.UInt2) ? 0 : ~0u; dst.UInt3 = IsNaN(a.UInt3) || IsNaN(b.UInt3) ? 0 : ~0u; return dst; } // _mm_cmpunord_ss /// Compare the lower single-precision (32-bit) floating-point elements in "a" and "b" to see if either is NaN, store the result in the lower element of "dst", and copy the upper 3 packed elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpunord_ss(v128 a, v128 b) { v128 dst = a; dst.UInt0 = IsNaN(a.UInt0) || IsNaN(b.UInt0) ? ~0u : 0; return dst; } // _mm_cmpunord_ps /// Compare packed single-precision (32-bit) floating-point elements in "a" and "b" to see if either is NaN, and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 cmpunord_ps(v128 a, v128 b) { v128 dst = default(v128); dst.UInt0 = IsNaN(a.UInt0) || IsNaN(b.UInt0) ? ~0u : 0; dst.UInt1 = IsNaN(a.UInt1) || IsNaN(b.UInt1) ? ~0u : 0; dst.UInt2 = IsNaN(a.UInt2) || IsNaN(b.UInt2) ? ~0u : 0; dst.UInt3 = IsNaN(a.UInt3) || IsNaN(b.UInt3) ? ~0u : 0; return dst; } // _mm_comieq_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for equality, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comieq_ss(v128 a, v128 b) { return a.Float0 == b.Float0 ? 1 : 0; } // _mm_comilt_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for less-than, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comilt_ss(v128 a, v128 b) { return a.Float0 < b.Float0 ? 1 : 0; } // _mm_comile_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for less-than-or-equal, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comile_ss(v128 a, v128 b) { return a.Float0 <= b.Float0 ? 1 : 0; } // _mm_comigt_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for greater-than, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comigt_ss(v128 a, v128 b) { return a.Float0 > b.Float0 ? 1 : 0; } // _mm_comige_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for greater-than-or-equal, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comige_ss(v128 a, v128 b) { return a.Float0 >= b.Float0 ? 1 : 0; } // _mm_comineq_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for not-equal, and return the boolean result (0 or 1). /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int comineq_ss(v128 a, v128 b) { return a.Float0 != b.Float0 ? 1 : 0; } // _mm_ucomieq_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for equality, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomieq_ss(v128 a, v128 b) { return a.Float0 == b.Float0 ? 1 : 0; } // _mm_ucomilt_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for less-than, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomilt_ss(v128 a, v128 b) { return a.Float0 < b.Float0 ? 1 : 0; } // _mm_ucomile_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for less-than-or-equal, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomile_ss(v128 a, v128 b) { return a.Float0 <= b.Float0 ? 1 : 0; } // _mm_ucomigt_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for greater-than, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomigt_ss(v128 a, v128 b) { return a.Float0 > b.Float0 ? 1 : 0; } // _mm_ucomige_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for greater-than-or-equal, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomige_ss(v128 a, v128 b) { return a.Float0 >= b.Float0 ? 1 : 0; } // _mm_ucomineq_ss /// Compare the lower single-precision (32-bit) floating-point element in "a" and "b" for not-equal, and return the boolean result (0 or 1). This instruction will not signal an exception for QNaNs. /// Vector a /// Vector b /// Boolean result [DebuggerStepThrough] public static int ucomineq_ss(v128 a, v128 b) { return a.Float0 != b.Float0 ? 1 : 0; } // _mm_cvtss_si32 /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 32-bit integer, and store the result in "dst". /// Vector a /// Integer [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static int cvtss_si32(v128 a) { return cvt_ss2si(a); } // _mm_cvt_ss2si /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 32-bit integer, and store the result in "dst". /// Vector a /// Integer [DebuggerStepThrough] public static int cvt_ss2si(v128 a) { return (int)a.Float0; } // _mm_cvtss_si64 /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 64-bit integer, and store the result in "dst". /// Vector a /// 64-bit integer [DebuggerStepThrough] public static long cvtss_si64(v128 a) { return (long)a.Float0; } // _mm_cvtss_f32 /// Copy the lower single-precision (32-bit) floating-point element of "a" to "dst". /// Vector a /// 32-bit floating point element [DebuggerStepThrough] public static float cvtss_f32(v128 a) { return a.Float0; } // _mm_cvttss_si32 /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 32-bit integer with truncation, and store the result in "dst". /// Vector a /// 32-bit integer [DebuggerStepThrough] public static int cvttss_si32(v128 a) { using (var csr = new RoundingScope(MXCSRBits.RoundTowardZero)) { return (int)a.Float0; } } // _mm_cvtt_ss2si /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 32-bit integer with truncation, and store the result in "dst". /// Vector a /// 32-bit integer [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static int cvtt_ss2si(v128 a) { return cvttss_si32(a); } // _mm_cvttss_si64 /// Convert the lower single-precision (32-bit) floating-point element in "a" to a 64-bit integer with truncation, and store the result in "dst". /// Vector a /// 64-bit integer [DebuggerStepThrough] public static long cvttss_si64(v128 a) { using (var csr = new RoundingScope(MXCSRBits.RoundTowardZero)) { return (long)a.Float0; } } // _mm_set_ss /// Copy single-precision (32-bit) floating-point element "a" to the lower element of "dst", and zero the upper 3 elements. /// Floating point element /// Vector [DebuggerStepThrough] public static v128 set_ss(float a) { return new v128(a, 0.0f, 0.0f, 0.0f); } // _mm_set1_ps /// Broadcast single-precision (32-bit) floating-point value "a" to all elements of "dst". /// Floating point element /// Vector [DebuggerStepThrough] public static v128 set1_ps(float a) { return new v128(a, a, a, a); } // _mm_set_ps1 /// Broadcast single-precision (32-bit) floating-point value "a" to all elements of "dst". /// Floating point element /// Vector [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static v128 set_ps1(float a) { return set1_ps(a); } // _mm_set_ps /// Set packed single-precision (32-bit) floating-point elements in "dst" with the supplied values. /// Floating point element 3 /// Floating point element 2 /// Floating point element 1 /// Floating point element 0 /// Vector [DebuggerStepThrough] public static v128 set_ps(float e3, float e2, float e1, float e0) { return new v128(e0, e1, e2, e3); } // _mm_setr_ps /// Set packed single-precision (32-bit) floating-point elements in "dst" with the supplied values in reverse order. /// Floating point element 3 /// Floating point element 2 /// Floating point element 1 /// Floating point element 0 /// Vector [DebuggerStepThrough] public static v128 setr_ps(float e3, float e2, float e1, float e0) { return new v128(e3, e2, e1, e0); } // _mm_move_ss /// Move the lower single-precision (32-bit) floating-point element from "b" to the lower element of "dst", and copy the upper 3 elements from "a" to the upper elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 move_ss(v128 a, v128 b) { v128 dst = a; dst.Float0 = b.Float0; return dst; } // _MM_SHUFFLE macro /// /// Return a shuffle immediate suitable for use with shuffle_ps and similar instructions. /// /// Integer d /// Integer c /// Integer b /// Integer a /// Shuffle suitable for use with shuffle_ps public static int SHUFFLE(int d, int c, int b, int a) { return ((a & 3)) | ((b & 3) << 2) | ((c & 3) << 4) | ((d & 3) << 6); } // _mm_shuffle_ps /// Shuffle single-precision (32-bit) floating-point elements in "a" using the control in "imm8", and store the results in "dst". /// Vector a /// Vector b /// Control /// Vector [DebuggerStepThrough] public static v128 shuffle_ps(v128 a, v128 b, int imm8) { v128 dst = default(v128); // Use integers, rather than floats, because of a Mono bug. uint* aptr = &a.UInt0; uint* bptr = &b.UInt0; dst.UInt0 = aptr[(imm8 >> 0) & 3]; dst.UInt1 = aptr[(imm8 >> 2) & 3]; dst.UInt2 = bptr[(imm8 >> 4) & 3]; dst.UInt3 = bptr[(imm8 >> 6) & 3]; return dst; } // _mm_unpackhi_ps /// Unpack and interleave single-precision (32-bit) floating-point elements from the high half "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 unpackhi_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = a.Float2; dst.Float1 = b.Float2; dst.Float2 = a.Float3; dst.Float3 = b.Float3; return dst; } // _mm_unpacklo_ps /// Unpack and interleave single-precision (32-bit) floating-point elements from the low half of "a" and "b", and store the results in "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 unpacklo_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = a.Float0; dst.Float1 = b.Float0; dst.Float2 = a.Float1; dst.Float3 = b.Float1; return dst; } // _mm_movehl_ps /// Move the upper 2 single-precision (32-bit) floating-point elements from "b" to the lower 2 elements of "dst", and copy the upper 2 elements from "a" to the upper 2 elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 movehl_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = b.Float2; dst.Float1 = b.Float3; dst.Float2 = a.Float2; dst.Float3 = a.Float3; return dst; } // _mm_movelh_ps /// Move the lower 2 single-precision (32-bit) floating-point elements from "b" to the upper 2 elements of "dst", and copy the lower 2 elements from "a" to the lower 2 elements of "dst". /// Vector a /// Vector b /// Vector [DebuggerStepThrough] public static v128 movelh_ps(v128 a, v128 b) { v128 dst = default(v128); dst.Float0 = a.Float0; dst.Float1 = a.Float1; dst.Float2 = b.Float0; dst.Float3 = b.Float1; return dst; } // _mm_movemask_ps /// Set each bit of mask "dst" based on the most significant bit of the corresponding packed single-precision (32-bit) floating-point element in "a". /// Vector a /// Integer [DebuggerStepThrough] public static int movemask_ps(v128 a) { int dst = 0; if ((a.UInt0 & 0x80000000) != 0) dst |= 1; if ((a.UInt1 & 0x80000000) != 0) dst |= 2; if ((a.UInt2 & 0x80000000) != 0) dst |= 4; if ((a.UInt3 & 0x80000000) != 0) dst |= 8; return dst; } /// /// Transposes a 4x4 matrix of single precision floating point values (_MM_TRANSPOSE4_PS). /// /// /// Arguments row0, row1, row2, and row3 are __m128 /// values whose elements form the corresponding rows /// of a 4x4 matrix. The matrix transpose is returned /// in arguments row0, row1, row2, and row3 where row0 /// now holds column 0 of the original matrix, row1 now /// holds column 1 of the original matrix, etc. /// /// __m128 value on corresponding row /// __m128 value on corresponding row /// __m128 value on corresponding row /// __m128 value on corresponding row [DebuggerStepThrough] [BurstTargetCpu(BurstTargetCpu.X64_SSE2)] public static void TRANSPOSE4_PS(ref v128 row0, ref v128 row1, ref v128 row2, ref v128 row3) { v128 _Tmp3, _Tmp2, _Tmp1, _Tmp0; _Tmp0 = shuffle_ps((row0), (row1), 0x44); _Tmp2 = shuffle_ps((row0), (row1), 0xEE); _Tmp1 = shuffle_ps((row2), (row3), 0x44); _Tmp3 = shuffle_ps((row2), (row3), 0xEE); row0 = shuffle_ps(_Tmp0, _Tmp1, 0x88); row1 = shuffle_ps(_Tmp0, _Tmp1, 0xDD); row2 = shuffle_ps(_Tmp2, _Tmp3, 0x88); row3 = shuffle_ps(_Tmp2, _Tmp3, 0xDD); } /// /// Return vector of type v128 with all elements set to zero. /// /// Vector [DebuggerStepThrough] public static v128 setzero_ps() { return default; } /// /// Load unaligned 16-bit integer from memory into the first element of dst. /// /// Memory address /// Vector [DebuggerStepThrough] public static v128 loadu_si16(void* mem_addr) { return new v128(*(short*)mem_addr, 0, 0, 0, 0, 0, 0, 0); } /// /// Store 16-bit integer from the first element of a into memory. /// mem_addr does not need to be aligned on any particular /// boundary. /// /// Memory address /// Vector a public static void storeu_si16(void* mem_addr, v128 a) { *(short*)mem_addr = a.SShort0; } /// /// Load unaligned 64-bit integer from memory into the first element of dst. /// /// Memory address /// Vector [DebuggerStepThrough] public static v128 loadu_si64(void* mem_addr) { return new v128(*(long*)mem_addr, 0); } /// /// Store 64-bit integer from the first element of a into memory. /// mem_addr does not need to be aligned on any particular /// boundary. /// /// Memory address /// Vector a [DebuggerStepThrough] public static void storeu_si64(void* mem_addr, v128 a) { *(long*)mem_addr = a.SLong0; } } } }