blob: 0002890c13938003dcd480a254f90761395a09eb [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 */
Sean Silvae4c37602015-09-12 02:55:19 +000023
Anders Carlssonb317efd2009-02-17 03:05:04 +000024#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__ ({ \
Craig Topper71481662015-11-10 05:08:05 +000069 (__m128i)__builtin_ia32_palignr128((__v16qi)(__m128i)(a), \
70 (__v16qi)(__m128i)(b), (n)); })
Bob Wilsonc9b97cc2011-11-05 06:08:06 +000071
72#define _mm_alignr_pi8(a, b, n) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +000073 (__m64)__builtin_ia32_palignr((__v8qi)(__m64)(a), (__v8qi)(__m64)(b), (n)); })
Anders Carlssonb317efd2009-02-17 03:05:04 +000074
Michael Kupersteine45af542015-06-30 13:36:19 +000075static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000076_mm_hadd_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000077{
David Blaikie3302f2b2013-01-16 23:08:36 +000078 return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000079}
80
Michael Kupersteine45af542015-06-30 13:36:19 +000081static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000082_mm_hadd_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000083{
David Blaikie3302f2b2013-01-16 23:08:36 +000084 return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000085}
86
Michael Kupersteine45af542015-06-30 13:36:19 +000087static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000088_mm_hadd_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000089{
David Blaikie3302f2b2013-01-16 23:08:36 +000090 return (__m64)__builtin_ia32_phaddw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000091}
92
Michael Kupersteine45af542015-06-30 13:36:19 +000093static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000094_mm_hadd_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +000095{
David Blaikie3302f2b2013-01-16 23:08:36 +000096 return (__m64)__builtin_ia32_phaddd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +000097}
98
Michael Kupersteine45af542015-06-30 13:36:19 +000099static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000100_mm_hadds_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000101{
David Blaikie3302f2b2013-01-16 23:08:36 +0000102 return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000103}
104
Michael Kupersteine45af542015-06-30 13:36:19 +0000105static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000106_mm_hadds_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000107{
David Blaikie3302f2b2013-01-16 23:08:36 +0000108 return (__m64)__builtin_ia32_phaddsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000109}
110
Michael Kupersteine45af542015-06-30 13:36:19 +0000111static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000112_mm_hsub_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000113{
David Blaikie3302f2b2013-01-16 23:08:36 +0000114 return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000115}
116
Michael Kupersteine45af542015-06-30 13:36:19 +0000117static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000118_mm_hsub_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000119{
David Blaikie3302f2b2013-01-16 23:08:36 +0000120 return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000121}
122
Michael Kupersteine45af542015-06-30 13:36:19 +0000123static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000124_mm_hsub_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000125{
David Blaikie3302f2b2013-01-16 23:08:36 +0000126 return (__m64)__builtin_ia32_phsubw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000127}
128
Michael Kupersteine45af542015-06-30 13:36:19 +0000129static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000130_mm_hsub_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000131{
David Blaikie3302f2b2013-01-16 23:08:36 +0000132 return (__m64)__builtin_ia32_phsubd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000133}
134
Michael Kupersteine45af542015-06-30 13:36:19 +0000135static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000136_mm_hsubs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000137{
David Blaikie3302f2b2013-01-16 23:08:36 +0000138 return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000139}
140
Michael Kupersteine45af542015-06-30 13:36:19 +0000141static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000142_mm_hsubs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000143{
David Blaikie3302f2b2013-01-16 23:08:36 +0000144 return (__m64)__builtin_ia32_phsubsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000145}
146
Michael Kupersteine45af542015-06-30 13:36:19 +0000147static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000148_mm_maddubs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000149{
David Blaikie3302f2b2013-01-16 23:08:36 +0000150 return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000151}
152
Michael Kupersteine45af542015-06-30 13:36:19 +0000153static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000154_mm_maddubs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000155{
David Blaikie3302f2b2013-01-16 23:08:36 +0000156 return (__m64)__builtin_ia32_pmaddubsw((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000157}
158
Michael Kupersteine45af542015-06-30 13:36:19 +0000159static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000160_mm_mulhrs_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000161{
David Blaikie3302f2b2013-01-16 23:08:36 +0000162 return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000163}
164
Michael Kupersteine45af542015-06-30 13:36:19 +0000165static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000166_mm_mulhrs_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000167{
David Blaikie3302f2b2013-01-16 23:08:36 +0000168 return (__m64)__builtin_ia32_pmulhrsw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000169}
170
Michael Kupersteine45af542015-06-30 13:36:19 +0000171static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000172_mm_shuffle_epi8(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000173{
David Blaikie3302f2b2013-01-16 23:08:36 +0000174 return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000175}
176
Michael Kupersteine45af542015-06-30 13:36:19 +0000177static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000178_mm_shuffle_pi8(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000179{
David Blaikie3302f2b2013-01-16 23:08:36 +0000180 return (__m64)__builtin_ia32_pshufb((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000181}
182
Michael Kupersteine45af542015-06-30 13:36:19 +0000183static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000184_mm_sign_epi8(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000185{
David Blaikie3302f2b2013-01-16 23:08:36 +0000186 return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000187}
188
Michael Kupersteine45af542015-06-30 13:36:19 +0000189static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000190_mm_sign_epi16(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000191{
David Blaikie3302f2b2013-01-16 23:08:36 +0000192 return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000193}
194
Michael Kupersteine45af542015-06-30 13:36:19 +0000195static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000196_mm_sign_epi32(__m128i __a, __m128i __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000197{
David Blaikie3302f2b2013-01-16 23:08:36 +0000198 return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000199}
200
Michael Kupersteine45af542015-06-30 13:36:19 +0000201static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000202_mm_sign_pi8(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000203{
David Blaikie3302f2b2013-01-16 23:08:36 +0000204 return (__m64)__builtin_ia32_psignb((__v8qi)__a, (__v8qi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000205}
206
Michael Kupersteine45af542015-06-30 13:36:19 +0000207static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000208_mm_sign_pi16(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000209{
David Blaikie3302f2b2013-01-16 23:08:36 +0000210 return (__m64)__builtin_ia32_psignw((__v4hi)__a, (__v4hi)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000211}
212
Michael Kupersteine45af542015-06-30 13:36:19 +0000213static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000214_mm_sign_pi32(__m64 __a, __m64 __b)
Anders Carlssonb317efd2009-02-17 03:05:04 +0000215{
David Blaikie3302f2b2013-01-16 23:08:36 +0000216 return (__m64)__builtin_ia32_psignd((__v2si)__a, (__v2si)__b);
Anders Carlssonb317efd2009-02-17 03:05:04 +0000217}
218
Michael Kupersteine45af542015-06-30 13:36:19 +0000219#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +0000220
Anders Carlssonb317efd2009-02-17 03:05:04 +0000221#endif /* __TMMINTRIN_H */