1 /* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 #ifndef _IMMINTRIN_H_INCLUDED
25 #define _IMMINTRIN_H_INCLUDED
32 #include <xmmintrin.h>
36 #include <emmintrin.h>
40 #include <pmmintrin.h>
44 #include <tmmintrin.h>
47 #if defined (__SSE4_2__) || defined (__SSE4_1__)
48 #include <smmintrin.h>
51 #if defined (__AES__) || defined (__PCLMUL__)
52 #include <wmmintrin.h>
56 #include <avxintrin.h>
60 extern __inline
unsigned short
61 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
64 return __builtin_ia32_rdrand16 ();
67 extern __inline
unsigned int
68 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
71 return __builtin_ia32_rdrand32 ();
73 #endif /* __RDRND__ */
77 extern __inline
unsigned int
78 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
79 _readfsbase_u32 (void)
81 return __builtin_ia32_rdfsbase32 ();
84 extern __inline
unsigned long long
85 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
86 _readfsbase_u64 (void)
88 return __builtin_ia32_rdfsbase64 ();
91 extern __inline
unsigned int
92 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
93 _readgsbase_u32 (void)
95 return __builtin_ia32_rdgsbase32 ();
98 extern __inline
unsigned long long
99 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
100 _readgsbase_u64 (void)
102 return __builtin_ia32_rdgsbase64 ();
106 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
107 _writefsbase_u32 (unsigned int __B
)
109 __builtin_ia32_wrfsbase32 (__B
);
113 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
114 _writefsbase_u64 (unsigned long long __B
)
116 __builtin_ia32_wrfsbase64 (__B
);
120 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
121 _writegsbase_u32 (unsigned int __B
)
123 __builtin_ia32_wrgsbase32 (__B
);
127 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
128 _writegsbase_u64 (unsigned long long __B
)
130 __builtin_ia32_wrgsbase64 (__B
);
132 #endif /* __FSGSBASE__ */
135 extern __inline
unsigned long long
136 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
139 return __builtin_ia32_rdrand64 ();
141 #endif /* __RDRND__ */
142 #endif /* __x86_64__ */
145 extern __inline
float __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
146 _cvtsh_ss (unsigned short __S
)
148 __v8hi __H
= __extension__ (__v8hi
){ __S
, 0, 0, 0, 0, 0, 0, 0 };
149 __v4sf __A
= __builtin_ia32_vcvtph2ps (__H
);
150 return __builtin_ia32_vec_ext_v4sf (__A
, 0);
153 extern __inline __m128
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
154 _mm_cvtph_ps (__m128i __A
)
156 return (__m128
) __builtin_ia32_vcvtph2ps ((__v8hi
) __A
);
159 extern __inline __m256
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
160 _mm256_cvtph_ps (__m128i __A
)
162 return (__m256
) __builtin_ia32_vcvtph2ps256 ((__v8hi
) __A
);
166 extern __inline
unsigned short __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
167 _cvtss_sh (float __F
, const int __I
)
169 __v4sf __A
= __extension__ (__v4sf
){ __F
, 0, 0, 0 };
170 __v8hi __H
= __builtin_ia32_vcvtps2ph (__A
, __I
);
171 return (unsigned short) __builtin_ia32_vec_ext_v8hi (__H
, 0);
174 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
175 _mm_cvtps_ph (__m128 __A
, const int __I
)
177 return (__m128i
) __builtin_ia32_vcvtps2ph ((__v4sf
) __A
, __I
);
180 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
181 _mm256_cvtps_ph (__m256 __A
, const int __I
)
183 return (__m128i
) __builtin_ia32_vcvtps2ph256 ((__v8sf
) __A
, __I
);
186 #define _cvtss_sh(__F, __I) \
189 __v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 }; \
190 __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I); \
191 (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0); \
194 #define _mm_cvtps_ph(A, I) \
195 ((__m128i) __builtin_ia32_vcvtps2ph ((__v4sf)(__m128) A, (int) (I)))
197 #define _mm256_cvtps_ph(A, I) \
198 ((__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf)(__m256) A, (int) (I)))
201 #endif /* __F16C__ */
203 #endif /* _IMMINTRIN_H_INCLUDED */