blob: a24e0eb85a2e53d278720614f73f67af763395df [file] [log] [blame]
Anders Carlsson566d8da2008-12-22 00:01:20 +00001/*===---- xmmintrin.h - SSE 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 __XMMINTRIN_H
25#define __XMMINTRIN_H
26
27#ifndef __SSE__
28#error "MMX instruction set not enabled"
29#else
30
31typedef float __m128 __attribute__((__vector_size__(16)));
32
33static inline __m128 __attribute__((__always_inline__)) _mm_add_ss(__m128 a, __m128 b)
34{
35 return __builtin_ia32_addss(a, b);
36}
37
38static inline __m128 __attribute__((__always_inline__)) _mm_add_ps(__m128 a, __m128 b)
39{
40 return a + b;
41}
42
43static inline __m128 __attribute__((__always_inline__)) _mm_sub_ss(__m128 a, __m128 b)
44{
45 return __builtin_ia32_subss(a, b);
46}
47
48static inline __m128 __attribute__((__always_inline__)) _mm_sub_ps(__m128 a, __m128 b)
49{
50 return a - b;
51}
52
53static inline __m128 __attribute__((__always_inline__)) _mm_mul_ss(__m128 a, __m128 b)
54{
55 return __builtin_ia32_mulss(a, b);
56}
57
58static inline __m128 __attribute__((__always_inline__)) _mm_mul_ps(__m128 a, __m128 b)
59{
60 return a * b;
61}
62
63static inline __m128 __attribute__((__always_inline__)) _mm_div_ss(__m128 a, __m128 b)
64{
65 return __builtin_ia32_divss(a, b);
66}
67
68static inline __m128 __attribute__((__always_inline__)) _mm_div_ps(__m128 a, __m128 b)
69{
70 return a / b;
71}
72
73static inline __m128 __attribute__((__always_inline__)) _mm_sqrt_ss(__m128 a)
74{
75 return __builtin_ia32_sqrtss(a);
76}
77
78static inline __m128 __attribute__((__always_inline__)) _mm_sqrt_ps(__m128 a)
79{
80 return __builtin_ia32_sqrtps(a);
81}
82
83static inline __m128 __attribute__((__always_inline__)) _mm_rcp_ss(__m128 a)
84{
85 return __builtin_ia32_rcpss(a);
86}
87
88static inline __m128 __attribute__((__always_inline__)) _mm_rcp_ps(__m128 a)
89{
90 return __builtin_ia32_rcpps(a);
91}
92
93static inline __m128 __attribute__((__always_inline__)) _mm_rsqrt_ss(__m128 a)
94{
95 return __builtin_ia32_rsqrtss(a);
96}
97
98static inline __m128 __attribute__((__always_inline__)) _mm_rsqrt_ps(__m128 a)
99{
100 return __builtin_ia32_rsqrtps(a);
101}
102
103static inline __m128 __attribute__((__always_inline__)) _mm_min_ss(__m128 a, __m128 b)
104{
105 return __builtin_ia32_minss(a, b);
106}
107
108static inline __m128 __attribute__((__always_inline__)) _mm_min_ps(__m128 a, __m128 b)
109{
110 return __builtin_ia32_minps(a, b);
111}
112
113static inline __m128 __attribute__((__always_inline__)) _mm_max_ss(__m128 a, __m128 b)
114{
115 return __builtin_ia32_maxss(a, b);
116}
117
118static inline __m128 __attribute__((__always_inline__)) _mm_max_ps(__m128 a, __m128 b)
119{
120 return __builtin_ia32_maxps(a, b);
121}
122
123static inline __m128 __attribute__((__always_inline__)) _mm_and_ps(__m128 a, __m128 b)
124{
125 return __builtin_ia32_andps(a, b);
126}
127
128static inline __m128 __attribute__((__always_inline__)) _mm_andnot_ps(__m128 a, __m128 b)
129{
130 return __builtin_ia32_andnps(a, b);
131}
132
133static inline __m128 __attribute__((__always_inline__)) _mm_or_ps(__m128 a, __m128 b)
134{
135 return __builtin_ia32_orps(a, b);
136}
137
138static inline __m128 __attribute__((__always_inline__)) _mm_xor_ps(__m128 a, __m128 b)
139{
140 return __builtin_ia32_xorps(a, b);
141}
142
143#endif /* __SSE__ */
144
145#endif /* __XMMINTRIN_H */