Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 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 | |
| 24 | #ifndef __IMMINTRIN_H |
| 25 | #define __IMMINTRIN_H |
| 26 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 27 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__MMX__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 28 | #include <mmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 29 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 30 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 31 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 32 | #include <xmmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 33 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 34 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 35 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE2__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 36 | #include <emmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 37 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 38 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 39 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE3__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 40 | #include <pmmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 41 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 42 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 43 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSSE3__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 44 | #include <tmmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 45 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 46 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 47 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 48 | (defined(__SSE4_2__) || defined(__SSE4_1__)) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 49 | #include <smmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 50 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 51 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 52 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 53 | (defined(__AES__) || defined(__PCLMUL__)) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 54 | #include <wmmintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 55 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 56 | |
Michael Zuckerman | b920665 | 2016-07-05 15:56:03 +0000 | [diff] [blame] | 57 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLFLUSHOPT__) |
| 58 | #include <clflushoptintrin.h> |
| 59 | #endif |
| 60 | |
Craig Topper | 89cd753 | 2017-10-12 18:57:15 +0000 | [diff] [blame] | 61 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLWB__) |
| 62 | #include <clwbintrin.h> |
| 63 | #endif |
| 64 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 65 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__) |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 66 | #include <avxintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 67 | #endif |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 68 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 69 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__) |
Craig Topper | dec792e | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 70 | #include <avx2intrin.h> |
Craig Topper | dec792e | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 71 | |
Paul Robinson | 941bc91 | 2015-12-02 18:41:52 +0000 | [diff] [blame] | 72 | /* The 256-bit versions of functions in f16cintrin.h. |
| 73 | Intel documents these as being in immintrin.h, and |
| 74 | they depend on typedefs from avxintrin.h. */ |
| 75 | |
Ekaterina Romanova | bf667b2 | 2016-11-20 08:35:05 +0000 | [diff] [blame] | 76 | /// \brief Converts a 256-bit vector of [8 x float] into a 128-bit vector |
| 77 | /// containing 16-bit half-precision float values. |
| 78 | /// |
| 79 | /// \headerfile <x86intrin.h> |
| 80 | /// |
| 81 | /// \code |
| 82 | /// __m128i _mm256_cvtps_ph(__m256 a, const int imm); |
| 83 | /// \endcode |
| 84 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 85 | /// This intrinsic corresponds to the <c> VCVTPS2PH </c> instruction. |
Ekaterina Romanova | bf667b2 | 2016-11-20 08:35:05 +0000 | [diff] [blame] | 86 | /// |
| 87 | /// \param a |
| 88 | /// A 256-bit vector containing 32-bit single-precision float values to be |
| 89 | /// converted to 16-bit half-precision float values. |
| 90 | /// \param imm |
Ekaterina Romanova | dffe45b | 2016-12-27 00:49:38 +0000 | [diff] [blame] | 91 | /// An immediate value controlling rounding using bits [2:0]: \n |
| 92 | /// 000: Nearest \n |
| 93 | /// 001: Down \n |
| 94 | /// 010: Up \n |
| 95 | /// 011: Truncate \n |
Ekaterina Romanova | bf667b2 | 2016-11-20 08:35:05 +0000 | [diff] [blame] | 96 | /// 1XX: Use MXCSR.RC for rounding |
| 97 | /// \returns A 128-bit vector containing the converted 16-bit half-precision |
| 98 | /// float values. |
Paul Robinson | 941bc91 | 2015-12-02 18:41:52 +0000 | [diff] [blame] | 99 | #define _mm256_cvtps_ph(a, imm) __extension__ ({ \ |
| 100 | (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); }) |
| 101 | |
Ekaterina Romanova | bf667b2 | 2016-11-20 08:35:05 +0000 | [diff] [blame] | 102 | /// \brief Converts a 128-bit vector containing 16-bit half-precision float |
| 103 | /// values into a 256-bit vector of [8 x float]. |
| 104 | /// |
| 105 | /// \headerfile <x86intrin.h> |
| 106 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 107 | /// This intrinsic corresponds to the <c> VCVTPH2PS </c> instruction. |
Ekaterina Romanova | bf667b2 | 2016-11-20 08:35:05 +0000 | [diff] [blame] | 108 | /// |
| 109 | /// \param __a |
| 110 | /// A 128-bit vector containing 16-bit half-precision float values to be |
| 111 | /// converted to 32-bit single-precision float values. |
| 112 | /// \returns A vector of [8 x float] containing the converted 32-bit |
| 113 | /// single-precision float values. |
Paul Robinson | 941bc91 | 2015-12-02 18:41:52 +0000 | [diff] [blame] | 114 | static __inline __m256 __attribute__((__always_inline__, __nodebug__, __target__("f16c"))) |
| 115 | _mm256_cvtph_ps(__m128i __a) |
| 116 | { |
| 117 | return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a); |
| 118 | } |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 119 | #endif /* __AVX2__ */ |
Paul Robinson | 941bc91 | 2015-12-02 18:41:52 +0000 | [diff] [blame] | 120 | |
Coby Tayree | cf96c87 | 2017-12-27 09:00:31 +0000 | [diff] [blame] | 121 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VPCLMULQDQ__) |
| 122 | #include <vpclmulqdqintrin.h> |
| 123 | #endif |
| 124 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 125 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__) |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 126 | #include <bmiintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 127 | #endif |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 128 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 129 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__) |
Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 130 | #include <bmi2intrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 131 | #endif |
Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 132 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 133 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__) |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 134 | #include <lzcntintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 135 | #endif |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 136 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 137 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__) |
Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 138 | #include <fmaintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 139 | #endif |
Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 140 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 141 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__) |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 142 | #include <avx512fintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 143 | #endif |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 144 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 145 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__) |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 146 | #include <avx512vlintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 147 | #endif |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 148 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 149 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__) |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 150 | #include <avx512bwintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 151 | #endif |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 152 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 153 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__) |
Asaf Badouh | a45b7ca | 2015-06-29 12:51:53 +0000 | [diff] [blame] | 154 | #include <avx512cdintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 155 | #endif |
Asaf Badouh | a45b7ca | 2015-06-29 12:51:53 +0000 | [diff] [blame] | 156 | |
Oren Ben Simhon | 140c1fb | 2017-05-25 13:44:11 +0000 | [diff] [blame] | 157 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__) |
| 158 | #include <avx512vpopcntdqintrin.h> |
| 159 | #endif |
| 160 | |
Craig Topper | b846d1f | 2017-12-16 06:02:31 +0000 | [diff] [blame] | 161 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 162 | (defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__)) |
| 163 | #include <avx512vpopcntdqvlintrin.h> |
| 164 | #endif |
| 165 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 166 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__) |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 167 | #include <avx512dqintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 168 | #endif |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 169 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 170 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 171 | (defined(__AVX512VL__) && defined(__AVX512BW__)) |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 172 | #include <avx512vlbwintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 173 | #endif |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 174 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 175 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 176 | (defined(__AVX512VL__) && defined(__AVX512CD__)) |
Michael Zuckerman | 8c2900f | 2016-04-27 11:43:14 +0000 | [diff] [blame] | 177 | #include <avx512vlcdintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 178 | #endif |
Michael Zuckerman | 8c2900f | 2016-04-27 11:43:14 +0000 | [diff] [blame] | 179 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 180 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 181 | (defined(__AVX512VL__) && defined(__AVX512DQ__)) |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 182 | #include <avx512vldqintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 183 | #endif |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 184 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 185 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512ER__) |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 186 | #include <avx512erintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 187 | #endif |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 188 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 189 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512IFMA__) |
Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 190 | #include <avx512ifmaintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 191 | #endif |
Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 192 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 193 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 194 | (defined(__AVX512IFMA__) && defined(__AVX512VL__)) |
Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 195 | #include <avx512ifmavlintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 196 | #endif |
Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 197 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 198 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VBMI__) |
Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 199 | #include <avx512vbmiintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 200 | #endif |
Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 201 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 202 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 203 | (defined(__AVX512VBMI__) && defined(__AVX512VL__)) |
Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 204 | #include <avx512vbmivlintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 205 | #endif |
Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 206 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 207 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512PF__) |
Michael Zuckerman | 4fa96af | 2016-04-21 12:47:27 +0000 | [diff] [blame] | 208 | #include <avx512pfintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 209 | #endif |
Michael Zuckerman | 4fa96af | 2016-04-21 12:47:27 +0000 | [diff] [blame] | 210 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 211 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__PKU__) |
Asaf Badouh | a9d1e18 | 2015-12-31 14:14:07 +0000 | [diff] [blame] | 212 | #include <pkuintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 213 | #endif |
Asaf Badouh | a9d1e18 | 2015-12-31 14:14:07 +0000 | [diff] [blame] | 214 | |
Coby Tayree | a1e5f0c | 2017-12-27 08:16:54 +0000 | [diff] [blame] | 215 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VAES__) |
| 216 | #include <vaesintrin.h> |
| 217 | #endif |
| 218 | |
Coby Tayree | f4811eb | 2017-12-27 08:37:47 +0000 | [diff] [blame] | 219 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__GFNI__) |
| 220 | #include <gfniintrin.h> |
| 221 | #endif |
| 222 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 223 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDRND__) |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 224 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 225 | _rdrand16_step(unsigned short *__p) |
| 226 | { |
| 227 | return __builtin_ia32_rdrand16_step(__p); |
| 228 | } |
| 229 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 230 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 231 | _rdrand32_step(unsigned int *__p) |
| 232 | { |
| 233 | return __builtin_ia32_rdrand32_step(__p); |
| 234 | } |
| 235 | |
Zvi Rackover | 064f000 | 2017-07-10 07:13:56 +0000 | [diff] [blame] | 236 | #ifdef __x86_64__ |
| 237 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
| 238 | _rdrand64_step(unsigned long long *__p) |
| 239 | { |
| 240 | return __builtin_ia32_rdrand64_step(__p); |
| 241 | } |
| 242 | #endif |
| 243 | #endif /* __RDRND__ */ |
| 244 | |
Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 245 | /* __bit_scan_forward */ |
| 246 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
| 247 | _bit_scan_forward(int __A) { |
David Majnemer | d423574 | 2016-06-13 17:26:16 +0000 | [diff] [blame] | 248 | return __builtin_ctz(__A); |
Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /* __bit_scan_reverse */ |
| 252 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
| 253 | _bit_scan_reverse(int __A) { |
David Majnemer | d423574 | 2016-06-13 17:26:16 +0000 | [diff] [blame] | 254 | return 31 - __builtin_clz(__A); |
Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 257 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FSGSBASE__) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 258 | #ifdef __x86_64__ |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 259 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 260 | _readfsbase_u32(void) |
| 261 | { |
| 262 | return __builtin_ia32_rdfsbase32(); |
| 263 | } |
| 264 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 265 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 266 | _readfsbase_u64(void) |
| 267 | { |
| 268 | return __builtin_ia32_rdfsbase64(); |
| 269 | } |
| 270 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 271 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 272 | _readgsbase_u32(void) |
| 273 | { |
| 274 | return __builtin_ia32_rdgsbase32(); |
| 275 | } |
| 276 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 277 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 278 | _readgsbase_u64(void) |
| 279 | { |
| 280 | return __builtin_ia32_rdgsbase64(); |
| 281 | } |
| 282 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 283 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 284 | _writefsbase_u32(unsigned int __V) |
| 285 | { |
| 286 | return __builtin_ia32_wrfsbase32(__V); |
| 287 | } |
| 288 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 289 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 290 | _writefsbase_u64(unsigned long long __V) |
| 291 | { |
| 292 | return __builtin_ia32_wrfsbase64(__V); |
| 293 | } |
| 294 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 295 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 296 | _writegsbase_u32(unsigned int __V) |
| 297 | { |
| 298 | return __builtin_ia32_wrgsbase32(__V); |
| 299 | } |
| 300 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 301 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 302 | _writegsbase_u64(unsigned long long __V) |
| 303 | { |
| 304 | return __builtin_ia32_wrgsbase64(__V); |
| 305 | } |
Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 306 | |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 307 | #endif |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 308 | #endif /* __FSGSBASE__ */ |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 309 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 310 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RTM__) |
Michael Liao | 625a875 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 311 | #include <rtmintrin.h> |
Eric Christopher | 3d920ee | 2015-06-17 18:42:07 +0000 | [diff] [blame] | 312 | #include <xtestintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 313 | #endif |
Michael Liao | 4442f79 | 2013-03-29 05:14:06 +0000 | [diff] [blame] | 314 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 315 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SHA__) |
Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 316 | #include <shaintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 317 | #endif |
Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 318 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 319 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FXSR__) |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 320 | #include <fxsrintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 321 | #endif |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 322 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 323 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVE__) |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 324 | #include <xsaveintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 325 | #endif |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 326 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 327 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEOPT__) |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 328 | #include <xsaveoptintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 329 | #endif |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 330 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 331 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEC__) |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 332 | #include <xsavecintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 333 | #endif |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 334 | |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 335 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVES__) |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 336 | #include <xsavesintrin.h> |
Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 337 | #endif |
Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 338 | |
Oren Ben Simhon | fec21ec | 2017-11-26 12:34:54 +0000 | [diff] [blame] | 339 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SHSTK__) |
| 340 | #include <cetintrin.h> |
| 341 | #endif |
| 342 | |
Eric Christopher | 29b7809 | 2015-06-17 18:42:03 +0000 | [diff] [blame] | 343 | /* Some intrinsics inside adxintrin.h are available only on processors with ADX, |
| 344 | * whereas others are also available at all times. */ |
Robert Khasanov | 83c419b | 2014-09-19 10:17:06 +0000 | [diff] [blame] | 345 | #include <adxintrin.h> |
| 346 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 347 | #endif /* __IMMINTRIN_H */ |