0c8356cd05707dcfb71ff5d351499adc65c726c8
[mesa.git] / src / gallium / auxiliary / util / u_sse.h
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * @file
30 * SSE intrinsics portability header.
31 *
32 * Although the SSE intrinsics are support by all modern x86 and x86-64
33 * compilers, there are some intrisincs missing in some implementations
34 * (especially older MSVC versions). This header abstracts that away.
35 */
36
37 #ifndef U_SSE_H_
38 #define U_SSE_H_
39
40 #include <xmmintrin.h>
41 #include <emmintrin.h>
42
43
44 /* MSVC before VC8 does not support the _mm_castxxx_yyy */
45 #if defined(_MSC_VER) && _MSC_VER < 1500
46
47 union __declspec(align(16)) m128_types {
48 __m128 m128;
49 __m128i m128i;
50 __m128d m128d;
51 };
52
53 static __inline __m128
54 _mm_castsi128_ps(__m128i a)
55 {
56 union m128_types u;
57 u.m128i = a;
58 return u.m128;
59 }
60
61 static __inline __m128i
62 _mm_castps_si128(__m128 a)
63 {
64 union m128_types u;
65 u.m128 = a;
66 return u.m128i;
67 }
68
69 #endif
70
71
72 #endif /* U_SSE_H_ */