Anders Carlsson | 566d8da | 2008-12-22 00:01:20 +0000 | [diff] [blame^] | 1 | /*===---- xmmintrin.h - SSE 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 __XMMINTRIN_H |
| 25 | #define __XMMINTRIN_H |
| 26 | |
| 27 | #ifndef __SSE__ |
| 28 | #error "MMX instruction set not enabled" |
| 29 | #else |
| 30 | |
| 31 | typedef float __m128 __attribute__((__vector_size__(16))); |
| 32 | |
| 33 | static inline __m128 __attribute__((__always_inline__)) _mm_add_ss(__m128 a, __m128 b) |
| 34 | { |
| 35 | return __builtin_ia32_addss(a, b); |
| 36 | } |
| 37 | |
| 38 | static inline __m128 __attribute__((__always_inline__)) _mm_add_ps(__m128 a, __m128 b) |
| 39 | { |
| 40 | return a + b; |
| 41 | } |
| 42 | |
| 43 | static inline __m128 __attribute__((__always_inline__)) _mm_sub_ss(__m128 a, __m128 b) |
| 44 | { |
| 45 | return __builtin_ia32_subss(a, b); |
| 46 | } |
| 47 | |
| 48 | static inline __m128 __attribute__((__always_inline__)) _mm_sub_ps(__m128 a, __m128 b) |
| 49 | { |
| 50 | return a - b; |
| 51 | } |
| 52 | |
| 53 | static inline __m128 __attribute__((__always_inline__)) _mm_mul_ss(__m128 a, __m128 b) |
| 54 | { |
| 55 | return __builtin_ia32_mulss(a, b); |
| 56 | } |
| 57 | |
| 58 | static inline __m128 __attribute__((__always_inline__)) _mm_mul_ps(__m128 a, __m128 b) |
| 59 | { |
| 60 | return a * b; |
| 61 | } |
| 62 | |
| 63 | static inline __m128 __attribute__((__always_inline__)) _mm_div_ss(__m128 a, __m128 b) |
| 64 | { |
| 65 | return __builtin_ia32_divss(a, b); |
| 66 | } |
| 67 | |
| 68 | static inline __m128 __attribute__((__always_inline__)) _mm_div_ps(__m128 a, __m128 b) |
| 69 | { |
| 70 | return a / b; |
| 71 | } |
| 72 | |
| 73 | static inline __m128 __attribute__((__always_inline__)) _mm_sqrt_ss(__m128 a) |
| 74 | { |
| 75 | return __builtin_ia32_sqrtss(a); |
| 76 | } |
| 77 | |
| 78 | static inline __m128 __attribute__((__always_inline__)) _mm_sqrt_ps(__m128 a) |
| 79 | { |
| 80 | return __builtin_ia32_sqrtps(a); |
| 81 | } |
| 82 | |
| 83 | static inline __m128 __attribute__((__always_inline__)) _mm_rcp_ss(__m128 a) |
| 84 | { |
| 85 | return __builtin_ia32_rcpss(a); |
| 86 | } |
| 87 | |
| 88 | static inline __m128 __attribute__((__always_inline__)) _mm_rcp_ps(__m128 a) |
| 89 | { |
| 90 | return __builtin_ia32_rcpps(a); |
| 91 | } |
| 92 | |
| 93 | static inline __m128 __attribute__((__always_inline__)) _mm_rsqrt_ss(__m128 a) |
| 94 | { |
| 95 | return __builtin_ia32_rsqrtss(a); |
| 96 | } |
| 97 | |
| 98 | static inline __m128 __attribute__((__always_inline__)) _mm_rsqrt_ps(__m128 a) |
| 99 | { |
| 100 | return __builtin_ia32_rsqrtps(a); |
| 101 | } |
| 102 | |
| 103 | static inline __m128 __attribute__((__always_inline__)) _mm_min_ss(__m128 a, __m128 b) |
| 104 | { |
| 105 | return __builtin_ia32_minss(a, b); |
| 106 | } |
| 107 | |
| 108 | static inline __m128 __attribute__((__always_inline__)) _mm_min_ps(__m128 a, __m128 b) |
| 109 | { |
| 110 | return __builtin_ia32_minps(a, b); |
| 111 | } |
| 112 | |
| 113 | static inline __m128 __attribute__((__always_inline__)) _mm_max_ss(__m128 a, __m128 b) |
| 114 | { |
| 115 | return __builtin_ia32_maxss(a, b); |
| 116 | } |
| 117 | |
| 118 | static inline __m128 __attribute__((__always_inline__)) _mm_max_ps(__m128 a, __m128 b) |
| 119 | { |
| 120 | return __builtin_ia32_maxps(a, b); |
| 121 | } |
| 122 | |
| 123 | static inline __m128 __attribute__((__always_inline__)) _mm_and_ps(__m128 a, __m128 b) |
| 124 | { |
| 125 | return __builtin_ia32_andps(a, b); |
| 126 | } |
| 127 | |
| 128 | static inline __m128 __attribute__((__always_inline__)) _mm_andnot_ps(__m128 a, __m128 b) |
| 129 | { |
| 130 | return __builtin_ia32_andnps(a, b); |
| 131 | } |
| 132 | |
| 133 | static inline __m128 __attribute__((__always_inline__)) _mm_or_ps(__m128 a, __m128 b) |
| 134 | { |
| 135 | return __builtin_ia32_orps(a, b); |
| 136 | } |
| 137 | |
| 138 | static inline __m128 __attribute__((__always_inline__)) _mm_xor_ps(__m128 a, __m128 b) |
| 139 | { |
| 140 | return __builtin_ia32_xorps(a, b); |
| 141 | } |
| 142 | |
| 143 | #endif /* __SSE__ */ |
| 144 | |
| 145 | #endif /* __XMMINTRIN_H */ |