blob: 120d73c34f575a7c8c01e0f0f63799025abc5c89 [file] [log] [blame]
Anders Carlssonb317efd2009-02-17 03:05:04 +00001/*===---- tmmintrin.h - SSSE3 intrinsics -----------------------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24#ifndef __TMMINTRIN_H
25#define __TMMINTRIN_H
26
Anders Carlssonb317efd2009-02-17 03:05:04 +000027#include <pmmintrin.h>
28
Eric Christopher4d1851682015-06-17 07:09:20 +000029/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000030#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("ssse3")))
Eric Christopher4d1851682015-06-17 07:09:20 +000031
Michael Kupersteine45af542015-06-30 13:36:19 +000032static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000033_mm_abs_pi8(__m64 __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000034{
David Blaikie3302f2b2013-01-16 23:08:36 +000035 return (__m64)__builtin_ia32_pabsb((__v8qi)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000036}
37
Michael Kupersteine45af542015-06-30 13:36:19 +000038static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000039_mm_abs_epi8(__m128i __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000040{
David Blaikie3302f2b2013-01-16 23:08:36 +000041 return (__m128i)__builtin_ia32_pabsb128((__v16qi)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000042}
43
Michael Kupersteine45af542015-06-30 13:36:19 +000044static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000045_mm_abs_pi16(__m64 __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000046{
David Blaikie3302f2b2013-01-16 23:08:36 +000047 return (__m64)__builtin_ia32_pabsw((__v4hi)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000048}
49
Michael Kupersteine45af542015-06-30 13:36:19 +000050static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000051_mm_abs_epi16(__m128i __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000052{
David Blaikie3302f2b2013-01-16 23:08:36 +000053 return (__m128i)__builtin_ia32_pabsw128((__v8hi)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000054}
55
Michael Kupersteine45af542015-06-30 13:36:19 +000056static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000057_mm_abs_pi32(__m64 __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000058{
David Blaikie3302f2b2013-01-16 23:08:36 +000059 return (__m64)__builtin_ia32_pabsd((__v2si)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000060}
61
Michael Kupersteine45af542015-06-30 13:36:19 +000062static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000063_mm_abs_epi32(__m128i __a)
Anders Carlssonb317efd2009-02-17 03:05:04 +000064{
David Blaikie3302f2b2013-01-16 23:08:36 +000065 return (__m128i)__builtin_ia32_pabsd128((__v4si)__a);
Anders Carlssonb317efd2009-02-17 03:05:04 +000066}
67
Bob Wilsonc9b97cc2011-11-05 06:08:06 +000068#define _mm_alignr_epi8(a, b, n) __extension__ ({ \
69 __m128i __a = (a); \
70 __m128i __b = (b); \
71 (__m128i)__builtin_ia32_palignr128((__v16qi)__a, (__v16qi)__b, (n)); })
72
73#define _mm_alignr_pi8(a, b, n) __extension__ ({ \
74 __m64 __a = (a); \
75 __m64 __b = (b); \
76 (__m64)__builtin_ia32_palignr((__v8qi)__a, (__v8qi)__b, (n)); })
Anders Carlssonb317efd2009-02-17 03:05:04 +000077
Michael Kupersteine45af542015-06-30 13:36:19 +000078static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000079_mm_hadd_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000080{
David Blaikie3302f2b2013-01-16 23:08:36 +000081 return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000082}
83
Michael Kupersteine45af542015-06-30 13:36:19 +000084static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000085_mm_hadd_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000086{
David Blaikie3302f2b2013-01-16 23:08:36 +000087 return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000088}
89
Michael Kupersteine45af542015-06-30 13:36:19 +000090static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000091_mm_hadd_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000092{
David Blaikie3302f2b2013-01-16 23:08:36 +000093 return (__m64)__builtin_ia32_phaddw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000094}
95
Michael Kupersteine45af542015-06-30 13:36:19 +000096static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000097_mm_hadd_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000098{
David Blaikie3302f2b2013-01-16 23:08:36 +000099 return (__m64)__builtin_ia32_phaddd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000100}
101
Michael Kupersteine45af542015-06-30 13:36:19 +0000102static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000103_mm_hadds_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000104{
David Blaikie3302f2b2013-01-16 23:08:36 +0000105 return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000106}
107
Michael Kupersteine45af542015-06-30 13:36:19 +0000108static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000109_mm_hadds_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000110{
David Blaikie3302f2b2013-01-16 23:08:36 +0000111 return (__m64)__builtin_ia32_phaddsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000112}
113
Michael Kupersteine45af542015-06-30 13:36:19 +0000114static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000115_mm_hsub_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000116{
David Blaikie3302f2b2013-01-16 23:08:36 +0000117 return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000118}
119
Michael Kupersteine45af542015-06-30 13:36:19 +0000120static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000121_mm_hsub_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000122{
David Blaikie3302f2b2013-01-16 23:08:36 +0000123 return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000124}
125
Michael Kupersteine45af542015-06-30 13:36:19 +0000126static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000127_mm_hsub_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000128{
David Blaikie3302f2b2013-01-16 23:08:36 +0000129 return (__m64)__builtin_ia32_phsubw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000130}
131
Michael Kupersteine45af542015-06-30 13:36:19 +0000132static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000133_mm_hsub_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000134{
David Blaikie3302f2b2013-01-16 23:08:36 +0000135 return (__m64)__builtin_ia32_phsubd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000136}
137
Michael Kupersteine45af542015-06-30 13:36:19 +0000138static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000139_mm_hsubs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000140{
David Blaikie3302f2b2013-01-16 23:08:36 +0000141 return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000142}
143
Michael Kupersteine45af542015-06-30 13:36:19 +0000144static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000145_mm_hsubs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000146{
David Blaikie3302f2b2013-01-16 23:08:36 +0000147 return (__m64)__builtin_ia32_phsubsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000148}
149
Michael Kupersteine45af542015-06-30 13:36:19 +0000150static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000151_mm_maddubs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000152{
David Blaikie3302f2b2013-01-16 23:08:36 +0000153 return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000154}
155
Michael Kupersteine45af542015-06-30 13:36:19 +0000156static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000157_mm_maddubs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000158{
David Blaikie3302f2b2013-01-16 23:08:36 +0000159 return (__m64)__builtin_ia32_pmaddubsw((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000160}
161
Michael Kupersteine45af542015-06-30 13:36:19 +0000162static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000163_mm_mulhrs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000164{
David Blaikie3302f2b2013-01-16 23:08:36 +0000165 return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000166}
167
Michael Kupersteine45af542015-06-30 13:36:19 +0000168static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000169_mm_mulhrs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000170{
David Blaikie3302f2b2013-01-16 23:08:36 +0000171 return (__m64)__builtin_ia32_pmulhrsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000172}
173
Michael Kupersteine45af542015-06-30 13:36:19 +0000174static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000175_mm_shuffle_epi8(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000176{
David Blaikie3302f2b2013-01-16 23:08:36 +0000177 return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000178}
179
Michael Kupersteine45af542015-06-30 13:36:19 +0000180static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000181_mm_shuffle_pi8(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000182{
David Blaikie3302f2b2013-01-16 23:08:36 +0000183 return (__m64)__builtin_ia32_pshufb((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000184}
185
Michael Kupersteine45af542015-06-30 13:36:19 +0000186static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000187_mm_sign_epi8(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000188{
David Blaikie3302f2b2013-01-16 23:08:36 +0000189 return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000190}
191
Michael Kupersteine45af542015-06-30 13:36:19 +0000192static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000193_mm_sign_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000194{
David Blaikie3302f2b2013-01-16 23:08:36 +0000195 return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000196}
197
Michael Kupersteine45af542015-06-30 13:36:19 +0000198static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000199_mm_sign_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000200{
David Blaikie3302f2b2013-01-16 23:08:36 +0000201 return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000202}
203
Michael Kupersteine45af542015-06-30 13:36:19 +0000204static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000205_mm_sign_pi8(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000206{
David Blaikie3302f2b2013-01-16 23:08:36 +0000207 return (__m64)__builtin_ia32_psignb((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000208}
209
Michael Kupersteine45af542015-06-30 13:36:19 +0000210static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000211_mm_sign_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000212{
David Blaikie3302f2b2013-01-16 23:08:36 +0000213 return (__m64)__builtin_ia32_psignw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000214}
215
Michael Kupersteine45af542015-06-30 13:36:19 +0000216static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000217_mm_sign_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000218{
David Blaikie3302f2b2013-01-16 23:08:36 +0000219 return (__m64)__builtin_ia32_psignd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000220}
221
Michael Kupersteine45af542015-06-30 13:36:19 +0000222#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +0000223
Anders Carlssonb317efd2009-02-17 03:05:04 +0000224#endif /* __TMMINTRIN_H */