Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 1 | /*===---- fxsrintrin.h - FXSR intrinsic ------------------------------------=== |
| 2 | * |
Logan Chien | df4f766 | 2019-09-04 16:45:23 -0700 | [diff] [blame] | 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-exception |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 6 | * |
| 7 | *===-----------------------------------------------------------------------=== |
| 8 | */ |
| 9 | |
| 10 | #ifndef __IMMINTRIN_H |
| 11 | #error "Never use <fxsrintrin.h> directly; include <immintrin.h> instead." |
| 12 | #endif |
| 13 | |
| 14 | #ifndef __FXSRINTRIN_H |
| 15 | #define __FXSRINTRIN_H |
| 16 | |
| 17 | #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fxsr"))) |
| 18 | |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 19 | /// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte |
| 20 | /// memory region pointed to by the input parameter \a __p. |
| 21 | /// |
| 22 | /// \headerfile <x86intrin.h> |
| 23 | /// |
| 24 | /// This intrinsic corresponds to the <c> FXSAVE </c> instruction. |
| 25 | /// |
| 26 | /// \param __p |
| 27 | /// A pointer to a 512-byte memory region. The beginning of this memory |
| 28 | /// region should be aligned on a 16-byte boundary. |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 29 | static __inline__ void __DEFAULT_FN_ATTRS |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 30 | _fxsave(void *__p) |
| 31 | { |
| 32 | __builtin_ia32_fxsave(__p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 33 | } |
| 34 | |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 35 | /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte |
| 36 | /// memory region pointed to by the input parameter \a __p. The contents of |
| 37 | /// this memory region should have been written to by a previous \c _fxsave |
| 38 | /// or \c _fxsave64 intrinsic. |
| 39 | /// |
| 40 | /// \headerfile <x86intrin.h> |
| 41 | /// |
| 42 | /// This intrinsic corresponds to the <c> FXRSTOR </c> instruction. |
| 43 | /// |
| 44 | /// \param __p |
| 45 | /// A pointer to a 512-byte memory region. The beginning of this memory |
| 46 | /// region should be aligned on a 16-byte boundary. |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 47 | static __inline__ void __DEFAULT_FN_ATTRS |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 48 | _fxrstor(void *__p) |
| 49 | { |
| 50 | __builtin_ia32_fxrstor(__p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 51 | } |
| 52 | |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 53 | #ifdef __x86_64__ |
| 54 | /// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte |
| 55 | /// memory region pointed to by the input parameter \a __p. |
| 56 | /// |
| 57 | /// \headerfile <x86intrin.h> |
| 58 | /// |
| 59 | /// This intrinsic corresponds to the <c> FXSAVE64 </c> instruction. |
| 60 | /// |
| 61 | /// \param __p |
| 62 | /// A pointer to a 512-byte memory region. The beginning of this memory |
| 63 | /// region should be aligned on a 16-byte boundary. |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 64 | static __inline__ void __DEFAULT_FN_ATTRS |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 65 | _fxsave64(void *__p) |
| 66 | { |
| 67 | __builtin_ia32_fxsave64(__p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 68 | } |
| 69 | |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 70 | /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte |
| 71 | /// memory region pointed to by the input parameter \a __p. The contents of |
| 72 | /// this memory region should have been written to by a previous \c _fxsave |
| 73 | /// or \c _fxsave64 intrinsic. |
| 74 | /// |
| 75 | /// \headerfile <x86intrin.h> |
| 76 | /// |
| 77 | /// This intrinsic corresponds to the <c> FXRSTOR64 </c> instruction. |
| 78 | /// |
| 79 | /// \param __p |
| 80 | /// A pointer to a 512-byte memory region. The beginning of this memory |
| 81 | /// region should be aligned on a 16-byte boundary. |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 82 | static __inline__ void __DEFAULT_FN_ATTRS |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 83 | _fxrstor64(void *__p) |
| 84 | { |
| 85 | __builtin_ia32_fxrstor64(__p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 86 | } |
Logan Chien | 55afb0a | 2018-10-15 10:42:14 +0800 | [diff] [blame] | 87 | #endif |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 88 | |
| 89 | #undef __DEFAULT_FN_ATTRS |
| 90 | |
| 91 | #endif |