u_sse.h revision 4a49301e
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 "pipe/p_config.h" 41 42#if defined(PIPE_ARCH_SSE) 43 44#include <xmmintrin.h> 45#include <emmintrin.h> 46 47 48/* MSVC before VC8 does not support the _mm_castxxx_yyy */ 49#if defined(_MSC_VER) && _MSC_VER < 1500 50 51union __declspec(align(16)) m128_types { 52 __m128 m128; 53 __m128i m128i; 54 __m128d m128d; 55}; 56 57static __inline __m128 58_mm_castsi128_ps(__m128i a) 59{ 60 union m128_types u; 61 u.m128i = a; 62 return u.m128; 63} 64 65static __inline __m128i 66_mm_castps_si128(__m128 a) 67{ 68 union m128_types u; 69 u.m128 = a; 70 return u.m128i; 71} 72 73#endif /* defined(_MSC_VER) && _MSC_VER < 1500 */ 74 75#endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */ 76 77#endif /* U_SSE_H_ */ 78