64 lines · c
1/*===---- xsaveintrin.h - XSAVE intrinsic ----------------------------------===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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef __IMMINTRIN_H11#error "Never use <xsaveintrin.h> directly; include <immintrin.h> instead."12#endif13 14#ifndef __XSAVEINTRIN_H15#define __XSAVEINTRIN_H16 17#ifdef _MSC_VER18#define _XCR_XFEATURE_ENABLED_MASK 019#endif20 21/* Define the default attributes for the functions in this file. */22#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsave")))23 24static __inline__ void __DEFAULT_FN_ATTRS25_xsave(void *__p, unsigned long long __m) {26 __builtin_ia32_xsave(__p, __m);27}28 29static __inline__ void __DEFAULT_FN_ATTRS30_xrstor(void *__p, unsigned long long __m) {31 __builtin_ia32_xrstor(__p, __m);32}33 34#ifndef _MSC_VER35#define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))36#define _xsetbv(A, B) __builtin_ia32_xsetbv((unsigned int)(A), (unsigned long long)(B))37#else38#ifdef __cplusplus39extern "C" {40#endif41unsigned __int64 __cdecl _xgetbv(unsigned int);42void __cdecl _xsetbv(unsigned int, unsigned __int64);43#ifdef __cplusplus44}45#endif46#endif /* _MSC_VER */47 48#ifdef __x86_64__49static __inline__ void __DEFAULT_FN_ATTRS50_xsave64(void *__p, unsigned long long __m) {51 __builtin_ia32_xsave64(__p, __m);52}53 54static __inline__ void __DEFAULT_FN_ATTRS55_xrstor64(void *__p, unsigned long long __m) {56 __builtin_ia32_xrstor64(__p, __m);57}58 59#endif60 61#undef __DEFAULT_FN_ATTRS62 63#endif64