blob: 4194eb5910a86db704e3717af50f5b141ab65bf0 [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
Craig Topperf2855ad2011-12-25 06:25:37 +000045#include <bmiintrin.h>
Craig Topperf2855ad2011-12-25 06:25:37 +000046
Craig Topperc334dd62011-12-26 02:31:10 +000047#include <bmi2intrin.h>
Craig Topperc334dd62011-12-26 02:31:10 +000048
Craig Topperf2855ad2011-12-25 06:25:37 +000049#include <lzcntintrin.h>
Craig Topperf2855ad2011-12-25 06:25:37 +000050
Craig Topper2b1eda32012-06-04 03:42:47 +000051#include <fmaintrin.h>
Craig Topper2b1eda32012-06-04 03:42:47 +000052
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000053#include <avx512fintrin.h>
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000054
Robert Khasanovb9f3a912014-10-08 17:18:13 +000055#include <avx512vlintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000056
Robert Khasanovb9f3a912014-10-08 17:18:13 +000057#include <avx512bwintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000058
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000059#include <avx512dqintrin.h>
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000060
Robert Khasanovb9f3a912014-10-08 17:18:13 +000061#include <avx512vlbwintrin.h>
Robert Khasanovb9f3a912014-10-08 17:18:13 +000062
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000063#include <avx512vldqintrin.h>
Elena Demikhovskye7d4c2e2015-04-30 09:24:29 +000064
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000065#include <avx512erintrin.h>
Elena Demikhovskyfcc6df32014-07-22 11:31:39 +000066
Eric Christopher9fc7fb22015-06-17 07:09:32 +000067static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000068_rdrand16_step(unsigned short *__p)
69{
70 return __builtin_ia32_rdrand16_step(__p);
71}
72
Eric Christopher9fc7fb22015-06-17 07:09:32 +000073static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000074_rdrand32_step(unsigned int *__p)
75{
76 return __builtin_ia32_rdrand32_step(__p);
77}
78
79#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +000080static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
Benjamin Kramera43b6992012-07-12 09:33:03 +000081_rdrand64_step(unsigned long long *__p)
82{
83 return __builtin_ia32_rdrand64_step(__p);
84}
85#endif
Benjamin Kramera43b6992012-07-12 09:33:03 +000086
Craig Topper8c7f2512014-11-03 06:51:41 +000087#ifdef __x86_64__
Eric Christopher9fc7fb22015-06-17 07:09:32 +000088static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +000089_readfsbase_u32(void)
90{
91 return __builtin_ia32_rdfsbase32();
92}
93
Eric Christopher9fc7fb22015-06-17 07:09:32 +000094static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +000095_readfsbase_u64(void)
96{
97 return __builtin_ia32_rdfsbase64();
98}
99
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000100static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000101_readgsbase_u32(void)
102{
103 return __builtin_ia32_rdgsbase32();
104}
105
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000106static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000107_readgsbase_u64(void)
108{
109 return __builtin_ia32_rdgsbase64();
110}
111
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000112static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000113_writefsbase_u32(unsigned int __V)
114{
115 return __builtin_ia32_wrfsbase32(__V);
116}
117
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000118static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000119_writefsbase_u64(unsigned long long __V)
120{
121 return __builtin_ia32_wrfsbase64(__V);
122}
123
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000124static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000125_writegsbase_u32(unsigned int __V)
126{
127 return __builtin_ia32_wrgsbase32(__V);
128}
129
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000130static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
Craig Topper8c7f2512014-11-03 06:51:41 +0000131_writegsbase_u64(unsigned long long __V)
132{
133 return __builtin_ia32_wrgsbase64(__V);
134}
135#endif
Craig Topper8c7f2512014-11-03 06:51:41 +0000136
Michael Liao625a8752012-11-10 05:17:46 +0000137#include <rtmintrin.h>
Michael Liao625a8752012-11-10 05:17:46 +0000138
Eric Christopher29b78092015-06-17 18:42:03 +0000139/* xtest returns non-zero if the instruction is executed within an RTM or active
140 * HLE region. */
141/* FIXME: This can be an either or for RTM/HLE. Deal with this when HLE is
142 * supported. */
Eric Christopher9fc7fb22015-06-17 07:09:32 +0000143static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rtm")))
Michael Liao4442f792013-03-29 05:14:06 +0000144_xtest(void)
145{
146 return __builtin_ia32_xtest();
147}
Michael Liao4442f792013-03-29 05:14:06 +0000148
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000149#include <shaintrin.h>
Ben Langmuir6efe3a82013-09-19 14:00:22 +0000150
Eric Christopher29b78092015-06-17 18:42:03 +0000151/* Some intrinsics inside adxintrin.h are available only on processors with ADX,
152 * whereas others are also available at all times. */
Robert Khasanov83c419b2014-09-19 10:17:06 +0000153#include <adxintrin.h>
154
Benjamin Kramer65b9f7b2010-08-20 18:04:07 +0000155#endif /* __IMMINTRIN_H */