blob: 6e61539fb2ca5af4bcb518e638f1ff3180e68bed [file] [log] [blame]
Anders Carlssond0d8c542009-02-11 06:39:50 +00001/*===---- pmmintrin.h - SSE3 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 __PMMINTRIN_H
25#define __PMMINTRIN_H
26
Anders Carlssond0d8c542009-02-11 06:39:50 +000027#include <emmintrin.h>
28
Eric Christopher4d1851682015-06-17 07:09:20 +000029/* Define the default attributes for the functions in this file. */
Eric Christopher9fc7fb22015-06-17 07:09:32 +000030#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse3")))
Eric Christopher4d1851682015-06-17 07:09:20 +000031
32static __inline__ __m128i DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000033_mm_lddqu_si128(__m128i const *__p)
Anders Carlssond0d8c542009-02-11 06:39:50 +000034{
David Blaikie3302f2b2013-01-16 23:08:36 +000035 return (__m128i)__builtin_ia32_lddqu((char const *)__p);
Anders Carlssond0d8c542009-02-11 06:39:50 +000036}
37
Eric Christopher4d1851682015-06-17 07:09:20 +000038static __inline__ __m128 DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000039_mm_addsub_ps(__m128 __a, __m128 __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000040{
David Blaikie3302f2b2013-01-16 23:08:36 +000041 return __builtin_ia32_addsubps(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000042}
43
Eric Christopher4d1851682015-06-17 07:09:20 +000044static __inline__ __m128 DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000045_mm_hadd_ps(__m128 __a, __m128 __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000046{
David Blaikie3302f2b2013-01-16 23:08:36 +000047 return __builtin_ia32_haddps(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000048}
49
Eric Christopher4d1851682015-06-17 07:09:20 +000050static __inline__ __m128 DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000051_mm_hsub_ps(__m128 __a, __m128 __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000052{
David Blaikie3302f2b2013-01-16 23:08:36 +000053 return __builtin_ia32_hsubps(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000054}
55
Eric Christopher4d1851682015-06-17 07:09:20 +000056static __inline__ __m128 DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000057_mm_movehdup_ps(__m128 __a)
Anders Carlssond0d8c542009-02-11 06:39:50 +000058{
David Blaikie3302f2b2013-01-16 23:08:36 +000059 return __builtin_shufflevector(__a, __a, 1, 1, 3, 3);
Anders Carlssond0d8c542009-02-11 06:39:50 +000060}
61
Eric Christopher4d1851682015-06-17 07:09:20 +000062static __inline__ __m128 DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000063_mm_moveldup_ps(__m128 __a)
Anders Carlssond0d8c542009-02-11 06:39:50 +000064{
David Blaikie3302f2b2013-01-16 23:08:36 +000065 return __builtin_shufflevector(__a, __a, 0, 0, 2, 2);
Anders Carlssond0d8c542009-02-11 06:39:50 +000066}
67
Eric Christopher4d1851682015-06-17 07:09:20 +000068static __inline__ __m128d DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000069_mm_addsub_pd(__m128d __a, __m128d __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000070{
David Blaikie3302f2b2013-01-16 23:08:36 +000071 return __builtin_ia32_addsubpd(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000072}
73
Eric Christopher4d1851682015-06-17 07:09:20 +000074static __inline__ __m128d DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000075_mm_hadd_pd(__m128d __a, __m128d __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000076{
David Blaikie3302f2b2013-01-16 23:08:36 +000077 return __builtin_ia32_haddpd(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000078}
79
Eric Christopher4d1851682015-06-17 07:09:20 +000080static __inline__ __m128d DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000081_mm_hsub_pd(__m128d __a, __m128d __b)
Anders Carlssond0d8c542009-02-11 06:39:50 +000082{
David Blaikie3302f2b2013-01-16 23:08:36 +000083 return __builtin_ia32_hsubpd(__a, __b);
Anders Carlssond0d8c542009-02-11 06:39:50 +000084}
85
Eli Friedman9bb51ad2011-09-15 23:15:27 +000086#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
Anders Carlssond0d8c542009-02-11 06:39:50 +000087
Eric Christopher4d1851682015-06-17 07:09:20 +000088static __inline__ __m128d DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000089_mm_movedup_pd(__m128d __a)
Anders Carlssond0d8c542009-02-11 06:39:50 +000090{
David Blaikie3302f2b2013-01-16 23:08:36 +000091 return __builtin_shufflevector(__a, __a, 0, 0);
Anders Carlssond0d8c542009-02-11 06:39:50 +000092}
93
94#define _MM_DENORMALS_ZERO_ON (0x0040)
95#define _MM_DENORMALS_ZERO_OFF (0x0000)
96
97#define _MM_DENORMALS_ZERO_MASK (0x0040)
98
99#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
100#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
101
Eric Christopher4d1851682015-06-17 07:09:20 +0000102static __inline__ void DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000103_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
Anders Carlssond0d8c542009-02-11 06:39:50 +0000104{
David Blaikie3302f2b2013-01-16 23:08:36 +0000105 __builtin_ia32_monitor((void *)__p, __extensions, __hints);
Anders Carlssond0d8c542009-02-11 06:39:50 +0000106}
107
Eric Christopher4d1851682015-06-17 07:09:20 +0000108static __inline__ void DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000109_mm_mwait(unsigned __extensions, unsigned __hints)
Anders Carlssond0d8c542009-02-11 06:39:50 +0000110{
David Blaikie3302f2b2013-01-16 23:08:36 +0000111 __builtin_ia32_mwait(__extensions, __hints);
Anders Carlssond0d8c542009-02-11 06:39:50 +0000112}
113
Eric Christopher4d1851682015-06-17 07:09:20 +0000114#undef DEFAULT_FN_ATTRS
115
Anders Carlssond0d8c542009-02-11 06:39:50 +0000116#endif /* __PMMINTRIN_H */