| 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 | 1fceff9 | 2018-05-22 20:33:04 +0000 | [diff] [blame] | 71 | #endif |
| Craig Topper | dec792e | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 72 | |
| Craig Topper | 34c8c0d | 2018-05-22 18:54:19 +0000 | [diff] [blame] | 73 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__F16C__) |
| 74 | #include <f16cintrin.h> |
| Craig Topper | 1fceff9 | 2018-05-22 20:33:04 +0000 | [diff] [blame] | 75 | #endif |
| Paul Robinson | 941bc91 | 2015-12-02 18:41:52 +0000 | [diff] [blame] | 76 | |
| Coby Tayree | cf96c87 | 2017-12-27 09:00:31 +0000 | [diff] [blame] | 77 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VPCLMULQDQ__) |
| 78 | #include <vpclmulqdqintrin.h> |
| 79 | #endif |
| 80 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 81 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__) |
| Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 82 | #include <bmiintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 83 | #endif |
| Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 84 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 85 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__) |
| Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 86 | #include <bmi2intrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 87 | #endif |
| Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 88 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 89 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__) |
| Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 90 | #include <lzcntintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 91 | #endif |
| Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 92 | |
| Craig Topper | 664af9b | 2018-05-23 18:32:58 +0000 | [diff] [blame] | 93 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__POPCNT__) |
| 94 | #include <popcntintrin.h> |
| 95 | #endif |
| 96 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 97 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__) |
| Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 98 | #include <fmaintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 99 | #endif |
| Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 100 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 101 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__) |
| Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 102 | #include <avx512fintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 103 | #endif |
| Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 104 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 105 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__) |
| Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 106 | #include <avx512vlintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 107 | #endif |
| Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 108 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 109 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__) |
| Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 110 | #include <avx512bwintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 111 | #endif |
| Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 112 | |
| Coby Tayree | 2268576 | 2017-12-27 10:01:00 +0000 | [diff] [blame] | 113 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BITALG__) |
| 114 | #include <avx512bitalgintrin.h> |
| 115 | #endif |
| 116 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 117 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__) |
| Asaf Badouh | a45b7ca | 2015-06-29 12:51:53 +0000 | [diff] [blame] | 118 | #include <avx512cdintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 119 | #endif |
| Asaf Badouh | a45b7ca | 2015-06-29 12:51:53 +0000 | [diff] [blame] | 120 | |
| Oren Ben Simhon | 140c1fb | 2017-05-25 13:44:11 +0000 | [diff] [blame] | 121 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__) |
| 122 | #include <avx512vpopcntdqintrin.h> |
| 123 | #endif |
| 124 | |
| Craig Topper | b846d1f | 2017-12-16 06:02:31 +0000 | [diff] [blame] | 125 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 126 | (defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__)) |
| 127 | #include <avx512vpopcntdqvlintrin.h> |
| 128 | #endif |
| 129 | |
| Coby Tayree | 3d9c88c | 2017-12-27 10:37:51 +0000 | [diff] [blame] | 130 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VNNI__) |
| 131 | #include <avx512vnniintrin.h> |
| 132 | #endif |
| 133 | |
| 134 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 135 | (defined(__AVX512VL__) && defined(__AVX512VNNI__)) |
| 136 | #include <avx512vlvnniintrin.h> |
| 137 | #endif |
| 138 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 139 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__) |
| Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 140 | #include <avx512dqintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 141 | #endif |
| Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 142 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 143 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| Coby Tayree | 2268576 | 2017-12-27 10:01:00 +0000 | [diff] [blame] | 144 | (defined(__AVX512VL__) && defined(__AVX512BITALG__)) |
| 145 | #include <avx512vlbitalgintrin.h> |
| 146 | #endif |
| 147 | |
| 148 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 149 | (defined(__AVX512VL__) && defined(__AVX512BW__)) |
| Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 150 | #include <avx512vlbwintrin.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) || \ |
| 154 | (defined(__AVX512VL__) && defined(__AVX512CD__)) |
| Michael Zuckerman | 8c2900f | 2016-04-27 11:43:14 +0000 | [diff] [blame] | 155 | #include <avx512vlcdintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 156 | #endif |
| Michael Zuckerman | 8c2900f | 2016-04-27 11:43:14 +0000 | [diff] [blame] | 157 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 158 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 159 | (defined(__AVX512VL__) && defined(__AVX512DQ__)) |
| Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 160 | #include <avx512vldqintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 161 | #endif |
| Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 162 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 163 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512ER__) |
| Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 164 | #include <avx512erintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 165 | #endif |
| Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 166 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 167 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512IFMA__) |
| Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 168 | #include <avx512ifmaintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 169 | #endif |
| Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 170 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 171 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 172 | (defined(__AVX512IFMA__) && defined(__AVX512VL__)) |
| Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 173 | #include <avx512ifmavlintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 174 | #endif |
| Michael Zuckerman | 0190c65 | 2016-03-07 09:55:55 +0000 | [diff] [blame] | 175 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 176 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VBMI__) |
| Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 177 | #include <avx512vbmiintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 178 | #endif |
| Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +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(__AVX512VBMI__) && defined(__AVX512VL__)) |
| Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 182 | #include <avx512vbmivlintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 183 | #endif |
| Michael Zuckerman | 9f33848 | 2016-03-07 17:04:11 +0000 | [diff] [blame] | 184 | |
| Coby Tayree | a09663a | 2017-12-27 11:25:07 +0000 | [diff] [blame] | 185 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VBMI2__) |
| 186 | #include <avx512vbmi2intrin.h> |
| 187 | #endif |
| 188 | |
| 189 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 190 | (defined(__AVX512VBMI2__) && defined(__AVX512VL__)) |
| 191 | #include <avx512vlvbmi2intrin.h> |
| 192 | #endif |
| 193 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 194 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512PF__) |
| Michael Zuckerman | 4fa96af | 2016-04-21 12:47:27 +0000 | [diff] [blame] | 195 | #include <avx512pfintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 196 | #endif |
| Michael Zuckerman | 4fa96af | 2016-04-21 12:47:27 +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(__PKU__) |
| Asaf Badouh | a9d1e18 | 2015-12-31 14:14:07 +0000 | [diff] [blame] | 199 | #include <pkuintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 200 | #endif |
| Asaf Badouh | a9d1e18 | 2015-12-31 14:14:07 +0000 | [diff] [blame] | 201 | |
| Coby Tayree | a1e5f0c | 2017-12-27 08:16:54 +0000 | [diff] [blame] | 202 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VAES__) |
| 203 | #include <vaesintrin.h> |
| 204 | #endif |
| 205 | |
| Coby Tayree | f4811eb | 2017-12-27 08:37:47 +0000 | [diff] [blame] | 206 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__GFNI__) |
| 207 | #include <gfniintrin.h> |
| 208 | #endif |
| 209 | |
| Craig Topper | 8cdb949 | 2018-01-20 18:36:52 +0000 | [diff] [blame] | 210 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDPID__) |
| Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 211 | /// Returns the value of the IA32_TSC_AUX MSR (0xc0000103). |
| Craig Topper | 8cdb949 | 2018-01-20 18:36:52 +0000 | [diff] [blame] | 212 | /// |
| 213 | /// \headerfile <immintrin.h> |
| 214 | /// |
| 215 | /// This intrinsic corresponds to the <c> RDPID </c> instruction. |
| 216 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("rdpid"))) |
| 217 | _rdpid_u32(void) { |
| 218 | return __builtin_ia32_rdpid(); |
| 219 | } |
| 220 | #endif // __RDPID__ |
| 221 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 222 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDRND__) |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 223 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
| Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 224 | _rdrand16_step(unsigned short *__p) |
| 225 | { |
| 226 | return __builtin_ia32_rdrand16_step(__p); |
| 227 | } |
| 228 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 229 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
| Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 230 | _rdrand32_step(unsigned int *__p) |
| 231 | { |
| 232 | return __builtin_ia32_rdrand32_step(__p); |
| 233 | } |
| 234 | |
| Zvi Rackover | 064f000 | 2017-07-10 07:13:56 +0000 | [diff] [blame] | 235 | #ifdef __x86_64__ |
| 236 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
| 237 | _rdrand64_step(unsigned long long *__p) |
| 238 | { |
| 239 | return __builtin_ia32_rdrand64_step(__p); |
| 240 | } |
| 241 | #endif |
| 242 | #endif /* __RDRND__ */ |
| 243 | |
| Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 244 | /* __bit_scan_forward */ |
| 245 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
| 246 | _bit_scan_forward(int __A) { |
| David Majnemer | d423574 | 2016-06-13 17:26:16 +0000 | [diff] [blame] | 247 | return __builtin_ctz(__A); |
| Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /* __bit_scan_reverse */ |
| 251 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
| 252 | _bit_scan_reverse(int __A) { |
| David Majnemer | d423574 | 2016-06-13 17:26:16 +0000 | [diff] [blame] | 253 | return 31 - __builtin_clz(__A); |
| Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 254 | } |
| 255 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 256 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FSGSBASE__) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 257 | #ifdef __x86_64__ |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 258 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 259 | _readfsbase_u32(void) |
| 260 | { |
| 261 | return __builtin_ia32_rdfsbase32(); |
| 262 | } |
| 263 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 264 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 265 | _readfsbase_u64(void) |
| 266 | { |
| 267 | return __builtin_ia32_rdfsbase64(); |
| 268 | } |
| 269 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 270 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 271 | _readgsbase_u32(void) |
| 272 | { |
| 273 | return __builtin_ia32_rdgsbase32(); |
| 274 | } |
| 275 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 276 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 277 | _readgsbase_u64(void) |
| 278 | { |
| 279 | return __builtin_ia32_rdgsbase64(); |
| 280 | } |
| 281 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 282 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 283 | _writefsbase_u32(unsigned int __V) |
| 284 | { |
| Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 285 | __builtin_ia32_wrfsbase32(__V); |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 288 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 289 | _writefsbase_u64(unsigned long long __V) |
| 290 | { |
| Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 291 | __builtin_ia32_wrfsbase64(__V); |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 294 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 295 | _writegsbase_u32(unsigned int __V) |
| 296 | { |
| Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 297 | __builtin_ia32_wrgsbase32(__V); |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 300 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 301 | _writegsbase_u64(unsigned long long __V) |
| 302 | { |
| Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 303 | __builtin_ia32_wrgsbase64(__V); |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 304 | } |
| Michael Zuckerman | e54093f | 2016-06-01 12:21:00 +0000 | [diff] [blame] | 305 | |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 306 | #endif |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 307 | #endif /* __FSGSBASE__ */ |
| Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 308 | |
| Craig Topper | 6ad9220 | 2018-09-28 17:09:51 +0000 | [diff] [blame] | 309 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__MOVBE__) |
| 310 | |
| 311 | /* The structs used below are to force the load/store to be unaligned. This |
| 312 | * is accomplished with the __packed__ attribute. The __may_alias__ prevents |
| 313 | * tbaa metadata from being generated based on the struct and the type of the |
| 314 | * field inside of it. |
| 315 | */ |
| 316 | |
| 317 | static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 318 | _loadbe_i16(void const * __P) { |
| 319 | struct __loadu_i16 { |
| 320 | short __v; |
| 321 | } __attribute__((__packed__, __may_alias__)); |
| 322 | return __builtin_bswap16(((struct __loadu_i16*)__P)->__v); |
| 323 | } |
| 324 | |
| 325 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 326 | _storebe_i16(void * __P, short __D) { |
| 327 | struct __storeu_i16 { |
| 328 | short __v; |
| 329 | } __attribute__((__packed__, __may_alias__)); |
| 330 | ((struct __storeu_i16*)__P)->__v = __builtin_bswap16(__D); |
| 331 | } |
| 332 | |
| 333 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 334 | _loadbe_i32(void const * __P) { |
| 335 | struct __loadu_i32 { |
| 336 | int __v; |
| 337 | } __attribute__((__packed__, __may_alias__)); |
| 338 | return __builtin_bswap32(((struct __loadu_i32*)__P)->__v); |
| 339 | } |
| 340 | |
| 341 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 342 | _storebe_i32(void * __P, int __D) { |
| 343 | struct __storeu_i32 { |
| 344 | int __v; |
| 345 | } __attribute__((__packed__, __may_alias__)); |
| 346 | ((struct __storeu_i32*)__P)->__v = __builtin_bswap32(__D); |
| 347 | } |
| 348 | |
| 349 | #ifdef __x86_64__ |
| 350 | static __inline__ long long __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 351 | _loadbe_i64(void const * __P) { |
| 352 | struct __loadu_i64 { |
| 353 | long long __v; |
| 354 | } __attribute__((__packed__, __may_alias__)); |
| 355 | return __builtin_bswap64(((struct __loadu_i64*)__P)->__v); |
| 356 | } |
| 357 | |
| 358 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) |
| 359 | _storebe_i64(void * __P, long long __D) { |
| 360 | struct __storeu_i64 { |
| 361 | long long __v; |
| 362 | } __attribute__((__packed__, __may_alias__)); |
| 363 | ((struct __storeu_i64*)__P)->__v = __builtin_bswap64(__D); |
| 364 | } |
| 365 | #endif |
| 366 | #endif /* __MOVBE */ |
| 367 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 368 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RTM__) |
| Michael Liao | 625a875 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 369 | #include <rtmintrin.h> |
| Eric Christopher | 3d920ee | 2015-06-17 18:42:07 +0000 | [diff] [blame] | 370 | #include <xtestintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 371 | #endif |
| Michael Liao | 4442f79 | 2013-03-29 05:14:06 +0000 | [diff] [blame] | 372 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 373 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SHA__) |
| Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 374 | #include <shaintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 375 | #endif |
| Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 376 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 377 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__FXSR__) |
| Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 378 | #include <fxsrintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 379 | #endif |
| Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 380 | |
| Craig Topper | 9317797 | 2019-01-16 22:56:25 +0000 | [diff] [blame] | 381 | /* No feature check desired due to internal MSC_VER checks */ |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 382 | #include <xsaveintrin.h> |
| 383 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 384 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEOPT__) |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 385 | #include <xsaveoptintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 386 | #endif |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 387 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 388 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEC__) |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 389 | #include <xsavecintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 390 | #endif |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 391 | |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 392 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVES__) |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 393 | #include <xsavesintrin.h> |
| Nico Weber | 379a195 | 2016-05-16 18:14:07 +0000 | [diff] [blame] | 394 | #endif |
| Amjad Aboud | 2b9b8a5 | 2015-10-13 12:29:35 +0000 | [diff] [blame] | 395 | |
| Oren Ben Simhon | fec21ec | 2017-11-26 12:34:54 +0000 | [diff] [blame] | 396 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SHSTK__) |
| 397 | #include <cetintrin.h> |
| 398 | #endif |
| 399 | |
| Eric Christopher | 29b7809 | 2015-06-17 18:42:03 +0000 | [diff] [blame] | 400 | /* Some intrinsics inside adxintrin.h are available only on processors with ADX, |
| 401 | * whereas others are also available at all times. */ |
| Robert Khasanov | 83c419b | 2014-09-19 10:17:06 +0000 | [diff] [blame] | 402 | #include <adxintrin.h> |
| 403 | |
| Craig Topper | 664af9b | 2018-05-23 18:32:58 +0000 | [diff] [blame] | 404 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDSEED__) |
| 405 | #include <rdseedintrin.h> |
| 406 | #endif |
| 407 | |
| Craig Topper | 664af9b | 2018-05-23 18:32:58 +0000 | [diff] [blame] | 408 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__WBNOINVD__) |
| 409 | #include <wbnoinvdintrin.h> |
| 410 | #endif |
| 411 | |
| 412 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLDEMOTE__) |
| 413 | #include <cldemoteintrin.h> |
| 414 | #endif |
| 415 | |
| 416 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__) |
| 417 | #include <waitpkgintrin.h> |
| 418 | #endif |
| 419 | |
| 420 | #if !defined(_MSC_VER) || __has_feature(modules) || \ |
| 421 | defined(__MOVDIRI__) || defined(__MOVDIR64B__) |
| 422 | #include <movdirintrin.h> |
| 423 | #endif |
| 424 | |
| 425 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__) |
| 426 | #include <pconfigintrin.h> |
| 427 | #endif |
| 428 | |
| 429 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__SGX__) |
| 430 | #include <sgxintrin.h> |
| 431 | #endif |
| 432 | |
| 433 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__PTWRITE__) |
| 434 | #include <ptwriteintrin.h> |
| 435 | #endif |
| 436 | |
| Gabor Buella | 078bb99 | 2018-05-25 06:34:42 +0000 | [diff] [blame] | 437 | #if !defined(_MSC_VER) || __has_feature(modules) || defined(__INVPCID__) |
| 438 | #include <invpcidintrin.h> |
| 439 | #endif |
| 440 | |
| Craig Topper | b521dc3 | 2018-06-14 18:43:52 +0000 | [diff] [blame] | 441 | #ifdef _MSC_VER |
| 442 | /* Define the default attributes for these intrinsics */ |
| 443 | #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) |
| 444 | #ifdef __cplusplus |
| 445 | extern "C" { |
| 446 | #endif |
| 447 | /*----------------------------------------------------------------------------*\ |
| 448 | |* Interlocked Exchange HLE |
| 449 | \*----------------------------------------------------------------------------*/ |
| 450 | #if defined(__i386__) || defined(__x86_64__) |
| 451 | static __inline__ long __DEFAULT_FN_ATTRS |
| 452 | _InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) { |
| 453 | __asm__ __volatile__(".byte 0xf2 ; lock ; xchg %0, %1" |
| 454 | : "+r" (_Value), "+m" (*_Target) :: "memory"); |
| 455 | return _Value; |
| 456 | } |
| 457 | static __inline__ long __DEFAULT_FN_ATTRS |
| 458 | _InterlockedExchange_HLERelease(long volatile *_Target, long _Value) { |
| 459 | __asm__ __volatile__(".byte 0xf3 ; lock ; xchg %0, %1" |
| 460 | : "+r" (_Value), "+m" (*_Target) :: "memory"); |
| 461 | return _Value; |
| 462 | } |
| 463 | #endif |
| 464 | #if defined(__x86_64__) |
| 465 | static __inline__ __int64 __DEFAULT_FN_ATTRS |
| 466 | _InterlockedExchange64_HLEAcquire(__int64 volatile *_Target, __int64 _Value) { |
| 467 | __asm__ __volatile__(".byte 0xf2 ; lock ; xchg %0, %1" |
| 468 | : "+r" (_Value), "+m" (*_Target) :: "memory"); |
| 469 | return _Value; |
| 470 | } |
| 471 | static __inline__ __int64 __DEFAULT_FN_ATTRS |
| 472 | _InterlockedExchange64_HLERelease(__int64 volatile *_Target, __int64 _Value) { |
| 473 | __asm__ __volatile__(".byte 0xf3 ; lock ; xchg %0, %1" |
| 474 | : "+r" (_Value), "+m" (*_Target) :: "memory"); |
| 475 | return _Value; |
| 476 | } |
| 477 | #endif |
| 478 | /*----------------------------------------------------------------------------*\ |
| 479 | |* Interlocked Compare Exchange HLE |
| 480 | \*----------------------------------------------------------------------------*/ |
| 481 | #if defined(__i386__) || defined(__x86_64__) |
| 482 | static __inline__ long __DEFAULT_FN_ATTRS |
| 483 | _InterlockedCompareExchange_HLEAcquire(long volatile *_Destination, |
| 484 | long _Exchange, long _Comparand) { |
| 485 | __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg %2, %1" |
| 486 | : "+a" (_Comparand), "+m" (*_Destination) |
| 487 | : "r" (_Exchange) : "memory"); |
| 488 | return _Comparand; |
| 489 | } |
| 490 | static __inline__ long __DEFAULT_FN_ATTRS |
| 491 | _InterlockedCompareExchange_HLERelease(long volatile *_Destination, |
| 492 | long _Exchange, long _Comparand) { |
| 493 | __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg %2, %1" |
| 494 | : "+a" (_Comparand), "+m" (*_Destination) |
| 495 | : "r" (_Exchange) : "memory"); |
| 496 | return _Comparand; |
| 497 | } |
| 498 | #endif |
| 499 | #if defined(__x86_64__) |
| 500 | static __inline__ __int64 __DEFAULT_FN_ATTRS |
| 501 | _InterlockedCompareExchange64_HLEAcquire(__int64 volatile *_Destination, |
| 502 | __int64 _Exchange, __int64 _Comparand) { |
| 503 | __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg %2, %1" |
| 504 | : "+a" (_Comparand), "+m" (*_Destination) |
| 505 | : "r" (_Exchange) : "memory"); |
| 506 | return _Comparand; |
| 507 | } |
| 508 | static __inline__ __int64 __DEFAULT_FN_ATTRS |
| 509 | _InterlockedCompareExchange64_HLERelease(__int64 volatile *_Destination, |
| 510 | __int64 _Exchange, __int64 _Comparand) { |
| 511 | __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg %2, %1" |
| 512 | : "+a" (_Comparand), "+m" (*_Destination) |
| 513 | : "r" (_Exchange) : "memory"); |
| 514 | return _Comparand; |
| 515 | } |
| 516 | #endif |
| 517 | #ifdef __cplusplus |
| 518 | } |
| 519 | #endif |
| 520 | |
| 521 | #undef __DEFAULT_FN_ATTRS |
| 522 | |
| 523 | #endif /* _MSC_VER */ |
| 524 | |
| Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 525 | #endif /* __IMMINTRIN_H */ |