clang 8.0.0

intrin.h
Go to the documentation of this file.
1 /* ===-------- intrin.h ---------------------------------------------------===
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 /* Only include this if we're compiling for the windows platform. */
25 #ifndef _MSC_VER
26 #include_next <intrin.h>
27 #else
28
29 #ifndef __INTRIN_H
30 #define __INTRIN_H
31
32 /* First include the standard intrinsics. */
33 #if defined(__i386__) || defined(__x86_64__)
34 #include <x86intrin.h>
35 #endif
36
37 #if defined(__arm__)
38 #include <armintr.h>
39 #endif
40
41 #if defined(__aarch64__)
42 #include <arm64intr.h>
43 #endif
44
45 /* For the definition of jmp_buf. */
46 #if __STDC_HOSTED__
47 #include <setjmp.h>
48 #endif
49
50 /* Define the default attributes for the functions in this file. */
51 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 #if defined(__MMX__)
58 /* And the random ones that aren't in those files. */
59 __m64 _m_from_float(float);
60 float _m_to_float(__m64);
61 #endif
62
63 /* Other assorted instruction intrinsics. */
64 void __addfsbyte(unsigned long, unsigned char);
65 void __addfsdword(unsigned long, unsigned long);
66 void __addfsword(unsigned long, unsigned short);
67 void __code_seg(const char *);
68 static __inline__
69 void __cpuid(int[4], int);
70 static __inline__
71 void __cpuidex(int[4], int, int);
72 static __inline__
73 __int64 __emul(int, int);
74 static __inline__
75 unsigned __int64 __emulu(unsigned int, unsigned int);
76 unsigned int __getcallerseflags(void);
77 static __inline__
78 void __halt(void);
79 unsigned char __inbyte(unsigned short);
80 void __inbytestring(unsigned short, unsigned char *, unsigned long);
81 void __incfsbyte(unsigned long);
82 void __incfsdword(unsigned long);
83 void __incfsword(unsigned long);
84 unsigned long __indword(unsigned short);
85 void __indwordstring(unsigned short, unsigned long *, unsigned long);
86 void __int2c(void);
87 void __invlpg(void *);
88 unsigned short __inword(unsigned short);
89 void __inwordstring(unsigned short, unsigned short *, unsigned long);
90 void __lidt(void *);
91 unsigned __int64 __ll_lshift(unsigned __int64, int);
92 __int64 __ll_rshift(__int64, int);
93 static __inline__
94 void __movsb(unsigned char *, unsigned char const *, size_t);
95 static __inline__
96 void __movsd(unsigned long *, unsigned long const *, size_t);
97 static __inline__
98 void __movsw(unsigned short *, unsigned short const *, size_t);
99 static __inline__
100 void __nop(void);
101 void __nvreg_restore_fence(void);
102 void __nvreg_save_fence(void);
103 void __outbyte(unsigned short, unsigned char);
104 void __outbytestring(unsigned short, unsigned char *, unsigned long);
105 void __outdword(unsigned short, unsigned long);
106 void __outdwordstring(unsigned short, unsigned long *, unsigned long);
107 void __outword(unsigned short, unsigned short);
108 void __outwordstring(unsigned short, unsigned short *, unsigned long);
109 unsigned long __readcr0(void);
110 unsigned long __readcr2(void);
111 static __inline__
112 unsigned long __readcr3(void);
113 unsigned long __readcr4(void);
114 unsigned long __readcr8(void);
115 unsigned int __readdr(unsigned int);
116 #ifdef __i386__
117 static __inline__
118 unsigned char __readfsbyte(unsigned long);
119 static __inline__
120 unsigned __int64 __readfsqword(unsigned long);
121 static __inline__
122 unsigned short __readfsword(unsigned long);
123 #endif
124 static __inline__
125 unsigned __int64 __readmsr(unsigned long);
126 unsigned __int64 __readpmc(unsigned long);
127 unsigned long __segmentlimit(unsigned long);
128 void __sidt(void *);
129 static __inline__
130 void __stosb(unsigned char *, unsigned char, size_t);
131 static __inline__
132 void __stosd(unsigned long *, unsigned long, size_t);
133 static __inline__
134 void __stosw(unsigned short *, unsigned short, size_t);
135 void __svm_clgi(void);
136 void __svm_invlpga(void *, int);
137 void __svm_skinit(int);
138 void __svm_stgi(void);
139 void __svm_vmload(size_t);
140 void __svm_vmrun(size_t);
141 void __svm_vmsave(size_t);
142 void __ud2(void);
143 unsigned __int64 __ull_rshift(unsigned __int64, int);
144 void __vmx_off(void);
145 void __vmx_vmptrst(unsigned __int64 *);
146 void __wbinvd(void);
147 void __writecr0(unsigned int);
148 static __inline__
149 void __writecr3(unsigned int);
150 void __writecr4(unsigned int);
151 void __writecr8(unsigned int);
152 void __writedr(unsigned int, unsigned int);
153 void __writefsbyte(unsigned long, unsigned char);
154 void __writefsdword(unsigned long, unsigned long);
155 void __writefsqword(unsigned long, unsigned __int64);
156 void __writefsword(unsigned long, unsigned short);
157 void __writemsr(unsigned long, unsigned __int64);
158 static __inline__
159 void *_AddressOfReturnAddress(void);
160 static __inline__
161 unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);
162 static __inline__
163 unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask);
164 unsigned char _bittest(long const *, long);
165 unsigned char _bittestandcomplement(long *, long);
166 unsigned char _bittestandreset(long *, long);
167 unsigned char _bittestandset(long *, long);
168 void __cdecl _disable(void);
169 void __cdecl _enable(void);
170 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
171 unsigned char _interlockedbittestandreset(long volatile *, long);
172 unsigned char _interlockedbittestandset(long volatile *, long);
173 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
174 void *);
175 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
176 void *);
177 long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
178 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
179 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
180 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
181 void __cdecl _invpcid(unsigned int, void *);
182 static __inline__ void
183 __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead")))
184 _ReadBarrier(void);
185 static __inline__ void
186 __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead")))
187 _ReadWriteBarrier(void);
188 unsigned int _rorx_u32(unsigned int, const unsigned int);
189 int _sarx_i32(int, unsigned int);
190 #if __STDC_HOSTED__
191 int __cdecl _setjmp(jmp_buf);
192 #endif
193 unsigned int _shlx_u32(unsigned int, unsigned int);
194 unsigned int _shrx_u32(unsigned int, unsigned int);
195 void _Store_HLERelease(long volatile *, long);
196 void _Store64_HLERelease(__int64 volatile *, __int64);
197 void _StorePointer_HLERelease(void *volatile *, void *);
198 static __inline__ void
199 __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead")))
200 _WriteBarrier(void);
201 unsigned __int32 xbegin(void);
202 void _xend(void);
203 static __inline__
204 #define _XCR_XFEATURE_ENABLED_MASK 0
205 unsigned __int64 __cdecl _xgetbv(unsigned int);
206 void __cdecl _xsetbv(unsigned int, unsigned __int64);
207
208 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
209 #ifdef __x86_64__
210 void __addgsbyte(unsigned long, unsigned char);
211 void __addgsdword(unsigned long, unsigned long);
212 void __addgsqword(unsigned long, unsigned __int64);
213 void __addgsword(unsigned long, unsigned short);
214 static __inline__
215 void __faststorefence(void);
216 void __incgsbyte(unsigned long);
217 void __incgsdword(unsigned long);
218 void __incgsqword(unsigned long);
219 void __incgsword(unsigned long);
220 static __inline__
221 void __movsq(unsigned long long *, unsigned long long const *, size_t);
222 static __inline__
223 unsigned char __readgsbyte(unsigned long);
224 static __inline__
225 unsigned long __readgsdword(unsigned long);
226 static __inline__
227 unsigned __int64 __readgsqword(unsigned long);
228 unsigned short __readgsword(unsigned long);
229 unsigned __int64 __shiftleft128(unsigned __int64 _LowPart,
230 unsigned __int64 _HighPart,
231 unsigned char _Shift);
232 unsigned __int64 __shiftright128(unsigned __int64 _LowPart,
233 unsigned __int64 _HighPart,
234 unsigned char _Shift);
235 static __inline__
236 void __stosq(unsigned __int64 *, unsigned __int64, size_t);
237 unsigned char __vmx_on(unsigned __int64 *);
238 unsigned char __vmx_vmclear(unsigned __int64 *);
239 unsigned char __vmx_vmlaunch(void);
240 unsigned char __vmx_vmptrld(unsigned __int64 *);
241 unsigned char __vmx_vmread(size_t, size_t *);
242 unsigned char __vmx_vmresume(void);
243 unsigned char __vmx_vmwrite(size_t, size_t);
244 void __writegsbyte(unsigned long, unsigned char);
245 void __writegsdword(unsigned long, unsigned long);
246 void __writegsqword(unsigned long, unsigned __int64);
247 void __writegsword(unsigned long, unsigned short);
248 unsigned char _bittest64(__int64 const *, __int64);
249 unsigned char _bittestandcomplement64(__int64 *, __int64);
250 unsigned char _bittestandreset64(__int64 *, __int64);
251 unsigned char _bittestandset64(__int64 *, __int64);
252 long _InterlockedAnd_np(long volatile *_Value, long _Mask);
253 short _InterlockedAnd16_np(short volatile *_Value, short _Mask);
254 __int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask);
255 char _InterlockedAnd8_np(char volatile *_Value, char _Mask);
256 unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64);
257 unsigned char _interlockedbittestandset64(__int64 volatile *, __int64);
258 long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange,
259 long _Comparand);
260 unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination,
261 __int64 _ExchangeHigh,
262 __int64 _ExchangeLow,
263 __int64 *_CompareandResult);
264 unsigned char _InterlockedCompareExchange128_np(__int64 volatile *_Destination,
265 __int64 _ExchangeHigh,
266 __int64 _ExchangeLow,
267 __int64 *_ComparandResult);
268 short _InterlockedCompareExchange16_np(short volatile *_Destination,
269 short _Exchange, short _Comparand);
270 __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination,
271 __int64 _Exchange, __int64 _Comparand);
272 void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination,
273 void *_Exchange, void *_Comparand);
274 long _InterlockedOr_np(long volatile *_Value, long _Mask);
275 short _InterlockedOr16_np(short volatile *_Value, short _Mask);
276 __int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask);
277 char _InterlockedOr8_np(char volatile *_Value, char _Mask);
278 long _InterlockedXor_np(long volatile *_Value, long _Mask);
279 short _InterlockedXor16_np(short volatile *_Value, short _Mask);
280 __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask);
281 char _InterlockedXor8_np(char volatile *_Value, char _Mask);
282 unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int);
283 __int64 _sarx_i64(__int64, unsigned int);
284 unsigned __int64 _shlx_u64(unsigned __int64, unsigned int);
285 unsigned __int64 _shrx_u64(unsigned __int64, unsigned int);
286 static __inline__
287 __int64 __mulh(__int64, __int64);
288 static __inline__
289 unsigned __int64 __umulh(unsigned __int64, unsigned __int64);
290 static __inline__
291 __int64 _mul128(__int64, __int64, __int64*);
292 static __inline__
293 unsigned __int64 _umul128(unsigned __int64,
294 unsigned __int64,
295 unsigned __int64*);
296
297 #endif /* __x86_64__ */
298
299 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
300
301 static __inline__
302 unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
303 static __inline__
304 unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
305
306 static __inline__
307 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
308 static __inline__
309 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
310 static __inline__
311 __int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value);
312 static __inline__
313 __int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value);
314 static __inline__
315 __int64 _InterlockedIncrement64(__int64 volatile *_Addend);
316 static __inline__
317 __int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask);
318 static __inline__
319 __int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask);
320 static __inline__
321 __int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask);
322
323 #endif
324
325 /*----------------------------------------------------------------------------*\
326 |* Interlocked Exchange Add
327 \*----------------------------------------------------------------------------*/
328 #if defined(__arm__) || defined(__aarch64__)
329 char _InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value);
330 char _InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value);
331 char _InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value);
332 short _InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value);
333 short _InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value);
334 short _InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value);
335 long _InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value);
336 long _InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value);
337 long _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value);
338 __int64 _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value);
339 __int64 _InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value);
340 __int64 _InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, __int64 _Value);
341 #endif
342 /*----------------------------------------------------------------------------*\
343 |* Interlocked Increment
344 \*----------------------------------------------------------------------------*/
345 #if defined(__arm__) || defined(__aarch64__)
346 short _InterlockedIncrement16_acq(short volatile *_Value);
347 short _InterlockedIncrement16_nf(short volatile *_Value);
348 short _InterlockedIncrement16_rel(short volatile *_Value);
349 long _InterlockedIncrement_acq(long volatile *_Value);
350 long _InterlockedIncrement_nf(long volatile *_Value);
351 long _InterlockedIncrement_rel(long volatile *_Value);
352 __int64 _InterlockedIncrement64_acq(__int64 volatile *_Value);
353 __int64 _InterlockedIncrement64_nf(__int64 volatile *_Value);
354 __int64 _InterlockedIncrement64_rel(__int64 volatile *_Value);
355 #endif
356 /*----------------------------------------------------------------------------*\
357 |* Interlocked Decrement
358 \*----------------------------------------------------------------------------*/
359 #if defined(__arm__) || defined(__aarch64__)
360 short _InterlockedDecrement16_acq(short volatile *_Value);
361 short _InterlockedDecrement16_nf(short volatile *_Value);
362 short _InterlockedDecrement16_rel(short volatile *_Value);
363 long _InterlockedDecrement_acq(long volatile *_Value);
364 long _InterlockedDecrement_nf(long volatile *_Value);
365 long _InterlockedDecrement_rel(long volatile *_Value);
366 __int64 _InterlockedDecrement64_acq(__int64 volatile *_Value);
367 __int64 _InterlockedDecrement64_nf(__int64 volatile *_Value);
368 __int64 _InterlockedDecrement64_rel(__int64 volatile *_Value);
369 #endif
370 /*----------------------------------------------------------------------------*\
371 |* Interlocked And
372 \*----------------------------------------------------------------------------*/
373 #if defined(__arm__) || defined(__aarch64__)
374 char _InterlockedAnd8_acq(char volatile *_Value, char _Mask);
375 char _InterlockedAnd8_nf(char volatile *_Value, char _Mask);
376 char _InterlockedAnd8_rel(char volatile *_Value, char _Mask);
377 short _InterlockedAnd16_acq(short volatile *_Value, short _Mask);
378 short _InterlockedAnd16_nf(short volatile *_Value, short _Mask);
379 short _InterlockedAnd16_rel(short volatile *_Value, short _Mask);
380 long _InterlockedAnd_acq(long volatile *_Value, long _Mask);
381 long _InterlockedAnd_nf(long volatile *_Value, long _Mask);
382 long _InterlockedAnd_rel(long volatile *_Value, long _Mask);
383 __int64 _InterlockedAnd64_acq(__int64 volatile *_Value, __int64 _Mask);
384 __int64 _InterlockedAnd64_nf(__int64 volatile *_Value, __int64 _Mask);
385 __int64 _InterlockedAnd64_rel(__int64 volatile *_Value, __int64 _Mask);
386 #endif
387 /*----------------------------------------------------------------------------*\
388 |* Bit Counting and Testing
389 \*----------------------------------------------------------------------------*/
390 #if defined(__arm__) || defined(__aarch64__)
391 unsigned char _interlockedbittestandset_acq(long volatile *_BitBase,
392 long _BitPos);
393 unsigned char _interlockedbittestandset_nf(long volatile *_BitBase,
394 long _BitPos);
395 unsigned char _interlockedbittestandset_rel(long volatile *_BitBase,
396 long _BitPos);
397 unsigned char _interlockedbittestandreset_acq(long volatile *_BitBase,
398 long _BitPos);
399 unsigned char _interlockedbittestandreset_nf(long volatile *_BitBase,
400 long _BitPos);
401 unsigned char _interlockedbittestandreset_rel(long volatile *_BitBase,
402 long _BitPos);
403 #endif
404 /*----------------------------------------------------------------------------*\
405 |* Interlocked Or
406 \*----------------------------------------------------------------------------*/
407 #if defined(__arm__) || defined(__aarch64__)
408 char _InterlockedOr8_acq(char volatile *_Value, char _Mask);
409 char _InterlockedOr8_nf(char volatile *_Value, char _Mask);
410 char _InterlockedOr8_rel(char volatile *_Value, char _Mask);
411 short _InterlockedOr16_acq(short volatile *_Value, short _Mask);
412 short _InterlockedOr16_nf(short volatile *_Value, short _Mask);
413 short _InterlockedOr16_rel(short volatile *_Value, short _Mask);
414 long _InterlockedOr_acq(long volatile *_Value, long _Mask);
415 long _InterlockedOr_nf(long volatile *_Value, long _Mask);
416 long _InterlockedOr_rel(long volatile *_Value, long _Mask);
417 __int64 _InterlockedOr64_acq(__int64 volatile *_Value, __int64 _Mask);
418 __int64 _InterlockedOr64_nf(__int64 volatile *_Value, __int64 _Mask);
419 __int64 _InterlockedOr64_rel(__int64 volatile *_Value, __int64 _Mask);
420 #endif
421 /*----------------------------------------------------------------------------*\
422 |* Interlocked Xor
423 \*----------------------------------------------------------------------------*/
424 #if defined(__arm__) || defined(__aarch64__)
425 char _InterlockedXor8_acq(char volatile *_Value, char _Mask);
426 char _InterlockedXor8_nf(char volatile *_Value, char _Mask);
427 char _InterlockedXor8_rel(char volatile *_Value, char _Mask);
428 short _InterlockedXor16_acq(short volatile *_Value, short _Mask);
429 short _InterlockedXor16_nf(short volatile *_Value, short _Mask);
430 short _InterlockedXor16_rel(short volatile *_Value, short _Mask);
431 long _InterlockedXor_acq(long volatile *_Value, long _Mask);
432 long _InterlockedXor_nf(long volatile *_Value, long _Mask);
433 long _InterlockedXor_rel(long volatile *_Value, long _Mask);
434 __int64 _InterlockedXor64_acq(__int64 volatile *_Value, __int64 _Mask);
435 __int64 _InterlockedXor64_nf(__int64 volatile *_Value, __int64 _Mask);
436 __int64 _InterlockedXor64_rel(__int64 volatile *_Value, __int64 _Mask);
437 #endif
438 /*----------------------------------------------------------------------------*\
439 |* Interlocked Exchange
440 \*----------------------------------------------------------------------------*/
441 #if defined(__arm__) || defined(__aarch64__)
442 char _InterlockedExchange8_acq(char volatile *_Target, char _Value);
443 char _InterlockedExchange8_nf(char volatile *_Target, char _Value);
444 char _InterlockedExchange8_rel(char volatile *_Target, char _Value);
445 short _InterlockedExchange16_acq(short volatile *_Target, short _Value);
446 short _InterlockedExchange16_nf(short volatile *_Target, short _Value);
447 short _InterlockedExchange16_rel(short volatile *_Target, short _Value);
448 long _InterlockedExchange_acq(long volatile *_Target, long _Value);
449 long _InterlockedExchange_nf(long volatile *_Target, long _Value);
450 long _InterlockedExchange_rel(long volatile *_Target, long _Value);
451 __int64 _InterlockedExchange64_acq(__int64 volatile *_Target, __int64 _Value);
452 __int64 _InterlockedExchange64_nf(__int64 volatile *_Target, __int64 _Value);
453 __int64 _InterlockedExchange64_rel(__int64 volatile *_Target, __int64 _Value);
454 #endif
455 /*----------------------------------------------------------------------------*\
456 |* Interlocked Compare Exchange
457 \*----------------------------------------------------------------------------*/
458 #if defined(__arm__) || defined(__aarch64__)
459 char _InterlockedCompareExchange8_acq(char volatile *_Destination,
460 char _Exchange, char _Comparand);
461 char _InterlockedCompareExchange8_nf(char volatile *_Destination,
462 char _Exchange, char _Comparand);
463 char _InterlockedCompareExchange8_rel(char volatile *_Destination,
464 char _Exchange, char _Comparand);
465 short _InterlockedCompareExchange16_acq(short volatile *_Destination,
466 short _Exchange, short _Comparand);
467 short _InterlockedCompareExchange16_nf(short volatile *_Destination,
468 short _Exchange, short _Comparand);
469 short _InterlockedCompareExchange16_rel(short volatile *_Destination,
470 short _Exchange, short _Comparand);
471 long _InterlockedCompareExchange_acq(long volatile *_Destination,
472 long _Exchange, long _Comparand);
473 long _InterlockedCompareExchange_nf(long volatile *_Destination,
474 long _Exchange, long _Comparand);
475 long _InterlockedCompareExchange_rel(long volatile *_Destination,
476 long _Exchange, long _Comparand);
477 __int64 _InterlockedCompareExchange64_acq(__int64 volatile *_Destination,
478 __int64 _Exchange, __int64 _Comparand);
479 __int64 _InterlockedCompareExchange64_nf(__int64 volatile *_Destination,
480 __int64 _Exchange, __int64 _Comparand);
481 __int64 _InterlockedCompareExchange64_rel(__int64 volatile *_Destination,
482 __int64 _Exchange, __int64 _Comparand);
483 #endif
484
485 /*----------------------------------------------------------------------------*\
486 |* movs, stos
487 \*----------------------------------------------------------------------------*/
488 #if defined(__i386__) || defined(__x86_64__)
489 static __inline__ void __DEFAULT_FN_ATTRS
490 __movsb(unsigned char *__dst, unsigned char const *__src, size_t __n) {
491 __asm__ __volatile__("rep movsb" : "+D"(__dst), "+S"(__src), "+c"(__n)
492 : : "memory");
493 }
494 static __inline__ void __DEFAULT_FN_ATTRS
495 __movsd(unsigned long *__dst, unsigned long const *__src, size_t __n) {
496 __asm__ __volatile__("rep movsl" : "+D"(__dst), "+S"(__src), "+c"(__n)
497 : : "memory");
498 }
499 static __inline__ void __DEFAULT_FN_ATTRS
500 __movsw(unsigned short *__dst, unsigned short const *__src, size_t __n) {
501 __asm__ __volatile__("rep movsw" : "+D"(__dst), "+S"(__src), "+c"(__n)
502 : : "memory");
503 }
504 static __inline__ void __DEFAULT_FN_ATTRS
505 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
506 __asm__ __volatile__("rep stosl" : "+D"(__dst), "+c"(__n) : "a"(__x)
507 : "memory");
508 }
509 static __inline__ void __DEFAULT_FN_ATTRS
510 __stosw(unsigned short *__dst, unsigned short __x, size_t __n) {
511 __asm__ __volatile__("rep stosw" : "+D"(__dst), "+c"(__n) : "a"(__x)
512 : "memory");
513 }
514 #endif
515 #ifdef __x86_64__
516 static __inline__ void __DEFAULT_FN_ATTRS
517 __movsq(unsigned long long *__dst, unsigned long long const *__src, size_t __n) {
518 __asm__ __volatile__("rep movsq" : "+D"(__dst), "+S"(__src), "+c"(__n)
519 : : "memory");
520 }
521 static __inline__ void __DEFAULT_FN_ATTRS
522 __stosq(unsigned __int64 *__dst, unsigned __int64 __x, size_t __n) {
523 __asm__ __volatile__("rep stosq" : "+D"(__dst), "+c"(__n) : "a"(__x)
524 : "memory");
525 }
526 #endif
527
528 /*----------------------------------------------------------------------------*\
529 |* Misc
530 \*----------------------------------------------------------------------------*/
531 #if defined(__i386__) || defined(__x86_64__)
532 static __inline__ void __DEFAULT_FN_ATTRS
533 __cpuid(int __info[4], int __level) {
534 __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3])
535 : "a"(__level), "c"(0));
536 }
537 static __inline__ void __DEFAULT_FN_ATTRS
538 __cpuidex(int __info[4], int __level, int __ecx) {
539 __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3])
540 : "a"(__level), "c"(__ecx));
541 }
542 static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
543 _xgetbv(unsigned int __xcr_no) {
544 unsigned int __eax, __edx;
545 __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
546 return ((unsigned __int64)__edx << 32) | __eax;
547 }
548 static __inline__ void __DEFAULT_FN_ATTRS
549 __halt(void) {
550 __asm__ volatile ("hlt");
551 }
552 #endif
553
554 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
555 static __inline__ void __DEFAULT_FN_ATTRS
556 __nop(void) {
557 __asm__ volatile ("nop");
558 }
559 #endif
560
561 /*----------------------------------------------------------------------------*\
562 |* MS AArch64 specific
563 \*----------------------------------------------------------------------------*/
564 #if defined(__aarch64__)
565 unsigned __int64 __getReg(int);
566 long _InterlockedAdd(long volatile *Addend, long Value);
567 int _ReadStatusReg(int);
568 void _WriteStatusReg(int, int);
569
570 static inline unsigned short _byteswap_ushort (unsigned short val) {
571 return __builtin_bswap16(val);
572 }
573 static inline unsigned long _byteswap_ulong (unsigned long val) {
574 return __builtin_bswap32(val);
575 }
576 static inline unsigned __int64 _byteswap_uint64 (unsigned __int64 val) {
577 return __builtin_bswap64(val);
578 }
579 #endif
580
581 /*----------------------------------------------------------------------------*\
582 |* Privileged intrinsics
583 \*----------------------------------------------------------------------------*/
584 #if defined(__i386__) || defined(__x86_64__)
585 static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
586 __readmsr(unsigned long __register) {
587 // Loads the contents of a 64-bit model specific register (MSR) specified in
588 // the ECX register into registers EDX:EAX. The EDX register is loaded with
589 // the high-order 32 bits of the MSR and the EAX register is loaded with the
590 // low-order 32 bits. If less than 64 bits are implemented in the MSR being
591 // read, the values returned to EDX:EAX in unimplemented bit locations are
592 // undefined.
593 unsigned long __edx;
594 unsigned long __eax;
595 __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register));
596 return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax;
597 }
598
599 static __inline__ unsigned long __DEFAULT_FN_ATTRS
600 __readcr3(void) {
601 unsigned long __cr3_val;
602 __asm__ __volatile__ ("mov %%cr3, %0" : "=q"(__cr3_val) : : "memory");
603 return __cr3_val;
604 }
605
606 static __inline__ void __DEFAULT_FN_ATTRS
607 __writecr3(unsigned int __cr3_val) {
608 __asm__ ("mov %0, %%cr3" : : "q"(__cr3_val) : "memory");
609 }
610 #endif
611
612 #ifdef __cplusplus
613 }
614 #endif
615
616 #undef __DEFAULT_FN_ATTRS
617
618 #endif /* __INTRIN_H */
619 #endif /* _MSC_VER */
__cpuid
#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx)
Definition: cpuid.h:242
__attribute__
vector signed char unaligned_vec_schar __attribute__((aligned(1)))
Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
Definition: altivec.h:16358
x86intrin.h
Value
Value
Definition: UninitializedValues.cpp:102
armintr.h
__src
static __inline__ void const void * __src
Definition: movdirintrin.h:59
arm64intr.h
_xend
static __inline__ void __DEFAULT_FN_ATTRS _xend(void)
Definition: rtmintrin.h:50
__DEFAULT_FN_ATTRS
#define __DEFAULT_FN_ATTRS
Definition: __wmmintrin_aes.h:32
__x
static __inline unsigned char unsigned int __x
Definition: adxintrin.h:36
or
#define or
Definition: iso646.h:37
AttributeLangSupport::C
Definition: SemaDeclAttr.cpp:45