tmmintrin.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* Copyright (C) 2006-2019 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. GCC is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. /* Implemented from the specification included in the Intel C++ Compiler
  19. User Guide and Reference, version 9.1. */
  20. #ifndef _TMMINTRIN_H_INCLUDED
  21. #define _TMMINTRIN_H_INCLUDED
  22. /* We need definitions from the SSE3, SSE2 and SSE header files*/
  23. #include <pmmintrin.h>
  24. #ifndef __SSSE3__
  25. #pragma GCC push_options
  26. #pragma GCC target("ssse3")
  27. #define __DISABLE_SSSE3__
  28. #endif /* __SSSE3__ */
  29. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  30. _mm_hadd_epi16 (__m128i __X, __m128i __Y)
  31. {
  32. return (__m128i) __builtin_ia32_phaddw128 ((__v8hi)__X, (__v8hi)__Y);
  33. }
  34. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  35. _mm_hadd_epi32 (__m128i __X, __m128i __Y)
  36. {
  37. return (__m128i) __builtin_ia32_phaddd128 ((__v4si)__X, (__v4si)__Y);
  38. }
  39. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  40. _mm_hadds_epi16 (__m128i __X, __m128i __Y)
  41. {
  42. return (__m128i) __builtin_ia32_phaddsw128 ((__v8hi)__X, (__v8hi)__Y);
  43. }
  44. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  45. _mm_hadd_pi16 (__m64 __X, __m64 __Y)
  46. {
  47. return (__m64) __builtin_ia32_phaddw ((__v4hi)__X, (__v4hi)__Y);
  48. }
  49. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  50. _mm_hadd_pi32 (__m64 __X, __m64 __Y)
  51. {
  52. return (__m64) __builtin_ia32_phaddd ((__v2si)__X, (__v2si)__Y);
  53. }
  54. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  55. _mm_hadds_pi16 (__m64 __X, __m64 __Y)
  56. {
  57. return (__m64) __builtin_ia32_phaddsw ((__v4hi)__X, (__v4hi)__Y);
  58. }
  59. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  60. _mm_hsub_epi16 (__m128i __X, __m128i __Y)
  61. {
  62. return (__m128i) __builtin_ia32_phsubw128 ((__v8hi)__X, (__v8hi)__Y);
  63. }
  64. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  65. _mm_hsub_epi32 (__m128i __X, __m128i __Y)
  66. {
  67. return (__m128i) __builtin_ia32_phsubd128 ((__v4si)__X, (__v4si)__Y);
  68. }
  69. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  70. _mm_hsubs_epi16 (__m128i __X, __m128i __Y)
  71. {
  72. return (__m128i) __builtin_ia32_phsubsw128 ((__v8hi)__X, (__v8hi)__Y);
  73. }
  74. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  75. _mm_hsub_pi16 (__m64 __X, __m64 __Y)
  76. {
  77. return (__m64) __builtin_ia32_phsubw ((__v4hi)__X, (__v4hi)__Y);
  78. }
  79. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  80. _mm_hsub_pi32 (__m64 __X, __m64 __Y)
  81. {
  82. return (__m64) __builtin_ia32_phsubd ((__v2si)__X, (__v2si)__Y);
  83. }
  84. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  85. _mm_hsubs_pi16 (__m64 __X, __m64 __Y)
  86. {
  87. return (__m64) __builtin_ia32_phsubsw ((__v4hi)__X, (__v4hi)__Y);
  88. }
  89. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  90. _mm_maddubs_epi16 (__m128i __X, __m128i __Y)
  91. {
  92. return (__m128i) __builtin_ia32_pmaddubsw128 ((__v16qi)__X, (__v16qi)__Y);
  93. }
  94. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  95. _mm_maddubs_pi16 (__m64 __X, __m64 __Y)
  96. {
  97. return (__m64) __builtin_ia32_pmaddubsw ((__v8qi)__X, (__v8qi)__Y);
  98. }
  99. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  100. _mm_mulhrs_epi16 (__m128i __X, __m128i __Y)
  101. {
  102. return (__m128i) __builtin_ia32_pmulhrsw128 ((__v8hi)__X, (__v8hi)__Y);
  103. }
  104. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  105. _mm_mulhrs_pi16 (__m64 __X, __m64 __Y)
  106. {
  107. return (__m64) __builtin_ia32_pmulhrsw ((__v4hi)__X, (__v4hi)__Y);
  108. }
  109. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  110. _mm_shuffle_epi8 (__m128i __X, __m128i __Y)
  111. {
  112. return (__m128i) __builtin_ia32_pshufb128 ((__v16qi)__X, (__v16qi)__Y);
  113. }
  114. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  115. _mm_shuffle_pi8 (__m64 __X, __m64 __Y)
  116. {
  117. return (__m64) __builtin_ia32_pshufb ((__v8qi)__X, (__v8qi)__Y);
  118. }
  119. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  120. _mm_sign_epi8 (__m128i __X, __m128i __Y)
  121. {
  122. return (__m128i) __builtin_ia32_psignb128 ((__v16qi)__X, (__v16qi)__Y);
  123. }
  124. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  125. _mm_sign_epi16 (__m128i __X, __m128i __Y)
  126. {
  127. return (__m128i) __builtin_ia32_psignw128 ((__v8hi)__X, (__v8hi)__Y);
  128. }
  129. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  130. _mm_sign_epi32 (__m128i __X, __m128i __Y)
  131. {
  132. return (__m128i) __builtin_ia32_psignd128 ((__v4si)__X, (__v4si)__Y);
  133. }
  134. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  135. _mm_sign_pi8 (__m64 __X, __m64 __Y)
  136. {
  137. return (__m64) __builtin_ia32_psignb ((__v8qi)__X, (__v8qi)__Y);
  138. }
  139. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  140. _mm_sign_pi16 (__m64 __X, __m64 __Y)
  141. {
  142. return (__m64) __builtin_ia32_psignw ((__v4hi)__X, (__v4hi)__Y);
  143. }
  144. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  145. _mm_sign_pi32 (__m64 __X, __m64 __Y)
  146. {
  147. return (__m64) __builtin_ia32_psignd ((__v2si)__X, (__v2si)__Y);
  148. }
  149. #ifdef __OPTIMIZE__
  150. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  151. _mm_alignr_epi8(__m128i __X, __m128i __Y, const int __N)
  152. {
  153. return (__m128i) __builtin_ia32_palignr128 ((__v2di)__X,
  154. (__v2di)__Y, __N * 8);
  155. }
  156. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  157. _mm_alignr_pi8(__m64 __X, __m64 __Y, const int __N)
  158. {
  159. return (__m64) __builtin_ia32_palignr ((__v1di)__X,
  160. (__v1di)__Y, __N * 8);
  161. }
  162. #else
  163. #define _mm_alignr_epi8(X, Y, N) \
  164. ((__m128i) __builtin_ia32_palignr128 ((__v2di)(__m128i)(X), \
  165. (__v2di)(__m128i)(Y), \
  166. (int)(N) * 8))
  167. #define _mm_alignr_pi8(X, Y, N) \
  168. ((__m64) __builtin_ia32_palignr ((__v1di)(__m64)(X), \
  169. (__v1di)(__m64)(Y), \
  170. (int)(N) * 8))
  171. #endif
  172. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  173. _mm_abs_epi8 (__m128i __X)
  174. {
  175. return (__m128i) __builtin_ia32_pabsb128 ((__v16qi)__X);
  176. }
  177. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  178. _mm_abs_epi16 (__m128i __X)
  179. {
  180. return (__m128i) __builtin_ia32_pabsw128 ((__v8hi)__X);
  181. }
  182. extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  183. _mm_abs_epi32 (__m128i __X)
  184. {
  185. return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
  186. }
  187. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  188. _mm_abs_pi8 (__m64 __X)
  189. {
  190. return (__m64) __builtin_ia32_pabsb ((__v8qi)__X);
  191. }
  192. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  193. _mm_abs_pi16 (__m64 __X)
  194. {
  195. return (__m64) __builtin_ia32_pabsw ((__v4hi)__X);
  196. }
  197. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  198. _mm_abs_pi32 (__m64 __X)
  199. {
  200. return (__m64) __builtin_ia32_pabsd ((__v2si)__X);
  201. }
  202. #ifdef __DISABLE_SSSE3__
  203. #undef __DISABLE_SSSE3__
  204. #pragma GCC pop_options
  205. #endif /* __DISABLE_SSSE3__ */
  206. #endif /* _TMMINTRIN_H_INCLUDED */