1193326Sed/*===---- pmmintrin.h - SSE3 intrinsics ------------------------------------===
2193326Sed *
3193326Sed * Permission is hereby granted, free of charge, to any person obtaining a copy
4193326Sed * of this software and associated documentation files (the "Software"), to deal
5193326Sed * in the Software without restriction, including without limitation the rights
6193326Sed * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7193326Sed * copies of the Software, and to permit persons to whom the Software is
8193326Sed * furnished to do so, subject to the following conditions:
9193326Sed *
10193326Sed * The above copyright notice and this permission notice shall be included in
11193326Sed * all copies or substantial portions of the Software.
12193326Sed *
13193326Sed * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14193326Sed * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15193326Sed * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16193326Sed * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17193326Sed * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18193326Sed * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19193326Sed * THE SOFTWARE.
20193326Sed *
21193326Sed *===-----------------------------------------------------------------------===
22193326Sed */
23193326Sed
24193326Sed#ifndef __PMMINTRIN_H
25193326Sed#define __PMMINTRIN_H
26193326Sed
27193326Sed#ifndef __SSE3__
28193326Sed#error "SSE3 instruction set not enabled"
29193326Sed#else
30193326Sed
31193326Sed#include <emmintrin.h>
32193326Sed
33206084Srdivackystatic __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
34249423Sdim_mm_lddqu_si128(__m128i const *__p)
35193326Sed{
36249423Sdim  return (__m128i)__builtin_ia32_lddqu((char const *)__p);
37193326Sed}
38193326Sed
39206084Srdivackystatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
40249423Sdim_mm_addsub_ps(__m128 __a, __m128 __b)
41193326Sed{
42249423Sdim  return __builtin_ia32_addsubps(__a, __b);
43193326Sed}
44193326Sed
45206084Srdivackystatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
46249423Sdim_mm_hadd_ps(__m128 __a, __m128 __b)
47193326Sed{
48249423Sdim  return __builtin_ia32_haddps(__a, __b);
49193326Sed}
50193326Sed
51206084Srdivackystatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
52249423Sdim_mm_hsub_ps(__m128 __a, __m128 __b)
53193326Sed{
54249423Sdim  return __builtin_ia32_hsubps(__a, __b);
55193326Sed}
56193326Sed
57206084Srdivackystatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
58249423Sdim_mm_movehdup_ps(__m128 __a)
59193326Sed{
60249423Sdim  return __builtin_shufflevector(__a, __a, 1, 1, 3, 3);
61193326Sed}
62193326Sed
63206084Srdivackystatic __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
64249423Sdim_mm_moveldup_ps(__m128 __a)
65193326Sed{
66249423Sdim  return __builtin_shufflevector(__a, __a, 0, 0, 2, 2);
67193326Sed}
68193326Sed
69206084Srdivackystatic __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
70249423Sdim_mm_addsub_pd(__m128d __a, __m128d __b)
71193326Sed{
72249423Sdim  return __builtin_ia32_addsubpd(__a, __b);
73193326Sed}
74193326Sed
75206084Srdivackystatic __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
76249423Sdim_mm_hadd_pd(__m128d __a, __m128d __b)
77193326Sed{
78249423Sdim  return __builtin_ia32_haddpd(__a, __b);
79193326Sed}
80193326Sed
81206084Srdivackystatic __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
82249423Sdim_mm_hsub_pd(__m128d __a, __m128d __b)
83193326Sed{
84249423Sdim  return __builtin_ia32_hsubpd(__a, __b);
85193326Sed}
86193326Sed
87226633Sdim#define        _mm_loaddup_pd(dp)        _mm_load1_pd(dp)
88193326Sed
89206084Srdivackystatic __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
90249423Sdim_mm_movedup_pd(__m128d __a)
91193326Sed{
92249423Sdim  return __builtin_shufflevector(__a, __a, 0, 0);
93193326Sed}
94193326Sed
95193326Sed#define _MM_DENORMALS_ZERO_ON   (0x0040)
96193326Sed#define _MM_DENORMALS_ZERO_OFF  (0x0000)
97193326Sed
98193326Sed#define _MM_DENORMALS_ZERO_MASK (0x0040)
99193326Sed
100193326Sed#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
101193326Sed#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
102193326Sed
103206084Srdivackystatic __inline__ void __attribute__((__always_inline__, __nodebug__))
104249423Sdim_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
105193326Sed{
106249423Sdim  __builtin_ia32_monitor((void *)__p, __extensions, __hints);
107193326Sed}
108193326Sed
109206084Srdivackystatic __inline__ void __attribute__((__always_inline__, __nodebug__))
110249423Sdim_mm_mwait(unsigned __extensions, unsigned __hints)
111193326Sed{
112249423Sdim  __builtin_ia32_mwait(__extensions, __hints);
113193326Sed}
114193326Sed
115193326Sed#endif /* __SSE3__ */
116193326Sed
117193326Sed#endif /* __PMMINTRIN_H */
118