blob: 6f1fc3294644e7ab26bc0315e430b445cbd72af0 [file] [log] [blame]
Ying Wanga6720142011-12-20 14:43:20 -08001/*===---- 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
33static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070034_mm_lddqu_si128(__m128i const *__p)
Ying Wanga6720142011-12-20 14:43:20 -080035{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070036 return (__m128i)__builtin_ia32_lddqu((char const *)__p);
Ying Wanga6720142011-12-20 14:43:20 -080037}
38
39static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070040_mm_addsub_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080041{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070042 return __builtin_ia32_addsubps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080043}
44
45static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070046_mm_hadd_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080047{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070048 return __builtin_ia32_haddps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080049}
50
51static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070052_mm_hsub_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080053{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070054 return __builtin_ia32_hsubps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080055}
56
57static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070058_mm_movehdup_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -080059{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070060 return __builtin_shufflevector(__a, __a, 1, 1, 3, 3);
Ying Wanga6720142011-12-20 14:43:20 -080061}
62
63static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070064_mm_moveldup_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -080065{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070066 return __builtin_shufflevector(__a, __a, 0, 0, 2, 2);
Ying Wanga6720142011-12-20 14:43:20 -080067}
68
69static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070070_mm_addsub_pd(__m128d __a, __m128d __b)
Ying Wanga6720142011-12-20 14:43:20 -080071{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070072 return __builtin_ia32_addsubpd(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080073}
74
75static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070076_mm_hadd_pd(__m128d __a, __m128d __b)
Ying Wanga6720142011-12-20 14:43:20 -080077{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070078 return __builtin_ia32_haddpd(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080079}
80
81static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070082_mm_hsub_pd(__m128d __a, __m128d __b)
Ying Wanga6720142011-12-20 14:43:20 -080083{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070084 return __builtin_ia32_hsubpd(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -080085}
86
87#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
88
89static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070090_mm_movedup_pd(__m128d __a)
Ying Wanga6720142011-12-20 14:43:20 -080091{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070092 return __builtin_shufflevector(__a, __a, 0, 0);
Ying Wanga6720142011-12-20 14:43:20 -080093}
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
103static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700104_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
Ying Wanga6720142011-12-20 14:43:20 -0800105{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700106 __builtin_ia32_monitor((void *)__p, __extensions, __hints);
Ying Wanga6720142011-12-20 14:43:20 -0800107}
108
109static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700110_mm_mwait(unsigned __extensions, unsigned __hints)
Ying Wanga6720142011-12-20 14:43:20 -0800111{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700112 __builtin_ia32_mwait(__extensions, __hints);
Ying Wanga6720142011-12-20 14:43:20 -0800113}
114
115#endif /* __SSE3__ */
116
117#endif /* __PMMINTRIN_H */