1f4a2713aSLionel Sambuc /*===---- immintrin.h - Intel intrinsics -----------------------------------===
2f4a2713aSLionel Sambuc *
3f4a2713aSLionel Sambuc * Permission is hereby granted, free of charge, to any person obtaining a copy
4f4a2713aSLionel Sambuc * of this software and associated documentation files (the "Software"), to deal
5f4a2713aSLionel Sambuc * in the Software without restriction, including without limitation the rights
6f4a2713aSLionel Sambuc * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7f4a2713aSLionel Sambuc * copies of the Software, and to permit persons to whom the Software is
8f4a2713aSLionel Sambuc * furnished to do so, subject to the following conditions:
9f4a2713aSLionel Sambuc *
10f4a2713aSLionel Sambuc * The above copyright notice and this permission notice shall be included in
11f4a2713aSLionel Sambuc * all copies or substantial portions of the Software.
12f4a2713aSLionel Sambuc *
13f4a2713aSLionel Sambuc * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14f4a2713aSLionel Sambuc * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15f4a2713aSLionel Sambuc * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16f4a2713aSLionel Sambuc * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17f4a2713aSLionel Sambuc * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18f4a2713aSLionel Sambuc * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19f4a2713aSLionel Sambuc * THE SOFTWARE.
20f4a2713aSLionel Sambuc *
21f4a2713aSLionel Sambuc *===-----------------------------------------------------------------------===
22f4a2713aSLionel Sambuc */
23f4a2713aSLionel Sambuc
24f4a2713aSLionel Sambuc #ifndef __IMMINTRIN_H
25f4a2713aSLionel Sambuc #define __IMMINTRIN_H
26f4a2713aSLionel Sambuc
27f4a2713aSLionel Sambuc #ifdef __MMX__
28f4a2713aSLionel Sambuc #include <mmintrin.h>
29f4a2713aSLionel Sambuc #endif
30f4a2713aSLionel Sambuc
31f4a2713aSLionel Sambuc #ifdef __SSE__
32f4a2713aSLionel Sambuc #include <xmmintrin.h>
33f4a2713aSLionel Sambuc #endif
34f4a2713aSLionel Sambuc
35f4a2713aSLionel Sambuc #ifdef __SSE2__
36f4a2713aSLionel Sambuc #include <emmintrin.h>
37f4a2713aSLionel Sambuc #endif
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc #ifdef __SSE3__
40f4a2713aSLionel Sambuc #include <pmmintrin.h>
41f4a2713aSLionel Sambuc #endif
42f4a2713aSLionel Sambuc
43f4a2713aSLionel Sambuc #ifdef __SSSE3__
44f4a2713aSLionel Sambuc #include <tmmintrin.h>
45f4a2713aSLionel Sambuc #endif
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc #if defined (__SSE4_2__) || defined (__SSE4_1__)
48f4a2713aSLionel Sambuc #include <smmintrin.h>
49f4a2713aSLionel Sambuc #endif
50f4a2713aSLionel Sambuc
51*0a6a1f1dSLionel Sambuc #if defined (__AES__) || defined (__PCLMUL__)
52f4a2713aSLionel Sambuc #include <wmmintrin.h>
53f4a2713aSLionel Sambuc #endif
54f4a2713aSLionel Sambuc
55f4a2713aSLionel Sambuc #ifdef __AVX__
56f4a2713aSLionel Sambuc #include <avxintrin.h>
57f4a2713aSLionel Sambuc #endif
58f4a2713aSLionel Sambuc
59f4a2713aSLionel Sambuc #ifdef __AVX2__
60f4a2713aSLionel Sambuc #include <avx2intrin.h>
61f4a2713aSLionel Sambuc #endif
62f4a2713aSLionel Sambuc
63f4a2713aSLionel Sambuc #ifdef __BMI__
64f4a2713aSLionel Sambuc #include <bmiintrin.h>
65f4a2713aSLionel Sambuc #endif
66f4a2713aSLionel Sambuc
67f4a2713aSLionel Sambuc #ifdef __BMI2__
68f4a2713aSLionel Sambuc #include <bmi2intrin.h>
69f4a2713aSLionel Sambuc #endif
70f4a2713aSLionel Sambuc
71f4a2713aSLionel Sambuc #ifdef __LZCNT__
72f4a2713aSLionel Sambuc #include <lzcntintrin.h>
73f4a2713aSLionel Sambuc #endif
74f4a2713aSLionel Sambuc
75f4a2713aSLionel Sambuc #ifdef __FMA__
76f4a2713aSLionel Sambuc #include <fmaintrin.h>
77f4a2713aSLionel Sambuc #endif
78f4a2713aSLionel Sambuc
79*0a6a1f1dSLionel Sambuc #ifdef __AVX512F__
80*0a6a1f1dSLionel Sambuc #include <avx512fintrin.h>
81*0a6a1f1dSLionel Sambuc #endif
82*0a6a1f1dSLionel Sambuc
83*0a6a1f1dSLionel Sambuc #ifdef __AVX512VL__
84*0a6a1f1dSLionel Sambuc #include <avx512vlintrin.h>
85*0a6a1f1dSLionel Sambuc #endif
86*0a6a1f1dSLionel Sambuc
87*0a6a1f1dSLionel Sambuc #ifdef __AVX512BW__
88*0a6a1f1dSLionel Sambuc #include <avx512bwintrin.h>
89*0a6a1f1dSLionel Sambuc #endif
90*0a6a1f1dSLionel Sambuc
91*0a6a1f1dSLionel Sambuc #if defined (__AVX512VL__) && defined (__AVX512BW__)
92*0a6a1f1dSLionel Sambuc #include <avx512vlbwintrin.h>
93*0a6a1f1dSLionel Sambuc #endif
94*0a6a1f1dSLionel Sambuc
95*0a6a1f1dSLionel Sambuc #ifdef __AVX512ER__
96*0a6a1f1dSLionel Sambuc #include <avx512erintrin.h>
97*0a6a1f1dSLionel Sambuc #endif
98*0a6a1f1dSLionel Sambuc
99f4a2713aSLionel Sambuc #ifdef __RDRND__
100f4a2713aSLionel Sambuc static __inline__ int __attribute__((__always_inline__, __nodebug__))
_rdrand16_step(unsigned short * __p)101f4a2713aSLionel Sambuc _rdrand16_step(unsigned short *__p)
102f4a2713aSLionel Sambuc {
103f4a2713aSLionel Sambuc return __builtin_ia32_rdrand16_step(__p);
104f4a2713aSLionel Sambuc }
105f4a2713aSLionel Sambuc
106f4a2713aSLionel Sambuc static __inline__ int __attribute__((__always_inline__, __nodebug__))
_rdrand32_step(unsigned int * __p)107f4a2713aSLionel Sambuc _rdrand32_step(unsigned int *__p)
108f4a2713aSLionel Sambuc {
109f4a2713aSLionel Sambuc return __builtin_ia32_rdrand32_step(__p);
110f4a2713aSLionel Sambuc }
111f4a2713aSLionel Sambuc
112f4a2713aSLionel Sambuc #ifdef __x86_64__
113f4a2713aSLionel Sambuc static __inline__ int __attribute__((__always_inline__, __nodebug__))
_rdrand64_step(unsigned long long * __p)114f4a2713aSLionel Sambuc _rdrand64_step(unsigned long long *__p)
115f4a2713aSLionel Sambuc {
116f4a2713aSLionel Sambuc return __builtin_ia32_rdrand64_step(__p);
117f4a2713aSLionel Sambuc }
118f4a2713aSLionel Sambuc #endif
119f4a2713aSLionel Sambuc #endif /* __RDRND__ */
120f4a2713aSLionel Sambuc
121*0a6a1f1dSLionel Sambuc #ifdef __FSGSBASE__
122*0a6a1f1dSLionel Sambuc #ifdef __x86_64__
123*0a6a1f1dSLionel Sambuc static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
_readfsbase_u32(void)124*0a6a1f1dSLionel Sambuc _readfsbase_u32(void)
125*0a6a1f1dSLionel Sambuc {
126*0a6a1f1dSLionel Sambuc return __builtin_ia32_rdfsbase32();
127*0a6a1f1dSLionel Sambuc }
128*0a6a1f1dSLionel Sambuc
129*0a6a1f1dSLionel Sambuc static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
_readfsbase_u64(void)130*0a6a1f1dSLionel Sambuc _readfsbase_u64(void)
131*0a6a1f1dSLionel Sambuc {
132*0a6a1f1dSLionel Sambuc return __builtin_ia32_rdfsbase64();
133*0a6a1f1dSLionel Sambuc }
134*0a6a1f1dSLionel Sambuc
135*0a6a1f1dSLionel Sambuc static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
_readgsbase_u32(void)136*0a6a1f1dSLionel Sambuc _readgsbase_u32(void)
137*0a6a1f1dSLionel Sambuc {
138*0a6a1f1dSLionel Sambuc return __builtin_ia32_rdgsbase32();
139*0a6a1f1dSLionel Sambuc }
140*0a6a1f1dSLionel Sambuc
141*0a6a1f1dSLionel Sambuc static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
_readgsbase_u64(void)142*0a6a1f1dSLionel Sambuc _readgsbase_u64(void)
143*0a6a1f1dSLionel Sambuc {
144*0a6a1f1dSLionel Sambuc return __builtin_ia32_rdgsbase64();
145*0a6a1f1dSLionel Sambuc }
146*0a6a1f1dSLionel Sambuc
147*0a6a1f1dSLionel Sambuc static __inline__ void __attribute__((__always_inline__, __nodebug__))
_writefsbase_u32(unsigned int __V)148*0a6a1f1dSLionel Sambuc _writefsbase_u32(unsigned int __V)
149*0a6a1f1dSLionel Sambuc {
150*0a6a1f1dSLionel Sambuc return __builtin_ia32_wrfsbase32(__V);
151*0a6a1f1dSLionel Sambuc }
152*0a6a1f1dSLionel Sambuc
153*0a6a1f1dSLionel Sambuc static __inline__ void __attribute__((__always_inline__, __nodebug__))
_writefsbase_u64(unsigned long long __V)154*0a6a1f1dSLionel Sambuc _writefsbase_u64(unsigned long long __V)
155*0a6a1f1dSLionel Sambuc {
156*0a6a1f1dSLionel Sambuc return __builtin_ia32_wrfsbase64(__V);
157*0a6a1f1dSLionel Sambuc }
158*0a6a1f1dSLionel Sambuc
159*0a6a1f1dSLionel Sambuc static __inline__ void __attribute__((__always_inline__, __nodebug__))
_writegsbase_u32(unsigned int __V)160*0a6a1f1dSLionel Sambuc _writegsbase_u32(unsigned int __V)
161*0a6a1f1dSLionel Sambuc {
162*0a6a1f1dSLionel Sambuc return __builtin_ia32_wrgsbase32(__V);
163*0a6a1f1dSLionel Sambuc }
164*0a6a1f1dSLionel Sambuc
165*0a6a1f1dSLionel Sambuc static __inline__ void __attribute__((__always_inline__, __nodebug__))
_writegsbase_u64(unsigned long long __V)166*0a6a1f1dSLionel Sambuc _writegsbase_u64(unsigned long long __V)
167*0a6a1f1dSLionel Sambuc {
168*0a6a1f1dSLionel Sambuc return __builtin_ia32_wrgsbase64(__V);
169*0a6a1f1dSLionel Sambuc }
170*0a6a1f1dSLionel Sambuc #endif
171*0a6a1f1dSLionel Sambuc #endif /* __FSGSBASE__ */
172*0a6a1f1dSLionel Sambuc
173f4a2713aSLionel Sambuc #ifdef __RTM__
174f4a2713aSLionel Sambuc #include <rtmintrin.h>
175f4a2713aSLionel Sambuc #endif
176f4a2713aSLionel Sambuc
177f4a2713aSLionel Sambuc /* FIXME: check __HLE__ as well when HLE is supported. */
178f4a2713aSLionel Sambuc #if defined (__RTM__)
179f4a2713aSLionel Sambuc static __inline__ int __attribute__((__always_inline__, __nodebug__))
_xtest(void)180f4a2713aSLionel Sambuc _xtest(void)
181f4a2713aSLionel Sambuc {
182f4a2713aSLionel Sambuc return __builtin_ia32_xtest();
183f4a2713aSLionel Sambuc }
184f4a2713aSLionel Sambuc #endif
185f4a2713aSLionel Sambuc
186f4a2713aSLionel Sambuc #ifdef __SHA__
187f4a2713aSLionel Sambuc #include <shaintrin.h>
188f4a2713aSLionel Sambuc #endif
189f4a2713aSLionel Sambuc
190*0a6a1f1dSLionel Sambuc /* Some intrinsics inside adxintrin.h are available only if __ADX__ defined,
191*0a6a1f1dSLionel Sambuc * whereas others are also available if __ADX__ undefined */
192*0a6a1f1dSLionel Sambuc #include <adxintrin.h>
193*0a6a1f1dSLionel Sambuc
194f4a2713aSLionel Sambuc #endif /* __IMMINTRIN_H */
195