blob: f3c6d1914d61b1aa75a3fe127e8577f562a46579 [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
Eric Christopher9fc7fb22015-06-17 07:09:32 +000082static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000083_rdrand16_step(unsigned short *__p)
84{
85 return __builtin_ia32_rdrand16_step(__p);
86}
87
Eric Christopher9fc7fb22015-06-17 07:09:32 +000088static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000089_rdrand32_step(unsigned int *__p)
90{
91 return __builtin_ia32_rdrand32_step(__p);
92}
93
94#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +000095static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000096_rdrand64_step(unsigned long long *__p)
97{
98 return __builtin_ia32_rdrand64_step(__p);
99}
100#endif
Benjamin Kramera43b6992012-07-12 09:33:03 +0000101
Craig Topper8c7f2512014-11-03 06:51:41 +0000102#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000103static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000104_readfsbase_u32(void)
105{
106 return __builtin_ia32_rdfsbase32();
107}
108
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000109static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000110_readfsbase_u64(void)
111{
112 return __builtin_ia32_rdfsbase64();
113}
114
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000115static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000116_readgsbase_u32(void)
117{
118 return __builtin_ia32_rdgsbase32();
119}
120
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000121static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000122_readgsbase_u64(void)
123{
124 return __builtin_ia32_rdgsbase64();
125}
126
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000127static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000128_writefsbase_u32(unsigned int __V)
129{
130 return __builtin_ia32_wrfsbase32(__V);
131}
132
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000133static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000134_writefsbase_u64(unsigned long long __V)
135{
136 return __builtin_ia32_wrfsbase64(__V);
137}
138
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000139static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000140_writegsbase_u32(unsigned int __V)
141{
142 return __builtin_ia32_wrgsbase32(__V);
143}
144
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000145static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000146_writegsbase_u64(unsigned long long __V)
147{
148 return __builtin_ia32_wrgsbase64(__V);
149}
150#endif
Craig Topper8c7f2512014-11-03 06:51:41 +0000151
Michael Liao625a8752012-11-10 05:17:46 +0000152#include <rtmintrin.h>
Michael Liao625a8752012-11-10 05:17:46 +0000153
Eric Christopher3d920ee2015-06-17 18:42:07 +0000154#include <xtestintrin.h>
Michael Liao4442f792013-03-29 05:14:06 +0000155
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000156#include <shaintrin.h>
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000157
Michael Kupersteina3c7b742015-06-30 09:45:38 +0000158#include <fxsrintrin.h>
159
Amjad Aboud2b9b8a52015-10-13 12:29:35 +0000160#include <xsaveintrin.h>
161
162#include <xsaveoptintrin.h>
163
164#include <xsavecintrin.h>
165
166#include <xsavesintrin.h>
167
Eric Christopher29b78092015-06-17 18:42:03 +0000168/* Some intrinsics inside adxintrin.h are available only on processors with ADX,
169 * whereas others are also available at all times. */
Robert Khasanov83c419b2014-09-19 10:17:06 +0000170#include <adxintrin.h>
171
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +0000172#endif /* __IMMINTRIN_H */