blob: 6f1fc3294644e7ab26bc0315e430b445cbd72af0 [file] [log] [blame]
Anders Carlssonf29b7742009-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
27#ifndef __SSE3__
28#error "SSE3 instruction set not enabled"
29#else
30
31#include <emmintrin.h>
32
Chris Lattner1bddbcb2010-03-22 18:14:12 +000033static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000034_mm_lddqu_si128(__m128i const *__p)
Anders Carlssonf29b7742009-02-11 06:39:50 +000035{
David Blaikie4f918ae2013-01-16 23:08:36 +000036 return (__m128i)__builtin_ia32_lddqu((char const *)__p);
Anders Carlssonf29b7742009-02-11 06:39:50 +000037}
38
Chris Lattner1bddbcb2010-03-22 18:14:12 +000039static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000040_mm_addsub_ps(__m128 __a, __m128 __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000041{
David Blaikie4f918ae2013-01-16 23:08:36 +000042 return __builtin_ia32_addsubps(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000043}
44
Chris Lattner1bddbcb2010-03-22 18:14:12 +000045static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000046_mm_hadd_ps(__m128 __a, __m128 __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000047{
David Blaikie4f918ae2013-01-16 23:08:36 +000048 return __builtin_ia32_haddps(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000049}
50
Chris Lattner1bddbcb2010-03-22 18:14:12 +000051static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000052_mm_hsub_ps(__m128 __a, __m128 __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000053{
David Blaikie4f918ae2013-01-16 23:08:36 +000054 return __builtin_ia32_hsubps(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000055}
56
Chris Lattner1bddbcb2010-03-22 18:14:12 +000057static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000058_mm_movehdup_ps(__m128 __a)
Anders Carlssonf29b7742009-02-11 06:39:50 +000059{
David Blaikie4f918ae2013-01-16 23:08:36 +000060 return __builtin_shufflevector(__a, __a, 1, 1, 3, 3);
Anders Carlssonf29b7742009-02-11 06:39:50 +000061}
62
Chris Lattner1bddbcb2010-03-22 18:14:12 +000063static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000064_mm_moveldup_ps(__m128 __a)
Anders Carlssonf29b7742009-02-11 06:39:50 +000065{
David Blaikie4f918ae2013-01-16 23:08:36 +000066 return __builtin_shufflevector(__a, __a, 0, 0, 2, 2);
Anders Carlssonf29b7742009-02-11 06:39:50 +000067}
68
Chris Lattner1bddbcb2010-03-22 18:14:12 +000069static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000070_mm_addsub_pd(__m128d __a, __m128d __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000071{
David Blaikie4f918ae2013-01-16 23:08:36 +000072 return __builtin_ia32_addsubpd(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000073}
74
Chris Lattner1bddbcb2010-03-22 18:14:12 +000075static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000076_mm_hadd_pd(__m128d __a, __m128d __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000077{
David Blaikie4f918ae2013-01-16 23:08:36 +000078 return __builtin_ia32_haddpd(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000079}
80
Chris Lattner1bddbcb2010-03-22 18:14:12 +000081static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000082_mm_hsub_pd(__m128d __a, __m128d __b)
Anders Carlssonf29b7742009-02-11 06:39:50 +000083{
David Blaikie4f918ae2013-01-16 23:08:36 +000084 return __builtin_ia32_hsubpd(__a, __b);
Anders Carlssonf29b7742009-02-11 06:39:50 +000085}
86
Eli Friedman7c06f6b2011-09-15 23:15:27 +000087#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
Anders Carlssonf29b7742009-02-11 06:39:50 +000088
Chris Lattner1bddbcb2010-03-22 18:14:12 +000089static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +000090_mm_movedup_pd(__m128d __a)
Anders Carlssonf29b7742009-02-11 06:39:50 +000091{
David Blaikie4f918ae2013-01-16 23:08:36 +000092 return __builtin_shufflevector(__a, __a, 0, 0);
Anders Carlssonf29b7742009-02-11 06:39:50 +000093}
94
95#define _MM_DENORMALS_ZERO_ON (0x0040)
96#define _MM_DENORMALS_ZERO_OFF (0x0000)
97
98#define _MM_DENORMALS_ZERO_MASK (0x0040)
99
100#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
101#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
102
Chris Lattner1bddbcb2010-03-22 18:14:12 +0000103static __inline__ void __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +0000104_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
Anders Carlssonf29b7742009-02-11 06:39:50 +0000105{
David Blaikie4f918ae2013-01-16 23:08:36 +0000106 __builtin_ia32_monitor((void *)__p, __extensions, __hints);
Anders Carlssonf29b7742009-02-11 06:39:50 +0000107}
108
Chris Lattner1bddbcb2010-03-22 18:14:12 +0000109static __inline__ void __attribute__((__always_inline__, __nodebug__))
David Blaikie4f918ae2013-01-16 23:08:36 +0000110_mm_mwait(unsigned __extensions, unsigned __hints)
Anders Carlssonf29b7742009-02-11 06:39:50 +0000111{
David Blaikie4f918ae2013-01-16 23:08:36 +0000112 __builtin_ia32_mwait(__extensions, __hints);
Anders Carlssonf29b7742009-02-11 06:39:50 +0000113}
114
115#endif /* __SSE3__ */
116
117#endif /* __PMMINTRIN_H */