11897Swollman/*===---- fxsrintrin.h - FXSR intrinsic ------------------------------------===
299979Salfred *
399979Salfred * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
499979Salfred * See https://llvm.org/LICENSE.txt for license information.
51897Swollman * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61897Swollman *
71897Swollman *===-----------------------------------------------------------------------===
81897Swollman */
91897Swollman
101897Swollman#ifndef __IMMINTRIN_H
11100441Scharnier#error "Never use <fxsrintrin.h> directly; include <immintrin.h> instead."
121897Swollman#endif
131897Swollman
141897Swollman#ifndef __FXSRINTRIN_H
15100441Scharnier#define __FXSRINTRIN_H
161897Swollman
171897Swollman#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("fxsr")))
181897Swollman
19100441Scharnier/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
201897Swollman///    memory region pointed to by the input parameter \a __p.
211897Swollman///
221897Swollman/// \headerfile <x86intrin.h>
23100441Scharnier///
241897Swollman/// This intrinsic corresponds to the <c> FXSAVE </c> instruction.
251897Swollman///
261897Swollman/// \param __p
27100441Scharnier///    A pointer to a 512-byte memory region. The beginning of this memory
281897Swollman///    region should be aligned on a 16-byte boundary.
291897Swollmanstatic __inline__ void __DEFAULT_FN_ATTRS
301897Swollman_fxsave(void *__p)
311897Swollman{
3299979Salfred  __builtin_ia32_fxsave(__p);
331897Swollman}
3412798Swpaul
3512798Swpaul/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
3612798Swpaul///    memory region pointed to by the input parameter \a __p. The contents of
3712798Swpaul///    this memory region should have been written to by a previous \c _fxsave
3812798Swpaul///    or \c _fxsave64 intrinsic.
3912798Swpaul///
4012798Swpaul/// \headerfile <x86intrin.h>
4112798Swpaul///
4212798Swpaul/// This intrinsic corresponds to the <c> FXRSTOR </c> instruction.
4312798Swpaul///
4412798Swpaul/// \param __p
4512798Swpaul///    A pointer to a 512-byte memory region. The beginning of this memory
4612798Swpaul///    region should be aligned on a 16-byte boundary.
4712798Swpaulstatic __inline__ void __DEFAULT_FN_ATTRS
4812798Swpaul_fxrstor(void *__p)
4912798Swpaul{
5012798Swpaul  __builtin_ia32_fxrstor(__p);
5112798Swpaul}
5212798Swpaul
5312798Swpaul#ifdef __x86_64__
54100441Scharnier/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
5512798Swpaul///    memory region pointed to by the input parameter \a __p.
56100441Scharnier///
5712798Swpaul/// \headerfile <x86intrin.h>
5812798Swpaul///
5912798Swpaul/// This intrinsic corresponds to the <c> FXSAVE64 </c> instruction.
6012798Swpaul///
6112798Swpaul/// \param __p
62100441Scharnier///    A pointer to a 512-byte memory region. The beginning of this memory
6312798Swpaul///    region should be aligned on a 16-byte boundary.
6412798Swpaulstatic __inline__ void __DEFAULT_FN_ATTRS
6512798Swpaul_fxsave64(void *__p)
661897Swollman{
67100441Scharnier  __builtin_ia32_fxsave64(__p);
681897Swollman}
691897Swollman
701897Swollman/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
71100441Scharnier///    memory region pointed to by the input parameter \a __p. The contents of
721897Swollman///    this memory region should have been written to by a previous \c _fxsave
731897Swollman///    or \c _fxsave64 intrinsic.
741897Swollman///
7512798Swpaul/// \headerfile <x86intrin.h>
761897Swollman///
771897Swollman/// This intrinsic corresponds to the <c> FXRSTOR64 </c> instruction.
781897Swollman///
791897Swollman/// \param __p
801897Swollman///    A pointer to a 512-byte memory region. The beginning of this memory
811897Swollman///    region should be aligned on a 16-byte boundary.
821897Swollmanstatic __inline__ void __DEFAULT_FN_ATTRS
831897Swollman_fxrstor64(void *__p)
841897Swollman{
851897Swollman  __builtin_ia32_fxrstor64(__p);
861897Swollman}
871897Swollman#endif
881897Swollman
891897Swollman#undef __DEFAULT_FN_ATTRS
901897Swollman
911897Swollman#endif
921897Swollman