1 | /*************************************************************************** |
---|
2 | * Copyright (C) 2005 by Prakash Punnoor * |
---|
3 | * prakash@punnoor.de * |
---|
4 | * * |
---|
5 | * This program is free software; you can redistribute it and/or modify * |
---|
6 | * it under the terms of the GNU Library General Public License as * |
---|
7 | * published by the Free Software Foundation; either version 2 of the * |
---|
8 | * License, or (at your option) any later version. * |
---|
9 | * * |
---|
10 | * This program is distributed in the hope that it will be useful, * |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
13 | * GNU General Public License for more details. * |
---|
14 | * * |
---|
15 | * You should have received a copy of the GNU Library General Public * |
---|
16 | * License along with this program; if not, write to the * |
---|
17 | * Free Software Foundation, Inc., * |
---|
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
19 | ***************************************************************************/ |
---|
20 | #ifndef _X86_SIMD_SUPPORT_H_ |
---|
21 | #define _X86_SIMD_SUPPORT_H_ |
---|
22 | |
---|
23 | #ifdef __MMX__ |
---|
24 | /* |
---|
25 | * We use built-ins for gcc instead of Intel/MSVC style intrinsics |
---|
26 | * as (older) gccs are slower with them |
---|
27 | */ |
---|
28 | #if __GNUC__ && !__INTEL_COMPILER |
---|
29 | #if __GNUC__ < 4 |
---|
30 | typedef short v4hi __attribute__ ((__mode__(__V4HI__))); |
---|
31 | typedef int v2si __attribute__ ((__mode__(__V2SI__))); |
---|
32 | typedef int di __attribute__ ((__mode__(__DI__))); |
---|
33 | #else |
---|
34 | typedef short v4hi __attribute__ ((vector_size (8))); |
---|
35 | typedef int v2si __attribute__ ((vector_size (8))); |
---|
36 | typedef int di __attribute__ ((vector_size (8))); |
---|
37 | #endif |
---|
38 | |
---|
39 | #define ALIGN16(x) x __attribute__((aligned(16))) |
---|
40 | typedef unsigned long aint; |
---|
41 | |
---|
42 | #else /* NO GCC */ |
---|
43 | #include <mmintrin.h> |
---|
44 | typedef __m64 v4hi; |
---|
45 | typedef __m64 v2si; |
---|
46 | typedef __m64 di; |
---|
47 | |
---|
48 | #define __builtin_ia32_pand(X,Y) _mm_and_si64(X,Y) |
---|
49 | #define __builtin_ia32_pcmpeqw(X,Y) _mm_cmpeq_pi16(X,Y) |
---|
50 | #define __builtin_ia32_packssdw(X,Y) _mm_packs_pi32(X,Y) |
---|
51 | #define __builtin_ia32_punpcklwd(X,Y) _mm_unpacklo_pi16(X,Y) |
---|
52 | #define __builtin_ia32_punpckhwd(X,Y) _mm_unpackhi_pi16(X,Y) |
---|
53 | #define __builtin_ia32_paddd(X,Y) _mm_add_pi32(X,Y) |
---|
54 | #define __builtin_ia32_paddsw(X,Y) _mm_adds_pi16(X,Y) |
---|
55 | #define __builtin_ia32_pmulhw(X,Y) _mm_mulhi_pi16(X,Y) |
---|
56 | #define __builtin_ia32_psllw(X,Y) _mm_slli_pi16(X,Y) |
---|
57 | #define __builtin_ia32_emms() _mm_empty() |
---|
58 | |
---|
59 | #define ALIGN16(x) __declspec(align(16)) x |
---|
60 | |
---|
61 | /* FIXME: msvc++'s long in x86_64 isn't 8bytes? */ |
---|
62 | typedef unsigned long aint; |
---|
63 | #endif /* __GNUC__ */ |
---|
64 | |
---|
65 | #define MMX_ALIGN 8 |
---|
66 | #endif /* __MMX__ */ |
---|
67 | |
---|
68 | #endif /* _X86_SIMD_SUPPORT_H_ */ |
---|
69 | |
---|