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