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 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 27 | #include <mmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 28 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 29 | #include <xmmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 30 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 31 | #include <emmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 32 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 33 | #include <pmmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 34 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 35 | #include <tmmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 36 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 37 | #include <smmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 38 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 39 | #include <wmmintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 40 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 41 | #include <avxintrin.h> |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 42 | |
Craig Topper | dec792e | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 43 | #include <avx2intrin.h> |
Craig Topper | dec792e | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 44 | |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 45 | #include <bmiintrin.h> |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 46 | |
Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 47 | #include <bmi2intrin.h> |
Craig Topper | c334dd6 | 2011-12-26 02:31:10 +0000 | [diff] [blame] | 48 | |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 49 | #include <lzcntintrin.h> |
Craig Topper | f2855ad | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 50 | |
Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 51 | #include <fmaintrin.h> |
Craig Topper | 2b1eda3 | 2012-06-04 03:42:47 +0000 | [diff] [blame] | 52 | |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 53 | #include <avx512fintrin.h> |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 54 | |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 55 | #include <avx512vlintrin.h> |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 56 | |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 57 | #include <avx512bwintrin.h> |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 58 | |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 59 | #include <avx512dqintrin.h> |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 60 | |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 61 | #include <avx512vlbwintrin.h> |
Robert Khasanov | b9f3a91 | 2014-10-08 17:18:13 +0000 | [diff] [blame] | 62 | |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 63 | #include <avx512vldqintrin.h> |
Elena Demikhovsky | e7d4c2e | 2015-04-30 09:24:29 +0000 | [diff] [blame] | 64 | |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 65 | #include <avx512erintrin.h> |
Elena Demikhovsky | fcc6df3 | 2014-07-22 11:31:39 +0000 | [diff] [blame] | 66 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 67 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 68 | _rdrand16_step(unsigned short *__p) |
| 69 | { |
| 70 | return __builtin_ia32_rdrand16_step(__p); |
| 71 | } |
| 72 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 73 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 74 | _rdrand32_step(unsigned int *__p) |
| 75 | { |
| 76 | return __builtin_ia32_rdrand32_step(__p); |
| 77 | } |
| 78 | |
| 79 | #ifdef __x86_64__ |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 80 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 81 | _rdrand64_step(unsigned long long *__p) |
| 82 | { |
| 83 | return __builtin_ia32_rdrand64_step(__p); |
| 84 | } |
| 85 | #endif |
Benjamin Kramer | a43b699 | 2012-07-12 09:33:03 +0000 | [diff] [blame] | 86 | |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 87 | #ifdef __x86_64__ |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 88 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 89 | _readfsbase_u32(void) |
| 90 | { |
| 91 | return __builtin_ia32_rdfsbase32(); |
| 92 | } |
| 93 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 94 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 95 | _readfsbase_u64(void) |
| 96 | { |
| 97 | return __builtin_ia32_rdfsbase64(); |
| 98 | } |
| 99 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 100 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 101 | _readgsbase_u32(void) |
| 102 | { |
| 103 | return __builtin_ia32_rdgsbase32(); |
| 104 | } |
| 105 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 106 | static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 107 | _readgsbase_u64(void) |
| 108 | { |
| 109 | return __builtin_ia32_rdgsbase64(); |
| 110 | } |
| 111 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 112 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 113 | _writefsbase_u32(unsigned int __V) |
| 114 | { |
| 115 | return __builtin_ia32_wrfsbase32(__V); |
| 116 | } |
| 117 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 118 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 119 | _writefsbase_u64(unsigned long long __V) |
| 120 | { |
| 121 | return __builtin_ia32_wrfsbase64(__V); |
| 122 | } |
| 123 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 124 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 125 | _writegsbase_u32(unsigned int __V) |
| 126 | { |
| 127 | return __builtin_ia32_wrgsbase32(__V); |
| 128 | } |
| 129 | |
Eric Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 130 | static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 131 | _writegsbase_u64(unsigned long long __V) |
| 132 | { |
| 133 | return __builtin_ia32_wrgsbase64(__V); |
| 134 | } |
| 135 | #endif |
Craig Topper | 8c7f251 | 2014-11-03 06:51:41 +0000 | [diff] [blame] | 136 | |
Michael Liao | 625a875 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 137 | #include <rtmintrin.h> |
Michael Liao | 625a875 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 138 | |
Eric Christopher | 29b7809 | 2015-06-17 18:42:03 +0000 | [diff] [blame^] | 139 | /* 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 Christopher | 9fc7fb2 | 2015-06-17 07:09:32 +0000 | [diff] [blame] | 143 | static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rtm"))) |
Michael Liao | 4442f79 | 2013-03-29 05:14:06 +0000 | [diff] [blame] | 144 | _xtest(void) |
| 145 | { |
| 146 | return __builtin_ia32_xtest(); |
| 147 | } |
Michael Liao | 4442f79 | 2013-03-29 05:14:06 +0000 | [diff] [blame] | 148 | |
Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 149 | #include <shaintrin.h> |
Ben Langmuir | 6efe3a8 | 2013-09-19 14:00:22 +0000 | [diff] [blame] | 150 | |
Eric Christopher | 29b7809 | 2015-06-17 18:42:03 +0000 | [diff] [blame^] | 151 | /* Some intrinsics inside adxintrin.h are available only on processors with ADX, |
| 152 | * whereas others are also available at all times. */ |
Robert Khasanov | 83c419b | 2014-09-19 10:17:06 +0000 | [diff] [blame] | 153 | #include <adxintrin.h> |
| 154 | |
Benjamin Kramer | 65b9f7b | 2010-08-20 18:04:07 +0000 | [diff] [blame] | 155 | #endif /* __IMMINTRIN_H */ |