xref: /freebsd/contrib/llvm-project/clang/lib/Headers/x86gprintrin.h (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
1 /*===--------------- x86gprintrin.h - X86 GPR intrinsics ------------------===
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 #ifndef __X86GPRINTRIN_H
11 #define __X86GPRINTRIN_H
12 
13 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
14     defined(__HRESET__)
15 #include <hresetintrin.h>
16 #endif
17 
18 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
19     defined(__UINTR__)
20 #include <uintrintrin.h>
21 #endif
22 
23 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
24     defined(__USERMSR__)
25 #include <usermsrintrin.h>
26 #endif
27 
28 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
29     defined(__CRC32__)
30 #include <crc32intrin.h>
31 #endif
32 
33 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
34     defined(__PRFCHI__)
35 #include <prfchiintrin.h>
36 #endif
37 
38 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
39     defined(__RAOINT__)
40 #include <raointintrin.h>
41 #endif
42 
43 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
44     defined(__CMPCCXADD__)
45 #include <cmpccxaddintrin.h>
46 #endif
47 
48 #if defined(__i386__)
49 #define __SAVE_GPRBX "mov {%%ebx, %%eax |eax, ebx};"
50 #define __RESTORE_GPRBX "mov {%%eax, %%ebx |ebx, eax};"
51 #define __TMPGPR "eax"
52 #else
53 // When in 64-bit target, the 32-bit operands generate a 32-bit result,
54 // zero-extended to a 64-bit result in the destination general-purpose,
55 // It means "mov x %ebx" will clobber the higher 32 bits of rbx, so we
56 // should preserve the 64-bit register rbx.
57 #define __SAVE_GPRBX "mov {%%rbx, %%rax |rax, rbx};"
58 #define __RESTORE_GPRBX "mov {%%rax, %%rbx |rbx, rax};"
59 #define __TMPGPR "rax"
60 #endif
61 
62 #define __SSC_MARK(__Tag)                                                      \
63   __asm__ __volatile__( __SAVE_GPRBX                                           \
64                        "mov {%0, %%ebx|ebx, %0}; "                             \
65                        ".byte 0x64, 0x67, 0x90; "                              \
66                         __RESTORE_GPRBX                                        \
67                        ::"i"(__Tag)                                            \
68                        :  __TMPGPR );
69 
70 #endif /* __X86GPRINTRIN_H */
71