ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/MSYS2/mingw32/lib/gcc/i686-w64-mingw32/11.2.0/include/ia32intrin.h
Revision: 1166
Committed: Tue Oct 26 14:22:36 2021 UTC (4 years ago) by rossy
Content type: text/x-chdr
File size: 7641 byte(s)
Log Message:
Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File Contents

# Content
1 /* Copyright (C) 2009-2021 Free Software Foundation, Inc.
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
7 the Free Software Foundation; either version 3, or (at your option)
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
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/>. */
23
24 #ifndef _X86GPRINTRIN_H_INCLUDED
25 # error "Never use <ia32intrin.h> directly; include <x86gprintrin.h> instead."
26 #endif
27
28 /* 32bit bsf */
29 extern __inline int
30 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
31 __bsfd (int __X)
32 {
33 return __builtin_ctz (__X);
34 }
35
36 /* 32bit bsr */
37 extern __inline int
38 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
39 __bsrd (int __X)
40 {
41 return __builtin_ia32_bsrsi (__X);
42 }
43
44 /* 32bit bswap */
45 extern __inline int
46 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
47 __bswapd (int __X)
48 {
49 return __builtin_bswap32 (__X);
50 }
51
52 #ifndef __iamcu__
53
54 #ifndef __SSE4_2__
55 #pragma GCC push_options
56 #pragma GCC target("sse4.2")
57 #define __DISABLE_SSE4_2__
58 #endif /* __SSE4_2__ */
59
60 /* 32bit accumulate CRC32 (polynomial 0x11EDC6F41) value. */
61 extern __inline unsigned int
62 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
63 __crc32b (unsigned int __C, unsigned char __V)
64 {
65 return __builtin_ia32_crc32qi (__C, __V);
66 }
67
68 extern __inline unsigned int
69 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
70 __crc32w (unsigned int __C, unsigned short __V)
71 {
72 return __builtin_ia32_crc32hi (__C, __V);
73 }
74
75 extern __inline unsigned int
76 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
77 __crc32d (unsigned int __C, unsigned int __V)
78 {
79 return __builtin_ia32_crc32si (__C, __V);
80 }
81
82 #ifdef __DISABLE_SSE4_2__
83 #undef __DISABLE_SSE4_2__
84 #pragma GCC pop_options
85 #endif /* __DISABLE_SSE4_2__ */
86
87 #endif /* __iamcu__ */
88
89 /* 32bit popcnt */
90 extern __inline int
91 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
92 __popcntd (unsigned int __X)
93 {
94 return __builtin_popcount (__X);
95 }
96
97 #ifndef __iamcu__
98
99 /* rdpmc */
100 extern __inline unsigned long long
101 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
102 __rdpmc (int __S)
103 {
104 return __builtin_ia32_rdpmc (__S);
105 }
106
107 #endif /* __iamcu__ */
108
109 /* rdtsc */
110 #define __rdtsc() __builtin_ia32_rdtsc ()
111
112 #ifndef __iamcu__
113
114 /* rdtscp */
115 #define __rdtscp(a) __builtin_ia32_rdtscp (a)
116
117 #endif /* __iamcu__ */
118
119 /* 8bit rol */
120 extern __inline unsigned char
121 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
122 __rolb (unsigned char __X, int __C)
123 {
124 return __builtin_ia32_rolqi (__X, __C);
125 }
126
127 /* 16bit rol */
128 extern __inline unsigned short
129 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
130 __rolw (unsigned short __X, int __C)
131 {
132 return __builtin_ia32_rolhi (__X, __C);
133 }
134
135 /* 32bit rol */
136 extern __inline unsigned int
137 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
138 __rold (unsigned int __X, int __C)
139 {
140 __C &= 31;
141 return (__X << __C) | (__X >> (-__C & 31));
142 }
143
144 /* 8bit ror */
145 extern __inline unsigned char
146 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
147 __rorb (unsigned char __X, int __C)
148 {
149 return __builtin_ia32_rorqi (__X, __C);
150 }
151
152 /* 16bit ror */
153 extern __inline unsigned short
154 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
155 __rorw (unsigned short __X, int __C)
156 {
157 return __builtin_ia32_rorhi (__X, __C);
158 }
159
160 /* 32bit ror */
161 extern __inline unsigned int
162 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
163 __rord (unsigned int __X, int __C)
164 {
165 __C &= 31;
166 return (__X >> __C) | (__X << (-__C & 31));
167 }
168
169 /* Pause */
170 extern __inline void
171 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
172 __pause (void)
173 {
174 __builtin_ia32_pause ();
175 }
176
177 #ifdef __x86_64__
178 /* 64bit bsf */
179 extern __inline int
180 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
181 __bsfq (long long __X)
182 {
183 return __builtin_ctzll (__X);
184 }
185
186 /* 64bit bsr */
187 extern __inline int
188 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
189 __bsrq (long long __X)
190 {
191 return __builtin_ia32_bsrdi (__X);
192 }
193
194 /* 64bit bswap */
195 extern __inline long long
196 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
197 __bswapq (long long __X)
198 {
199 return __builtin_bswap64 (__X);
200 }
201
202 #ifndef __SSE4_2__
203 #pragma GCC push_options
204 #pragma GCC target("sse4.2")
205 #define __DISABLE_SSE4_2__
206 #endif /* __SSE4_2__ */
207
208 /* 64bit accumulate CRC32 (polynomial 0x11EDC6F41) value. */
209 extern __inline unsigned long long
210 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
211 __crc32q (unsigned long long __C, unsigned long long __V)
212 {
213 return __builtin_ia32_crc32di (__C, __V);
214 }
215
216 #ifdef __DISABLE_SSE4_2__
217 #undef __DISABLE_SSE4_2__
218 #pragma GCC pop_options
219 #endif /* __DISABLE_SSE4_2__ */
220
221 /* 64bit popcnt */
222 extern __inline long long
223 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
224 __popcntq (unsigned long long __X)
225 {
226 return __builtin_popcountll (__X);
227 }
228
229 /* 64bit rol */
230 extern __inline unsigned long long
231 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
232 __rolq (unsigned long long __X, int __C)
233 {
234 __C &= 63;
235 return (__X << __C) | (__X >> (-__C & 63));
236 }
237
238 /* 64bit ror */
239 extern __inline unsigned long long
240 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
241 __rorq (unsigned long long __X, int __C)
242 {
243 __C &= 63;
244 return (__X >> __C) | (__X << (-__C & 63));
245 }
246
247 /* Read flags register */
248 extern __inline unsigned long long
249 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
250 __readeflags (void)
251 {
252 return __builtin_ia32_readeflags_u64 ();
253 }
254
255 /* Write flags register */
256 extern __inline void
257 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
258 __writeeflags (unsigned long long __X)
259 {
260 __builtin_ia32_writeeflags_u64 (__X);
261 }
262
263 #define _bswap64(a) __bswapq(a)
264 #define _popcnt64(a) __popcntq(a)
265 #else
266
267 /* Read flags register */
268 extern __inline unsigned int
269 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
270 __readeflags (void)
271 {
272 return __builtin_ia32_readeflags_u32 ();
273 }
274
275 /* Write flags register */
276 extern __inline void
277 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
278 __writeeflags (unsigned int __X)
279 {
280 __builtin_ia32_writeeflags_u32 (__X);
281 }
282
283 #endif
284
285 /* On LP64 systems, longs are 64-bit. Use the appropriate rotate
286 * function. */
287 #ifdef __LP64__
288 #define _lrotl(a,b) __rolq((a), (b))
289 #define _lrotr(a,b) __rorq((a), (b))
290 #else
291 #define _lrotl(a,b) __rold((a), (b))
292 #define _lrotr(a,b) __rord((a), (b))
293 #endif
294
295 #define _bit_scan_forward(a) __bsfd(a)
296 #define _bit_scan_reverse(a) __bsrd(a)
297 #define _bswap(a) __bswapd(a)
298 #define _popcnt32(a) __popcntd(a)
299 #ifndef __iamcu__
300 #define _rdpmc(a) __rdpmc(a)
301 #define _rdtscp(a) __rdtscp(a)
302 #endif /* __iamcu__ */
303 #define _rdtsc() __rdtsc()
304 #define _rotwl(a,b) __rolw((a), (b))
305 #define _rotwr(a,b) __rorw((a), (b))
306 #define _rotl(a,b) __rold((a), (b))
307 #define _rotr(a,b) __rord((a), (b))