1 /* Copyright (C) 2020-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 #define _X86GPRINTRIN_H_INCLUDED
26 
27 #if defined __MMX__ || defined __SSE__
28 #pragma GCC push_options
29 #pragma GCC target("general-regs-only")
30 #define __DISABLE_GENERAL_REGS_ONLY__
31 #endif
32 
33 #include <ia32intrin.h>
34 
35 #ifndef __iamcu__
36 
37 #include <stddef.h>
38 
39 #include <adxintrin.h>
40 
41 #include <bmiintrin.h>
42 
43 #include <bmi2intrin.h>
44 
45 #include <cetintrin.h>
46 
47 #include <cldemoteintrin.h>
48 
49 #include <clflushoptintrin.h>
50 
51 #include <clwbintrin.h>
52 
53 #include <clzerointrin.h>
54 
55 #include <enqcmdintrin.h>
56 
57 #include <fxsrintrin.h>
58 
59 #include <lzcntintrin.h>
60 
61 #include <lwpintrin.h>
62 
63 #include <movdirintrin.h>
64 
65 #include <mwaitintrin.h>
66 
67 #include <mwaitxintrin.h>
68 
69 #include <pconfigintrin.h>
70 
71 #include <popcntintrin.h>
72 
73 #include <pkuintrin.h>
74 
75 #include <rdseedintrin.h>
76 
77 #include <rtmintrin.h>
78 
79 #include <serializeintrin.h>
80 
81 #include <sgxintrin.h>
82 
83 #include <tbmintrin.h>
84 
85 #include <tsxldtrkintrin.h>
86 
87 #include <uintrintrin.h>
88 
89 #include <waitpkgintrin.h>
90 
91 #include <wbnoinvdintrin.h>
92 
93 #include <xsaveintrin.h>
94 
95 #include <xsavecintrin.h>
96 
97 #include <xsaveoptintrin.h>
98 
99 #include <xsavesintrin.h>
100 
101 #include <xtestintrin.h>
102 
103 #include <hresetintrin.h>
104 
105 extern __inline void
106 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wbinvd(void)107 _wbinvd (void)
108 {
109   __builtin_ia32_wbinvd ();
110 }
111 
112 #ifndef __RDRND__
113 #pragma GCC push_options
114 #pragma GCC target("rdrnd")
115 #define __DISABLE_RDRND__
116 #endif /* __RDRND__ */
117 extern __inline int
118 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand16_step(unsigned short * __P)119 _rdrand16_step (unsigned short *__P)
120 {
121   return __builtin_ia32_rdrand16_step (__P);
122 }
123 
124 extern __inline int
125 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand32_step(unsigned int * __P)126 _rdrand32_step (unsigned int *__P)
127 {
128   return __builtin_ia32_rdrand32_step (__P);
129 }
130 #ifdef __DISABLE_RDRND__
131 #undef __DISABLE_RDRND__
132 #pragma GCC pop_options
133 #endif /* __DISABLE_RDRND__ */
134 
135 #ifndef __RDPID__
136 #pragma GCC push_options
137 #pragma GCC target("rdpid")
138 #define __DISABLE_RDPID__
139 #endif /* __RDPID__ */
140 extern __inline unsigned int
141 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdpid_u32(void)142 _rdpid_u32 (void)
143 {
144   return __builtin_ia32_rdpid ();
145 }
146 #ifdef __DISABLE_RDPID__
147 #undef __DISABLE_RDPID__
148 #pragma GCC pop_options
149 #endif /* __DISABLE_RDPID__ */
150 
151 #ifdef  __x86_64__
152 
153 #ifndef __FSGSBASE__
154 #pragma GCC push_options
155 #pragma GCC target("fsgsbase")
156 #define __DISABLE_FSGSBASE__
157 #endif /* __FSGSBASE__ */
158 extern __inline unsigned int
159 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readfsbase_u32(void)160 _readfsbase_u32 (void)
161 {
162   return __builtin_ia32_rdfsbase32 ();
163 }
164 
165 extern __inline unsigned long long
166 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readfsbase_u64(void)167 _readfsbase_u64 (void)
168 {
169   return __builtin_ia32_rdfsbase64 ();
170 }
171 
172 extern __inline unsigned int
173 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readgsbase_u32(void)174 _readgsbase_u32 (void)
175 {
176   return __builtin_ia32_rdgsbase32 ();
177 }
178 
179 extern __inline unsigned long long
180 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readgsbase_u64(void)181 _readgsbase_u64 (void)
182 {
183   return __builtin_ia32_rdgsbase64 ();
184 }
185 
186 extern __inline void
187 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writefsbase_u32(unsigned int __B)188 _writefsbase_u32 (unsigned int __B)
189 {
190   __builtin_ia32_wrfsbase32 (__B);
191 }
192 
193 extern __inline void
194 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writefsbase_u64(unsigned long long __B)195 _writefsbase_u64 (unsigned long long __B)
196 {
197   __builtin_ia32_wrfsbase64 (__B);
198 }
199 
200 extern __inline void
201 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writegsbase_u32(unsigned int __B)202 _writegsbase_u32 (unsigned int __B)
203 {
204   __builtin_ia32_wrgsbase32 (__B);
205 }
206 
207 extern __inline void
208 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writegsbase_u64(unsigned long long __B)209 _writegsbase_u64 (unsigned long long __B)
210 {
211   __builtin_ia32_wrgsbase64 (__B);
212 }
213 #ifdef __DISABLE_FSGSBASE__
214 #undef __DISABLE_FSGSBASE__
215 #pragma GCC pop_options
216 #endif /* __DISABLE_FSGSBASE__ */
217 
218 #ifndef __RDRND__
219 #pragma GCC push_options
220 #pragma GCC target("rdrnd")
221 #define __DISABLE_RDRND__
222 #endif /* __RDRND__ */
223 extern __inline int
224 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand64_step(unsigned long long * __P)225 _rdrand64_step (unsigned long long *__P)
226 {
227   return __builtin_ia32_rdrand64_step (__P);
228 }
229 #ifdef __DISABLE_RDRND__
230 #undef __DISABLE_RDRND__
231 #pragma GCC pop_options
232 #endif /* __DISABLE_RDRND__ */
233 
234 #endif /* __x86_64__  */
235 
236 #ifndef __PTWRITE__
237 #pragma GCC push_options
238 #pragma GCC target("ptwrite")
239 #define __DISABLE_PTWRITE__
240 #endif
241 
242 #ifdef __x86_64__
243 extern __inline void
244 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_ptwrite64(unsigned long long __B)245 _ptwrite64 (unsigned long long __B)
246 {
247   __builtin_ia32_ptwrite64 (__B);
248 }
249 #endif /* __x86_64__ */
250 
251 extern __inline void
252 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_ptwrite32(unsigned __B)253 _ptwrite32 (unsigned __B)
254 {
255   __builtin_ia32_ptwrite32 (__B);
256 }
257 #ifdef __DISABLE_PTWRITE__
258 #undef __DISABLE_PTWRITE__
259 #pragma GCC pop_options
260 #endif /* __DISABLE_PTWRITE__ */
261 
262 #endif /* __iamcu__ */
263 
264 #ifdef __DISABLE_GENERAL_REGS_ONLY__
265 #undef __DISABLE_GENERAL_REGS_ONLY__
266 #pragma GCC pop_options
267 #endif /* __DISABLE_GENERAL_REGS_ONLY__ */
268 
269 #endif /* _X86GPRINTRIN_H_INCLUDED.  */
270