]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/i386/tmmintrin.h
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / gcc / config / i386 / tmmintrin.h
CommitLineData
748086b7 1/* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
b1875f52
L
2
3 This file is part of GCC.
4
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
748086b7 7 the Free Software Foundation; either version 3, or (at your option)
b1875f52
L
8 any later version.
9
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.
14
748086b7
JJ
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
b1875f52 18
748086b7
JJ
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
b1875f52
L
23
24/* Implemented from the specification included in the Intel C++ Compiler
25 User Guide and Reference, version 9.1. */
26
27#ifndef _TMMINTRIN_H_INCLUDED
28#define _TMMINTRIN_H_INCLUDED
29
21efb4d4
HJ
30#ifndef __SSSE3__
31# error "SSSE3 instruction set not enabled"
32#else
33
34/* We need definitions from the SSE3, SSE2 and SSE header files*/
b1875f52
L
35#include <pmmintrin.h>
36
1359ef39 37extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
38_mm_hadd_epi16 (__m128i __X, __m128i __Y)
39{
40 return (__m128i) __builtin_ia32_phaddw128 ((__v8hi)__X, (__v8hi)__Y);
41}
42
1359ef39 43extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
44_mm_hadd_epi32 (__m128i __X, __m128i __Y)
45{
46 return (__m128i) __builtin_ia32_phaddd128 ((__v4si)__X, (__v4si)__Y);
47}
48
1359ef39 49extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
50_mm_hadds_epi16 (__m128i __X, __m128i __Y)
51{
52 return (__m128i) __builtin_ia32_phaddsw128 ((__v8hi)__X, (__v8hi)__Y);
53}
54
1359ef39 55extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
56_mm_hadd_pi16 (__m64 __X, __m64 __Y)
57{
58 return (__m64) __builtin_ia32_phaddw ((__v4hi)__X, (__v4hi)__Y);
59}
60
1359ef39 61extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
62_mm_hadd_pi32 (__m64 __X, __m64 __Y)
63{
64 return (__m64) __builtin_ia32_phaddd ((__v2si)__X, (__v2si)__Y);
65}
66
1359ef39 67extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
68_mm_hadds_pi16 (__m64 __X, __m64 __Y)
69{
70 return (__m64) __builtin_ia32_phaddsw ((__v4hi)__X, (__v4hi)__Y);
71}
72
1359ef39 73extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
74_mm_hsub_epi16 (__m128i __X, __m128i __Y)
75{
76 return (__m128i) __builtin_ia32_phsubw128 ((__v8hi)__X, (__v8hi)__Y);
77}
78
1359ef39 79extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
80_mm_hsub_epi32 (__m128i __X, __m128i __Y)
81{
82 return (__m128i) __builtin_ia32_phsubd128 ((__v4si)__X, (__v4si)__Y);
83}
84
1359ef39 85extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
86_mm_hsubs_epi16 (__m128i __X, __m128i __Y)
87{
88 return (__m128i) __builtin_ia32_phsubsw128 ((__v8hi)__X, (__v8hi)__Y);
89}
90
1359ef39 91extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
92_mm_hsub_pi16 (__m64 __X, __m64 __Y)
93{
94 return (__m64) __builtin_ia32_phsubw ((__v4hi)__X, (__v4hi)__Y);
95}
96
1359ef39 97extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
98_mm_hsub_pi32 (__m64 __X, __m64 __Y)
99{
100 return (__m64) __builtin_ia32_phsubd ((__v2si)__X, (__v2si)__Y);
101}
102
1359ef39 103extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
104_mm_hsubs_pi16 (__m64 __X, __m64 __Y)
105{
106 return (__m64) __builtin_ia32_phsubsw ((__v4hi)__X, (__v4hi)__Y);
107}
108
1359ef39 109extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
110_mm_maddubs_epi16 (__m128i __X, __m128i __Y)
111{
112 return (__m128i) __builtin_ia32_pmaddubsw128 ((__v16qi)__X, (__v16qi)__Y);
113}
114
1359ef39 115extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
116_mm_maddubs_pi16 (__m64 __X, __m64 __Y)
117{
118 return (__m64) __builtin_ia32_pmaddubsw ((__v8qi)__X, (__v8qi)__Y);
119}
120
1359ef39 121extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
122_mm_mulhrs_epi16 (__m128i __X, __m128i __Y)
123{
124 return (__m128i) __builtin_ia32_pmulhrsw128 ((__v8hi)__X, (__v8hi)__Y);
125}
126
1359ef39 127extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
128_mm_mulhrs_pi16 (__m64 __X, __m64 __Y)
129{
130 return (__m64) __builtin_ia32_pmulhrsw ((__v4hi)__X, (__v4hi)__Y);
131}
132
1359ef39 133extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
134_mm_shuffle_epi8 (__m128i __X, __m128i __Y)
135{
136 return (__m128i) __builtin_ia32_pshufb128 ((__v16qi)__X, (__v16qi)__Y);
137}
138
1359ef39 139extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
140_mm_shuffle_pi8 (__m64 __X, __m64 __Y)
141{
142 return (__m64) __builtin_ia32_pshufb ((__v8qi)__X, (__v8qi)__Y);
143}
144
1359ef39 145extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
146_mm_sign_epi8 (__m128i __X, __m128i __Y)
147{
148 return (__m128i) __builtin_ia32_psignb128 ((__v16qi)__X, (__v16qi)__Y);
149}
150
1359ef39 151extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
152_mm_sign_epi16 (__m128i __X, __m128i __Y)
153{
154 return (__m128i) __builtin_ia32_psignw128 ((__v8hi)__X, (__v8hi)__Y);
155}
156
1359ef39 157extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
158_mm_sign_epi32 (__m128i __X, __m128i __Y)
159{
160 return (__m128i) __builtin_ia32_psignd128 ((__v4si)__X, (__v4si)__Y);
161}
162
1359ef39 163extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
164_mm_sign_pi8 (__m64 __X, __m64 __Y)
165{
166 return (__m64) __builtin_ia32_psignb ((__v8qi)__X, (__v8qi)__Y);
167}
168
1359ef39 169extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
170_mm_sign_pi16 (__m64 __X, __m64 __Y)
171{
172 return (__m64) __builtin_ia32_psignw ((__v4hi)__X, (__v4hi)__Y);
173}
174
1359ef39 175extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
176_mm_sign_pi32 (__m64 __X, __m64 __Y)
177{
178 return (__m64) __builtin_ia32_psignd ((__v2si)__X, (__v2si)__Y);
179}
180
8ec3e357 181#ifdef __OPTIMIZE__
1359ef39 182extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
46fb8f6b
UB
183_mm_alignr_epi8(__m128i __X, __m128i __Y, const int __N)
184{
bfcd7233
UB
185 return (__m128i) __builtin_ia32_palignr128 ((__v2di)__X,
186 (__v2di)__Y, __N * 8);
187}
b1875f52 188
1359ef39 189extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
46fb8f6b
UB
190_mm_alignr_pi8(__m64 __X, __m64 __Y, const int __N)
191{
99c25ac1
L
192 return (__m64) __builtin_ia32_palignr ((__v1di)__X,
193 (__v1di)__Y, __N * 8);
46fb8f6b 194}
32fe15ec 195#else
bfcd7233
UB
196#define _mm_alignr_epi8(X, Y, N) \
197 ((__m128i) __builtin_ia32_palignr128 ((__v2di)(__m128i)(X), \
198 (__v2di)(__m128i)(Y), \
199 (int)(N) * 8))
200#define _mm_alignr_pi8(X, Y, N) \
99c25ac1
L
201 ((__m64) __builtin_ia32_palignr ((__v1di)(__m64)(X), \
202 (__v1di)(__m64)(Y), \
bfcd7233 203 (int)(N) * 8))
32fe15ec 204#endif
b1875f52 205
1359ef39 206extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
207_mm_abs_epi8 (__m128i __X)
208{
209 return (__m128i) __builtin_ia32_pabsb128 ((__v16qi)__X);
210}
211
1359ef39 212extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
213_mm_abs_epi16 (__m128i __X)
214{
215 return (__m128i) __builtin_ia32_pabsw128 ((__v8hi)__X);
216}
217
1359ef39 218extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
219_mm_abs_epi32 (__m128i __X)
220{
221 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
222}
223
1359ef39 224extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
225_mm_abs_pi8 (__m64 __X)
226{
227 return (__m64) __builtin_ia32_pabsb ((__v8qi)__X);
228}
229
1359ef39 230extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
231_mm_abs_pi16 (__m64 __X)
232{
233 return (__m64) __builtin_ia32_pabsw ((__v4hi)__X);
234}
235
1359ef39 236extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
b1875f52
L
237_mm_abs_pi32 (__m64 __X)
238{
239 return (__m64) __builtin_ia32_pabsd ((__v2si)__X);
240}
241
242#endif /* __SSSE3__ */
243
244#endif /* _TMMINTRIN_H_INCLUDED */