mm3dnow.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*===---- mm3dnow.h - 3DNow! intrinsics ------------------------------------===
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. *
  21. *===-----------------------------------------------------------------------===
  22. */
  23. #ifndef _MM3DNOW_H_INCLUDED
  24. #define _MM3DNOW_H_INCLUDED
  25. #include <mmintrin.h>
  26. #include <prfchwintrin.h>
  27. typedef float __v2sf __attribute__((__vector_size__(8)));
  28. /* Define the default attributes for the functions in this file. */
  29. #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("3dnow")))
  30. static __inline__ void __DEFAULT_FN_ATTRS
  31. _m_femms(void) {
  32. __builtin_ia32_femms();
  33. }
  34. static __inline__ __m64 __DEFAULT_FN_ATTRS
  35. _m_pavgusb(__m64 __m1, __m64 __m2) {
  36. return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
  37. }
  38. static __inline__ __m64 __DEFAULT_FN_ATTRS
  39. _m_pf2id(__m64 __m) {
  40. return (__m64)__builtin_ia32_pf2id((__v2sf)__m);
  41. }
  42. static __inline__ __m64 __DEFAULT_FN_ATTRS
  43. _m_pfacc(__m64 __m1, __m64 __m2) {
  44. return (__m64)__builtin_ia32_pfacc((__v2sf)__m1, (__v2sf)__m2);
  45. }
  46. static __inline__ __m64 __DEFAULT_FN_ATTRS
  47. _m_pfadd(__m64 __m1, __m64 __m2) {
  48. return (__m64)__builtin_ia32_pfadd((__v2sf)__m1, (__v2sf)__m2);
  49. }
  50. static __inline__ __m64 __DEFAULT_FN_ATTRS
  51. _m_pfcmpeq(__m64 __m1, __m64 __m2) {
  52. return (__m64)__builtin_ia32_pfcmpeq((__v2sf)__m1, (__v2sf)__m2);
  53. }
  54. static __inline__ __m64 __DEFAULT_FN_ATTRS
  55. _m_pfcmpge(__m64 __m1, __m64 __m2) {
  56. return (__m64)__builtin_ia32_pfcmpge((__v2sf)__m1, (__v2sf)__m2);
  57. }
  58. static __inline__ __m64 __DEFAULT_FN_ATTRS
  59. _m_pfcmpgt(__m64 __m1, __m64 __m2) {
  60. return (__m64)__builtin_ia32_pfcmpgt((__v2sf)__m1, (__v2sf)__m2);
  61. }
  62. static __inline__ __m64 __DEFAULT_FN_ATTRS
  63. _m_pfmax(__m64 __m1, __m64 __m2) {
  64. return (__m64)__builtin_ia32_pfmax((__v2sf)__m1, (__v2sf)__m2);
  65. }
  66. static __inline__ __m64 __DEFAULT_FN_ATTRS
  67. _m_pfmin(__m64 __m1, __m64 __m2) {
  68. return (__m64)__builtin_ia32_pfmin((__v2sf)__m1, (__v2sf)__m2);
  69. }
  70. static __inline__ __m64 __DEFAULT_FN_ATTRS
  71. _m_pfmul(__m64 __m1, __m64 __m2) {
  72. return (__m64)__builtin_ia32_pfmul((__v2sf)__m1, (__v2sf)__m2);
  73. }
  74. static __inline__ __m64 __DEFAULT_FN_ATTRS
  75. _m_pfrcp(__m64 __m) {
  76. return (__m64)__builtin_ia32_pfrcp((__v2sf)__m);
  77. }
  78. static __inline__ __m64 __DEFAULT_FN_ATTRS
  79. _m_pfrcpit1(__m64 __m1, __m64 __m2) {
  80. return (__m64)__builtin_ia32_pfrcpit1((__v2sf)__m1, (__v2sf)__m2);
  81. }
  82. static __inline__ __m64 __DEFAULT_FN_ATTRS
  83. _m_pfrcpit2(__m64 __m1, __m64 __m2) {
  84. return (__m64)__builtin_ia32_pfrcpit2((__v2sf)__m1, (__v2sf)__m2);
  85. }
  86. static __inline__ __m64 __DEFAULT_FN_ATTRS
  87. _m_pfrsqrt(__m64 __m) {
  88. return (__m64)__builtin_ia32_pfrsqrt((__v2sf)__m);
  89. }
  90. static __inline__ __m64 __DEFAULT_FN_ATTRS
  91. _m_pfrsqrtit1(__m64 __m1, __m64 __m2) {
  92. return (__m64)__builtin_ia32_pfrsqit1((__v2sf)__m1, (__v2sf)__m2);
  93. }
  94. static __inline__ __m64 __DEFAULT_FN_ATTRS
  95. _m_pfsub(__m64 __m1, __m64 __m2) {
  96. return (__m64)__builtin_ia32_pfsub((__v2sf)__m1, (__v2sf)__m2);
  97. }
  98. static __inline__ __m64 __DEFAULT_FN_ATTRS
  99. _m_pfsubr(__m64 __m1, __m64 __m2) {
  100. return (__m64)__builtin_ia32_pfsubr((__v2sf)__m1, (__v2sf)__m2);
  101. }
  102. static __inline__ __m64 __DEFAULT_FN_ATTRS
  103. _m_pi2fd(__m64 __m) {
  104. return (__m64)__builtin_ia32_pi2fd((__v2si)__m);
  105. }
  106. static __inline__ __m64 __DEFAULT_FN_ATTRS
  107. _m_pmulhrw(__m64 __m1, __m64 __m2) {
  108. return (__m64)__builtin_ia32_pmulhrw((__v4hi)__m1, (__v4hi)__m2);
  109. }
  110. /* Handle the 3dnowa instructions here. */
  111. #undef __DEFAULT_FN_ATTRS
  112. #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("3dnowa")))
  113. static __inline__ __m64 __DEFAULT_FN_ATTRS
  114. _m_pf2iw(__m64 __m) {
  115. return (__m64)__builtin_ia32_pf2iw((__v2sf)__m);
  116. }
  117. static __inline__ __m64 __DEFAULT_FN_ATTRS
  118. _m_pfnacc(__m64 __m1, __m64 __m2) {
  119. return (__m64)__builtin_ia32_pfnacc((__v2sf)__m1, (__v2sf)__m2);
  120. }
  121. static __inline__ __m64 __DEFAULT_FN_ATTRS
  122. _m_pfpnacc(__m64 __m1, __m64 __m2) {
  123. return (__m64)__builtin_ia32_pfpnacc((__v2sf)__m1, (__v2sf)__m2);
  124. }
  125. static __inline__ __m64 __DEFAULT_FN_ATTRS
  126. _m_pi2fw(__m64 __m) {
  127. return (__m64)__builtin_ia32_pi2fw((__v2si)__m);
  128. }
  129. static __inline__ __m64 __DEFAULT_FN_ATTRS
  130. _m_pswapdsf(__m64 __m) {
  131. return (__m64)__builtin_ia32_pswapdsf((__v2sf)__m);
  132. }
  133. static __inline__ __m64 __DEFAULT_FN_ATTRS
  134. _m_pswapdsi(__m64 __m) {
  135. return (__m64)__builtin_ia32_pswapdsi((__v2si)__m);
  136. }
  137. #undef __DEFAULT_FN_ATTRS
  138. #endif