blob: 704b5ad60aa5a3ea02ea5326aba2a0a1d53777fe [file] [log] [blame]
Michael Kupersteina3c7b742015-06-30 09:45:38 +00001/*===---- fxsrintrin.h - FXSR intrinsic ------------------------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24#ifndef __IMMINTRIN_H
25#error "Never use <fxsrintrin.h> directly; include <immintrin.h> instead."
26#endif
27
28#ifndef __FXSRINTRIN_H
29#define __FXSRINTRIN_H
30
Craig Toppere33f51f2015-10-16 06:22:36 +000031#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fxsr")))
Michael Kupersteina3c7b742015-06-30 09:45:38 +000032
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000033/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
Ekaterina Romanova3494a592016-12-08 23:32:07 +000034/// memory region pointed to by the input parameter \a __p.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000035///
36/// \headerfile <x86intrin.h>
37///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000038/// This intrinsic corresponds to the <c> FXSAVE </c> instruction.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000039///
40/// \param __p
41/// A pointer to a 512-byte memory region. The beginning of this memory
42/// region should be aligned on a 16-byte boundary.
Michael Kupersteine45af542015-06-30 13:36:19 +000043static __inline__ void __DEFAULT_FN_ATTRS
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000044_fxsave(void *__p)
45{
Craig Topper819f2a22018-05-30 17:23:45 +000046 __builtin_ia32_fxsave(__p);
Michael Kupersteina3c7b742015-06-30 09:45:38 +000047}
48
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000049/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
Ekaterina Romanova3494a592016-12-08 23:32:07 +000050/// memory region pointed to by the input parameter \a __p. The contents of
51/// this memory region should have been written to by a previous \c _fxsave
52/// or \c _fxsave64 intrinsic.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000053///
54/// \headerfile <x86intrin.h>
55///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000056/// This intrinsic corresponds to the <c> FXRSTOR </c> instruction.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000057///
58/// \param __p
59/// A pointer to a 512-byte memory region. The beginning of this memory
60/// region should be aligned on a 16-byte boundary.
Michael Kupersteine45af542015-06-30 13:36:19 +000061static __inline__ void __DEFAULT_FN_ATTRS
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000062_fxrstor(void *__p)
63{
Craig Topper819f2a22018-05-30 17:23:45 +000064 __builtin_ia32_fxrstor(__p);
Michael Kupersteina3c7b742015-06-30 09:45:38 +000065}
66
Craig Topper45db56c2016-07-21 07:38:39 +000067#ifdef __x86_64__
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000068/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
Ekaterina Romanova3494a592016-12-08 23:32:07 +000069/// memory region pointed to by the input parameter \a __p.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000070///
71/// \headerfile <x86intrin.h>
72///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000073/// This intrinsic corresponds to the <c> FXSAVE64 </c> instruction.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000074///
75/// \param __p
76/// A pointer to a 512-byte memory region. The beginning of this memory
77/// region should be aligned on a 16-byte boundary.
Craig Topper45db56c2016-07-21 07:38:39 +000078static __inline__ void __DEFAULT_FN_ATTRS
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000079_fxsave64(void *__p)
80{
Craig Topper819f2a22018-05-30 17:23:45 +000081 __builtin_ia32_fxsave64(__p);
Craig Topper45db56c2016-07-21 07:38:39 +000082}
83
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000084/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
Ekaterina Romanova3494a592016-12-08 23:32:07 +000085/// memory region pointed to by the input parameter \a __p. The contents of
86/// this memory region should have been written to by a previous \c _fxsave
87/// or \c _fxsave64 intrinsic.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000088///
89/// \headerfile <x86intrin.h>
90///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000091/// This intrinsic corresponds to the <c> FXRSTOR64 </c> instruction.
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000092///
93/// \param __p
94/// A pointer to a 512-byte memory region. The beginning of this memory
95/// region should be aligned on a 16-byte boundary.
Michael Kupersteine45af542015-06-30 13:36:19 +000096static __inline__ void __DEFAULT_FN_ATTRS
Ekaterina Romanova53088dd2016-11-18 01:42:01 +000097_fxrstor64(void *__p)
98{
Craig Topper819f2a22018-05-30 17:23:45 +000099 __builtin_ia32_fxrstor64(__p);
Michael Kupersteina3c7b742015-06-30 09:45:38 +0000100}
Craig Topper45db56c2016-07-21 07:38:39 +0000101#endif
Michael Kupersteina3c7b742015-06-30 09:45:38 +0000102
Michael Kupersteine45af542015-06-30 13:36:19 +0000103#undef __DEFAULT_FN_ATTRS
Michael Kuperstein9101a982015-06-30 10:18:54 +0000104
Michael Kupersteina3c7b742015-06-30 09:45:38 +0000105#endif