1566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson/*===---- xmmintrin.h - SSE intrinsics -------------------------------------===
2566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson *
3566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * Permission is hereby granted, free of charge, to any person obtaining a copy
4566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * of this software and associated documentation files (the "Software"), to deal
5566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * in the Software without restriction, including without limitation the rights
6566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * copies of the Software, and to permit persons to whom the Software is
8566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * furnished to do so, subject to the following conditions:
9566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson *
10566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * The above copyright notice and this permission notice shall be included in
11566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * all copies or substantial portions of the Software.
12566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson *
13566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson * THE SOFTWARE.
20566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson *
21566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson *===-----------------------------------------------------------------------===
22566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson */
23566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
24566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#ifndef __XMMINTRIN_H
25566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#define __XMMINTRIN_H
26566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
27566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#ifndef __SSE__
284fd3e63cb043cbd140a3e8028374bd2e4312b90eAnders Carlsson#error "SSE instruction set not enabled"
29566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#else
30566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
314fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson#include <mmintrin.h>
324fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
33020f1ed8a97a630780f6aca8a6d6515ca7717ea9Eric Christophertypedef int __v4si __attribute__((__vector_size__(16)));
34398082e33c6d2e3c22733b1444228ea4b10b353fAnders Carlssontypedef float __v4sf __attribute__((__vector_size__(16)));
35566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlssontypedef float __m128 __attribute__((__vector_size__(16)));
36566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
377acb953031bed92c7420aaf1200d6732239e562eChandler Carruth// This header should only be included in a hosted environment as it depends on
387acb953031bed92c7420aaf1200d6732239e562eChandler Carruth// a standard library to provide allocation routines.
397acb953031bed92c7420aaf1200d6732239e562eChandler Carruth#if __STDC_HOSTED__
40398082e33c6d2e3c22733b1444228ea4b10b353fAnders Carlsson#include <mm_malloc.h>
417acb953031bed92c7420aaf1200d6732239e562eChandler Carruth#endif
42398082e33c6d2e3c22733b1444228ea4b10b353fAnders Carlsson
431bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
444f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_add_ss(__m128 __a, __m128 __b)
45566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
464f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] += __b[0];
474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
48566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
49566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
501bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
514f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_add_ps(__m128 __a, __m128 __b)
52566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a + __b;
54566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
55566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
561bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
574f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_sub_ss(__m128 __a, __m128 __b)
58566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] -= __b[0];
604f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
61566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
62566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
631bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
644f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_sub_ps(__m128 __a, __m128 __b)
65566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
664f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a - __b;
67566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
68566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
691bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
704f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_mul_ss(__m128 __a, __m128 __b)
71566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
724f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] *= __b[0];
734f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
74566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
75566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
761bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_mul_ps(__m128 __a, __m128 __b)
78566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
794f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a * __b;
80566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
81566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
821bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_div_ss(__m128 __a, __m128 __b)
84566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
854f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] /= __b[0];
864f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
87566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
88566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
891bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
904f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_div_ps(__m128 __a, __m128 __b)
91566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
924f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a / __b;
93566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
94566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
951bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
964f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_sqrt_ss(__m128 __a)
97566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
984f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __c = __builtin_ia32_sqrtss(__a);
994f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
100566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
101566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1021bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1034f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_sqrt_ps(__m128 __a)
104566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1054f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_sqrtps(__a);
106566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
107566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1081bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1094f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_rcp_ss(__m128 __a)
110566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1114f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __c = __builtin_ia32_rcpss(__a);
1124f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
113566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
114566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1151bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1164f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_rcp_ps(__m128 __a)
117566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1184f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_rcpps(__a);
119566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
120566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1211bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1224f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_rsqrt_ss(__m128 __a)
123566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1244f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __c = __builtin_ia32_rsqrtss(__a);
1254f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
126566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
127566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1281bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1294f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_rsqrt_ps(__m128 __a)
130566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1314f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_rsqrtps(__a);
132566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
133566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1341bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1354f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_min_ss(__m128 __a, __m128 __b)
136566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1374f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_minss(__a, __b);
138566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
139566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1401bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1414f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_min_ps(__m128 __a, __m128 __b)
142566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1434f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_minps(__a, __b);
144566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
145566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1461bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_max_ss(__m128 __a, __m128 __b)
148566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_maxss(__a, __b);
150566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
151566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1521bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_max_ps(__m128 __a, __m128 __b)
154566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_maxps(__a, __b);
156566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
157566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1581bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_and_ps(__m128 __a, __m128 __b)
160566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1614f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)((__v4si)__a & (__v4si)__b);
162566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
163566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1641bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_andnot_ps(__m128 __a, __m128 __b)
166566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)(~(__v4si)__a & (__v4si)__b);
168566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
169566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1701bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1714f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_or_ps(__m128 __a, __m128 __b)
172566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1734f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)((__v4si)__a | (__v4si)__b);
174566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
175566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1761bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_xor_ps(__m128 __a, __m128 __b)
178566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson{
1794f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)((__v4si)__a ^ (__v4si)__b);
180566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson}
181566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1821bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpeq_ss(__m128 __a, __m128 __b)
184f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
1854f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 0);
186f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
187f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
1881bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1894f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpeq_ps(__m128 __a, __m128 __b)
190f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
1914f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 0);
192f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
193f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
1941bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
1954f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmplt_ss(__m128 __a, __m128 __b)
196f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
1974f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 1);
198f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
199f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2001bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2014f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmplt_ps(__m128 __a, __m128 __b)
202f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2034f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 1);
204f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
205f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2061bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2074f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmple_ss(__m128 __a, __m128 __b)
208f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2094f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 2);
210f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
211f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2121bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2134f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmple_ps(__m128 __a, __m128 __b)
214f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2154f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 2);
216f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
217f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2181bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2194f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpgt_ss(__m128 __a, __m128 __b)
220f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
221492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren  return (__m128)__builtin_shufflevector(__a,
222492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         __builtin_ia32_cmpss(__b, __a, 1),
223492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         4, 1, 2, 3);
224f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
225f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2261bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2274f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpgt_ps(__m128 __a, __m128 __b)
228f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2294f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__b, __a, 1);
230f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
231f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2321bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2334f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpge_ss(__m128 __a, __m128 __b)
234f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
235492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren  return (__m128)__builtin_shufflevector(__a,
236492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         __builtin_ia32_cmpss(__b, __a, 2),
237492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         4, 1, 2, 3);
238f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
239f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2401bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2414f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpge_ps(__m128 __a, __m128 __b)
242f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2434f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__b, __a, 2);
244f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
245f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2461bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpneq_ss(__m128 __a, __m128 __b)
248f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 4);
250f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
251f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2521bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpneq_ps(__m128 __a, __m128 __b)
254f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 4);
256f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
257f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2581bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnlt_ss(__m128 __a, __m128 __b)
260f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2614f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 5);
262f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
263f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2641bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnlt_ps(__m128 __a, __m128 __b)
266f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 5);
268f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
269f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2701bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2714f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnle_ss(__m128 __a, __m128 __b)
272f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2734f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 6);
274f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
275f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2761bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnle_ps(__m128 __a, __m128 __b)
278f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2794f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 6);
280f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
281f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2821bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpngt_ss(__m128 __a, __m128 __b)
284f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
285492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren  return (__m128)__builtin_shufflevector(__a,
286492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         __builtin_ia32_cmpss(__b, __a, 5),
287492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         4, 1, 2, 3);
288f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
289f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2901bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2914f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpngt_ps(__m128 __a, __m128 __b)
292f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
2934f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__b, __a, 5);
294f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
295f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
2961bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
2974f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnge_ss(__m128 __a, __m128 __b)
298f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
299492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren  return (__m128)__builtin_shufflevector(__a,
300492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         __builtin_ia32_cmpss(__b, __a, 6),
301492d84c0f737840d6ff8f894879405dacb3dd88bManman Ren                                         4, 1, 2, 3);
302f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
303f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3041bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
3054f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpnge_ps(__m128 __a, __m128 __b)
306f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3074f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__b, __a, 6);
308f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
309f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3101bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
3114f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpord_ss(__m128 __a, __m128 __b)
312f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3134f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 7);
314f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
315f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3161bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
3174f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpord_ps(__m128 __a, __m128 __b)
318f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3194f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 7);
320f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
321f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3221bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
3234f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpunord_ss(__m128 __a, __m128 __b)
324f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3254f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpss(__a, __b, 3);
326f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
327f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3281bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
3294f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cmpunord_ps(__m128 __a, __m128 __b)
330f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3314f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128)__builtin_ia32_cmpps(__a, __b, 3);
332f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
333f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3341bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3354f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comieq_ss(__m128 __a, __m128 __b)
336f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3374f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comieq(__a, __b);
338f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
339f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3401bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3414f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comilt_ss(__m128 __a, __m128 __b)
342f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3434f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comilt(__a, __b);
344f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
345f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3461bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comile_ss(__m128 __a, __m128 __b)
348f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comile(__a, __b);
350f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
351f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3521bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comigt_ss(__m128 __a, __m128 __b)
354f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comigt(__a, __b);
356f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
357f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3581bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comige_ss(__m128 __a, __m128 __b)
360f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3614f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comige(__a, __b);
362f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
363f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3641bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_comineq_ss(__m128 __a, __m128 __b)
366f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_comineq(__a, __b);
368f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
369f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3701bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3714f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomieq_ss(__m128 __a, __m128 __b)
372f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3734f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomieq(__a, __b);
374f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
375f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3761bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomilt_ss(__m128 __a, __m128 __b)
378f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3794f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomilt(__a, __b);
380f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
381f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3821bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomile_ss(__m128 __a, __m128 __b)
384f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3854f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomile(__a, __b);
386f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
387f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3881bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3894f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomigt_ss(__m128 __a, __m128 __b)
390f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3914f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomigt(__a, __b);
392f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
393f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
3941bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3954f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomige_ss(__m128 __a, __m128 __b)
396f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
3974f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomige(__a, __b);
398f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
399f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
4001bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
4014f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_ucomineq_ss(__m128 __a, __m128 __b)
402f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson{
4034f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_ucomineq(__a, __b);
404f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson}
405f62c68183984016e9f7356096e47cc7156534b9cAnders Carlsson
4061bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
4074f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtss_si32(__m128 __a)
4084fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4094f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_cvtss2si(__a);
4104fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4114fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
4121bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
4134f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvt_ss2si(__m128 __a)
414ef5ebf60c86813151e3a29768546d25927183021Chris Lattner{
4154f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtss_si32(__a);
416ef5ebf60c86813151e3a29768546d25927183021Chris Lattner}
417ef5ebf60c86813151e3a29768546d25927183021Chris Lattner
41880c800465865aa15ec4b094407170c149ce344cdEli Friedman#ifdef __x86_64__
41980c800465865aa15ec4b094407170c149ce344cdEli Friedman
4201bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ long long __attribute__((__always_inline__, __nodebug__))
4214f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtss_si64(__m128 __a)
4224fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4234f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_cvtss2si64(__a);
4244fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4254fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
42680c800465865aa15ec4b094407170c149ce344cdEli Friedman#endif
42780c800465865aa15ec4b094407170c149ce344cdEli Friedman
4281bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
4294f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtps_pi32(__m128 __a)
4304fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4314f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_cvtps2pi(__a);
4324fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4334fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
434fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruthstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
4354f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvt_ps2pi(__m128 __a)
436fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth{
4374f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtps_pi32(__a);
438fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth}
439fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
4401bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
4414f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvttss_si32(__m128 __a)
4424fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4434f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a[0];
4444fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4454fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
4461bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
4474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtt_ss2si(__m128 __a)
448ef5ebf60c86813151e3a29768546d25927183021Chris Lattner{
4494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvttss_si32(__a);
450ef5ebf60c86813151e3a29768546d25927183021Chris Lattner}
451ef5ebf60c86813151e3a29768546d25927183021Chris Lattner
4521bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ long long __attribute__((__always_inline__, __nodebug__))
4534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvttss_si64(__m128 __a)
4544fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a[0];
4564fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4574fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
4581bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
4594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvttps_pi32(__m128 __a)
4604fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4614f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_cvttps2pi(__a);
4624fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4634fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
464fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruthstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
4654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtt_ps2pi(__m128 __a)
466fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth{
4674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvttps_pi32(__a);
468fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth}
469fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
4701bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
4714f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtsi32_ss(__m128 __a, int __b)
4724fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4734f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] = __b;
4744f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
4754fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4764fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
477fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruthstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
4784f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvt_si2ss(__m128 __a, int __b)
479fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth{
4804f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtsi32_ss(__a, __b);
481fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth}
482fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
4831b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson#ifdef __x86_64__
4841b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson
4851bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
4864f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtsi64_ss(__m128 __a, long long __b)
4874fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4884f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a[0] = __b;
4894f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a;
4904fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4914fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
4921b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson#endif
4931b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson
4941bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
4954f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpi32_ps(__m128 __a, __m64 __b)
4964fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson{
4974f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_cvtpi2ps(__a, (__v2si)__b);
4984fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson}
4994fcc313c624bcad3e6ae79a8507c58ec5b02a8deAnders Carlsson
500fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruthstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5014f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvt_pi2ps(__m128 __a, __m64 __b)
502fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth{
5034f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtpi32_ps(__a, __b);
504fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth}
505fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
5061bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ float __attribute__((__always_inline__, __nodebug__))
5074f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtss_f32(__m128 __a)
5081b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson{
5094f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __a[0];
5101b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson}
5111b76b80f7509657e9f5b68ccac50033a6afbb684Anders Carlsson
5121bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5134f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_loadh_pi(__m128 __a, const __m64 *__p)
5149770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5157c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  typedef float __mm_loadh_pi_v2f32 __attribute__((__vector_size__(8)));
5167c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  struct __mm_loadh_pi_struct {
5174f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    __mm_loadh_pi_v2f32 __u;
5187c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
5194f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __mm_loadh_pi_v2f32 __b = ((struct __mm_loadh_pi_struct*)__p)->__u;
5204f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
5214f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
5229770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5239770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5241bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5254f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_loadl_pi(__m128 __a, const __m64 *__p)
5269770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5277c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  typedef float __mm_loadl_pi_v2f32 __attribute__((__vector_size__(8)));
5287c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  struct __mm_loadl_pi_struct {
5294f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    __mm_loadl_pi_v2f32 __u;
5307c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
5314f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __mm_loadl_pi_v2f32 __b = ((struct __mm_loadl_pi_struct*)__p)->__u;
5324f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
5334f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
5349770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5359770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5361bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5374f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_load_ss(const float *__p)
5389770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5397c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  struct __mm_load_ss_struct {
5404f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    float __u;
5417c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
5424f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  float __u = ((struct __mm_load_ss_struct*)__p)->__u;
5434f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __u, 0, 0, 0 };
5449770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5459770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5461bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_load1_ps(const float *__p)
5489770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5497c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  struct __mm_load1_ps_struct {
5504f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    float __u;
5517c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
5524f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  float __u = ((struct __mm_load1_ps_struct*)__p)->__u;
5534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __u, __u, __u, __u };
5549770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5559770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
556db7351af8e9f9b46075e62137a29a84c666404b2Eli Friedman#define        _mm_load_ps1(p) _mm_load1_ps(p)
557db7351af8e9f9b46075e62137a29a84c666404b2Eli Friedman
5581bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_load_ps(const float *__p)
5609770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5614f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return *(__m128*)__p;
5629770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5639770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5641bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_loadu_ps(const float *__p)
5669770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
567eed92a18829575f316313659d6294fd2ef275838Bill Wendling  struct __loadu_ps {
5684f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    __m128 __v;
5697c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
5704f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return ((struct __loadu_ps*)__p)->__v;
5719770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5729770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5731bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5744f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_loadr_ps(const float *__p)
5759770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson{
5764f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __a = _mm_load_ps(__p);
5774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
5789770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson}
5799770086950fae6d458e2c1cf397f1b6ec86506bbAnders Carlsson
5801bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5814f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_set_ss(float __w)
582a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson{
5834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __w, 0, 0, 0 };
584a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson}
585a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson
5861bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5874f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_set1_ps(float __w)
588a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson{
5894f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __w, __w, __w, __w };
590a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson}
591a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson
59212868cc25c6c5d87581a39cbb2fd13a963d0c41aAnders Carlsson// Microsoft specific.
5931bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
5944f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_set_ps1(float __w)
59512868cc25c6c5d87581a39cbb2fd13a963d0c41aAnders Carlsson{
5964f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    return _mm_set1_ps(__w);
59712868cc25c6c5d87581a39cbb2fd13a963d0c41aAnders Carlsson}
59812868cc25c6c5d87581a39cbb2fd13a963d0c41aAnders Carlsson
5991bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
6004f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_set_ps(float __z, float __y, float __x, float __w)
601a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson{
6024f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __w, __x, __y, __z };
603a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson}
604a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson
6051bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
6064f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_setr_ps(float __z, float __y, float __x, float __w)
607a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson{
6084f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m128){ __z, __y, __x, __w };
609a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson}
610a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson
6111bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__))
612dae4413d77b3e7599ce81307eb7a7d1dedbac547Mike Stump_mm_setzero_ps(void)
613a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson{
614a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson  return (__m128){ 0, 0, 0, 0 };
615a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson}
616a6ba0012fb26d2e735b30ebdde23b36be8439c77Anders Carlsson
6171bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__))
6184f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_storeh_pi(__m64 *__p, __m128 __a)
61909b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6204f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_storehps((__v2si *)__p, __a);
62109b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
62209b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6231bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__))
6244f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_storel_pi(__m64 *__p, __m128 __a)
62509b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6264f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_storelps((__v2si *)__p, __a);
62709b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
62809b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6291bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__))
6304f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_store_ss(float *__p, __m128 __a)
63109b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6327c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  struct __mm_store_ss_struct {
6334f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    float __u;
6347c06f6b319b272ea9e2df8ef03793c7b89e8dfabEli Friedman  } __attribute__((__packed__, __may_alias__));
6354f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  ((struct __mm_store_ss_struct*)__p)->__u = __a[0];
63609b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
63709b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6381bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6394f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_storeu_ps(float *__p, __m128 __a)
64009b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6414f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_storeups(__p, __a);
64209b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
64309b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6441bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6454f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_store1_ps(float *__p, __m128 __a)
64609b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a = __builtin_shufflevector(__a, __a, 0, 0, 0, 0);
6484f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  _mm_storeu_ps(__p, __a);
64909b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
65009b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6511bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6524f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_store_ps1(float *__p, __m128 __a)
653fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth{
6544f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie    return _mm_store1_ps(__p, __a);
655fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth}
656fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
657fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruthstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6584f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_store_ps(float *__p, __m128 __a)
65909b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6604f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  *(__m128 *)__p = __a;
66109b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
66209b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
6631bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6644f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_storer_ps(float *__p, __m128 __a)
66509b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson{
6664f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a = __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
6674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  _mm_store_ps(__p, __a);
66809b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson}
66909b9305acfd140283c3a204878750bd6edde7a00Anders Carlsson
670551f37c6920fc5d502d775aa22c994079ce6706fChris Lattner#define _MM_HINT_T0 3
671dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson#define _MM_HINT_T1 2
672551f37c6920fc5d502d775aa22c994079ce6706fChris Lattner#define _MM_HINT_T2 1
673dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson#define _MM_HINT_NTA 0
674dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
675c2b9b367b9fd9ca200de4cacf3c3539bc7fafedeNick Lewycky/* FIXME: We have to #define this because "sel" must be a constant integer, and
67662af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson   Sema doesn't do any form of constant propagation yet. */
677dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
67834a1da4354959522cd1721ce9ca099cc5c743f01Craig Topper#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel)))
679dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
6801bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6814f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_stream_pi(__m64 *__p, __m64 __a)
682dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson{
6834f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_movntq(__p, __a);
684dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson}
685dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
6861bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
6874f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_stream_ps(float *__p, __m128 __a)
688dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson{
6894f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_movntps(__p, __a);
690dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson}
691dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
6921bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
693dae4413d77b3e7599ce81307eb7a7d1dedbac547Mike Stump_mm_sfence(void)
694dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson{
695dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson  __builtin_ia32_sfence();
696dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson}
697dedad4ed6752ac8a4d15cdab6ecdfb54ba43ec95Anders Carlsson
6981bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
6994f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_extract_pi16(__m64 __a, int __n)
70062af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7014f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __v4hi __b = (__v4hi)__a;
7024f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (unsigned short)__b[__n & 3];
70362af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
70462af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7051bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7064f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_insert_pi16(__m64 __a, int __d, int __n)
70762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7084f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie   __v4hi __b = (__v4hi)__a;
7094f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie   __b[__n & 3] = __d;
7104f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie   return (__m64)__b;
71162af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
71262af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7131bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7144f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_max_pi16(__m64 __a, __m64 __b)
71562af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7164f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pmaxsw((__v4hi)__a, (__v4hi)__b);
71762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
71862af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7191bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7204f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_max_pu8(__m64 __a, __m64 __b)
72162af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7224f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pmaxub((__v8qi)__a, (__v8qi)__b);
72362af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
72462af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7251bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7264f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_min_pi16(__m64 __a, __m64 __b)
72762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7284f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pminsw((__v4hi)__a, (__v4hi)__b);
72962af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
73062af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7311bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7324f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_min_pu8(__m64 __a, __m64 __b)
73362af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7344f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pminub((__v8qi)__a, (__v8qi)__b);
73562af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
73662af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7371bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
7384f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_movemask_pi8(__m64 __a)
73962af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7404f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_pmovmskb((__v8qi)__a);
74162af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
74262af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7431bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7444f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_mulhi_pu16(__m64 __a, __m64 __b)
74562af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7464f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pmulhuw((__v4hi)__a, (__v4hi)__b);
74762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
74862af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
74932bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson#define _mm_shuffle_pi16(a, n) __extension__ ({ \
75032bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson  __m64 __a = (a); \
75132bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson  (__m64)__builtin_ia32_pshufw((__v4hi)__a, (n)); })
75262af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7531bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
7544f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_maskmove_si64(__m64 __d, __m64 __n, char *__p)
75562af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7564f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_maskmovq((__v8qi)__d, (__v8qi)__n, __p);
75762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
75862af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7591bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7604f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_avg_pu8(__m64 __a, __m64 __b)
76162af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7624f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pavgb((__v8qi)__a, (__v8qi)__b);
76362af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
76462af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7651bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7664f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_avg_pu16(__m64 __a, __m64 __b)
76762af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7684f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_pavgw((__v4hi)__a, (__v4hi)__b);
76962af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
77062af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson
7711bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
7724f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_sad_pu8(__m64 __a, __m64 __b)
77362af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson{
7744f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return (__m64)__builtin_ia32_psadbw((__v8qi)__a, (__v8qi)__b);
77562af71c07ee4b993f85c7aa05cc501c2718c85f8Anders Carlsson}
776c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson
7771bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
778dae4413d77b3e7599ce81307eb7a7d1dedbac547Mike Stump_mm_getcsr(void)
779c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson{
780c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson  return __builtin_ia32_stmxcsr();
781c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson}
782c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson
7831bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
7844f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_setcsr(unsigned int __i)
785c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson{
7864f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __builtin_ia32_ldmxcsr(__i);
787c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson}
788c1f9afd5f013767ede72a38af90961ab49041181Anders Carlsson
78932bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson#define _mm_shuffle_ps(a, b, mask) __extension__ ({ \
79032bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson  __m128 __a = (a); \
79132bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson  __m128 __b = (b); \
79232bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson  (__m128)__builtin_shufflevector((__v4sf)__a, (__v4sf)__b, \
79332bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson                                  (mask) & 0x3, ((mask) & 0xc) >> 2, \
79432bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson                                  (((mask) & 0x30) >> 4) + 4, \
79532bae37b821e6ade738849ac14e3d3de06afb0beBob Wilson                                  (((mask) & 0xc0) >> 6) + 4); })
79650099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
7971bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
7984f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_unpackhi_ps(__m128 __a, __m128 __b)
79950099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
8004f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __b, 2, 6, 3, 7);
80150099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
80250099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
8031bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8044f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_unpacklo_ps(__m128 __a, __m128 __b)
80550099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
8064f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __b, 0, 4, 1, 5);
80750099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
80850099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
8091bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8104f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_move_ss(__m128 __a, __m128 __b)
81150099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
8124f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __b, 4, 1, 2, 3);
81350099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
81450099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
8151bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8164f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_movehl_ps(__m128 __a, __m128 __b)
81750099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
8184f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __b, 6, 7, 2, 3);
81950099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
82050099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
8211bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8224f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_movelh_ps(__m128 __a, __m128 __b)
82350099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
8244f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_shufflevector(__a, __b, 0, 1, 4, 5);
82550099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
82650099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
8271bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8284f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpi16_ps(__m64 __a)
829a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
8304f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b, __c;
8314f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __r;
832a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8334f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_setzero_si64();
8344f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_cmpgt_pi16(__b, __a);
8354f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_unpackhi_pi16(__a, __b);
8364f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_setzero_ps();
8374f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_cvtpi32_ps(__r, __c);
8384f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_movelh_ps(__r, __r);
8394f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_unpacklo_pi16(__a, __b);
8404f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_cvtpi32_ps(__r, __c);
841a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8424f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __r;
843a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
844a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8451bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8464f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpu16_ps(__m64 __a)
847a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
8484f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b, __c;
8494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __r;
850a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8514f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_setzero_si64();
8524f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_unpackhi_pi16(__a, __b);
8534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_setzero_ps();
8544f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_cvtpi32_ps(__r, __c);
8554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_movelh_ps(__r, __r);
8564f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_unpacklo_pi16(__a, __b);
8574f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __r = _mm_cvtpi32_ps(__r, __c);
858a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8594f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __r;
860a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
861a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8621bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8634f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpi8_ps(__m64 __a)
864a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
8654f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b;
866a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8674f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_setzero_si64();
8684f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_cmpgt_pi8(__b, __a);
8694f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_unpacklo_pi8(__a, __b);
870a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8714f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtpi16_ps(__b);
872a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
873a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8741bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8754f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpu8_ps(__m64 __a)
876a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
8774f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b;
878a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8794f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_setzero_si64();
8804f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_unpacklo_pi8(__a, __b);
881a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8824f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtpi16_ps(__b);
883a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
884a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8851bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
8864f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtpi32x2_ps(__m64 __a, __m64 __b)
887a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
8884f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m128 __c;
889a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8904f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_setzero_ps();
8914f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_cvtpi32_ps(__c, __b);
8924f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_movelh_ps(__c, __c);
893a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8944f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_cvtpi32_ps(__c, __a);
895a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
896a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
8971bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
8984f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtps_pi16(__m128 __a)
899a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
9004f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b, __c;
901a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9024f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_cvtps_pi32(__a);
9034f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __a = _mm_movehl_ps(__a, __a);
9044f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_cvtps_pi32(__a);
905a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9064f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_packs_pi16(__b, __c);
907a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
908a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9091bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
9104f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtps_pi8(__m128 __a)
911a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson{
9124f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __m64 __b, __c;
913a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9144f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __b = _mm_cvtps_pi16(__a);
9154f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  __c = _mm_setzero_si64();
916a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9174f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return _mm_packs_pi16(__b, __c);
918a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson}
919a6431dc8d2ebf54de31323bae1fd197dc165f8b2Anders Carlsson
9201bddbcbd11de09c7bcb48c3d661c447967db73a7Chris Lattnerstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
9214f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_movemask_ps(__m128 __a)
92250099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson{
9234f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie  return __builtin_ia32_movmskps(__a);
92450099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson}
92550099cbb48185577df0ad2448bb53501365b6d94Anders Carlsson
926b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
927b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson
9284cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_INVALID    (0x0001)
9294cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_DENORM     (0x0002)
9304cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_DIV_ZERO   (0x0004)
9314cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_OVERFLOW   (0x0008)
9324cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_UNDERFLOW  (0x0010)
9334cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_EXCEPT_INEXACT    (0x0020)
934bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_EXCEPT_MASK       (0x003f)
9354cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson
936bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_MASK_INVALID      (0x0080)
937bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_MASK_DENORM       (0x0100)
938a837a07d46494aa53fc7ba827759ea1ef35b72d2Anders Carlsson#define _MM_MASK_DIV_ZERO     (0x0200)
939a837a07d46494aa53fc7ba827759ea1ef35b72d2Anders Carlsson#define _MM_MASK_OVERFLOW     (0x0400)
940a837a07d46494aa53fc7ba827759ea1ef35b72d2Anders Carlsson#define _MM_MASK_UNDERFLOW    (0x0800)
941a837a07d46494aa53fc7ba827759ea1ef35b72d2Anders Carlsson#define _MM_MASK_INEXACT      (0x1000)
942bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_MASK_MASK         (0x1f80)
943bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson
944bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_ROUND_NEAREST     (0x0000)
945bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_ROUND_DOWN        (0x2000)
946bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_ROUND_UP          (0x4000)
947bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_ROUND_TOWARD_ZERO (0x6000)
9484cc44279846d9a4394c73bca539ae3e646a041b0Anders Carlsson#define _MM_ROUND_MASK        (0x6000)
949bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson
950bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_FLUSH_ZERO_MASK   (0x8000)
951bbd1fa24fc939819079ca2c104b05dcfefe166b0Anders Carlsson#define _MM_FLUSH_ZERO_ON     (0x8000)
952092acb08e0b1ad47978c6932330240da546d4ec3Bob Wilson#define _MM_FLUSH_ZERO_OFF    (0x0000)
953b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson
954b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
955b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
95662005c16bc3a416c1ecfe0ceaeda9a8dd3e5b0beAnders Carlsson#define _MM_GET_FLUSH_ZERO_MODE() (_mm_getcsr() & _MM_FLUSH_ZERO_MASK)
957b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_GET_ROUNDING_MODE() (_mm_getcsr() & _MM_ROUND_MASK)
958b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson
95962005c16bc3a416c1ecfe0ceaeda9a8dd3e5b0beAnders Carlsson#define _MM_SET_EXCEPTION_MASK(x) (_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (x)))
960b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_SET_EXCEPTION_STATE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (x)))
96162005c16bc3a416c1ecfe0ceaeda9a8dd3e5b0beAnders Carlsson#define _MM_SET_FLUSH_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (x)))
962b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_SET_ROUNDING_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (x)))
963b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson
964b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
965b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlssondo { \
966b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  __m128 tmp3, tmp2, tmp1, tmp0; \
967b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  tmp0 = _mm_unpacklo_ps((row0), (row1)); \
968b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  tmp2 = _mm_unpacklo_ps((row2), (row3)); \
969b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  tmp1 = _mm_unpackhi_ps((row0), (row1)); \
970b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  tmp3 = _mm_unpackhi_ps((row2), (row3)); \
971b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  (row0) = _mm_movelh_ps(tmp0, tmp2); \
972b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  (row1) = _mm_movehl_ps(tmp2, tmp0); \
973b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson  (row2) = _mm_movelh_ps(tmp1, tmp3); \
9749afb227116f675fdaaa9552ea93e4190253d77dfChris Lattner  (row3) = _mm_movehl_ps(tmp3, tmp1); \
975b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson} while (0)
976b595509bf5c07b65616d9c7ef26dca4858768ac7Anders Carlsson
977fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth/* Aliases for compatibility. */
978fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pextrw _mm_extract_pi16
979fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pinsrw _mm_insert_pi16
980fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pmaxsw _mm_max_pi16
981fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pmaxub _mm_max_pu8
982fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pminsw _mm_min_pi16
983fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pminub _mm_min_pu8
984fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pmovmskb _mm_movemask_pi8
985fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pmulhuw _mm_mulhi_pu16
986fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pshufw _mm_shuffle_pi16
987fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_maskmovq _mm_maskmove_si64
988fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pavgb _mm_avg_pu8
989fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_pavgw _mm_avg_pu16
990fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_psadbw _mm_sad_pu8
991fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_ _mm_
992fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth#define _m_ _mm_
993fa38c81b67426e1363b58b86d702caa91a0c2ddbChandler Carruth
994c7d95dcb4e0b3d9ebc1a79d2c45f16af10cf88c1Eli Friedman/* Ugly hack for backwards-compatibility (compatible with gcc) */
995c7d95dcb4e0b3d9ebc1a79d2c45f16af10cf88c1Eli Friedman#ifdef __SSE2__
9963eef3e16ffdb88420ab6e9bb7902874713fd1b85Daniel Dunbar#include <emmintrin.h>
997c7d95dcb4e0b3d9ebc1a79d2c45f16af10cf88c1Eli Friedman#endif
9983eef3e16ffdb88420ab6e9bb7902874713fd1b85Daniel Dunbar
999566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#endif /* __SSE__ */
1000566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson
1001566d8da28294650ef9be8a5358a8d7ddd88c5f27Anders Carlsson#endif /* __XMMINTRIN_H */
1002