Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 1 | /*===---- pmmintrin.h - SSE3 intrinsics ------------------------------------=== |
| 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 __PMMINTRIN_H |
| 25 | #define __PMMINTRIN_H |
| 26 | |
| 27 | #ifndef __SSE3__ |
| 28 | #error "SSE3 instruction set not enabled" |
| 29 | #else |
| 30 | |
| 31 | #include <emmintrin.h> |
| 32 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 33 | /* Define the default attributes for the functions in this file. */ |
| 34 | #define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) |
| 35 | |
| 36 | static __inline__ __m128i DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 37 | _mm_lddqu_si128(__m128i const *__p) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 38 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 39 | return (__m128i)__builtin_ia32_lddqu((char const *)__p); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 42 | static __inline__ __m128 DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 43 | _mm_addsub_ps(__m128 __a, __m128 __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 44 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 45 | return __builtin_ia32_addsubps(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 48 | static __inline__ __m128 DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 49 | _mm_hadd_ps(__m128 __a, __m128 __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 50 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 51 | return __builtin_ia32_haddps(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 54 | static __inline__ __m128 DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 55 | _mm_hsub_ps(__m128 __a, __m128 __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 56 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 57 | return __builtin_ia32_hsubps(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 60 | static __inline__ __m128 DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 61 | _mm_movehdup_ps(__m128 __a) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 62 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 63 | return __builtin_shufflevector(__a, __a, 1, 1, 3, 3); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 66 | static __inline__ __m128 DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 67 | _mm_moveldup_ps(__m128 __a) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 68 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 69 | return __builtin_shufflevector(__a, __a, 0, 0, 2, 2); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 72 | static __inline__ __m128d DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 73 | _mm_addsub_pd(__m128d __a, __m128d __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 74 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 75 | return __builtin_ia32_addsubpd(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 78 | static __inline__ __m128d DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 79 | _mm_hadd_pd(__m128d __a, __m128d __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 80 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 81 | return __builtin_ia32_haddpd(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 84 | static __inline__ __m128d DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 85 | _mm_hsub_pd(__m128d __a, __m128d __b) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 86 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 87 | return __builtin_ia32_hsubpd(__a, __b); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Eli Friedman | 9bb51ad | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 90 | #define _mm_loaddup_pd(dp) _mm_load1_pd(dp) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 91 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 92 | static __inline__ __m128d DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 93 | _mm_movedup_pd(__m128d __a) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 94 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 95 | return __builtin_shufflevector(__a, __a, 0, 0); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | #define _MM_DENORMALS_ZERO_ON (0x0040) |
| 99 | #define _MM_DENORMALS_ZERO_OFF (0x0000) |
| 100 | |
| 101 | #define _MM_DENORMALS_ZERO_MASK (0x0040) |
| 102 | |
| 103 | #define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK) |
| 104 | #define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) |
| 105 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 106 | static __inline__ void DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 107 | _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 108 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 109 | __builtin_ia32_monitor((void *)__p, __extensions, __hints); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 112 | static __inline__ void DEFAULT_FN_ATTRS |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 113 | _mm_mwait(unsigned __extensions, unsigned __hints) |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 114 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 115 | __builtin_ia32_mwait(__extensions, __hints); |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Eric Christopher | 4d185168 | 2015-06-17 07:09:20 +0000 | [diff] [blame^] | 118 | #undef DEFAULT_FN_ATTRS |
| 119 | |
Anders Carlsson | d0d8c54 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 120 | #endif /* __SSE3__ */ |
| 121 | |
| 122 | #endif /* __PMMINTRIN_H */ |