immintrin.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*===---- immintrin.h - Intel 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 __IMMINTRIN_H
  24. #define __IMMINTRIN_H
  25. #ifdef __MMX__
  26. #include <mmintrin.h>
  27. #endif
  28. #ifdef __SSE__
  29. #include <xmmintrin.h>
  30. #endif
  31. #ifdef __SSE2__
  32. #include <emmintrin.h>
  33. #endif
  34. #ifdef __SSE3__
  35. #include <pmmintrin.h>
  36. #endif
  37. #ifdef __SSSE3__
  38. #include <tmmintrin.h>
  39. #endif
  40. #if defined (__SSE4_2__) || defined (__SSE4_1__)
  41. #include <smmintrin.h>
  42. #endif
  43. #if defined (__AES__) || defined (__PCLMUL__)
  44. #include <wmmintrin.h>
  45. #endif
  46. #ifdef __AVX__
  47. #include <avxintrin.h>
  48. #endif
  49. #ifdef __AVX2__
  50. #include <avx2intrin.h>
  51. #endif
  52. #ifdef __BMI__
  53. #include <bmiintrin.h>
  54. #endif
  55. #ifdef __BMI2__
  56. #include <bmi2intrin.h>
  57. #endif
  58. #ifdef __LZCNT__
  59. #include <lzcntintrin.h>
  60. #endif
  61. #ifdef __FMA__
  62. #include <fmaintrin.h>
  63. #endif
  64. #ifdef __AVX512F__
  65. #include <avx512fintrin.h>
  66. #endif
  67. #ifdef __AVX512VL__
  68. #include <avx512vlintrin.h>
  69. #endif
  70. #ifdef __AVX512BW__
  71. #include <avx512bwintrin.h>
  72. #endif
  73. #ifdef __AVX512CD__
  74. #include <avx512cdintrin.h>
  75. #endif
  76. #ifdef __AVX512DQ__
  77. #include <avx512dqintrin.h>
  78. #endif
  79. #if defined (__AVX512VL__) && defined (__AVX512BW__)
  80. #include <avx512vlbwintrin.h>
  81. #endif
  82. #if defined (__AVX512VL__) && defined (__AVX512DQ__)
  83. #include <avx512vldqintrin.h>
  84. #endif
  85. #ifdef __AVX512ER__
  86. #include <avx512erintrin.h>
  87. #endif
  88. #ifdef __RDRND__
  89. static __inline__ int __attribute__((__always_inline__, __nodebug__))
  90. _rdrand16_step(unsigned short *__p)
  91. {
  92. return __builtin_ia32_rdrand16_step(__p);
  93. }
  94. static __inline__ int __attribute__((__always_inline__, __nodebug__))
  95. _rdrand32_step(unsigned int *__p)
  96. {
  97. return __builtin_ia32_rdrand32_step(__p);
  98. }
  99. #ifdef __x86_64__
  100. static __inline__ int __attribute__((__always_inline__, __nodebug__))
  101. _rdrand64_step(unsigned long long *__p)
  102. {
  103. return __builtin_ia32_rdrand64_step(__p);
  104. }
  105. #endif
  106. #endif /* __RDRND__ */
  107. #ifdef __FSGSBASE__
  108. #ifdef __x86_64__
  109. static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
  110. _readfsbase_u32(void)
  111. {
  112. return __builtin_ia32_rdfsbase32();
  113. }
  114. static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
  115. _readfsbase_u64(void)
  116. {
  117. return __builtin_ia32_rdfsbase64();
  118. }
  119. static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
  120. _readgsbase_u32(void)
  121. {
  122. return __builtin_ia32_rdgsbase32();
  123. }
  124. static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
  125. _readgsbase_u64(void)
  126. {
  127. return __builtin_ia32_rdgsbase64();
  128. }
  129. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  130. _writefsbase_u32(unsigned int __V)
  131. {
  132. return __builtin_ia32_wrfsbase32(__V);
  133. }
  134. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  135. _writefsbase_u64(unsigned long long __V)
  136. {
  137. return __builtin_ia32_wrfsbase64(__V);
  138. }
  139. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  140. _writegsbase_u32(unsigned int __V)
  141. {
  142. return __builtin_ia32_wrgsbase32(__V);
  143. }
  144. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  145. _writegsbase_u64(unsigned long long __V)
  146. {
  147. return __builtin_ia32_wrgsbase64(__V);
  148. }
  149. #endif
  150. #endif /* __FSGSBASE__ */
  151. #ifdef __RTM__
  152. #include <rtmintrin.h>
  153. #endif
  154. #ifdef __RTM__
  155. #include <xtestintrin.h>
  156. #endif
  157. #ifdef __SHA__
  158. #include <shaintrin.h>
  159. #endif
  160. #include <fxsrintrin.h>
  161. /* Some intrinsics inside adxintrin.h are available only on processors with ADX,
  162. * whereas others are also available at all times. */
  163. #include <adxintrin.h>
  164. #endif /* __IMMINTRIN_H */