暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Sse3.cs 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Diagnostics;
  3. namespace Unity.Burst.Intrinsics
  4. {
  5. public unsafe static partial class X86
  6. {
  7. /// <summary>
  8. /// SSE3 intrinsics
  9. /// </summary>
  10. public static class Sse3
  11. {
  12. /// <summary>
  13. /// Evaluates to true at compile time if SSE3 intrinsics are supported.
  14. /// </summary>
  15. public static bool IsSse3Supported { get { return false; } }
  16. // _mm_addsub_ps
  17. /// <summary> Alternatively add and subtract packed single-precision (32-bit) floating-point elements in "a" to/from packed elements in "b", and store the results in "dst". </summary>
  18. /// <param name="a">Vector a</param>
  19. /// <param name="b">Vector b</param>
  20. /// <returns>Vector</returns>
  21. [DebuggerStepThrough]
  22. public static v128 addsub_ps(v128 a, v128 b)
  23. {
  24. v128 dst = default(v128);
  25. dst.Float0 = a.Float0 - b.Float0;
  26. dst.Float1 = a.Float1 + b.Float1;
  27. dst.Float2 = a.Float2 - b.Float2;
  28. dst.Float3 = a.Float3 + b.Float3;
  29. return dst;
  30. }
  31. // _mm_addsub_pd
  32. /// <summary> Alternatively add and subtract packed double-precision (64-bit) floating-point elements in "a" to/from packed elements in "b", and store the results in "dst". </summary>
  33. /// <param name="a">Vector a</param>
  34. /// <param name="b">Vector b</param>
  35. /// <returns>Vector</returns>
  36. [DebuggerStepThrough]
  37. public static v128 addsub_pd(v128 a, v128 b)
  38. {
  39. v128 dst = default(v128);
  40. dst.Double0 = a.Double0 - b.Double0;
  41. dst.Double1 = a.Double1 + b.Double1;
  42. return dst;
  43. }
  44. // _mm_hadd_pd
  45. /// <summary> Horizontally add adjacent pairs of double-precision (64-bit) floating-point elements in "a" and "b", and pack the results in "dst". </summary>
  46. /// <param name="a">Vector a</param>
  47. /// <param name="b">Vector b</param>
  48. /// <returns>Vector</returns>
  49. [DebuggerStepThrough]
  50. public static v128 hadd_pd(v128 a, v128 b)
  51. {
  52. v128 dst = default(v128);
  53. dst.Double0 = a.Double0 + a.Double1;
  54. dst.Double1 = b.Double0 + b.Double1;
  55. return dst;
  56. }
  57. // _mm_hadd_ps
  58. /// <summary> Horizontally add adjacent pairs of single-precision (32-bit) floating-point elements in "a" and "b", and pack the results in "dst". </summary>
  59. /// <param name="a">Vector a</param>
  60. /// <param name="b">Vector b</param>
  61. /// <returns>Vector</returns>
  62. [DebuggerStepThrough]
  63. public static v128 hadd_ps(v128 a, v128 b)
  64. {
  65. v128 dst = default(v128);
  66. dst.Float0 = a.Float0 + a.Float1;
  67. dst.Float1 = a.Float2 + a.Float3;
  68. dst.Float2 = b.Float0 + b.Float1;
  69. dst.Float3 = b.Float2 + b.Float3;
  70. return dst;
  71. }
  72. // _mm_hsub_pd
  73. /// <summary> Horizontally subtract adjacent pairs of double-precision (64-bit) floating-point elements in "a" and "b", and pack the results in "dst". </summary>
  74. /// <param name="a">Vector a</param>
  75. /// <param name="b">Vector b</param>
  76. /// <returns>Vector</returns>
  77. [DebuggerStepThrough]
  78. public static v128 hsub_pd(v128 a, v128 b)
  79. {
  80. v128 dst = default(v128);
  81. dst.Double0 = a.Double0 - a.Double1;
  82. dst.Double1 = b.Double0 - b.Double1;
  83. return dst;
  84. }
  85. // _mm_hsub_ps
  86. /// <summary> Horizontally add adjacent pairs of single-precision (32-bit) floating-point elements in "a" and "b", and pack the results in "dst". </summary>
  87. /// <param name="a">Vector a</param>
  88. /// <param name="b">Vector b</param>
  89. /// <returns>Vector</returns>
  90. [DebuggerStepThrough]
  91. public static v128 hsub_ps(v128 a, v128 b)
  92. {
  93. v128 dst = default(v128);
  94. dst.Float0 = a.Float0 - a.Float1;
  95. dst.Float1 = a.Float2 - a.Float3;
  96. dst.Float2 = b.Float0 - b.Float1;
  97. dst.Float3 = b.Float2 - b.Float3;
  98. return dst;
  99. }
  100. // _mm_movedup_pd
  101. /// <summary> Duplicate the low double-precision (64-bit) floating-point element from "a", and store the results in "dst". </summary>
  102. /// <param name="a">Vector a</param>
  103. /// <returns>Vector</returns>
  104. [DebuggerStepThrough]
  105. public static v128 movedup_pd(v128 a)
  106. {
  107. // Burst IR is fine
  108. v128 dst = default(v128);
  109. dst.Double0 = a.Double0;
  110. dst.Double1 = a.Double0;
  111. return dst;
  112. }
  113. // _mm_movehdup_ps
  114. /// <summary> Duplicate odd-indexed single-precision (32-bit) floating-point elements from "a", and store the results in "dst". </summary>
  115. /// <param name="a">Vector a</param>
  116. /// <returns>Vector</returns>
  117. [DebuggerStepThrough]
  118. public static v128 movehdup_ps(v128 a)
  119. {
  120. // Burst IR is fine
  121. v128 dst = default(v128);
  122. dst.Float0 = a.Float1;
  123. dst.Float1 = a.Float1;
  124. dst.Float2 = a.Float3;
  125. dst.Float3 = a.Float3;
  126. return dst;
  127. }
  128. // _mm_moveldup_ps
  129. /// <summary> Duplicate even-indexed single-precision (32-bit) floating-point elements from "a", and store the results in "dst". </summary>
  130. /// <param name="a">Vector a</param>
  131. /// <returns>Vector</returns>
  132. [DebuggerStepThrough]
  133. public static v128 moveldup_ps(v128 a)
  134. {
  135. // Burst IR is fine
  136. v128 dst = default(v128);
  137. dst.Float0 = a.Float0;
  138. dst.Float1 = a.Float0;
  139. dst.Float2 = a.Float2;
  140. dst.Float3 = a.Float2;
  141. return dst;
  142. }
  143. }
  144. }
  145. }