1 /* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GCC 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.
15 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING. If not, write to
17 the Free Software Foundation, 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* As a special exception, if you include this header file into source
21 files compiled by GCC, this header file does not by itself cause
22 the resulting executable to be covered by the GNU General Public
23 License. This exception does not however invalidate any other
24 reasons why the executable file might be covered by the GNU General
27 /* Implemented from the specification included in the Intel C++ Compiler
28 User Guide and Reference, version 9.1. */
30 #ifndef _TMMINTRIN_H_INCLUDED
31 #define _TMMINTRIN_H_INCLUDED
34 # error "SSSE3 instruction set not enabled"
37 /* We need definitions from the SSE3, SSE2 and SSE header files*/
38 #include <pmmintrin.h>
40 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
41 _mm_hadd_epi16 (__m128i __X
, __m128i __Y
)
43 return (__m128i
) __builtin_ia32_phaddw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
46 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
47 _mm_hadd_epi32 (__m128i __X
, __m128i __Y
)
49 return (__m128i
) __builtin_ia32_phaddd128 ((__v4si
)__X
, (__v4si
)__Y
);
52 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
53 _mm_hadds_epi16 (__m128i __X
, __m128i __Y
)
55 return (__m128i
) __builtin_ia32_phaddsw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
58 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
59 _mm_hadd_pi16 (__m64 __X
, __m64 __Y
)
61 return (__m64
) __builtin_ia32_phaddw ((__v4hi
)__X
, (__v4hi
)__Y
);
64 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
65 _mm_hadd_pi32 (__m64 __X
, __m64 __Y
)
67 return (__m64
) __builtin_ia32_phaddd ((__v2si
)__X
, (__v2si
)__Y
);
70 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
71 _mm_hadds_pi16 (__m64 __X
, __m64 __Y
)
73 return (__m64
) __builtin_ia32_phaddsw ((__v4hi
)__X
, (__v4hi
)__Y
);
76 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
77 _mm_hsub_epi16 (__m128i __X
, __m128i __Y
)
79 return (__m128i
) __builtin_ia32_phsubw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
82 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
83 _mm_hsub_epi32 (__m128i __X
, __m128i __Y
)
85 return (__m128i
) __builtin_ia32_phsubd128 ((__v4si
)__X
, (__v4si
)__Y
);
88 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
89 _mm_hsubs_epi16 (__m128i __X
, __m128i __Y
)
91 return (__m128i
) __builtin_ia32_phsubsw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
94 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
95 _mm_hsub_pi16 (__m64 __X
, __m64 __Y
)
97 return (__m64
) __builtin_ia32_phsubw ((__v4hi
)__X
, (__v4hi
)__Y
);
100 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
101 _mm_hsub_pi32 (__m64 __X
, __m64 __Y
)
103 return (__m64
) __builtin_ia32_phsubd ((__v2si
)__X
, (__v2si
)__Y
);
106 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
107 _mm_hsubs_pi16 (__m64 __X
, __m64 __Y
)
109 return (__m64
) __builtin_ia32_phsubsw ((__v4hi
)__X
, (__v4hi
)__Y
);
112 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
113 _mm_maddubs_epi16 (__m128i __X
, __m128i __Y
)
115 return (__m128i
) __builtin_ia32_pmaddubsw128 ((__v16qi
)__X
, (__v16qi
)__Y
);
118 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
119 _mm_maddubs_pi16 (__m64 __X
, __m64 __Y
)
121 return (__m64
) __builtin_ia32_pmaddubsw ((__v8qi
)__X
, (__v8qi
)__Y
);
124 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
125 _mm_mulhrs_epi16 (__m128i __X
, __m128i __Y
)
127 return (__m128i
) __builtin_ia32_pmulhrsw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
130 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
131 _mm_mulhrs_pi16 (__m64 __X
, __m64 __Y
)
133 return (__m64
) __builtin_ia32_pmulhrsw ((__v4hi
)__X
, (__v4hi
)__Y
);
136 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
137 _mm_shuffle_epi8 (__m128i __X
, __m128i __Y
)
139 return (__m128i
) __builtin_ia32_pshufb128 ((__v16qi
)__X
, (__v16qi
)__Y
);
142 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
143 _mm_shuffle_pi8 (__m64 __X
, __m64 __Y
)
145 return (__m64
) __builtin_ia32_pshufb ((__v8qi
)__X
, (__v8qi
)__Y
);
148 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
149 _mm_sign_epi8 (__m128i __X
, __m128i __Y
)
151 return (__m128i
) __builtin_ia32_psignb128 ((__v16qi
)__X
, (__v16qi
)__Y
);
154 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
155 _mm_sign_epi16 (__m128i __X
, __m128i __Y
)
157 return (__m128i
) __builtin_ia32_psignw128 ((__v8hi
)__X
, (__v8hi
)__Y
);
160 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
161 _mm_sign_epi32 (__m128i __X
, __m128i __Y
)
163 return (__m128i
) __builtin_ia32_psignd128 ((__v4si
)__X
, (__v4si
)__Y
);
166 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
167 _mm_sign_pi8 (__m64 __X
, __m64 __Y
)
169 return (__m64
) __builtin_ia32_psignb ((__v8qi
)__X
, (__v8qi
)__Y
);
172 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
173 _mm_sign_pi16 (__m64 __X
, __m64 __Y
)
175 return (__m64
) __builtin_ia32_psignw ((__v4hi
)__X
, (__v4hi
)__Y
);
178 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
179 _mm_sign_pi32 (__m64 __X
, __m64 __Y
)
181 return (__m64
) __builtin_ia32_psignd ((__v2si
)__X
, (__v2si
)__Y
);
185 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
186 _mm_alignr_epi8(__m128i __X
, __m128i __Y
, const int __N
)
188 return (__m128i
) __builtin_ia32_palignr128 ((__v2di
)__X
,
189 (__v2di
)__Y
, __N
* 8);
192 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
193 _mm_alignr_pi8(__m64 __X
, __m64 __Y
, const int __N
)
195 return (__m64
) __builtin_ia32_palignr ((long long)__X
,
196 (long long)__Y
, __N
* 8);
199 #define _mm_alignr_epi8(X, Y, N) \
200 ((__m128i) __builtin_ia32_palignr128 ((__v2di)(__m128i)(X), \
201 (__v2di)(__m128i)(Y), \
203 #define _mm_alignr_pi8(X, Y, N) \
204 ((__m64) __builtin_ia32_palignr ((long long)(__m64)(X), \
205 (long long)(__m64)(Y), \
209 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
210 _mm_abs_epi8 (__m128i __X
)
212 return (__m128i
) __builtin_ia32_pabsb128 ((__v16qi
)__X
);
215 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
216 _mm_abs_epi16 (__m128i __X
)
218 return (__m128i
) __builtin_ia32_pabsw128 ((__v8hi
)__X
);
221 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
222 _mm_abs_epi32 (__m128i __X
)
224 return (__m128i
) __builtin_ia32_pabsd128 ((__v4si
)__X
);
227 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
228 _mm_abs_pi8 (__m64 __X
)
230 return (__m64
) __builtin_ia32_pabsb ((__v8qi
)__X
);
233 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
234 _mm_abs_pi16 (__m64 __X
)
236 return (__m64
) __builtin_ia32_pabsw ((__v4hi
)__X
);
239 extern __inline __m64
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
240 _mm_abs_pi32 (__m64 __X
)
242 return (__m64
) __builtin_ia32_pabsd ((__v2si
)__X
);
245 #endif /* __SSSE3__ */
247 #endif /* _TMMINTRIN_H_INCLUDED */