blob: cb93faf2b6a4969a34822b1889adaa4986ce17be [file] [log] [blame]
Michael J. Spencer1737c9e2011-04-15 15:11:21 +00001/*===---- mm3dnow.h - 3DNow! 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 _MM3DNOW_H_INCLUDED
25#define _MM3DNOW_H_INCLUDED
26
27#include <mmintrin.h>
Michael Liao74f4eaf2013-03-26 17:52:08 +000028#include <prfchwintrin.h>
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000029
30typedef float __v2sf __attribute__((__vector_size__(8)));
31
Eric Christopher4d1851682015-06-17 07:09:20 +000032/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000033#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("3dnow")))
Eric Christopher4d1851682015-06-17 07:09:20 +000034
Michael Kupersteine45af542015-06-30 13:36:19 +000035static __inline__ void __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000036_m_femms() {
37 __builtin_ia32_femms();
38}
39
Michael Kupersteine45af542015-06-30 13:36:19 +000040static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000041_m_pavgusb(__m64 __m1, __m64 __m2) {
42 return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
43}
44
Michael Kupersteine45af542015-06-30 13:36:19 +000045static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000046_m_pf2id(__m64 __m) {
47 return (__m64)__builtin_ia32_pf2id((__v2sf)__m);
48}
49
Michael Kupersteine45af542015-06-30 13:36:19 +000050static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000051_m_pfacc(__m64 __m1, __m64 __m2) {
52 return (__m64)__builtin_ia32_pfacc((__v2sf)__m1, (__v2sf)__m2);
53}
54
Michael Kupersteine45af542015-06-30 13:36:19 +000055static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000056_m_pfadd(__m64 __m1, __m64 __m2) {
57 return (__m64)__builtin_ia32_pfadd((__v2sf)__m1, (__v2sf)__m2);
58}
59
Michael Kupersteine45af542015-06-30 13:36:19 +000060static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000061_m_pfcmpeq(__m64 __m1, __m64 __m2) {
62 return (__m64)__builtin_ia32_pfcmpeq((__v2sf)__m1, (__v2sf)__m2);
63}
64
Michael Kupersteine45af542015-06-30 13:36:19 +000065static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000066_m_pfcmpge(__m64 __m1, __m64 __m2) {
67 return (__m64)__builtin_ia32_pfcmpge((__v2sf)__m1, (__v2sf)__m2);
68}
69
Michael Kupersteine45af542015-06-30 13:36:19 +000070static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000071_m_pfcmpgt(__m64 __m1, __m64 __m2) {
72 return (__m64)__builtin_ia32_pfcmpgt((__v2sf)__m1, (__v2sf)__m2);
73}
74
Michael Kupersteine45af542015-06-30 13:36:19 +000075static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000076_m_pfmax(__m64 __m1, __m64 __m2) {
77 return (__m64)__builtin_ia32_pfmax((__v2sf)__m1, (__v2sf)__m2);
78}
79
Michael Kupersteine45af542015-06-30 13:36:19 +000080static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000081_m_pfmin(__m64 __m1, __m64 __m2) {
82 return (__m64)__builtin_ia32_pfmin((__v2sf)__m1, (__v2sf)__m2);
83}
84
Michael Kupersteine45af542015-06-30 13:36:19 +000085static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000086_m_pfmul(__m64 __m1, __m64 __m2) {
87 return (__m64)__builtin_ia32_pfmul((__v2sf)__m1, (__v2sf)__m2);
88}
89
Michael Kupersteine45af542015-06-30 13:36:19 +000090static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000091_m_pfrcp(__m64 __m) {
92 return (__m64)__builtin_ia32_pfrcp((__v2sf)__m);
93}
94
Michael Kupersteine45af542015-06-30 13:36:19 +000095static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +000096_m_pfrcpit1(__m64 __m1, __m64 __m2) {
97 return (__m64)__builtin_ia32_pfrcpit1((__v2sf)__m1, (__v2sf)__m2);
98}
99
Michael Kupersteine45af542015-06-30 13:36:19 +0000100static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000101_m_pfrcpit2(__m64 __m1, __m64 __m2) {
102 return (__m64)__builtin_ia32_pfrcpit2((__v2sf)__m1, (__v2sf)__m2);
103}
104
Michael Kupersteine45af542015-06-30 13:36:19 +0000105static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000106_m_pfrsqrt(__m64 __m) {
107 return (__m64)__builtin_ia32_pfrsqrt((__v2sf)__m);
108}
109
Michael Kupersteine45af542015-06-30 13:36:19 +0000110static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000111_m_pfrsqrtit1(__m64 __m1, __m64 __m2) {
Craig Topperd6d3a052012-01-30 08:18:19 +0000112 return (__m64)__builtin_ia32_pfrsqit1((__v2sf)__m1, (__v2sf)__m2);
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000113}
114
Michael Kupersteine45af542015-06-30 13:36:19 +0000115static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000116_m_pfsub(__m64 __m1, __m64 __m2) {
117 return (__m64)__builtin_ia32_pfsub((__v2sf)__m1, (__v2sf)__m2);
118}
119
Michael Kupersteine45af542015-06-30 13:36:19 +0000120static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000121_m_pfsubr(__m64 __m1, __m64 __m2) {
122 return (__m64)__builtin_ia32_pfsubr((__v2sf)__m1, (__v2sf)__m2);
123}
124
Michael Kupersteine45af542015-06-30 13:36:19 +0000125static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000126_m_pi2fd(__m64 __m) {
127 return (__m64)__builtin_ia32_pi2fd((__v2si)__m);
128}
129
Michael Kupersteine45af542015-06-30 13:36:19 +0000130static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000131_m_pmulhrw(__m64 __m1, __m64 __m2) {
132 return (__m64)__builtin_ia32_pmulhrw((__v4hi)__m1, (__v4hi)__m2);
133}
134
Eric Christopher525334c2015-10-13 18:40:17 +0000135/* Handle the 3dnowa instructions here. */
136#undef __DEFAULT_FN_ATTRS
137#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("3dnowa")))
138
Michael Kupersteine45af542015-06-30 13:36:19 +0000139static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000140_m_pf2iw(__m64 __m) {
141 return (__m64)__builtin_ia32_pf2iw((__v2sf)__m);
142}
143
Michael Kupersteine45af542015-06-30 13:36:19 +0000144static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000145_m_pfnacc(__m64 __m1, __m64 __m2) {
146 return (__m64)__builtin_ia32_pfnacc((__v2sf)__m1, (__v2sf)__m2);
147}
148
Michael Kupersteine45af542015-06-30 13:36:19 +0000149static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000150_m_pfpnacc(__m64 __m1, __m64 __m2) {
151 return (__m64)__builtin_ia32_pfpnacc((__v2sf)__m1, (__v2sf)__m2);
152}
153
Michael Kupersteine45af542015-06-30 13:36:19 +0000154static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000155_m_pi2fw(__m64 __m) {
156 return (__m64)__builtin_ia32_pi2fw((__v2si)__m);
157}
158
Michael Kupersteine45af542015-06-30 13:36:19 +0000159static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000160_m_pswapdsf(__m64 __m) {
161 return (__m64)__builtin_ia32_pswapdsf((__v2sf)__m);
162}
163
Michael Kupersteine45af542015-06-30 13:36:19 +0000164static __inline__ __m64 __DEFAULT_FN_ATTRS
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000165_m_pswapdsi(__m64 __m) {
166 return (__m64)__builtin_ia32_pswapdsi((__v2si)__m);
167}
168
Michael Kupersteine45af542015-06-30 13:36:19 +0000169#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +0000170
Michael J. Spencer1737c9e2011-04-15 15:11:21 +0000171#endif