Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 1 | /*===---- 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 Topper | e33f51f | 2015-10-16 06:22:36 +0000 | [diff] [blame] | 31 | #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fxsr"))) |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 32 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 33 | /// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte |
Ekaterina Romanova | 3494a59 | 2016-12-08 23:32:07 +0000 | [diff] [blame] | 34 | /// memory region pointed to by the input parameter \a __p. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 35 | /// |
| 36 | /// \headerfile <x86intrin.h> |
| 37 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 38 | /// This intrinsic corresponds to the <c> FXSAVE </c> instruction. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 39 | /// |
| 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 Kuperstein | e45af54 | 2015-06-30 13:36:19 +0000 | [diff] [blame] | 43 | static __inline__ void __DEFAULT_FN_ATTRS |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 44 | _fxsave(void *__p) |
| 45 | { |
Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 46 | __builtin_ia32_fxsave(__p); |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 49 | /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte |
Ekaterina Romanova | 3494a59 | 2016-12-08 23:32:07 +0000 | [diff] [blame] | 50 | /// 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 Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 53 | /// |
| 54 | /// \headerfile <x86intrin.h> |
| 55 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 56 | /// This intrinsic corresponds to the <c> FXRSTOR </c> instruction. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 57 | /// |
| 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 Kuperstein | e45af54 | 2015-06-30 13:36:19 +0000 | [diff] [blame] | 61 | static __inline__ void __DEFAULT_FN_ATTRS |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 62 | _fxrstor(void *__p) |
| 63 | { |
Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 64 | __builtin_ia32_fxrstor(__p); |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Craig Topper | 45db56c | 2016-07-21 07:38:39 +0000 | [diff] [blame] | 67 | #ifdef __x86_64__ |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 68 | /// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte |
Ekaterina Romanova | 3494a59 | 2016-12-08 23:32:07 +0000 | [diff] [blame] | 69 | /// memory region pointed to by the input parameter \a __p. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 70 | /// |
| 71 | /// \headerfile <x86intrin.h> |
| 72 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 73 | /// This intrinsic corresponds to the <c> FXSAVE64 </c> instruction. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 74 | /// |
| 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 Topper | 45db56c | 2016-07-21 07:38:39 +0000 | [diff] [blame] | 78 | static __inline__ void __DEFAULT_FN_ATTRS |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 79 | _fxsave64(void *__p) |
| 80 | { |
Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 81 | __builtin_ia32_fxsave64(__p); |
Craig Topper | 45db56c | 2016-07-21 07:38:39 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 84 | /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte |
Ekaterina Romanova | 3494a59 | 2016-12-08 23:32:07 +0000 | [diff] [blame] | 85 | /// 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 Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 88 | /// |
| 89 | /// \headerfile <x86intrin.h> |
| 90 | /// |
Ekaterina Romanova | 0c1c3bb | 2016-12-09 18:35:50 +0000 | [diff] [blame] | 91 | /// This intrinsic corresponds to the <c> FXRSTOR64 </c> instruction. |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 92 | /// |
| 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 Kuperstein | e45af54 | 2015-06-30 13:36:19 +0000 | [diff] [blame] | 96 | static __inline__ void __DEFAULT_FN_ATTRS |
Ekaterina Romanova | 53088dd | 2016-11-18 01:42:01 +0000 | [diff] [blame] | 97 | _fxrstor64(void *__p) |
| 98 | { |
Craig Topper | 819f2a2 | 2018-05-30 17:23:45 +0000 | [diff] [blame] | 99 | __builtin_ia32_fxrstor64(__p); |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 100 | } |
Craig Topper | 45db56c | 2016-07-21 07:38:39 +0000 | [diff] [blame] | 101 | #endif |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 102 | |
Michael Kuperstein | e45af54 | 2015-06-30 13:36:19 +0000 | [diff] [blame] | 103 | #undef __DEFAULT_FN_ATTRS |
Michael Kuperstein | 9101a98 | 2015-06-30 10:18:54 +0000 | [diff] [blame] | 104 | |
Michael Kuperstein | a3c7b74 | 2015-06-30 09:45:38 +0000 | [diff] [blame] | 105 | #endif |