blob: ceaa103835040440c9a3c5b64c60ab029cbcab3e [file] [log] [blame]
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +00001/*===---- 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
24#ifndef __IMMINTRIN_H
25#define __IMMINTRIN_H
26
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000027#include <mmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000028
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000029#include <xmmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000030
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000031#include <emmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000032
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000033#include <pmmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000034
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000035#include <tmmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000036
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000037#include <smmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000038
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000039#include <wmmintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000040
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000041#include <avxintrin.h>
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +000042
Craig Topperdec792e2011-12-19 05:04:33 +000043#include <avx2intrin.h>
Craig Topperdec792e2011-12-19 05:04:33 +000044
Paul Robinson941bc912015-12-02 18:41:52 +000045/* The 256-bit versions of functions in f16cintrin.h.
46 Intel documents these as being in immintrin.h, and
47 they depend on typedefs from avxintrin.h. */
48
49#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
50 (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
51
52static __inline __m256 __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
53_mm256_cvtph_ps(__m128i __a)
54{
55 return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
56}
57
Craig Topperf2855ad2011-12-25 06:25:37 +000058#include <bmiintrin.h>
Craig Topperf2855ad2011-12-25 06:25:37 +000059
Craig Topperc334dd62011-12-26 02:31:10 +000060#include <bmi2intrin.h>
Craig Topperc334dd62011-12-26 02:31:10 +000061
Craig Topperf2855ad2011-12-25 06:25:37 +000062#include <lzcntintrin.h>
Craig Topperf2855ad2011-12-25 06:25:37 +000063
Craig Topper2b1eda32012-06-04 03:42:47 +000064#include <fmaintrin.h>
Craig Topper2b1eda32012-06-04 03:42:47 +000065
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000066#include <avx512fintrin.h>
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000067
Robert Khasanovb9f3a912014-10-08 17:18:13 +000068#include <avx512vlintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000069
Robert Khasanovb9f3a912014-10-08 17:18:13 +000070#include <avx512bwintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000071
Asaf Badouha45b7ca2015-06-29 12:51:53 +000072#include <avx512cdintrin.h>
73
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000074#include <avx512dqintrin.h>
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000075
Robert Khasanovb9f3a912014-10-08 17:18:13 +000076#include <avx512vlbwintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000077
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000078#include <avx512vldqintrin.h>
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000079
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000080#include <avx512erintrin.h>
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000081
Michael Zuckerman0190c652016-03-07 09:55:55 +000082#include <avx512ifmaintrin.h>
83
84#include <avx512ifmavlintrin.h>
85
Michael Zuckerman9f338482016-03-07 17:04:11 +000086#include <avx512vbmiintrin.h>
87
88#include <avx512vbmivlintrin.h>
89
Asaf Badouha9d1e182015-12-31 14:14:07 +000090#include <pkuintrin.h>
91
Eric Christopher9fc7fb22015-06-17 07:09:32 +000092static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000093_rdrand16_step(unsigned short *__p)
94{
95 return __builtin_ia32_rdrand16_step(__p);
96}
97
Eric Christopher9fc7fb22015-06-17 07:09:32 +000098static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000099_rdrand32_step(unsigned int *__p)
100{
101 return __builtin_ia32_rdrand32_step(__p);
102}
103
104#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000105static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +0000106_rdrand64_step(unsigned long long *__p)
107{
108 return __builtin_ia32_rdrand64_step(__p);
109}
110#endif
Benjamin Kramera43b6992012-07-12 09:33:03 +0000111
Craig Topper8c7f2512014-11-03 06:51:41 +0000112#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000113static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000114_readfsbase_u32(void)
115{
116 return __builtin_ia32_rdfsbase32();
117}
118
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000119static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000120_readfsbase_u64(void)
121{
122 return __builtin_ia32_rdfsbase64();
123}
124
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000125static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000126_readgsbase_u32(void)
127{
128 return __builtin_ia32_rdgsbase32();
129}
130
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000131static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000132_readgsbase_u64(void)
133{
134 return __builtin_ia32_rdgsbase64();
135}
136
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000137static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000138_writefsbase_u32(unsigned int __V)
139{
140 return __builtin_ia32_wrfsbase32(__V);
141}
142
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000143static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000144_writefsbase_u64(unsigned long long __V)
145{
146 return __builtin_ia32_wrfsbase64(__V);
147}
148
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000149static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000150_writegsbase_u32(unsigned int __V)
151{
152 return __builtin_ia32_wrgsbase32(__V);
153}
154
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000155static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000156_writegsbase_u64(unsigned long long __V)
157{
158 return __builtin_ia32_wrgsbase64(__V);
159}
160#endif
Craig Topper8c7f2512014-11-03 06:51:41 +0000161
Michael Liao625a8752012-11-10 05:17:46 +0000162#include <rtmintrin.h>
Michael Liao625a8752012-11-10 05:17:46 +0000163
Eric Christopher3d920ee2015-06-17 18:42:07 +0000164#include <xtestintrin.h>
Michael Liao4442f792013-03-29 05:14:06 +0000165
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000166#include <shaintrin.h>
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000167
Michael Kupersteina3c7b742015-06-30 09:45:38 +0000168#include <fxsrintrin.h>
169
Amjad Aboud2b9b8a52015-10-13 12:29:35 +0000170#include <xsaveintrin.h>
171
172#include <xsaveoptintrin.h>
173
174#include <xsavecintrin.h>
175
176#include <xsavesintrin.h>
177
Eric Christopher29b78092015-06-17 18:42:03 +0000178/* Some intrinsics inside adxintrin.h are available only on processors with ADX,
179 * whereas others are also available at all times. */
Robert Khasanov83c419b2014-09-19 10:17:06 +0000180#include <adxintrin.h>
181
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +0000182#endif /* __IMMINTRIN_H */