]>
Commit | Line | Data |
---|---|---|
d652f226 | 1 | /* Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
21898431 L |
2 | |
3 | This file is part of GCC. | |
4 | ||
5 | GCC is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
748086b7 | 7 | the Free Software Foundation; either version 3, or (at your option) |
21898431 L |
8 | any later version. |
9 | ||
10 | GCC is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
748086b7 JJ |
15 | Under Section 7 of GPL version 3, you are granted additional |
16 | permissions described in the GCC Runtime Library Exception, version | |
17 | 3.1, as published by the Free Software Foundation. | |
18 | ||
19 | You should have received a copy of the GNU General Public License and | |
20 | a copy of the GCC Runtime Library Exception along with this program; | |
21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
22 | <http://www.gnu.org/licenses/>. */ | |
21898431 L |
23 | |
24 | #ifndef _IMMINTRIN_H_INCLUDED | |
25 | #define _IMMINTRIN_H_INCLUDED | |
26 | ||
27 | #ifdef __MMX__ | |
28 | #include <mmintrin.h> | |
29 | #endif | |
30 | ||
31 | #ifdef __SSE__ | |
32 | #include <xmmintrin.h> | |
33 | #endif | |
34 | ||
35 | #ifdef __SSE2__ | |
36 | #include <emmintrin.h> | |
37 | #endif | |
38 | ||
39 | #ifdef __SSE3__ | |
40 | #include <pmmintrin.h> | |
41 | #endif | |
42 | ||
43 | #ifdef __SSSE3__ | |
44 | #include <tmmintrin.h> | |
45 | #endif | |
46 | ||
47 | #if defined (__SSE4_2__) || defined (__SSE4_1__) | |
48 | #include <smmintrin.h> | |
49 | #endif | |
50 | ||
51 | #if defined (__AES__) || defined (__PCLMUL__) | |
52 | #include <wmmintrin.h> | |
53 | #endif | |
54 | ||
55 | #ifdef __AVX__ | |
56 | #include <avxintrin.h> | |
57 | #endif | |
58 | ||
977e83a3 KY |
59 | #ifdef __AVX2__ |
60 | #include <avx2intrin.h> | |
61 | #endif | |
62 | ||
4ee89d5f | 63 | #ifdef __RDRND__ |
11c4a1c0 | 64 | extern __inline int |
4ee89d5f | 65 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
11c4a1c0 | 66 | _rdrand16_step (unsigned short *__P) |
4ee89d5f | 67 | { |
11c4a1c0 | 68 | return __builtin_ia32_rdrand16_step (__P); |
4ee89d5f L |
69 | } |
70 | ||
11c4a1c0 | 71 | extern __inline int |
4ee89d5f | 72 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
11c4a1c0 | 73 | _rdrand32_step (unsigned int *__P) |
4ee89d5f | 74 | { |
11c4a1c0 | 75 | return __builtin_ia32_rdrand32_step (__P); |
4ee89d5f L |
76 | } |
77 | #endif /* __RDRND__ */ | |
78 | ||
79 | #ifdef __x86_64__ | |
80 | #ifdef __FSGSBASE__ | |
81 | extern __inline unsigned int | |
82 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
83 | _readfsbase_u32 (void) | |
84 | { | |
85 | return __builtin_ia32_rdfsbase32 (); | |
86 | } | |
87 | ||
88 | extern __inline unsigned long long | |
89 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
90 | _readfsbase_u64 (void) | |
91 | { | |
92 | return __builtin_ia32_rdfsbase64 (); | |
93 | } | |
94 | ||
95 | extern __inline unsigned int | |
96 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
97 | _readgsbase_u32 (void) | |
98 | { | |
99 | return __builtin_ia32_rdgsbase32 (); | |
100 | } | |
101 | ||
102 | extern __inline unsigned long long | |
103 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
104 | _readgsbase_u64 (void) | |
105 | { | |
106 | return __builtin_ia32_rdgsbase64 (); | |
107 | } | |
108 | ||
109 | extern __inline void | |
110 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
111 | _writefsbase_u32 (unsigned int __B) | |
112 | { | |
113 | __builtin_ia32_wrfsbase32 (__B); | |
114 | } | |
115 | ||
116 | extern __inline void | |
117 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
118 | _writefsbase_u64 (unsigned long long __B) | |
119 | { | |
120 | __builtin_ia32_wrfsbase64 (__B); | |
121 | } | |
122 | ||
123 | extern __inline void | |
124 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
125 | _writegsbase_u32 (unsigned int __B) | |
126 | { | |
127 | __builtin_ia32_wrgsbase32 (__B); | |
128 | } | |
129 | ||
130 | extern __inline void | |
131 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
132 | _writegsbase_u64 (unsigned long long __B) | |
133 | { | |
134 | __builtin_ia32_wrgsbase64 (__B); | |
135 | } | |
136 | #endif /* __FSGSBASE__ */ | |
137 | ||
138 | #ifdef __RDRND__ | |
11c4a1c0 | 139 | extern __inline int |
4ee89d5f | 140 | __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
11c4a1c0 | 141 | _rdrand64_step (unsigned long long *__P) |
4ee89d5f | 142 | { |
11c4a1c0 | 143 | return __builtin_ia32_rdrand64_step (__P); |
4ee89d5f L |
144 | } |
145 | #endif /* __RDRND__ */ | |
146 | #endif /* __x86_64__ */ | |
147 | ||
148 | #ifdef __F16C__ | |
149 | extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
150 | _cvtsh_ss (unsigned short __S) | |
151 | { | |
152 | __v8hi __H = __extension__ (__v8hi){ __S, 0, 0, 0, 0, 0, 0, 0 }; | |
153 | __v4sf __A = __builtin_ia32_vcvtph2ps (__H); | |
154 | return __builtin_ia32_vec_ext_v4sf (__A, 0); | |
155 | } | |
156 | ||
157 | extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
158 | _mm_cvtph_ps (__m128i __A) | |
159 | { | |
160 | return (__m128) __builtin_ia32_vcvtph2ps ((__v8hi) __A); | |
161 | } | |
162 | ||
163 | extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
164 | _mm256_cvtph_ps (__m128i __A) | |
165 | { | |
166 | return (__m256) __builtin_ia32_vcvtph2ps256 ((__v8hi) __A); | |
167 | } | |
168 | ||
169 | #ifdef __OPTIMIZE__ | |
170 | extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
171 | _cvtss_sh (float __F, const int __I) | |
172 | { | |
173 | __v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 }; | |
174 | __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I); | |
175 | return (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0); | |
176 | } | |
177 | ||
178 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
179 | _mm_cvtps_ph (__m128 __A, const int __I) | |
180 | { | |
181 | return (__m128i) __builtin_ia32_vcvtps2ph ((__v4sf) __A, __I); | |
182 | } | |
183 | ||
184 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
185 | _mm256_cvtps_ph (__m256 __A, const int __I) | |
186 | { | |
187 | return (__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf) __A, __I); | |
188 | } | |
189 | #else | |
190 | #define _cvtss_sh(__F, __I) \ | |
191 | (__extension__ \ | |
192 | ({ \ | |
193 | __v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 }; \ | |
194 | __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I); \ | |
195 | (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0); \ | |
196 | })) | |
197 | ||
198 | #define _mm_cvtps_ph(A, I) \ | |
199 | ((__m128i) __builtin_ia32_vcvtps2ph ((__v4sf)(__m128) A, (int) (I))) | |
200 | ||
201 | #define _mm256_cvtps_ph(A, I) \ | |
202 | ((__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf)(__m256) A, (int) (I))) | |
203 | #endif | |
204 | ||
205 | #endif /* __F16C__ */ | |
206 | ||
21898431 | 207 | #endif /* _IMMINTRIN_H_INCLUDED */ |