Benjamin Kramer | 0930b6e | 2010-08-20 16:47:17 +0000 | [diff] [blame] | 1 | /*===---- emmintrin.h - SSE2 intrinsics ------------------------------------=== |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 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 | */ |
Benjamin Kramer | 0930b6e | 2010-08-20 16:47:17 +0000 | [diff] [blame] | 23 | |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 24 | #ifndef __EMMINTRIN_H |
| 25 | #define __EMMINTRIN_H |
| 26 | |
| 27 | #ifndef __SSE2__ |
| 28 | #error "SSE2 instruction set not enabled" |
| 29 | #else |
| 30 | |
| 31 | #include <xmmintrin.h> |
| 32 | |
| 33 | typedef double __m128d __attribute__((__vector_size__(16))); |
| 34 | typedef long long __m128i __attribute__((__vector_size__(16))); |
| 35 | |
Eric Christopher | faf9404 | 2010-08-26 02:09:25 +0000 | [diff] [blame] | 36 | /* Type defines. */ |
| 37 | typedef double __v2df __attribute__ ((__vector_size__ (16))); |
| 38 | typedef long long __v2di __attribute__ ((__vector_size__ (16))); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 39 | typedef short __v8hi __attribute__((__vector_size__(16))); |
Anders Carlsson | 4bf4e30 | 2009-09-18 19:18:19 +0000 | [diff] [blame] | 40 | typedef char __v16qi __attribute__((__vector_size__(16))); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 41 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 42 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 43 | _mm_add_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 44 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 45 | __a[0] += __b[0]; |
| 46 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 49 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 50 | _mm_add_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 51 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 52 | return __a + __b; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 55 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 56 | _mm_sub_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 57 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 58 | __a[0] -= __b[0]; |
| 59 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 62 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 63 | _mm_sub_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 64 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 65 | return __a - __b; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 68 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 69 | _mm_mul_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 70 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 71 | __a[0] *= __b[0]; |
| 72 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 75 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 76 | _mm_mul_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 77 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 78 | return __a * __b; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 81 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 82 | _mm_div_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 83 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 84 | __a[0] /= __b[0]; |
| 85 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 88 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 89 | _mm_div_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 90 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 91 | return __a / __b; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 94 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 95 | _mm_sqrt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 96 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 97 | __m128d __c = __builtin_ia32_sqrtsd(__b); |
| 98 | return (__m128d) { __c[0], __a[1] }; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 101 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 102 | _mm_sqrt_pd(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 103 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 104 | return __builtin_ia32_sqrtpd(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 107 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 108 | _mm_min_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 109 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 110 | return __builtin_ia32_minsd(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 113 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 114 | _mm_min_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 115 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 116 | return __builtin_ia32_minpd(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 117 | } |
| 118 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 119 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 120 | _mm_max_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 121 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 122 | return __builtin_ia32_maxsd(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 125 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 126 | _mm_max_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 127 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 128 | return __builtin_ia32_maxpd(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 131 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 132 | _mm_and_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 133 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 134 | return (__m128d)((__v4si)__a & (__v4si)__b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 137 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 138 | _mm_andnot_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 139 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 140 | return (__m128d)(~(__v4si)__a & (__v4si)__b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 143 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 144 | _mm_or_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 145 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 146 | return (__m128d)((__v4si)__a | (__v4si)__b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 149 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 150 | _mm_xor_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 151 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 152 | return (__m128d)((__v4si)__a ^ (__v4si)__b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 155 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 156 | _mm_cmpeq_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 157 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 158 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 0); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 161 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 162 | _mm_cmplt_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 163 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 164 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 167 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 168 | _mm_cmple_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 169 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 170 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 173 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 174 | _mm_cmpgt_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 175 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 176 | return (__m128d)__builtin_ia32_cmppd(__b, __a, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 179 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 180 | _mm_cmpge_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 181 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 182 | return (__m128d)__builtin_ia32_cmppd(__b, __a, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 185 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 186 | _mm_cmpord_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 187 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 188 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 7); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 191 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 192 | _mm_cmpunord_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 193 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 194 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 3); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 195 | } |
| 196 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 197 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 198 | _mm_cmpneq_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 199 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 200 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 4); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 203 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 204 | _mm_cmpnlt_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 205 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 206 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 209 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 210 | _mm_cmpnle_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 211 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 212 | return (__m128d)__builtin_ia32_cmppd(__a, __b, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 215 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 216 | _mm_cmpngt_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 217 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 218 | return (__m128d)__builtin_ia32_cmppd(__b, __a, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 221 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 222 | _mm_cmpnge_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 223 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 224 | return (__m128d)__builtin_ia32_cmppd(__b, __a, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 227 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 228 | _mm_cmpeq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 229 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 230 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 0); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 231 | } |
| 232 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 233 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 234 | _mm_cmplt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 235 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 236 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 239 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 240 | _mm_cmple_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 241 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 242 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 245 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 246 | _mm_cmpgt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 247 | { |
Manman Ren | 492d84c0 | 2013-06-17 19:42:49 +0000 | [diff] [blame] | 248 | __m128d __c = __builtin_ia32_cmpsd(__b, __a, 1); |
| 249 | return (__m128d) { __c[0], __a[1] }; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 252 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 253 | _mm_cmpge_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 254 | { |
Manman Ren | 492d84c0 | 2013-06-17 19:42:49 +0000 | [diff] [blame] | 255 | __m128d __c = __builtin_ia32_cmpsd(__b, __a, 2); |
| 256 | return (__m128d) { __c[0], __a[1] }; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 259 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 260 | _mm_cmpord_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 261 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 262 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 7); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 263 | } |
| 264 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 265 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 266 | _mm_cmpunord_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 267 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 268 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 3); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 271 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 272 | _mm_cmpneq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 273 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 274 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 4); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 275 | } |
| 276 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 277 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 278 | _mm_cmpnlt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 279 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 280 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 283 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 284 | _mm_cmpnle_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 285 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 286 | return (__m128d)__builtin_ia32_cmpsd(__a, __b, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 289 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 290 | _mm_cmpngt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 291 | { |
Manman Ren | 492d84c0 | 2013-06-17 19:42:49 +0000 | [diff] [blame] | 292 | __m128d __c = __builtin_ia32_cmpsd(__b, __a, 5); |
| 293 | return (__m128d) { __c[0], __a[1] }; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 296 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 297 | _mm_cmpnge_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 298 | { |
Manman Ren | 492d84c0 | 2013-06-17 19:42:49 +0000 | [diff] [blame] | 299 | __m128d __c = __builtin_ia32_cmpsd(__b, __a, 6); |
| 300 | return (__m128d) { __c[0], __a[1] }; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 301 | } |
| 302 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 303 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 304 | _mm_comieq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 305 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 306 | return __builtin_ia32_comisdeq(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 307 | } |
| 308 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 309 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 310 | _mm_comilt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 311 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 312 | return __builtin_ia32_comisdlt(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 313 | } |
| 314 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 315 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 316 | _mm_comile_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 317 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 318 | return __builtin_ia32_comisdle(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 321 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 322 | _mm_comigt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 323 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 324 | return __builtin_ia32_comisdgt(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 327 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 328 | _mm_comige_sd(__m128d __a, __m128d __b) |
Eli Friedman | 8052a4f | 2011-10-06 20:31:50 +0000 | [diff] [blame] | 329 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 330 | return __builtin_ia32_comisdge(__a, __b); |
Eli Friedman | 8052a4f | 2011-10-06 20:31:50 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 334 | _mm_comineq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 335 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 336 | return __builtin_ia32_comisdneq(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 339 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 340 | _mm_ucomieq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 341 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 342 | return __builtin_ia32_ucomisdeq(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 345 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 346 | _mm_ucomilt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 347 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 348 | return __builtin_ia32_ucomisdlt(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 349 | } |
| 350 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 351 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 352 | _mm_ucomile_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 353 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 354 | return __builtin_ia32_ucomisdle(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 357 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 358 | _mm_ucomigt_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 359 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 360 | return __builtin_ia32_ucomisdgt(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 363 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 364 | _mm_ucomige_sd(__m128d __a, __m128d __b) |
Eli Friedman | ef534ce | 2011-08-29 21:26:24 +0000 | [diff] [blame] | 365 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 366 | return __builtin_ia32_ucomisdge(__a, __b); |
Eli Friedman | ef534ce | 2011-08-29 21:26:24 +0000 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 370 | _mm_ucomineq_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 371 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 372 | return __builtin_ia32_ucomisdneq(__a, __b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 375 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 376 | _mm_cvtpd_ps(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 377 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 378 | return __builtin_ia32_cvtpd2ps(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 381 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 382 | _mm_cvtps_pd(__m128 __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 383 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 384 | return __builtin_ia32_cvtps2pd(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 387 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 388 | _mm_cvtepi32_pd(__m128i __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 389 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 390 | return __builtin_ia32_cvtdq2pd((__v4si)__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 393 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 394 | _mm_cvtpd_epi32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 395 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 396 | return __builtin_ia32_cvtpd2dq(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 399 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 400 | _mm_cvtsd_si32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 401 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 402 | return __builtin_ia32_cvtsd2si(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 403 | } |
| 404 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 405 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 406 | _mm_cvtsd_ss(__m128 __a, __m128d __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 407 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 408 | __a[0] = __b[0]; |
| 409 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 410 | } |
| 411 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 412 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 413 | _mm_cvtsi32_sd(__m128d __a, int __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 414 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 415 | __a[0] = __b; |
| 416 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 419 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 420 | _mm_cvtss_sd(__m128d __a, __m128 __b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 421 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 422 | __a[0] = __b[0]; |
| 423 | return __a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 424 | } |
| 425 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 426 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 427 | _mm_cvttpd_epi32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 428 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 429 | return (__m128i)__builtin_ia32_cvttpd2dq(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 430 | } |
| 431 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 432 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 433 | _mm_cvttsd_si32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 434 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 435 | return __a[0]; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 436 | } |
| 437 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 438 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 439 | _mm_cvtpd_pi32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 440 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 441 | return (__m64)__builtin_ia32_cvtpd2pi(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 444 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 445 | _mm_cvttpd_pi32(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 446 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 447 | return (__m64)__builtin_ia32_cvttpd2pi(__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 450 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 451 | _mm_cvtpi32_pd(__m64 __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 452 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 453 | return __builtin_ia32_cvtpi2pd((__v2si)__a); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 456 | static __inline__ double __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 457 | _mm_cvtsd_f64(__m128d __a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 458 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 459 | return __a[0]; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 460 | } |
| 461 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 462 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 463 | _mm_load_pd(double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 464 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 465 | return *(__m128d*)__dp; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 466 | } |
| 467 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 468 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 469 | _mm_load1_pd(double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 470 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 471 | struct __mm_load1_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 472 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 473 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 474 | double __u = ((struct __mm_load1_pd_struct*)__dp)->__u; |
| 475 | return (__m128d){ __u, __u }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Eli Friedman | db7351a | 2009-06-02 05:55:48 +0000 | [diff] [blame] | 478 | #define _mm_load_pd1(dp) _mm_load1_pd(dp) |
| 479 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 480 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 481 | _mm_loadr_pd(double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 482 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 483 | __m128d __u = *(__m128d*)__dp; |
| 484 | return __builtin_shufflevector(__u, __u, 1, 0); |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 485 | } |
| 486 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 487 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 488 | _mm_loadu_pd(double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 489 | { |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 490 | struct __loadu_pd { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 491 | __m128d __v; |
Bill Wendling | 8e3ec9c | 2011-05-13 01:24:00 +0000 | [diff] [blame] | 492 | } __attribute__((packed, may_alias)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 493 | return ((struct __loadu_pd*)__dp)->__v; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 496 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 497 | _mm_load_sd(double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 498 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 499 | struct __mm_load_sd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 500 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 501 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 502 | double __u = ((struct __mm_load_sd_struct*)__dp)->__u; |
| 503 | return (__m128d){ __u, 0 }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 506 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 507 | _mm_loadh_pd(__m128d __a, double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 508 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 509 | struct __mm_loadh_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 510 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 511 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 512 | double __u = ((struct __mm_loadh_pd_struct*)__dp)->__u; |
| 513 | return (__m128d){ __a[0], __u }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 514 | } |
| 515 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 516 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 517 | _mm_loadl_pd(__m128d __a, double const *__dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 518 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 519 | struct __mm_loadl_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 520 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 521 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 522 | double __u = ((struct __mm_loadl_pd_struct*)__dp)->__u; |
| 523 | return (__m128d){ __u, __a[1] }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 524 | } |
| 525 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 526 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 527 | _mm_set_sd(double __w) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 528 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 529 | return (__m128d){ __w, 0 }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 530 | } |
| 531 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 532 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 533 | _mm_set1_pd(double __w) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 534 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 535 | return (__m128d){ __w, __w }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 536 | } |
| 537 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 538 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 539 | _mm_set_pd(double __w, double __x) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 540 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 541 | return (__m128d){ __x, __w }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 542 | } |
| 543 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 544 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 545 | _mm_setr_pd(double __w, double __x) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 546 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 547 | return (__m128d){ __w, __x }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 550 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 551 | _mm_setzero_pd(void) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 552 | { |
| 553 | return (__m128d){ 0, 0 }; |
| 554 | } |
| 555 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 556 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 557 | _mm_move_sd(__m128d __a, __m128d __b) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 558 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 559 | return (__m128d){ __b[0], __a[1] }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 560 | } |
| 561 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 562 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 563 | _mm_store_sd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 564 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 565 | struct __mm_store_sd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 566 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 567 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 568 | ((struct __mm_store_sd_struct*)__dp)->__u = __a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 571 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 572 | _mm_store1_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 573 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 574 | struct __mm_store1_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 575 | double __u[2]; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 576 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 577 | ((struct __mm_store1_pd_struct*)__dp)->__u[0] = __a[0]; |
| 578 | ((struct __mm_store1_pd_struct*)__dp)->__u[1] = __a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 579 | } |
| 580 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 581 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 582 | _mm_store_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 583 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 584 | *(__m128d *)__dp = __a; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 585 | } |
| 586 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 587 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 588 | _mm_storeu_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 589 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 590 | __builtin_ia32_storeupd(__dp, __a); |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 591 | } |
| 592 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 593 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 594 | _mm_storer_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 595 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 596 | __a = __builtin_shufflevector(__a, __a, 1, 0); |
| 597 | *(__m128d *)__dp = __a; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 600 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 601 | _mm_storeh_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 602 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 603 | struct __mm_storeh_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 604 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 605 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 606 | ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[1]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 609 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 610 | _mm_storel_pd(double *__dp, __m128d __a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 611 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 612 | struct __mm_storeh_pd_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 613 | double __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 614 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 615 | ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 616 | } |
| 617 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 618 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 619 | _mm_add_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 620 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 621 | return (__m128i)((__v16qi)__a + (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 624 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 625 | _mm_add_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 626 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 627 | return (__m128i)((__v8hi)__a + (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 628 | } |
| 629 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 630 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 631 | _mm_add_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 632 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 633 | return (__m128i)((__v4si)__a + (__v4si)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 636 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 637 | _mm_add_si64(__m64 __a, __m64 __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 638 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 639 | return __a + __b; |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 642 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 643 | _mm_add_epi64(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 644 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 645 | return __a + __b; |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 646 | } |
| 647 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 648 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 649 | _mm_adds_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 650 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 651 | return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 652 | } |
| 653 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 654 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 655 | _mm_adds_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 656 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 657 | return (__m128i)__builtin_ia32_paddsw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 658 | } |
| 659 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 660 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 661 | _mm_adds_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 662 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 663 | return (__m128i)__builtin_ia32_paddusb128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 666 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 667 | _mm_adds_epu16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 668 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 669 | return (__m128i)__builtin_ia32_paddusw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 670 | } |
| 671 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 672 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 673 | _mm_avg_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 674 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 675 | return (__m128i)__builtin_ia32_pavgb128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 676 | } |
| 677 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 678 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 679 | _mm_avg_epu16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 680 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 681 | return (__m128i)__builtin_ia32_pavgw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 682 | } |
| 683 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 684 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 685 | _mm_madd_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 686 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 687 | return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 688 | } |
| 689 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 690 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 691 | _mm_max_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 692 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 693 | return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 696 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 697 | _mm_max_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 698 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 699 | return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 700 | } |
| 701 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 702 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 703 | _mm_min_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 704 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 705 | return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 708 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 709 | _mm_min_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 710 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 711 | return (__m128i)__builtin_ia32_pminub128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 712 | } |
| 713 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 714 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 715 | _mm_mulhi_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 716 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 717 | return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 718 | } |
| 719 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 720 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 721 | _mm_mulhi_epu16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 722 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 723 | return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 724 | } |
| 725 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 726 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 727 | _mm_mullo_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 728 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 729 | return (__m128i)((__v8hi)__a * (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 730 | } |
| 731 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 732 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 733 | _mm_mul_su32(__m64 __a, __m64 __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 734 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 735 | return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 738 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 739 | _mm_mul_epu32(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 740 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 741 | return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 742 | } |
| 743 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 744 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 745 | _mm_sad_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 746 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 747 | return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 748 | } |
| 749 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 750 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 751 | _mm_sub_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 752 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 753 | return (__m128i)((__v16qi)__a - (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 754 | } |
| 755 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 756 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 757 | _mm_sub_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 758 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 759 | return (__m128i)((__v8hi)__a - (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 760 | } |
| 761 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 762 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 763 | _mm_sub_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 764 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 765 | return (__m128i)((__v4si)__a - (__v4si)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 766 | } |
| 767 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 768 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 769 | _mm_sub_si64(__m64 __a, __m64 __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 770 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 771 | return __a - __b; |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 772 | } |
| 773 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 774 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 775 | _mm_sub_epi64(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 776 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 777 | return __a - __b; |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 778 | } |
| 779 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 780 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 781 | _mm_subs_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 782 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 783 | return (__m128i)__builtin_ia32_psubsb128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 784 | } |
| 785 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 786 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 787 | _mm_subs_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 788 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 789 | return (__m128i)__builtin_ia32_psubsw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 790 | } |
| 791 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 792 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 793 | _mm_subs_epu8(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 794 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 795 | return (__m128i)__builtin_ia32_psubusb128((__v16qi)__a, (__v16qi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 796 | } |
| 797 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 798 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 799 | _mm_subs_epu16(__m128i __a, __m128i __b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 800 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 801 | return (__m128i)__builtin_ia32_psubusw128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 802 | } |
| 803 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 804 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 805 | _mm_and_si128(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 806 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 807 | return __a & __b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 808 | } |
| 809 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 810 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 811 | _mm_andnot_si128(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 812 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 813 | return ~__a & __b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 816 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 817 | _mm_or_si128(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 818 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 819 | return __a | __b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 822 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 823 | _mm_xor_si128(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 824 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 825 | return __a ^ __b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 826 | } |
| 827 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 828 | #define _mm_slli_si128(a, count) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 829 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 830 | __m128i __a = (a); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 831 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 832 | (__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); }) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 833 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 834 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 835 | _mm_slli_epi16(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 836 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 837 | return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 838 | } |
| 839 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 840 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 841 | _mm_sll_epi16(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 842 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 843 | return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 844 | } |
| 845 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 846 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 847 | _mm_slli_epi32(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 848 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 849 | return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 850 | } |
| 851 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 852 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 853 | _mm_sll_epi32(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 854 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 855 | return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 856 | } |
| 857 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 858 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 859 | _mm_slli_epi64(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 860 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 861 | return __builtin_ia32_psllqi128(__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 864 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 865 | _mm_sll_epi64(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 866 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 867 | return __builtin_ia32_psllq128(__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 868 | } |
| 869 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 870 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 871 | _mm_srai_epi16(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 872 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 873 | return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 874 | } |
| 875 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 876 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 877 | _mm_sra_epi16(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 878 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 879 | return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 880 | } |
| 881 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 882 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 883 | _mm_srai_epi32(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 884 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 885 | return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 886 | } |
| 887 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 888 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 889 | _mm_sra_epi32(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 890 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 891 | return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 892 | } |
| 893 | |
Chris Lattner | fcb0b25 | 2010-10-01 06:58:49 +0000 | [diff] [blame] | 894 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 895 | #define _mm_srli_si128(a, count) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 896 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 897 | __m128i __a = (a); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 898 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 899 | (__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); }) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 900 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 901 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 902 | _mm_srli_epi16(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 903 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 904 | return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 905 | } |
| 906 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 907 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 908 | _mm_srl_epi16(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 909 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 910 | return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 913 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 914 | _mm_srli_epi32(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 915 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 916 | return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 917 | } |
| 918 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 919 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 920 | _mm_srl_epi32(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 921 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 922 | return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 923 | } |
| 924 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 925 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 926 | _mm_srli_epi64(__m128i __a, int __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 927 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 928 | return __builtin_ia32_psrlqi128(__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 931 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 932 | _mm_srl_epi64(__m128i __a, __m128i __count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 933 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 934 | return __builtin_ia32_psrlq128(__a, __count); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 937 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 938 | _mm_cmpeq_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 939 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 940 | return (__m128i)((__v16qi)__a == (__v16qi)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 941 | } |
| 942 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 943 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 944 | _mm_cmpeq_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 945 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 946 | return (__m128i)((__v8hi)__a == (__v8hi)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 947 | } |
| 948 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 949 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 950 | _mm_cmpeq_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 951 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 952 | return (__m128i)((__v4si)__a == (__v4si)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 953 | } |
| 954 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 955 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 956 | _mm_cmpgt_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 957 | { |
Nick Lewycky | 279114c | 2012-02-04 02:16:48 +0000 | [diff] [blame] | 958 | /* This function always performs a signed comparison, but __v16qi is a char |
| 959 | which may be signed or unsigned. */ |
Nick Lewycky | f42f85c | 2012-02-03 23:57:48 +0000 | [diff] [blame] | 960 | typedef signed char __v16qs __attribute__((__vector_size__(16))); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 961 | return (__m128i)((__v16qs)__a > (__v16qs)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 962 | } |
| 963 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 964 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 965 | _mm_cmpgt_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 966 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 967 | return (__m128i)((__v8hi)__a > (__v8hi)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 968 | } |
| 969 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 970 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 971 | _mm_cmpgt_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 972 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 973 | return (__m128i)((__v4si)__a > (__v4si)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 974 | } |
| 975 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 976 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 977 | _mm_cmplt_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 978 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 979 | return _mm_cmpgt_epi8(__b, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 980 | } |
| 981 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 982 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 983 | _mm_cmplt_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 984 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 985 | return _mm_cmpgt_epi16(__b, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 986 | } |
| 987 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 988 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 989 | _mm_cmplt_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 990 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 991 | return _mm_cmpgt_epi32(__b, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 995 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 996 | _mm_cvtsi64_sd(__m128d __a, long long __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 997 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 998 | __a[0] = __b; |
| 999 | return __a; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1002 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1003 | _mm_cvtsd_si64(__m128d __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1004 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1005 | return __builtin_ia32_cvtsd2si64(__a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1006 | } |
| 1007 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1008 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1009 | _mm_cvttsd_si64(__m128d __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1010 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1011 | return __a[0]; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1012 | } |
| 1013 | #endif |
| 1014 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1015 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1016 | _mm_cvtepi32_ps(__m128i __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1017 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1018 | return __builtin_ia32_cvtdq2ps((__v4si)__a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1021 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1022 | _mm_cvtps_epi32(__m128 __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1023 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1024 | return (__m128i)__builtin_ia32_cvtps2dq(__a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1027 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1028 | _mm_cvttps_epi32(__m128 __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1029 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1030 | return (__m128i)__builtin_ia32_cvttps2dq(__a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1033 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1034 | _mm_cvtsi32_si128(int __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1035 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1036 | return (__m128i)(__v4si){ __a, 0, 0, 0 }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1040 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1041 | _mm_cvtsi64_si128(long long __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1042 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1043 | return (__m128i){ __a, 0 }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1044 | } |
| 1045 | #endif |
| 1046 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1047 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1048 | _mm_cvtsi128_si32(__m128i __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1049 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1050 | __v4si __b = (__v4si)__a; |
| 1051 | return __b[0]; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1055 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1056 | _mm_cvtsi128_si64(__m128i __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1057 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1058 | return __a[0]; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1059 | } |
| 1060 | #endif |
| 1061 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1062 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1063 | _mm_load_si128(__m128i const *__p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1064 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1065 | return *__p; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1068 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1069 | _mm_loadu_si128(__m128i const *__p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1070 | { |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 1071 | struct __loadu_si128 { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1072 | __m128i __v; |
Bill Wendling | 8e3ec9c | 2011-05-13 01:24:00 +0000 | [diff] [blame] | 1073 | } __attribute__((packed, may_alias)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1074 | return ((struct __loadu_si128*)__p)->__v; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1077 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1078 | _mm_loadl_epi64(__m128i const *__p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1079 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 1080 | struct __mm_loadl_epi64_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1081 | long long __u; |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 1082 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1083 | return (__m128i) { ((struct __mm_loadl_epi64_struct*)__p)->__u, 0}; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1086 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 1087 | _mm_set_epi64x(long long q1, long long q0) |
| 1088 | { |
| 1089 | return (__m128i){ q0, q1 }; |
| 1090 | } |
| 1091 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1092 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1093 | _mm_set_epi64(__m64 q1, __m64 q0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1094 | { |
| 1095 | return (__m128i){ (long long)q0, (long long)q1 }; |
| 1096 | } |
| 1097 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1098 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1099 | _mm_set_epi32(int i3, int i2, int i1, int i0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1100 | { |
| 1101 | return (__m128i)(__v4si){ i0, i1, i2, i3}; |
| 1102 | } |
| 1103 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1104 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1105 | _mm_set_epi16(short w7, short w6, short w5, short w4, short w3, short w2, short w1, short w0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1106 | { |
| 1107 | return (__m128i)(__v8hi){ w0, w1, w2, w3, w4, w5, w6, w7 }; |
| 1108 | } |
| 1109 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1110 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1111 | _mm_set_epi8(char b15, char b14, char b13, char b12, char b11, char b10, char b9, char b8, char b7, char b6, char b5, char b4, char b3, char b2, char b1, char b0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1112 | { |
| 1113 | return (__m128i)(__v16qi){ b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15 }; |
| 1114 | } |
| 1115 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1116 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1117 | _mm_set1_epi64x(long long __q) |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 1118 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1119 | return (__m128i){ __q, __q }; |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 1120 | } |
| 1121 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1122 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1123 | _mm_set1_epi64(__m64 __q) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1124 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1125 | return (__m128i){ (long long)__q, (long long)__q }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1128 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1129 | _mm_set1_epi32(int __i) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1130 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1131 | return (__m128i)(__v4si){ __i, __i, __i, __i }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1134 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1135 | _mm_set1_epi16(short __w) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1136 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1137 | return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1138 | } |
| 1139 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1140 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1141 | _mm_set1_epi8(char __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1142 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1143 | return (__m128i)(__v16qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b }; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1146 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1147 | _mm_setr_epi64(__m64 q0, __m64 q1) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1148 | { |
| 1149 | return (__m128i){ (long long)q0, (long long)q1 }; |
| 1150 | } |
| 1151 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1152 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1153 | _mm_setr_epi32(int i0, int i1, int i2, int i3) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1154 | { |
| 1155 | return (__m128i)(__v4si){ i0, i1, i2, i3}; |
| 1156 | } |
| 1157 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1158 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1159 | _mm_setr_epi16(short w0, short w1, short w2, short w3, short w4, short w5, short w6, short w7) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1160 | { |
| 1161 | return (__m128i)(__v8hi){ w0, w1, w2, w3, w4, w5, w6, w7 }; |
| 1162 | } |
| 1163 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1164 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1165 | _mm_setr_epi8(char b0, char b1, char b2, char b3, char b4, char b5, char b6, char b7, char b8, char b9, char b10, char b11, char b12, char b13, char b14, char b15) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1166 | { |
| 1167 | return (__m128i)(__v16qi){ b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15 }; |
| 1168 | } |
| 1169 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1170 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1171 | _mm_setzero_si128(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1172 | { |
| 1173 | return (__m128i){ 0LL, 0LL }; |
| 1174 | } |
| 1175 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1176 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1177 | _mm_store_si128(__m128i *__p, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1178 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1179 | *__p = __b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1180 | } |
| 1181 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1182 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1183 | _mm_storeu_si128(__m128i *__p, __m128i __b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1184 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1185 | __builtin_ia32_storedqu((char *)__p, (__v16qi)__b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1186 | } |
| 1187 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1188 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1189 | _mm_maskmoveu_si128(__m128i __d, __m128i __n, char *__p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1190 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1191 | __builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1194 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1195 | _mm_storel_epi64(__m128i *__p, __m128i __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1196 | { |
Chad Rosier | c5713cf | 2012-05-01 18:11:51 +0000 | [diff] [blame] | 1197 | struct __mm_storel_epi64_struct { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1198 | long long __u; |
Chad Rosier | c5713cf | 2012-05-01 18:11:51 +0000 | [diff] [blame] | 1199 | } __attribute__((__packed__, __may_alias__)); |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1200 | ((struct __mm_storel_epi64_struct*)__p)->__u = __a[0]; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1203 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1204 | _mm_stream_pd(double *__p, __m128d __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1205 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1206 | __builtin_ia32_movntpd(__p, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1209 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1210 | _mm_stream_si128(__m128i *__p, __m128i __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1211 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1212 | __builtin_ia32_movntdq(__p, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1213 | } |
| 1214 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1215 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1216 | _mm_stream_si32(int *__p, int __a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1217 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1218 | __builtin_ia32_movnti(__p, __a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1219 | } |
| 1220 | |
Eli Friedman | 440a5f4 | 2013-09-23 23:38:39 +0000 | [diff] [blame] | 1221 | #ifdef __x86_64__ |
| 1222 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
| 1223 | _mm_stream_si64(long long *__p, long long __a) |
| 1224 | { |
| 1225 | __builtin_ia32_movnti64(__p, __a); |
| 1226 | } |
| 1227 | #endif |
| 1228 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1229 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1230 | _mm_clflush(void const *__p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1231 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1232 | __builtin_ia32_clflush(__p); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1235 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1236 | _mm_lfence(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1237 | { |
| 1238 | __builtin_ia32_lfence(); |
| 1239 | } |
| 1240 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1241 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1242 | _mm_mfence(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1243 | { |
| 1244 | __builtin_ia32_mfence(); |
| 1245 | } |
| 1246 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1247 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1248 | _mm_packs_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1249 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1250 | return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1253 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1254 | _mm_packs_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1255 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1256 | return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1259 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1260 | _mm_packus_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1261 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1262 | return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1265 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1266 | _mm_extract_epi16(__m128i __a, int __imm) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1267 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1268 | __v8hi __b = (__v8hi)__a; |
| 1269 | return (unsigned short)__b[__imm]; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1272 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1273 | _mm_insert_epi16(__m128i __a, int __b, int __imm) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1274 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1275 | __v8hi __c = (__v8hi)__a; |
| 1276 | __c[__imm & 7] = __b; |
| 1277 | return (__m128i)__c; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1278 | } |
| 1279 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1280 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1281 | _mm_movemask_epi8(__m128i __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1282 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1283 | return __builtin_ia32_pmovmskb128((__v16qi)__a); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1284 | } |
| 1285 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1286 | #define _mm_shuffle_epi32(a, imm) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1287 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1288 | __m128i __a = (a); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1289 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1290 | (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si) _mm_set1_epi32(0), \ |
| 1291 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ |
| 1292 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); }) |
Chris Lattner | 85e59d7 | 2011-04-25 20:42:40 +0000 | [diff] [blame] | 1293 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1294 | #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1295 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1296 | __m128i __a = (a); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1297 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1298 | (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ |
| 1299 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ |
| 1300 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ |
| 1301 | 4, 5, 6, 7); }) |
Chris Lattner | 85e59d7 | 2011-04-25 20:42:40 +0000 | [diff] [blame] | 1302 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1303 | #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1304 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1305 | __m128i __a = (a); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1306 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1307 | (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ |
| 1308 | 0, 1, 2, 3, \ |
| 1309 | 4 + (((imm) & 0x03) >> 0), \ |
| 1310 | 4 + (((imm) & 0x0c) >> 2), \ |
| 1311 | 4 + (((imm) & 0x30) >> 4), \ |
| 1312 | 4 + (((imm) & 0xc0) >> 6)); }) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1313 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1314 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1315 | _mm_unpackhi_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1316 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1317 | return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1318 | } |
| 1319 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1320 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1321 | _mm_unpackhi_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1322 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1323 | return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1324 | } |
| 1325 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1326 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1327 | _mm_unpackhi_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1328 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1329 | return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4+2, 3, 4+3); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1330 | } |
| 1331 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1332 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1333 | _mm_unpackhi_epi64(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1334 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1335 | return (__m128i)__builtin_shufflevector(__a, __b, 1, 2+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1336 | } |
| 1337 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1338 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1339 | _mm_unpacklo_epi8(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1340 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1341 | return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1342 | } |
| 1343 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1344 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1345 | _mm_unpacklo_epi16(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1346 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1347 | return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1348 | } |
| 1349 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1350 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1351 | _mm_unpacklo_epi32(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1352 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1353 | return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4+0, 1, 4+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1354 | } |
| 1355 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1356 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1357 | _mm_unpacklo_epi64(__m128i __a, __m128i __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1358 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1359 | return (__m128i)__builtin_shufflevector(__a, __b, 0, 2+0); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1362 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1363 | _mm_movepi64_pi64(__m128i __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1364 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1365 | return (__m64)__a[0]; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1366 | } |
| 1367 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1368 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1369 | _mm_movpi64_pi64(__m64 __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1370 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1371 | return (__m128i){ (long long)__a, 0 }; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1372 | } |
| 1373 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1374 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1375 | _mm_move_epi64(__m128i __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1376 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1377 | return __builtin_shufflevector(__a, (__m128i){ 0 }, 0, 2); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1378 | } |
| 1379 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1380 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1381 | _mm_unpackhi_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1382 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1383 | return __builtin_shufflevector(__a, __b, 1, 2+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1384 | } |
| 1385 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1386 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1387 | _mm_unpacklo_pd(__m128d __a, __m128d __b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1388 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1389 | return __builtin_shufflevector(__a, __b, 0, 2+0); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1392 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1393 | _mm_movemask_pd(__m128d __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1394 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1395 | return __builtin_ia32_movmskpd(__a); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1396 | } |
| 1397 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1398 | #define _mm_shuffle_pd(a, b, i) __extension__ ({ \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1399 | _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1400 | __m128d __a = (a); \ |
| 1401 | __m128d __b = (b); \ |
Ted Kremenek | 185f156 | 2013-10-07 23:51:11 +0000 | [diff] [blame] | 1402 | _Pragma("clang diagnostic pop"); \ |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1403 | __builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); }) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1404 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1405 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1406 | _mm_castpd_ps(__m128d __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1407 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1408 | return (__m128)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1409 | } |
| 1410 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1411 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1412 | _mm_castpd_si128(__m128d __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1413 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1414 | return (__m128i)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1415 | } |
| 1416 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1417 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1418 | _mm_castps_pd(__m128 __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1419 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1420 | return (__m128d)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1421 | } |
| 1422 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1423 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1424 | _mm_castps_si128(__m128 __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1425 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1426 | return (__m128i)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1427 | } |
| 1428 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1429 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1430 | _mm_castsi128_ps(__m128i __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1431 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1432 | return (__m128)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1433 | } |
| 1434 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1435 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1436 | _mm_castsi128_pd(__m128i __a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1437 | { |
Reid Kleckner | f0cdc84 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1438 | return (__m128d)__a; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1439 | } |
| 1440 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1441 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1442 | _mm_pause(void) |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1443 | { |
Anders Carlsson | 4bcd44d | 2008-12-26 02:22:10 +0000 | [diff] [blame] | 1444 | __asm__ volatile ("pause"); |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1445 | } |
| 1446 | |
Anders Carlsson | bbd1fa2 | 2009-01-21 01:49:39 +0000 | [diff] [blame] | 1447 | #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y)) |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1448 | |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 1449 | #endif /* __SSE2__ */ |
| 1450 | |
| 1451 | #endif /* __EMMINTRIN_H */ |