25 #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_DETAIL_H_
26 #define _GLIBCXX_EXPERIMENTAL_SIMD_DETAIL_H_
28 #if __cplusplus >= 201703L
35 #define _GLIBCXX_SIMD_BEGIN_NAMESPACE \
36 namespace std _GLIBCXX_VISIBILITY(default) \
38 _GLIBCXX_BEGIN_NAMESPACE_VERSION \
39 namespace experimental { \
40 inline namespace parallelism_v2 {
41 #define _GLIBCXX_SIMD_END_NAMESPACE \
44 _GLIBCXX_END_NAMESPACE_VERSION \
49 #if defined __ARM_NEON
50 #define _GLIBCXX_SIMD_HAVE_NEON 1
52 #define _GLIBCXX_SIMD_HAVE_NEON 0
54 #if defined __ARM_NEON && (__ARM_ARCH >= 8 || defined __aarch64__)
55 #define _GLIBCXX_SIMD_HAVE_NEON_A32 1
57 #define _GLIBCXX_SIMD_HAVE_NEON_A32 0
59 #if defined __ARM_NEON && defined __aarch64__
60 #define _GLIBCXX_SIMD_HAVE_NEON_A64 1
62 #define _GLIBCXX_SIMD_HAVE_NEON_A64 0
67 #define _GLIBCXX_SIMD_HAVE_MMX 1
69 #define _GLIBCXX_SIMD_HAVE_MMX 0
71 #if defined __SSE__ || defined __x86_64__
72 #define _GLIBCXX_SIMD_HAVE_SSE 1
74 #define _GLIBCXX_SIMD_HAVE_SSE 0
76 #if defined __SSE2__ || defined __x86_64__
77 #define _GLIBCXX_SIMD_HAVE_SSE2 1
79 #define _GLIBCXX_SIMD_HAVE_SSE2 0
82 #define _GLIBCXX_SIMD_HAVE_SSE3 1
84 #define _GLIBCXX_SIMD_HAVE_SSE3 0
87 #define _GLIBCXX_SIMD_HAVE_SSSE3 1
89 #define _GLIBCXX_SIMD_HAVE_SSSE3 0
92 #define _GLIBCXX_SIMD_HAVE_SSE4_1 1
94 #define _GLIBCXX_SIMD_HAVE_SSE4_1 0
97 #define _GLIBCXX_SIMD_HAVE_SSE4_2 1
99 #define _GLIBCXX_SIMD_HAVE_SSE4_2 0
102 #define _GLIBCXX_SIMD_HAVE_XOP 1
104 #define _GLIBCXX_SIMD_HAVE_XOP 0
107 #define _GLIBCXX_SIMD_HAVE_AVX 1
109 #define _GLIBCXX_SIMD_HAVE_AVX 0
112 #define _GLIBCXX_SIMD_HAVE_AVX2 1
114 #define _GLIBCXX_SIMD_HAVE_AVX2 0
117 #define _GLIBCXX_SIMD_HAVE_BMI1 1
119 #define _GLIBCXX_SIMD_HAVE_BMI1 0
122 #define _GLIBCXX_SIMD_HAVE_BMI2 1
124 #define _GLIBCXX_SIMD_HAVE_BMI2 0
127 #define _GLIBCXX_SIMD_HAVE_LZCNT 1
129 #define _GLIBCXX_SIMD_HAVE_LZCNT 0
132 #define _GLIBCXX_SIMD_HAVE_SSE4A 1
134 #define _GLIBCXX_SIMD_HAVE_SSE4A 0
137 #define _GLIBCXX_SIMD_HAVE_FMA 1
139 #define _GLIBCXX_SIMD_HAVE_FMA 0
142 #define _GLIBCXX_SIMD_HAVE_FMA4 1
144 #define _GLIBCXX_SIMD_HAVE_FMA4 0
147 #define _GLIBCXX_SIMD_HAVE_F16C 1
149 #define _GLIBCXX_SIMD_HAVE_F16C 0
152 #define _GLIBCXX_SIMD_HAVE_POPCNT 1
154 #define _GLIBCXX_SIMD_HAVE_POPCNT 0
157 #define _GLIBCXX_SIMD_HAVE_AVX512F 1
159 #define _GLIBCXX_SIMD_HAVE_AVX512F 0
162 #define _GLIBCXX_SIMD_HAVE_AVX512DQ 1
164 #define _GLIBCXX_SIMD_HAVE_AVX512DQ 0
167 #define _GLIBCXX_SIMD_HAVE_AVX512VL 1
169 #define _GLIBCXX_SIMD_HAVE_AVX512VL 0
172 #define _GLIBCXX_SIMD_HAVE_AVX512BW 1
174 #define _GLIBCXX_SIMD_HAVE_AVX512BW 0
176 #ifdef __AVX512BITALG__
177 #define _GLIBCXX_SIMD_HAVE_AVX512BITALG 1
179 #define _GLIBCXX_SIMD_HAVE_AVX512BITALG 0
181 #ifdef __AVX512VBMI2__
182 #define _GLIBCXX_SIMD_HAVE_AVX512VBMI2 1
184 #define _GLIBCXX_SIMD_HAVE_AVX512VBMI2 0
186 #ifdef __AVX512VBMI__
187 #define _GLIBCXX_SIMD_HAVE_AVX512VBMI 1
189 #define _GLIBCXX_SIMD_HAVE_AVX512VBMI 0
191 #ifdef __AVX512IFMA__
192 #define _GLIBCXX_SIMD_HAVE_AVX512IFMA 1
194 #define _GLIBCXX_SIMD_HAVE_AVX512IFMA 0
197 #define _GLIBCXX_SIMD_HAVE_AVX512CD 1
199 #define _GLIBCXX_SIMD_HAVE_AVX512CD 0
201 #ifdef __AVX512VNNI__
202 #define _GLIBCXX_SIMD_HAVE_AVX512VNNI 1
204 #define _GLIBCXX_SIMD_HAVE_AVX512VNNI 0
206 #ifdef __AVX512VPOPCNTDQ__
207 #define _GLIBCXX_SIMD_HAVE_AVX512VPOPCNTDQ 1
209 #define _GLIBCXX_SIMD_HAVE_AVX512VPOPCNTDQ 0
211 #ifdef __AVX512VP2INTERSECT__
212 #define _GLIBCXX_SIMD_HAVE_AVX512VP2INTERSECT 1
214 #define _GLIBCXX_SIMD_HAVE_AVX512VP2INTERSECT 0
217 #if _GLIBCXX_SIMD_HAVE_SSE
218 #define _GLIBCXX_SIMD_HAVE_SSE_ABI 1
220 #define _GLIBCXX_SIMD_HAVE_SSE_ABI 0
222 #if _GLIBCXX_SIMD_HAVE_SSE2
223 #define _GLIBCXX_SIMD_HAVE_FULL_SSE_ABI 1
225 #define _GLIBCXX_SIMD_HAVE_FULL_SSE_ABI 0
228 #if _GLIBCXX_SIMD_HAVE_AVX
229 #define _GLIBCXX_SIMD_HAVE_AVX_ABI 1
231 #define _GLIBCXX_SIMD_HAVE_AVX_ABI 0
233 #if _GLIBCXX_SIMD_HAVE_AVX2
234 #define _GLIBCXX_SIMD_HAVE_FULL_AVX_ABI 1
236 #define _GLIBCXX_SIMD_HAVE_FULL_AVX_ABI 0
239 #if _GLIBCXX_SIMD_HAVE_AVX512F
240 #define _GLIBCXX_SIMD_HAVE_AVX512_ABI 1
242 #define _GLIBCXX_SIMD_HAVE_AVX512_ABI 0
244 #if _GLIBCXX_SIMD_HAVE_AVX512BW
245 #define _GLIBCXX_SIMD_HAVE_FULL_AVX512_ABI 1
247 #define _GLIBCXX_SIMD_HAVE_FULL_AVX512_ABI 0
250 #if defined __x86_64__ && !_GLIBCXX_SIMD_HAVE_SSE2
251 #error "Use of SSE2 is required on AMD64"
256 #define _GLIBCXX_SIMD_NORMAL_MATH
258 #define _GLIBCXX_SIMD_NORMAL_MATH \
259 [[__gnu__::__optimize__("finite-math-only,no-signed-zeros")]]
261 #define _GLIBCXX_SIMD_NEVER_INLINE [[__gnu__::__noinline__]]
262 #define _GLIBCXX_SIMD_INTRINSIC \
263 [[__gnu__::__always_inline__, __gnu__::__artificial__]] inline
264 #define _GLIBCXX_SIMD_ALWAYS_INLINE [[__gnu__::__always_inline__]] inline
265 #define _GLIBCXX_SIMD_IS_UNLIKELY(__x) __builtin_expect(__x, 0)
266 #define _GLIBCXX_SIMD_IS_LIKELY(__x) __builtin_expect(__x, 1)
268 #if defined __STRICT_ANSI__ && __STRICT_ANSI__
269 #define _GLIBCXX_SIMD_CONSTEXPR
270 #define _GLIBCXX_SIMD_USE_CONSTEXPR_API const
272 #define _GLIBCXX_SIMD_CONSTEXPR constexpr
273 #define _GLIBCXX_SIMD_USE_CONSTEXPR_API constexpr
276 #if defined __clang__
277 #define _GLIBCXX_SIMD_USE_CONSTEXPR const
279 #define _GLIBCXX_SIMD_USE_CONSTEXPR constexpr
282 #define _GLIBCXX_SIMD_LIST_BINARY(__macro) __macro(|) __macro(&) __macro(^)
283 #define _GLIBCXX_SIMD_LIST_SHIFTS(__macro) __macro(<<) __macro(>>)
284 #define _GLIBCXX_SIMD_LIST_ARITHMETICS(__macro) \
285 __macro(+) __macro(-) __macro(*) __macro(/) __macro(%)
287 #define _GLIBCXX_SIMD_ALL_BINARY(__macro) \
288 _GLIBCXX_SIMD_LIST_BINARY(__macro) static_assert(true)
289 #define _GLIBCXX_SIMD_ALL_SHIFTS(__macro) \
290 _GLIBCXX_SIMD_LIST_SHIFTS(__macro) static_assert(true)
291 #define _GLIBCXX_SIMD_ALL_ARITHMETICS(__macro) \
292 _GLIBCXX_SIMD_LIST_ARITHMETICS(__macro) static_assert(true)
294 #ifdef _GLIBCXX_SIMD_NO_ALWAYS_INLINE
295 #undef _GLIBCXX_SIMD_ALWAYS_INLINE
296 #define _GLIBCXX_SIMD_ALWAYS_INLINE inline
297 #undef _GLIBCXX_SIMD_INTRINSIC
298 #define _GLIBCXX_SIMD_INTRINSIC inline
301 #if _GLIBCXX_SIMD_HAVE_SSE || _GLIBCXX_SIMD_HAVE_MMX
302 #define _GLIBCXX_SIMD_X86INTRIN 1
304 #define _GLIBCXX_SIMD_X86INTRIN 0
311 #define _GLIBCXX_SIMD_USE_ALIASING_LOADS 1
314 #if _GLIBCXX_SIMD_X86INTRIN
315 #define _GLIBCXX_SIMD_WORKAROUND_PR85048 1
319 #define _GLIBCXX_SIMD_WORKAROUND_PR90993 1
323 #if _GLIBCXX_SIMD_X86INTRIN
324 #define _GLIBCXX_SIMD_WORKAROUND_XXX_1 1
328 #define _GLIBCXX_SIMD_WORKAROUND_PR90424 1
331 #if _GLIBCXX_SIMD_X86INTRIN
332 #define _GLIBCXX_SIMD_WORKAROUND_XXX_3 1
337 #define _GLIBCXX_SIMD_FIX_P2TS_ISSUE65 1
341 #define _GLIBCXX_SIMD_FIX_P2TS_ISSUE66 1