1 /* Copyright (C) 2008, 2009, 2010 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 #include <avx2intrin.h>
65 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
66 _rdrand16_step (unsigned short *__P)
68 return __builtin_ia32_rdrand16_step (__P);
72 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
73 _rdrand32_step (unsigned int *__P)
75 return __builtin_ia32_rdrand32_step (__P);
77 #endif /* __RDRND__ */
81 extern __inline unsigned int
82 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
83 _readfsbase_u32 (void)
85 return __builtin_ia32_rdfsbase32 ();
88 extern __inline unsigned long long
89 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
90 _readfsbase_u64 (void)
92 return __builtin_ia32_rdfsbase64 ();
95 extern __inline unsigned int
96 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
97 _readgsbase_u32 (void)
99 return __builtin_ia32_rdgsbase32 ();
102 extern __inline unsigned long long
103 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
104 _readgsbase_u64 (void)
106 return __builtin_ia32_rdgsbase64 ();
110 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
111 _writefsbase_u32 (unsigned int __B)
113 __builtin_ia32_wrfsbase32 (__B);
117 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
118 _writefsbase_u64 (unsigned long long __B)
120 __builtin_ia32_wrfsbase64 (__B);
124 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
125 _writegsbase_u32 (unsigned int __B)
127 __builtin_ia32_wrgsbase32 (__B);
131 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
132 _writegsbase_u64 (unsigned long long __B)
134 __builtin_ia32_wrgsbase64 (__B);
136 #endif /* __FSGSBASE__ */
140 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
141 _rdrand64_step (unsigned long long *__P)
143 return __builtin_ia32_rdrand64_step (__P);
145 #endif /* __RDRND__ */
146 #endif /* __x86_64__ */
149 extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
150 _cvtsh_ss (unsigned short __S)
152 __v8hi __H = __extension__ (__v8hi){ __S, 0, 0, 0, 0, 0, 0, 0 };
153 __v4sf __A = __builtin_ia32_vcvtph2ps (__H);
154 return __builtin_ia32_vec_ext_v4sf (__A, 0);
157 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
158 _mm_cvtph_ps (__m128i __A)
160 return (__m128) __builtin_ia32_vcvtph2ps ((__v8hi) __A);
163 extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
164 _mm256_cvtph_ps (__m128i __A)
166 return (__m256) __builtin_ia32_vcvtph2ps256 ((__v8hi) __A);
170 extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
171 _cvtss_sh (float __F, const int __I)
173 __v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 };
174 __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I);
175 return (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0);
178 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
179 _mm_cvtps_ph (__m128 __A, const int __I)
181 return (__m128i) __builtin_ia32_vcvtps2ph ((__v4sf) __A, __I);
184 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
185 _mm256_cvtps_ph (__m256 __A, const int __I)
187 return (__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf) __A, __I);
190 #define _cvtss_sh(__F, __I) \
193 __v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 }; \
194 __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I); \
195 (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0); \
198 #define _mm_cvtps_ph(A, I) \
199 ((__m128i) __builtin_ia32_vcvtps2ph ((__v4sf)(__m128) A, (int) (I)))
201 #define _mm256_cvtps_ph(A, I) \
202 ((__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf)(__m256) A, (int) (I)))
205 #endif /* __F16C__ */
207 #endif /* _IMMINTRIN_H_INCLUDED */