Anders Carlsson | f29b774 | 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 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 33 | static inline __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 34 | _mm_lddqu_si128(__m128i const *p) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 35 | { |
| 36 | return (__m128i)__builtin_ia32_lddqu((char const *)p); |
| 37 | } |
| 38 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 39 | static inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 40 | _mm_addsub_ps(__m128 a, __m128 b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 41 | { |
| 42 | return __builtin_ia32_addsubps(a, b); |
| 43 | } |
| 44 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 45 | static inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 46 | _mm_hadd_ps(__m128 a, __m128 b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 47 | { |
| 48 | return __builtin_ia32_haddps(a, b); |
| 49 | } |
| 50 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 51 | static inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 52 | _mm_hsub_ps(__m128 a, __m128 b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 53 | { |
| 54 | return __builtin_ia32_hsubps(a, b); |
| 55 | } |
| 56 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 57 | static inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 58 | _mm_movehdup_ps(__m128 a) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 59 | { |
| 60 | return __builtin_shufflevector(a, a, 1, 1, 3, 3); |
| 61 | } |
| 62 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 63 | static inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 64 | _mm_moveldup_ps(__m128 a) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 65 | { |
| 66 | return __builtin_shufflevector(a, a, 0, 0, 2, 2); |
| 67 | } |
| 68 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 69 | static inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 70 | _mm_addsub_pd(__m128d a, __m128d b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 71 | { |
| 72 | return __builtin_ia32_addsubpd(a, b); |
| 73 | } |
| 74 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 75 | static inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 76 | _mm_hadd_pd(__m128d a, __m128d b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 77 | { |
| 78 | return __builtin_ia32_haddpd(a, b); |
| 79 | } |
| 80 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 81 | static inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 82 | _mm_hsub_pd(__m128d a, __m128d b) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 83 | { |
| 84 | return __builtin_ia32_hsubpd(a, b); |
| 85 | } |
| 86 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 87 | static inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 88 | _mm_loaddup_pd(double const *dp) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 89 | { |
Anders Carlsson | 13f5f6e | 2009-02-14 01:06:58 +0000 | [diff] [blame] | 90 | return (__m128d){ *dp, *dp }; |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 93 | static inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 94 | _mm_movedup_pd(__m128d a) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 95 | { |
| 96 | return __builtin_shufflevector(a, a, 0, 0); |
| 97 | } |
| 98 | |
| 99 | #define _MM_DENORMALS_ZERO_ON (0x0040) |
| 100 | #define _MM_DENORMALS_ZERO_OFF (0x0000) |
| 101 | |
| 102 | #define _MM_DENORMALS_ZERO_MASK (0x0040) |
| 103 | |
| 104 | #define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK) |
| 105 | #define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) |
| 106 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 107 | static inline void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 108 | _mm_monitor(void const *p, unsigned extensions, unsigned hints) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 109 | { |
| 110 | __builtin_ia32_monitor((void *)p, extensions, hints); |
| 111 | } |
| 112 | |
Anders Carlsson | a2f12ae | 2009-02-14 01:00:11 +0000 | [diff] [blame] | 113 | static inline void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 114 | _mm_mwait(unsigned extensions, unsigned hints) |
Anders Carlsson | f29b774 | 2009-02-11 06:39:50 +0000 | [diff] [blame] | 115 | { |
| 116 | __builtin_ia32_mwait(extensions, hints); |
| 117 | } |
| 118 | |
| 119 | #endif /* __SSE3__ */ |
| 120 | |
| 121 | #endif /* __PMMINTRIN_H */ |