1*7330f729Sjoerg /*===---- xsaveintrin.h - XSAVE intrinsic ----------------------------------===
2*7330f729Sjoerg *
3*7330f729Sjoerg * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg * See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg *
7*7330f729Sjoerg *===-----------------------------------------------------------------------===
8*7330f729Sjoerg */
9*7330f729Sjoerg
10*7330f729Sjoerg #ifndef __IMMINTRIN_H
11*7330f729Sjoerg #error "Never use <xsaveintrin.h> directly; include <immintrin.h> instead."
12*7330f729Sjoerg #endif
13*7330f729Sjoerg
14*7330f729Sjoerg #ifndef __XSAVEINTRIN_H
15*7330f729Sjoerg #define __XSAVEINTRIN_H
16*7330f729Sjoerg
17*7330f729Sjoerg #ifdef _MSC_VER
18*7330f729Sjoerg #define _XCR_XFEATURE_ENABLED_MASK 0
19*7330f729Sjoerg #endif
20*7330f729Sjoerg
21*7330f729Sjoerg /* Define the default attributes for the functions in this file. */
22*7330f729Sjoerg #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsave")))
23*7330f729Sjoerg
24*7330f729Sjoerg static __inline__ void __DEFAULT_FN_ATTRS
_xsave(void * __p,unsigned long long __m)25*7330f729Sjoerg _xsave(void *__p, unsigned long long __m) {
26*7330f729Sjoerg __builtin_ia32_xsave(__p, __m);
27*7330f729Sjoerg }
28*7330f729Sjoerg
29*7330f729Sjoerg static __inline__ void __DEFAULT_FN_ATTRS
_xrstor(void * __p,unsigned long long __m)30*7330f729Sjoerg _xrstor(void *__p, unsigned long long __m) {
31*7330f729Sjoerg __builtin_ia32_xrstor(__p, __m);
32*7330f729Sjoerg }
33*7330f729Sjoerg
34*7330f729Sjoerg #ifndef _MSC_VER
35*7330f729Sjoerg #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
36*7330f729Sjoerg #define _xsetbv(A, B) __builtin_ia32_xsetbv((unsigned int)(A), (unsigned long long)(B))
37*7330f729Sjoerg #else
38*7330f729Sjoerg #ifdef __cplusplus
39*7330f729Sjoerg extern "C" {
40*7330f729Sjoerg #endif
41*7330f729Sjoerg unsigned __int64 __cdecl _xgetbv(unsigned int);
42*7330f729Sjoerg void __cdecl _xsetbv(unsigned int, unsigned __int64);
43*7330f729Sjoerg #ifdef __cplusplus
44*7330f729Sjoerg }
45*7330f729Sjoerg #endif
46*7330f729Sjoerg #endif /* _MSC_VER */
47*7330f729Sjoerg
48*7330f729Sjoerg #ifdef __x86_64__
49*7330f729Sjoerg static __inline__ void __DEFAULT_FN_ATTRS
_xsave64(void * __p,unsigned long long __m)50*7330f729Sjoerg _xsave64(void *__p, unsigned long long __m) {
51*7330f729Sjoerg __builtin_ia32_xsave64(__p, __m);
52*7330f729Sjoerg }
53*7330f729Sjoerg
54*7330f729Sjoerg static __inline__ void __DEFAULT_FN_ATTRS
_xrstor64(void * __p,unsigned long long __m)55*7330f729Sjoerg _xrstor64(void *__p, unsigned long long __m) {
56*7330f729Sjoerg __builtin_ia32_xrstor64(__p, __m);
57*7330f729Sjoerg }
58*7330f729Sjoerg
59*7330f729Sjoerg #endif
60*7330f729Sjoerg
61*7330f729Sjoerg #undef __DEFAULT_FN_ATTRS
62*7330f729Sjoerg
63*7330f729Sjoerg #endif
64