authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-11 16:20:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-19 09:37:31-07:00
log1861036f3b61828d0b7641dcce65f37e516fd3f6
tree30fb5a5dfec4e83c176d10296ee78d97318c29eb
parent3ed40b114020ff774279a5af993851d74da64b52

update C language headers to LLVM 17

release/17.x branch, commit 8f4dd44097c9ae25dd203d5ac87f3b48f854bba8

49 files changed, 8865 insertions(+), 401 deletions(-)

lib/include/__clang_cuda_intrinsics.h+191
......@@ -513,6 +513,197 @@ __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
513513 return __nv_cvta_generic_to_shared_impl(__ptr);
514514}
515515} // extern "C"
516
517#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
518__device__ inline unsigned __reduce_add_sync(unsigned __mask,
519 unsigned __value) {
520 return __nvvm_redux_sync_add(__mask, __value);
521}
522__device__ inline unsigned __reduce_min_sync(unsigned __mask,
523 unsigned __value) {
524 return __nvvm_redux_sync_umin(__mask, __value);
525}
526__device__ inline unsigned __reduce_max_sync(unsigned __mask,
527 unsigned __value) {
528 return __nvvm_redux_sync_umax(__mask, __value);
529}
530__device__ inline int __reduce_min_sync(unsigned __mask, int __value) {
531 return __nvvm_redux_sync_min(__mask, __value);
532}
533__device__ inline int __reduce_max_sync(unsigned __mask, int __value) {
534 return __nvvm_redux_sync_max(__mask, __value);
535}
536__device__ inline unsigned __reduce_or_sync(unsigned __mask, unsigned __value) {
537 return __nvvm_redux_sync_or(__mask, __value);
538}
539__device__ inline unsigned __reduce_and_sync(unsigned __mask,
540 unsigned __value) {
541 return __nvvm_redux_sync_and(__mask, __value);
542}
543__device__ inline unsigned __reduce_xor_sync(unsigned __mask,
544 unsigned __value) {
545 return __nvvm_redux_sync_xor(__mask, __value);
546}
547
548__device__ inline void __nv_memcpy_async_shared_global_4(void *__dst,
549 const void *__src,
550 unsigned __src_size) {
551 __nvvm_cp_async_ca_shared_global_4(
552 (void __attribute__((address_space(3))) *)__dst,
553 (const void __attribute__((address_space(1))) *)__src, __src_size);
554}
555__device__ inline void __nv_memcpy_async_shared_global_8(void *__dst,
556 const void *__src,
557 unsigned __src_size) {
558 __nvvm_cp_async_ca_shared_global_8(
559 (void __attribute__((address_space(3))) *)__dst,
560 (const void __attribute__((address_space(1))) *)__src, __src_size);
561}
562__device__ inline void __nv_memcpy_async_shared_global_16(void *__dst,
563 const void *__src,
564 unsigned __src_size) {
565 __nvvm_cp_async_ca_shared_global_16(
566 (void __attribute__((address_space(3))) *)__dst,
567 (const void __attribute__((address_space(1))) *)__src, __src_size);
568}
569
570__device__ inline void *
571__nv_associate_access_property(const void *__ptr, unsigned long long __prop) {
572 // TODO: it appears to provide compiler with some sort of a hint. We do not
573 // know what exactly it is supposed to do. However, CUDA headers suggest that
574 // just passing through __ptr should not affect correctness. They do so on
575 // pre-sm80 GPUs where this builtin is not available.
576 return (void*)__ptr;
577}
578#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
579
580#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 900
581__device__ inline unsigned __isCtaShared(const void *ptr) {
582 return __isShared(ptr);
583}
584
585__device__ inline unsigned __isClusterShared(const void *__ptr) {
586 return __nvvm_isspacep_shared_cluster(__ptr);
587}
588
589__device__ inline void *__cluster_map_shared_rank(const void *__ptr,
590 unsigned __rank) {
591 return __nvvm_mapa((void *)__ptr, __rank);
592}
593
594__device__ inline unsigned __cluster_query_shared_rank(const void *__ptr) {
595 return __nvvm_getctarank((void *)__ptr);
596}
597
598__device__ inline uint2
599__cluster_map_shared_multicast(const void *__ptr,
600 unsigned int __cluster_cta_mask) {
601 return make_uint2((unsigned)__cvta_generic_to_shared(__ptr),
602 __cluster_cta_mask);
603}
604
605__device__ inline unsigned __clusterDimIsSpecified() {
606 return __nvvm_is_explicit_cluster();
607}
608
609__device__ inline dim3 __clusterDim() {
610 return dim3(__nvvm_read_ptx_sreg_cluster_nctaid_x(),
611 __nvvm_read_ptx_sreg_cluster_nctaid_y(),
612 __nvvm_read_ptx_sreg_cluster_nctaid_z());
613}
614
615__device__ inline dim3 __clusterRelativeBlockIdx() {
616 return dim3(__nvvm_read_ptx_sreg_cluster_ctaid_x(),
617 __nvvm_read_ptx_sreg_cluster_ctaid_y(),
618 __nvvm_read_ptx_sreg_cluster_ctaid_z());
619}
620
621__device__ inline dim3 __clusterGridDimInClusters() {
622 return dim3(__nvvm_read_ptx_sreg_nclusterid_x(),
623 __nvvm_read_ptx_sreg_nclusterid_y(),
624 __nvvm_read_ptx_sreg_nclusterid_z());
625}
626
627__device__ inline dim3 __clusterIdx() {
628 return dim3(__nvvm_read_ptx_sreg_clusterid_x(),
629 __nvvm_read_ptx_sreg_clusterid_y(),
630 __nvvm_read_ptx_sreg_clusterid_z());
631}
632
633__device__ inline unsigned __clusterRelativeBlockRank() {
634 return __nvvm_read_ptx_sreg_cluster_ctarank();
635}
636
637__device__ inline unsigned __clusterSizeInBlocks() {
638 return __nvvm_read_ptx_sreg_cluster_nctarank();
639}
640
641__device__ inline void __cluster_barrier_arrive() {
642 __nvvm_barrier_cluster_arrive();
643}
644
645__device__ inline void __cluster_barrier_arrive_relaxed() {
646 __nvvm_barrier_cluster_arrive_relaxed();
647}
648
649__device__ inline void __cluster_barrier_wait() {
650 __nvvm_barrier_cluster_wait();
651}
652
653__device__ inline void __threadfence_cluster() { __nvvm_fence_sc_cluster(); }
654
655__device__ inline float2 atomicAdd(float2 *__ptr, float2 __val) {
656 float2 __ret;
657 __asm__("atom.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
658 : "=f"(__ret.x), "=f"(__ret.y)
659 : "l"(__ptr), "f"(__val.x), "f"(__val.y));
660 return __ret;
661}
662
663__device__ inline float2 atomicAdd_block(float2 *__ptr, float2 __val) {
664 float2 __ret;
665 __asm__("atom.cta.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
666 : "=f"(__ret.x), "=f"(__ret.y)
667 : "l"(__ptr), "f"(__val.x), "f"(__val.y));
668 return __ret;
669}
670
671__device__ inline float2 atomicAdd_system(float2 *__ptr, float2 __val) {
672 float2 __ret;
673 __asm__("atom.sys.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
674 : "=f"(__ret.x), "=f"(__ret.y)
675 : "l"(__ptr), "f"(__val.x), "f"(__val.y));
676 return __ret;
677}
678
679__device__ inline float4 atomicAdd(float4 *__ptr, float4 __val) {
680 float4 __ret;
681 __asm__("atom.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
682 : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
683 : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w));
684 return __ret;
685}
686
687__device__ inline float4 atomicAdd_block(float4 *__ptr, float4 __val) {
688 float4 __ret;
689 __asm__(
690 "atom.cta.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
691 : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
692 : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w));
693 return __ret;
694}
695
696__device__ inline float4 atomicAdd_system(float4 *__ptr, float4 __val) {
697 float4 __ret;
698 __asm__(
699 "atom.sys.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
700 : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
701 : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w)
702 :);
703 return __ret;
704}
705
706#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 900
516707#endif // CUDA_VERSION >= 11000
517708
518709#endif // defined(__CLANG_CUDA_INTRINSICS_H__)
lib/include/__clang_hip_cmath.h+1-1
......@@ -171,7 +171,7 @@ __DEVICE__ __CONSTEXPR__ bool signbit(double __x) { return ::__signbit(__x); }
171171// Other functions.
172172__DEVICE__ __CONSTEXPR__ _Float16 fma(_Float16 __x, _Float16 __y,
173173 _Float16 __z) {
174 return __ocml_fma_f16(__x, __y, __z);
174 return __builtin_fmaf16(__x, __y, __z);
175175}
176176__DEVICE__ __CONSTEXPR__ _Float16 pow(_Float16 __base, int __iexp) {
177177 return __ocml_pown_f16(__base, __iexp);
lib/include/__clang_hip_libdevice_declares.h+32-30
......@@ -10,6 +10,10 @@
1010#ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
1111#define __CLANG_HIP_LIBDEVICE_DECLARES_H__
1212
13#if !defined(__HIPCC_RTC__) && __has_include("hip/hip_version.h")
14#include "hip/hip_version.h"
15#endif // __has_include("hip/hip_version.h")
16
1317#ifdef __cplusplus
1418extern "C" {
1519#endif
......@@ -137,23 +141,6 @@ __device__ __attribute__((const)) float __ocml_fma_rte_f32(float, float, float);
137141__device__ __attribute__((const)) float __ocml_fma_rtn_f32(float, float, float);
138142__device__ __attribute__((const)) float __ocml_fma_rtp_f32(float, float, float);
139143__device__ __attribute__((const)) float __ocml_fma_rtz_f32(float, float, float);
140
141__device__ inline __attribute__((const)) float
142__llvm_amdgcn_cos_f32(float __x) {
143 return __builtin_amdgcn_cosf(__x);
144}
145__device__ inline __attribute__((const)) float
146__llvm_amdgcn_rcp_f32(float __x) {
147 return __builtin_amdgcn_rcpf(__x);
148}
149__device__ inline __attribute__((const)) float
150__llvm_amdgcn_rsq_f32(float __x) {
151 return __builtin_amdgcn_rsqf(__x);
152}
153__device__ inline __attribute__((const)) float
154__llvm_amdgcn_sin_f32(float __x) {
155 return __builtin_amdgcn_sinf(__x);
156}
157144// END INTRINSICS
158145// END FLOAT
159146
......@@ -277,15 +264,6 @@ __device__ __attribute__((const)) double __ocml_fma_rtp_f64(double, double,
277264__device__ __attribute__((const)) double __ocml_fma_rtz_f64(double, double,
278265 double);
279266
280__device__ inline __attribute__((const)) double
281__llvm_amdgcn_rcp_f64(double __x) {
282 return __builtin_amdgcn_rcp(__x);
283}
284__device__ inline __attribute__((const)) double
285__llvm_amdgcn_rsq_f64(double __x) {
286 return __builtin_amdgcn_rsq(__x);
287}
288
289267__device__ __attribute__((const)) _Float16 __ocml_ceil_f16(_Float16);
290268__device__ _Float16 __ocml_cos_f16(_Float16);
291269__device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float);
......@@ -305,7 +283,6 @@ __device__ __attribute__((const)) int __ocml_isnan_f16(_Float16);
305283__device__ __attribute__((pure)) _Float16 __ocml_log_f16(_Float16);
306284__device__ __attribute__((pure)) _Float16 __ocml_log10_f16(_Float16);
307285__device__ __attribute__((pure)) _Float16 __ocml_log2_f16(_Float16);
308__device__ __attribute__((const)) _Float16 __llvm_amdgcn_rcp_f16(_Float16);
309286__device__ __attribute__((const)) _Float16 __ocml_rint_f16(_Float16);
310287__device__ __attribute__((const)) _Float16 __ocml_rsqrt_f16(_Float16);
311288__device__ _Float16 __ocml_sin_f16(_Float16);
......@@ -316,8 +293,15 @@ __device__ __attribute__((pure)) _Float16 __ocml_pown_f16(_Float16, int);
316293typedef _Float16 __2f16 __attribute__((ext_vector_type(2)));
317294typedef short __2i16 __attribute__((ext_vector_type(2)));
318295
296// We need to match C99's bool and get an i1 in the IR.
297#ifdef __cplusplus
298typedef bool __ockl_bool;
299#else
300typedef _Bool __ockl_bool;
301#endif
302
319303__device__ __attribute__((const)) float __ockl_fdot2(__2f16 a, __2f16 b,
320 float c, bool s);
304 float c, __ockl_bool s);
321305__device__ __attribute__((const)) __2f16 __ocml_ceil_2f16(__2f16);
322306__device__ __attribute__((const)) __2f16 __ocml_fabs_2f16(__2f16);
323307__device__ __2f16 __ocml_cos_2f16(__2f16);
......@@ -332,11 +316,29 @@ __device__ __attribute__((const)) __2i16 __ocml_isnan_2f16(__2f16);
332316__device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16);
333317__device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
334318__device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
319
320#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 560
321#define __DEPRECATED_SINCE_HIP_560(X) __attribute__((deprecated(X)))
322#else
323#define __DEPRECATED_SINCE_HIP_560(X)
324#endif
325
326// Deprecated, should be removed when rocm releases using it are no longer
327// relevant.
328__DEPRECATED_SINCE_HIP_560("use ((_Float16)1.0) / ")
329__device__ inline _Float16 __llvm_amdgcn_rcp_f16(_Float16 x) {
330 return ((_Float16)1.0f) / x;
331}
332
333__DEPRECATED_SINCE_HIP_560("use ((__2f16)1.0) / ")
335334__device__ inline __2f16
336__llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
335__llvm_amdgcn_rcp_2f16(__2f16 __x)
337336{
338 return (__2f16)(__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y));
337 return ((__2f16)1.0f) / __x;
339338}
339
340#undef __DEPRECATED_SINCE_HIP_560
341
340342__device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
341343__device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
342344__device__ __2f16 __ocml_sin_2f16(__2f16);
lib/include/__clang_hip_math.h+56-71
......@@ -182,10 +182,10 @@ __DEVICE__
182182float cbrtf(float __x) { return __ocml_cbrt_f32(__x); }
183183
184184__DEVICE__
185float ceilf(float __x) { return __ocml_ceil_f32(__x); }
185float ceilf(float __x) { return __builtin_ceilf(__x); }
186186
187187__DEVICE__
188float copysignf(float __x, float __y) { return __ocml_copysign_f32(__x, __y); }
188float copysignf(float __x, float __y) { return __builtin_copysignf(__x, __y); }
189189
190190__DEVICE__
191191float cosf(float __x) { return __ocml_cos_f32(__x); }
......@@ -221,10 +221,10 @@ __DEVICE__
221221float exp10f(float __x) { return __ocml_exp10_f32(__x); }
222222
223223__DEVICE__
224float exp2f(float __x) { return __ocml_exp2_f32(__x); }
224float exp2f(float __x) { return __builtin_exp2f(__x); }
225225
226226__DEVICE__
227float expf(float __x) { return __ocml_exp_f32(__x); }
227float expf(float __x) { return __builtin_expf(__x); }
228228
229229__DEVICE__
230230float expm1f(float __x) { return __ocml_expm1_f32(__x); }
......@@ -239,33 +239,25 @@ __DEVICE__
239239float fdividef(float __x, float __y) { return __x / __y; }
240240
241241__DEVICE__
242float floorf(float __x) { return __ocml_floor_f32(__x); }
242float floorf(float __x) { return __builtin_floorf(__x); }
243243
244244__DEVICE__
245245float fmaf(float __x, float __y, float __z) {
246 return __ocml_fma_f32(__x, __y, __z);
246 return __builtin_fmaf(__x, __y, __z);
247247}
248248
249249__DEVICE__
250float fmaxf(float __x, float __y) { return __ocml_fmax_f32(__x, __y); }
250float fmaxf(float __x, float __y) { return __builtin_fmaxf(__x, __y); }
251251
252252__DEVICE__
253float fminf(float __x, float __y) { return __ocml_fmin_f32(__x, __y); }
253float fminf(float __x, float __y) { return __builtin_fminf(__x, __y); }
254254
255255__DEVICE__
256256float fmodf(float __x, float __y) { return __ocml_fmod_f32(__x, __y); }
257257
258258__DEVICE__
259259float frexpf(float __x, int *__nptr) {
260 int __tmp;
261#ifdef __OPENMP_AMDGCN__
262#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
263#endif
264 float __r =
265 __ocml_frexp_f32(__x, (__attribute__((address_space(5))) int *)&__tmp);
266 *__nptr = __tmp;
267
268 return __r;
260 return __builtin_frexpf(__x, __nptr);
269261}
270262
271263__DEVICE__
......@@ -275,13 +267,13 @@ __DEVICE__
275267int ilogbf(float __x) { return __ocml_ilogb_f32(__x); }
276268
277269__DEVICE__
278__RETURN_TYPE __finitef(float __x) { return __ocml_isfinite_f32(__x); }
270__RETURN_TYPE __finitef(float __x) { return __builtin_isfinite(__x); }
279271
280272__DEVICE__
281__RETURN_TYPE __isinff(float __x) { return __ocml_isinf_f32(__x); }
273__RETURN_TYPE __isinff(float __x) { return __builtin_isinf(__x); }
282274
283275__DEVICE__
284__RETURN_TYPE __isnanf(float __x) { return __ocml_isnan_f32(__x); }
276__RETURN_TYPE __isnanf(float __x) { return __builtin_isnan(__x); }
285277
286278__DEVICE__
287279float j0f(float __x) { return __ocml_j0_f32(__x); }
......@@ -311,37 +303,37 @@ float jnf(int __n, float __x) { // TODO: we could use Ahmes multiplication
311303}
312304
313305__DEVICE__
314float ldexpf(float __x, int __e) { return __ocml_ldexp_f32(__x, __e); }
306float ldexpf(float __x, int __e) { return __builtin_amdgcn_ldexpf(__x, __e); }
315307
316308__DEVICE__
317309float lgammaf(float __x) { return __ocml_lgamma_f32(__x); }
318310
319311__DEVICE__
320long long int llrintf(float __x) { return __ocml_rint_f32(__x); }
312long long int llrintf(float __x) { return __builtin_rintf(__x); }
321313
322314__DEVICE__
323long long int llroundf(float __x) { return __ocml_round_f32(__x); }
315long long int llroundf(float __x) { return __builtin_roundf(__x); }
324316
325317__DEVICE__
326float log10f(float __x) { return __ocml_log10_f32(__x); }
318float log10f(float __x) { return __builtin_log10f(__x); }
327319
328320__DEVICE__
329321float log1pf(float __x) { return __ocml_log1p_f32(__x); }
330322
331323__DEVICE__
332float log2f(float __x) { return __ocml_log2_f32(__x); }
324float log2f(float __x) { return __builtin_log2f(__x); }
333325
334326__DEVICE__
335327float logbf(float __x) { return __ocml_logb_f32(__x); }
336328
337329__DEVICE__
338float logf(float __x) { return __ocml_log_f32(__x); }
330float logf(float __x) { return __builtin_logf(__x); }
339331
340332__DEVICE__
341long int lrintf(float __x) { return __ocml_rint_f32(__x); }
333long int lrintf(float __x) { return __builtin_rintf(__x); }
342334
343335__DEVICE__
344long int lroundf(float __x) { return __ocml_round_f32(__x); }
336long int lroundf(float __x) { return __builtin_roundf(__x); }
345337
346338__DEVICE__
347339float modff(float __x, float *__iptr) {
......@@ -377,7 +369,7 @@ float nanf(const char *__tagp __attribute__((nonnull))) {
377369}
378370
379371__DEVICE__
380float nearbyintf(float __x) { return __ocml_nearbyint_f32(__x); }
372float nearbyintf(float __x) { return __builtin_nearbyintf(__x); }
381373
382374__DEVICE__
383375float nextafterf(float __x, float __y) {
......@@ -443,7 +435,7 @@ __DEVICE__
443435float rhypotf(float __x, float __y) { return __ocml_rhypot_f32(__x, __y); }
444436
445437__DEVICE__
446float rintf(float __x) { return __ocml_rint_f32(__x); }
438float rintf(float __x) { return __builtin_rintf(__x); }
447439
448440__DEVICE__
449441float rnorm3df(float __x, float __y, float __z) {
......@@ -468,22 +460,22 @@ float rnormf(int __dim,
468460}
469461
470462__DEVICE__
471float roundf(float __x) { return __ocml_round_f32(__x); }
463float roundf(float __x) { return __builtin_roundf(__x); }
472464
473465__DEVICE__
474466float rsqrtf(float __x) { return __ocml_rsqrt_f32(__x); }
475467
476468__DEVICE__
477469float scalblnf(float __x, long int __n) {
478 return (__n < INT_MAX) ? __ocml_scalbn_f32(__x, __n)
470 return (__n < INT_MAX) ? __builtin_amdgcn_ldexpf(__x, __n)
479471 : __ocml_scalb_f32(__x, __n);
480472}
481473
482474__DEVICE__
483float scalbnf(float __x, int __n) { return __ocml_scalbn_f32(__x, __n); }
475float scalbnf(float __x, int __n) { return __builtin_amdgcn_ldexpf(__x, __n); }
484476
485477__DEVICE__
486__RETURN_TYPE __signbitf(float __x) { return __ocml_signbit_f32(__x); }
478__RETURN_TYPE __signbitf(float __x) { return __builtin_signbitf(__x); }
487479
488480__DEVICE__
489481void sincosf(float __x, float *__sinptr, float *__cosptr) {
......@@ -529,7 +521,7 @@ __DEVICE__
529521float tgammaf(float __x) { return __ocml_tgamma_f32(__x); }
530522
531523__DEVICE__
532float truncf(float __x) { return __ocml_trunc_f32(__x); }
524float truncf(float __x) { return __builtin_truncf(__x); }
533525
534526__DEVICE__
535527float y0f(float __x) { return __ocml_y0_f32(__x); }
......@@ -621,7 +613,7 @@ float __fmaf_rz(float __x, float __y, float __z) {
621613#else
622614__DEVICE__
623615float __fmaf_rn(float __x, float __y, float __z) {
624 return __ocml_fma_f32(__x, __y, __z);
616 return __builtin_fmaf(__x, __y, __z);
625617}
626618#endif
627619
......@@ -654,7 +646,7 @@ float __frcp_rn(float __x) { return 1.0f / __x; }
654646#endif
655647
656648__DEVICE__
657float __frsqrt_rn(float __x) { return __llvm_amdgcn_rsq_f32(__x); }
649float __frsqrt_rn(float __x) { return __builtin_amdgcn_rsqf(__x); }
658650
659651#if defined OCML_BASIC_ROUNDED_OPERATIONS
660652__DEVICE__
......@@ -739,11 +731,11 @@ __DEVICE__
739731double cbrt(double __x) { return __ocml_cbrt_f64(__x); }
740732
741733__DEVICE__
742double ceil(double __x) { return __ocml_ceil_f64(__x); }
734double ceil(double __x) { return __builtin_ceil(__x); }
743735
744736__DEVICE__
745737double copysign(double __x, double __y) {
746 return __ocml_copysign_f64(__x, __y);
738 return __builtin_copysign(__x, __y);
747739}
748740
749741__DEVICE__
......@@ -795,32 +787,25 @@ __DEVICE__
795787double fdim(double __x, double __y) { return __ocml_fdim_f64(__x, __y); }
796788
797789__DEVICE__
798double floor(double __x) { return __ocml_floor_f64(__x); }
790double floor(double __x) { return __builtin_floor(__x); }
799791
800792__DEVICE__
801793double fma(double __x, double __y, double __z) {
802 return __ocml_fma_f64(__x, __y, __z);
794 return __builtin_fma(__x, __y, __z);
803795}
804796
805797__DEVICE__
806double fmax(double __x, double __y) { return __ocml_fmax_f64(__x, __y); }
798double fmax(double __x, double __y) { return __builtin_fmax(__x, __y); }
807799
808800__DEVICE__
809double fmin(double __x, double __y) { return __ocml_fmin_f64(__x, __y); }
801double fmin(double __x, double __y) { return __builtin_fmin(__x, __y); }
810802
811803__DEVICE__
812804double fmod(double __x, double __y) { return __ocml_fmod_f64(__x, __y); }
813805
814806__DEVICE__
815807double frexp(double __x, int *__nptr) {
816 int __tmp;
817#ifdef __OPENMP_AMDGCN__
818#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
819#endif
820 double __r =
821 __ocml_frexp_f64(__x, (__attribute__((address_space(5))) int *)&__tmp);
822 *__nptr = __tmp;
823 return __r;
808 return __builtin_frexp(__x, __nptr);
824809}
825810
826811__DEVICE__
......@@ -830,13 +815,13 @@ __DEVICE__
830815int ilogb(double __x) { return __ocml_ilogb_f64(__x); }
831816
832817__DEVICE__
833__RETURN_TYPE __finite(double __x) { return __ocml_isfinite_f64(__x); }
818__RETURN_TYPE __finite(double __x) { return __builtin_isfinite(__x); }
834819
835820__DEVICE__
836__RETURN_TYPE __isinf(double __x) { return __ocml_isinf_f64(__x); }
821__RETURN_TYPE __isinf(double __x) { return __builtin_isinf(__x); }
837822
838823__DEVICE__
839__RETURN_TYPE __isnan(double __x) { return __ocml_isnan_f64(__x); }
824__RETURN_TYPE __isnan(double __x) { return __builtin_isnan(__x); }
840825
841826__DEVICE__
842827double j0(double __x) { return __ocml_j0_f64(__x); }
......@@ -866,16 +851,16 @@ double jn(int __n, double __x) { // TODO: we could use Ahmes multiplication
866851}
867852
868853__DEVICE__
869double ldexp(double __x, int __e) { return __ocml_ldexp_f64(__x, __e); }
854double ldexp(double __x, int __e) { return __builtin_amdgcn_ldexp(__x, __e); }
870855
871856__DEVICE__
872857double lgamma(double __x) { return __ocml_lgamma_f64(__x); }
873858
874859__DEVICE__
875long long int llrint(double __x) { return __ocml_rint_f64(__x); }
860long long int llrint(double __x) { return __builtin_rint(__x); }
876861
877862__DEVICE__
878long long int llround(double __x) { return __ocml_round_f64(__x); }
863long long int llround(double __x) { return __builtin_round(__x); }
879864
880865__DEVICE__
881866double log(double __x) { return __ocml_log_f64(__x); }
......@@ -893,10 +878,10 @@ __DEVICE__
893878double logb(double __x) { return __ocml_logb_f64(__x); }
894879
895880__DEVICE__
896long int lrint(double __x) { return __ocml_rint_f64(__x); }
881long int lrint(double __x) { return __builtin_rint(__x); }
897882
898883__DEVICE__
899long int lround(double __x) { return __ocml_round_f64(__x); }
884long int lround(double __x) { return __builtin_round(__x); }
900885
901886__DEVICE__
902887double modf(double __x, double *__iptr) {
......@@ -940,7 +925,7 @@ double nan(const char *__tagp) {
940925}
941926
942927__DEVICE__
943double nearbyint(double __x) { return __ocml_nearbyint_f64(__x); }
928double nearbyint(double __x) { return __builtin_nearbyint(__x); }
944929
945930__DEVICE__
946931double nextafter(double __x, double __y) {
......@@ -1006,7 +991,7 @@ __DEVICE__
1006991double rhypot(double __x, double __y) { return __ocml_rhypot_f64(__x, __y); }
1007992
1008993__DEVICE__
1009double rint(double __x) { return __ocml_rint_f64(__x); }
994double rint(double __x) { return __builtin_rint(__x); }
1010995
1011996__DEVICE__
1012997double rnorm(int __dim,
......@@ -1031,21 +1016,21 @@ double rnorm4d(double __x, double __y, double __z, double __w) {
10311016}
10321017
10331018__DEVICE__
1034double round(double __x) { return __ocml_round_f64(__x); }
1019double round(double __x) { return __builtin_round(__x); }
10351020
10361021__DEVICE__
10371022double rsqrt(double __x) { return __ocml_rsqrt_f64(__x); }
10381023
10391024__DEVICE__
10401025double scalbln(double __x, long int __n) {
1041 return (__n < INT_MAX) ? __ocml_scalbn_f64(__x, __n)
1026 return (__n < INT_MAX) ? __builtin_amdgcn_ldexp(__x, __n)
10421027 : __ocml_scalb_f64(__x, __n);
10431028}
10441029__DEVICE__
1045double scalbn(double __x, int __n) { return __ocml_scalbn_f64(__x, __n); }
1030double scalbn(double __x, int __n) { return __builtin_amdgcn_ldexp(__x, __n); }
10461031
10471032__DEVICE__
1048__RETURN_TYPE __signbit(double __x) { return __ocml_signbit_f64(__x); }
1033__RETURN_TYPE __signbit(double __x) { return __builtin_signbit(__x); }
10491034
10501035__DEVICE__
10511036double sin(double __x) { return __ocml_sin_f64(__x); }
......@@ -1091,7 +1076,7 @@ __DEVICE__
10911076double tgamma(double __x) { return __ocml_tgamma_f64(__x); }
10921077
10931078__DEVICE__
1094double trunc(double __x) { return __ocml_trunc_f64(__x); }
1079double trunc(double __x) { return __builtin_trunc(__x); }
10951080
10961081__DEVICE__
10971082double y0(double __x) { return __ocml_y0_f64(__x); }
......@@ -1258,7 +1243,7 @@ double __fma_rz(double __x, double __y, double __z) {
12581243#else
12591244__DEVICE__
12601245double __fma_rn(double __x, double __y, double __z) {
1261 return __ocml_fma_f64(__x, __y, __z);
1246 return __builtin_fma(__x, __y, __z);
12621247}
12631248#endif
12641249// END INTRINSICS
......@@ -1290,16 +1275,16 @@ __DEVICE__ int max(int __arg1, int __arg2) {
12901275}
12911276
12921277__DEVICE__
1293float max(float __x, float __y) { return fmaxf(__x, __y); }
1278float max(float __x, float __y) { return __builtin_fmaxf(__x, __y); }
12941279
12951280__DEVICE__
1296double max(double __x, double __y) { return fmax(__x, __y); }
1281double max(double __x, double __y) { return __builtin_fmax(__x, __y); }
12971282
12981283__DEVICE__
1299float min(float __x, float __y) { return fminf(__x, __y); }
1284float min(float __x, float __y) { return __builtin_fminf(__x, __y); }
13001285
13011286__DEVICE__
1302double min(double __x, double __y) { return fmin(__x, __y); }
1287double min(double __x, double __y) { return __builtin_fmin(__x, __y); }
13031288
13041289#if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
13051290__host__ inline static int min(int __arg1, int __arg2) {
lib/include/__clang_hip_runtime_wrapper.h+13
......@@ -80,12 +80,25 @@ extern "C" {
8080#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 405
8181extern "C" __device__ unsigned long long __ockl_dm_alloc(unsigned long long __size);
8282extern "C" __device__ void __ockl_dm_dealloc(unsigned long long __addr);
83#if __has_feature(address_sanitizer)
84extern "C" __device__ unsigned long long __asan_malloc_impl(unsigned long long __size, unsigned long long __pc);
85extern "C" __device__ void __asan_free_impl(unsigned long long __addr, unsigned long long __pc);
86__attribute__((noinline, weak)) __device__ void *malloc(__hip_size_t __size) {
87 unsigned long long __pc = (unsigned long long)__builtin_return_address(0);
88 return (void *)__asan_malloc_impl(__size, __pc);
89}
90__attribute__((noinline, weak)) __device__ void free(void *__ptr) {
91 unsigned long long __pc = (unsigned long long)__builtin_return_address(0);
92 __asan_free_impl((unsigned long long)__ptr, __pc);
93}
94#else
8395__attribute__((weak)) inline __device__ void *malloc(__hip_size_t __size) {
8496 return (void *) __ockl_dm_alloc(__size);
8597}
8698__attribute__((weak)) inline __device__ void free(void *__ptr) {
8799 __ockl_dm_dealloc((unsigned long long)__ptr);
88100}
101#endif // __has_feature(address_sanitizer)
89102#else // HIP version check
90103#if __HIP_ENABLE_DEVICE_MALLOC__
91104__device__ void *__hip_malloc(__hip_size_t __size);
lib/include/adxintrin.h+179-24
......@@ -17,56 +17,211 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
1919
20/* Intrinsics that are available only if __ADX__ defined */
21static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
22_addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
23 unsigned int *__p)
24{
20/* Use C++ inline semantics in C++, GNU inline for C mode. */
21#if defined(__cplusplus)
22#define __INLINE __inline
23#else
24#define __INLINE static __inline
25#endif
26
27#if defined(__cplusplus)
28extern "C" {
29#endif
30
31/* Intrinsics that are available only if __ADX__ is defined. */
32
33/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated
34/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory
35/// at \a __p, and returns the 8-bit carry-out (carry flag).
36///
37/// \code{.operation}
38/// temp := (__cf == 0) ? 0 : 1
39/// Store32(__p, __x + __y + temp)
40/// result := CF
41/// \endcode
42///
43/// \headerfile <immintrin.h>
44///
45/// This intrinsic corresponds to the \c ADCX instruction.
46///
47/// \param __cf
48/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
49/// \param __x
50/// A 32-bit unsigned addend.
51/// \param __y
52/// A 32-bit unsigned addend.
53/// \param __p
54/// Pointer to memory for storing the sum.
55/// \returns The 8-bit unsigned carry-out value.
56__INLINE unsigned char
57 __attribute__((__always_inline__, __nodebug__, __target__("adx")))
58 _addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
59 unsigned int *__p) {
2560 return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
2661}
2762
2863#ifdef __x86_64__
29static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
30_addcarryx_u64(unsigned char __cf, unsigned long long __x,
31 unsigned long long __y, unsigned long long *__p)
32{
64/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated
65/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory
66/// at \a __p, and returns the 8-bit carry-out (carry flag).
67///
68/// \code{.operation}
69/// temp := (__cf == 0) ? 0 : 1
70/// Store64(__p, __x + __y + temp)
71/// result := CF
72/// \endcode
73///
74/// \headerfile <immintrin.h>
75///
76/// This intrinsic corresponds to the \c ADCX instruction.
77///
78/// \param __cf
79/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
80/// \param __x
81/// A 64-bit unsigned addend.
82/// \param __y
83/// A 64-bit unsigned addend.
84/// \param __p
85/// Pointer to memory for storing the sum.
86/// \returns The 8-bit unsigned carry-out value.
87__INLINE unsigned char
88 __attribute__((__always_inline__, __nodebug__, __target__("adx")))
89 _addcarryx_u64(unsigned char __cf, unsigned long long __x,
90 unsigned long long __y, unsigned long long *__p) {
3391 return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
3492}
3593#endif
3694
37/* Intrinsics that are also available if __ADX__ undefined */
38static __inline unsigned char __DEFAULT_FN_ATTRS
39_addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
40 unsigned int *__p)
41{
95/* Intrinsics that are also available if __ADX__ is undefined. */
96
97/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated
98/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory
99/// at \a __p, and returns the 8-bit carry-out (carry flag).
100///
101/// \code{.operation}
102/// temp := (__cf == 0) ? 0 : 1
103/// Store32(__p, __x + __y + temp)
104/// result := CF
105/// \endcode
106///
107/// \headerfile <immintrin.h>
108///
109/// This intrinsic corresponds to the \c ADC instruction.
110///
111/// \param __cf
112/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
113/// \param __x
114/// A 32-bit unsigned addend.
115/// \param __y
116/// A 32-bit unsigned addend.
117/// \param __p
118/// Pointer to memory for storing the sum.
119/// \returns The 8-bit unsigned carry-out value.
120__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarry_u32(unsigned char __cf,
121 unsigned int __x,
122 unsigned int __y,
123 unsigned int *__p) {
42124 return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
43125}
44126
45127#ifdef __x86_64__
46static __inline unsigned char __DEFAULT_FN_ATTRS
128/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated
129/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory
130/// at \a __p, and returns the 8-bit carry-out (carry flag).
131///
132/// \code{.operation}
133/// temp := (__cf == 0) ? 0 : 1
134/// Store64(__p, __x + __y + temp)
135/// result := CF
136/// \endcode
137///
138/// \headerfile <immintrin.h>
139///
140/// This intrinsic corresponds to the \c ADC instruction.
141///
142/// \param __cf
143/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
144/// \param __x
145/// A 64-bit unsigned addend.
146/// \param __y
147/// A 64-bit unsigned addend.
148/// \param __p
149/// Pointer to memory for storing the sum.
150/// \returns The 8-bit unsigned carry-out value.
151__INLINE unsigned char __DEFAULT_FN_ATTRS
47152_addcarry_u64(unsigned char __cf, unsigned long long __x,
48 unsigned long long __y, unsigned long long *__p)
49{
153 unsigned long long __y, unsigned long long *__p) {
50154 return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
51155}
52156#endif
53157
54static __inline unsigned char __DEFAULT_FN_ATTRS
55_subborrow_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
56 unsigned int *__p)
57{
158/// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry
159/// flag \a __cf, and subtracts the result from unsigned 32-bit integer
160/// \a __x. Stores the unsigned 32-bit difference in the memory at \a __p,
161/// and returns the 8-bit carry-out (carry or overflow flag).
162///
163/// \code{.operation}
164/// temp := (__cf == 0) ? 0 : 1
165/// Store32(__p, __x - (__y + temp))
166/// result := CF
167/// \endcode
168///
169/// \headerfile <immintrin.h>
170///
171/// This intrinsic corresponds to the \c SBB instruction.
172///
173/// \param __cf
174/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
175/// \param __x
176/// The 32-bit unsigned minuend.
177/// \param __y
178/// The 32-bit unsigned subtrahend.
179/// \param __p
180/// Pointer to memory for storing the difference.
181/// \returns The 8-bit unsigned carry-out value.
182__INLINE unsigned char __DEFAULT_FN_ATTRS _subborrow_u32(unsigned char __cf,
183 unsigned int __x,
184 unsigned int __y,
185 unsigned int *__p) {
58186 return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p);
59187}
60188
61189#ifdef __x86_64__
62static __inline unsigned char __DEFAULT_FN_ATTRS
190/// Adds unsigned 64-bit integer \a __y to 0 or 1 as indicated by the carry
191/// flag \a __cf, and subtracts the result from unsigned 64-bit integer
192/// \a __x. Stores the unsigned 64-bit difference in the memory at \a __p,
193/// and returns the 8-bit carry-out (carry or overflow flag).
194///
195/// \code{.operation}
196/// temp := (__cf == 0) ? 0 : 1
197/// Store64(__p, __x - (__y + temp))
198/// result := CF
199/// \endcode
200///
201/// \headerfile <immintrin.h>
202///
203/// This intrinsic corresponds to the \c ADC instruction.
204///
205/// \param __cf
206/// The 8-bit unsigned carry flag; any non-zero value indicates carry.
207/// \param __x
208/// The 64-bit unsigned minuend.
209/// \param __y
210/// The 64-bit unsigned subtrahend.
211/// \param __p
212/// Pointer to memory for storing the difference.
213/// \returns The 8-bit unsigned carry-out value.
214__INLINE unsigned char __DEFAULT_FN_ATTRS
63215_subborrow_u64(unsigned char __cf, unsigned long long __x,
64 unsigned long long __y, unsigned long long *__p)
65{
216 unsigned long long __y, unsigned long long *__p) {
66217 return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p);
67218}
68219#endif
69220
221#if defined(__cplusplus)
222}
223#endif
224
70225#undef __DEFAULT_FN_ATTRS
71226
72227#endif /* __ADXINTRIN_H */
lib/include/altivec.h+136-124
......@@ -3202,71 +3202,79 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
32023202// the XL-compatible signatures are used for those functions.
32033203#ifdef __XL_COMPAT_ALTIVEC__
32043204#define vec_ctf(__a, __b) \
3205 _Generic( \
3206 (__a), vector int \
3207 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
3208 vector unsigned int \
3209 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3210 (__b)), \
3211 vector unsigned long long \
3212 : (vector float)(__builtin_vsx_xvcvuxdsp( \
3213 (vector unsigned long long)(__a)) * \
3214 (vector float)(vector unsigned)((0x7f - (__b)) << 23)), \
3215 vector signed long long \
3216 : (vector float)(__builtin_vsx_xvcvsxdsp( \
3217 (vector signed long long)(__a)) * \
3218 (vector float)(vector unsigned)((0x7f - (__b)) << 23)))
3205 _Generic((__a), \
3206 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3207 ((__b)&0x1F)), \
3208 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3209 (vector unsigned int)(__a), ((__b)&0x1F)), \
3210 vector unsigned long long: ( \
3211 vector float)(__builtin_vsx_xvcvuxdsp( \
3212 (vector unsigned long long)(__a)) * \
3213 (vector float)(vector unsigned)((0x7f - \
3214 ((__b)&0x1F)) \
3215 << 23)), \
3216 vector signed long long: ( \
3217 vector float)(__builtin_vsx_xvcvsxdsp( \
3218 (vector signed long long)(__a)) * \
3219 (vector float)(vector unsigned)((0x7f - \
3220 ((__b)&0x1F)) \
3221 << 23)))
32193222#else // __XL_COMPAT_ALTIVEC__
3220#define vec_ctf(__a, __b) \
3221 _Generic( \
3222 (__a), vector int \
3223 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
3224 vector unsigned int \
3225 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3226 (__b)), \
3227 vector unsigned long long \
3228 : (vector float)(__builtin_convertvector( \
3229 (vector unsigned long long)(__a), vector double) * \
3230 (vector double)(vector unsigned long long)((0x3ffULL - \
3231 (__b)) \
3232 << 52)), \
3233 vector signed long long \
3234 : (vector float)(__builtin_convertvector((vector signed long long)(__a), \
3235 vector double) * \
3236 (vector double)(vector unsigned long long)((0x3ffULL - \
3237 (__b)) \
3238 << 52)))
3223#define vec_ctf(__a, __b) \
3224 _Generic( \
3225 (__a), \
3226 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3227 ((__b)&0x1F)), \
3228 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3229 (vector unsigned int)(__a), ((__b)&0x1F)), \
3230 vector unsigned long long: ( \
3231 vector float)(__builtin_convertvector( \
3232 (vector unsigned long long)(__a), vector double) * \
3233 (vector double)(vector unsigned long long)((0x3ffULL - \
3234 ((__b)&0x1F)) \
3235 << 52)), \
3236 vector signed long long: ( \
3237 vector float)(__builtin_convertvector( \
3238 (vector signed long long)(__a), vector double) * \
3239 (vector double)(vector unsigned long long)((0x3ffULL - \
3240 ((__b)&0x1F)) \
3241 << 52)))
32393242#endif // __XL_COMPAT_ALTIVEC__
32403243#else
32413244#define vec_ctf(__a, __b) \
3242 _Generic((__a), vector int \
3243 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
3244 vector unsigned int \
3245 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3246 (__b)))
3245 _Generic((__a), \
3246 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3247 ((__b)&0x1F)), \
3248 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3249 (vector unsigned int)(__a), ((__b)&0x1F)))
32473250#endif
32483251
32493252/* vec_ctd */
32503253#ifdef __VSX__
32513254#define vec_ctd(__a, __b) \
3252 _Generic((__a), vector signed int \
3253 : (vec_doublee((vector signed int)(__a)) * \
3254 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3255 << 52)), \
3256 vector unsigned int \
3257 : (vec_doublee((vector unsigned int)(__a)) * \
3258 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3259 << 52)), \
3260 vector unsigned long long \
3261 : (__builtin_convertvector((vector unsigned long long)(__a), \
3262 vector double) * \
3263 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3264 << 52)), \
3265 vector signed long long \
3266 : (__builtin_convertvector((vector signed long long)(__a), \
3267 vector double) * \
3268 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3269 << 52)))
3255 _Generic((__a), \
3256 vector signed int: ( \
3257 vec_doublee((vector signed int)(__a)) * \
3258 (vector double)(vector unsigned long long)((0x3ffULL - \
3259 ((__b)&0x1F)) \
3260 << 52)), \
3261 vector unsigned int: ( \
3262 vec_doublee((vector unsigned int)(__a)) * \
3263 (vector double)(vector unsigned long long)((0x3ffULL - \
3264 ((__b)&0x1F)) \
3265 << 52)), \
3266 vector unsigned long long: ( \
3267 __builtin_convertvector((vector unsigned long long)(__a), \
3268 vector double) * \
3269 (vector double)(vector unsigned long long)((0x3ffULL - \
3270 ((__b)&0x1F)) \
3271 << 52)), \
3272 vector signed long long: ( \
3273 __builtin_convertvector((vector signed long long)(__a), \
3274 vector double) * \
3275 (vector double)(vector unsigned long long)((0x3ffULL - \
3276 ((__b)&0x1F)) \
3277 << 52)))
32703278#endif // __VSX__
32713279
32723280/* vec_vcfsx */
......@@ -3281,27 +3289,27 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
32813289#ifdef __VSX__
32823290#ifdef __XL_COMPAT_ALTIVEC__
32833291#define vec_cts(__a, __b) \
3284 _Generic((__a), vector float \
3285 : (vector signed int)__builtin_altivec_vctsxs((vector float)(__a), \
3286 (__b)), \
3287 vector double \
3288 : __extension__({ \
3292 _Generic((__a), \
3293 vector float: (vector signed int)__builtin_altivec_vctsxs( \
3294 (vector float)(__a), ((__b)&0x1F)), \
3295 vector double: __extension__({ \
32893296 vector double __ret = \
32903297 (vector double)(__a) * \
3291 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3298 (vector double)(vector unsigned long long)((0x3ffULL + \
3299 ((__b)&0x1F)) \
32923300 << 52); \
32933301 (vector signed long long)__builtin_vsx_xvcvdpsxws(__ret); \
32943302 }))
32953303#else // __XL_COMPAT_ALTIVEC__
32963304#define vec_cts(__a, __b) \
3297 _Generic((__a), vector float \
3298 : (vector signed int)__builtin_altivec_vctsxs((vector float)(__a), \
3299 (__b)), \
3300 vector double \
3301 : __extension__({ \
3305 _Generic((__a), \
3306 vector float: (vector signed int)__builtin_altivec_vctsxs( \
3307 (vector float)(__a), ((__b)&0x1F)), \
3308 vector double: __extension__({ \
33023309 vector double __ret = \
33033310 (vector double)(__a) * \
3304 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3311 (vector double)(vector unsigned long long)((0x3ffULL + \
3312 ((__b)&0x1F)) \
33053313 << 52); \
33063314 (vector signed long long)__builtin_convertvector( \
33073315 __ret, vector signed long long); \
......@@ -3320,27 +3328,27 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
33203328#ifdef __VSX__
33213329#ifdef __XL_COMPAT_ALTIVEC__
33223330#define vec_ctu(__a, __b) \
3323 _Generic((__a), vector float \
3324 : (vector unsigned int)__builtin_altivec_vctuxs( \
3325 (vector float)(__a), (__b)), \
3326 vector double \
3327 : __extension__({ \
3331 _Generic((__a), \
3332 vector float: (vector unsigned int)__builtin_altivec_vctuxs( \
3333 (vector float)(__a), ((__b)&0x1F)), \
3334 vector double: __extension__({ \
33283335 vector double __ret = \
33293336 (vector double)(__a) * \
3330 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3337 (vector double)(vector unsigned long long)((0x3ffULL + \
3338 ((__b)&0x1F)) \
33313339 << 52); \
33323340 (vector unsigned long long)__builtin_vsx_xvcvdpuxws(__ret); \
33333341 }))
33343342#else // __XL_COMPAT_ALTIVEC__
33353343#define vec_ctu(__a, __b) \
3336 _Generic((__a), vector float \
3337 : (vector unsigned int)__builtin_altivec_vctuxs( \
3338 (vector float)(__a), (__b)), \
3339 vector double \
3340 : __extension__({ \
3344 _Generic((__a), \
3345 vector float: (vector unsigned int)__builtin_altivec_vctuxs( \
3346 (vector float)(__a), ((__b)&0x1F)), \
3347 vector double: __extension__({ \
33413348 vector double __ret = \
33423349 (vector double)(__a) * \
3343 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3350 (vector double)(vector unsigned long long)((0x3ffULL + \
3351 ((__b)&0x1F)) \
33443352 << 52); \
33453353 (vector unsigned long long)__builtin_convertvector( \
33463354 __ret, vector unsigned long long); \
......@@ -3355,60 +3363,62 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
33553363
33563364#ifdef __VSX__
33573365#define vec_ctsl(__a, __b) \
3358 _Generic((__a), vector float \
3359 : __extension__({ \
3360 vector float __ret = \
3361 (vector float)(__a) * \
3362 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3363 __builtin_vsx_xvcvspsxds( \
3364 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3365 }), \
3366 vector double \
3367 : __extension__({ \
3368 vector double __ret = \
3369 (vector double)(__a) * \
3370 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3371 << 52); \
3372 __builtin_convertvector(__ret, vector signed long long); \
3373 }))
3366 _Generic( \
3367 (__a), vector float \
3368 : __extension__({ \
3369 vector float __ret = \
3370 (vector float)(__a) * \
3371 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3372 __builtin_vsx_xvcvspsxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3373 }), \
3374 vector double \
3375 : __extension__({ \
3376 vector double __ret = \
3377 (vector double)(__a) * \
3378 (vector double)(vector unsigned long long)((0x3ffULL + \
3379 ((__b)&0x1F)) \
3380 << 52); \
3381 __builtin_convertvector(__ret, vector signed long long); \
3382 }))
33743383
33753384/* vec_ctul */
33763385
33773386#define vec_ctul(__a, __b) \
3378 _Generic((__a), vector float \
3379 : __extension__({ \
3380 vector float __ret = \
3381 (vector float)(__a) * \
3382 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3383 __builtin_vsx_xvcvspuxds( \
3384 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3385 }), \
3386 vector double \
3387 : __extension__({ \
3388 vector double __ret = \
3389 (vector double)(__a) * \
3390 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3391 << 52); \
3392 __builtin_convertvector(__ret, vector unsigned long long); \
3393 }))
3387 _Generic( \
3388 (__a), vector float \
3389 : __extension__({ \
3390 vector float __ret = \
3391 (vector float)(__a) * \
3392 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3393 __builtin_vsx_xvcvspuxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3394 }), \
3395 vector double \
3396 : __extension__({ \
3397 vector double __ret = \
3398 (vector double)(__a) * \
3399 (vector double)(vector unsigned long long)((0x3ffULL + \
3400 ((__b)&0x1F)) \
3401 << 52); \
3402 __builtin_convertvector(__ret, vector unsigned long long); \
3403 }))
33943404#endif
33953405#else // __LITTLE_ENDIAN__
33963406/* vec_ctsl */
33973407
33983408#ifdef __VSX__
33993409#define vec_ctsl(__a, __b) \
3400 _Generic((__a), vector float \
3401 : __extension__({ \
3402 vector float __ret = \
3403 (vector float)(__a) * \
3404 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3405 __builtin_vsx_xvcvspsxds(__ret); \
3406 }), \
3407 vector double \
3408 : __extension__({ \
3410 _Generic((__a), \
3411 vector float: __extension__({ \
3412 vector float __ret = \
3413 (vector float)(__a) * \
3414 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3415 __builtin_vsx_xvcvspsxds(__ret); \
3416 }), \
3417 vector double: __extension__({ \
34093418 vector double __ret = \
34103419 (vector double)(__a) * \
3411 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3420 (vector double)(vector unsigned long long)((0x3ffULL + \
3421 ((__b)&0x1F)) \
34123422 << 52); \
34133423 __builtin_convertvector(__ret, vector signed long long); \
34143424 }))
......@@ -3420,14 +3430,16 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
34203430 : __extension__({ \
34213431 vector float __ret = \
34223432 (vector float)(__a) * \
3423 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3433 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) \
3434 << 23); \
34243435 __builtin_vsx_xvcvspuxds(__ret); \
34253436 }), \
34263437 vector double \
34273438 : __extension__({ \
34283439 vector double __ret = \
34293440 (vector double)(__a) * \
3430 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3441 (vector double)(vector unsigned long long)((0x3ffULL + \
3442 ((__b)&0x1F)) \
34313443 << 52); \
34323444 __builtin_convertvector(__ret, vector unsigned long long); \
34333445 }))
lib/include/amxcomplexintrin.h created+169
......@@ -0,0 +1,169 @@
1/*===--------- amxcomplexintrin.h - AMXCOMPLEX intrinsics -*- C++ -*---------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===------------------------------------------------------------------------===
8 */
9
10#ifndef __IMMINTRIN_H
11#error "Never use <amxcomplexintrin.h> directly; include <immintrin.h> instead."
12#endif // __IMMINTRIN_H
13
14#ifndef __AMX_COMPLEXINTRIN_H
15#define __AMX_COMPLEXINTRIN_H
16#ifdef __x86_64__
17
18#define __DEFAULT_FN_ATTRS_COMPLEX \
19 __attribute__((__always_inline__, __nodebug__, __target__("amx-complex")))
20
21/// Perform matrix multiplication of two tiles containing complex elements and
22/// accumulate the results into a packed single precision tile. Each dword
23/// element in input tiles \a a and \a b is interpreted as a complex number
24/// with FP16 real part and FP16 imaginary part.
25/// Calculates the imaginary part of the result. For each possible combination
26/// of (row of \a a, column of \a b), it performs a set of multiplication
27/// and accumulations on all corresponding complex numbers (one from \a a
28/// and one from \a b). The imaginary part of the \a a element is multiplied
29/// with the real part of the corresponding \a b element, and the real part
30/// of the \a a element is multiplied with the imaginary part of the
31/// corresponding \a b elements. The two accumulated results are added, and
32/// then accumulated into the corresponding row and column of \a dst.
33///
34/// \headerfile <x86intrin.h>
35///
36/// \code
37/// void _tile_cmmimfp16ps(__tile dst, __tile a, __tile b);
38/// \endcode
39///
40/// \code{.operation}
41/// FOR m := 0 TO dst.rows - 1
42/// tmp := dst.row[m]
43/// FOR k := 0 TO (a.colsb / 4) - 1
44/// FOR n := 0 TO (dst.colsb / 4) - 1
45/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+1])
46/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+0])
47/// ENDFOR
48/// ENDFOR
49/// write_row_and_zero(dst, m, tmp, dst.colsb)
50/// ENDFOR
51/// zero_upper_rows(dst, dst.rows)
52/// zero_tileconfig_start()
53/// \endcode
54///
55/// This intrinsic corresponds to the \c TCMMIMFP16PS instruction.
56///
57/// \param dst
58/// The destination tile. Max size is 1024 Bytes.
59/// \param a
60/// The 1st source tile. Max size is 1024 Bytes.
61/// \param b
62/// The 2nd source tile. Max size is 1024 Bytes.
63#define _tile_cmmimfp16ps(dst, a, b) __builtin_ia32_tcmmimfp16ps(dst, a, b)
64
65/// Perform matrix multiplication of two tiles containing complex elements and
66/// accumulate the results into a packed single precision tile. Each dword
67/// element in input tiles \a a and \a b is interpreted as a complex number
68/// with FP16 real part and FP16 imaginary part.
69/// Calculates the real part of the result. For each possible combination
70/// of (row of \a a, column of \a b), it performs a set of multiplication
71/// and accumulations on all corresponding complex numbers (one from \a a
72/// and one from \a b). The real part of the \a a element is multiplied
73/// with the real part of the corresponding \a b element, and the negated
74/// imaginary part of the \a a element is multiplied with the imaginary
75/// part of the corresponding \a b elements. The two accumulated results
76/// are added, and then accumulated into the corresponding row and column
77/// of \a dst.
78///
79/// \headerfile <x86intrin.h>
80///
81/// \code
82/// void _tile_cmmrlfp16ps(__tile dst, __tile a, __tile b);
83/// \endcode
84///
85/// \code{.operation}
86/// FOR m := 0 TO dst.rows - 1
87/// tmp := dst.row[m]
88/// FOR k := 0 TO (a.colsb / 4) - 1
89/// FOR n := 0 TO (dst.colsb / 4) - 1
90/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+0])
91/// tmp.fp32[n] += FP32(-a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+1])
92/// ENDFOR
93/// ENDFOR
94/// write_row_and_zero(dst, m, tmp, dst.colsb)
95/// ENDFOR
96/// zero_upper_rows(dst, dst.rows)
97/// zero_tileconfig_start()
98/// \endcode
99///
100/// This intrinsic corresponds to the \c TCMMIMFP16PS instruction.
101///
102/// \param dst
103/// The destination tile. Max size is 1024 Bytes.
104/// \param a
105/// The 1st source tile. Max size is 1024 Bytes.
106/// \param b
107/// The 2nd source tile. Max size is 1024 Bytes.
108#define _tile_cmmrlfp16ps(dst, a, b) __builtin_ia32_tcmmrlfp16ps(dst, a, b)
109
110static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX
111_tile_cmmimfp16ps_internal(unsigned short m, unsigned short n, unsigned short k,
112 _tile1024i dst, _tile1024i src1, _tile1024i src2) {
113 return __builtin_ia32_tcmmimfp16ps_internal(m, n, k, dst, src1, src2);
114}
115
116static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX
117_tile_cmmrlfp16ps_internal(unsigned short m, unsigned short n, unsigned short k,
118 _tile1024i dst, _tile1024i src1, _tile1024i src2) {
119 return __builtin_ia32_tcmmrlfp16ps_internal(m, n, k, dst, src1, src2);
120}
121
122/// Perform matrix multiplication of two tiles containing complex elements and
123/// accumulate the results into a packed single precision tile. Each dword
124/// element in input tiles src0 and src1 is interpreted as a complex number with
125/// FP16 real part and FP16 imaginary part.
126/// This function calculates the imaginary part of the result.
127///
128/// \headerfile <immintrin.h>
129///
130/// This intrinsic corresponds to the <c> TCMMIMFP16PS </c> instruction.
131///
132/// \param dst
133/// The destination tile. Max size is 1024 Bytes.
134/// \param src0
135/// The 1st source tile. Max size is 1024 Bytes.
136/// \param src1
137/// The 2nd source tile. Max size is 1024 Bytes.
138__DEFAULT_FN_ATTRS_COMPLEX
139static void __tile_cmmimfp16ps(__tile1024i *dst, __tile1024i src0,
140 __tile1024i src1) {
141 dst->tile = _tile_cmmimfp16ps_internal(src0.row, src1.col, src0.col,
142 dst->tile, src0.tile, src1.tile);
143}
144
145/// Perform matrix multiplication of two tiles containing complex elements and
146/// accumulate the results into a packed single precision tile. Each dword
147/// element in input tiles src0 and src1 is interpreted as a complex number with
148/// FP16 real part and FP16 imaginary part.
149/// This function calculates the real part of the result.
150///
151/// \headerfile <immintrin.h>
152///
153/// This intrinsic corresponds to the <c> TCMMRLFP16PS </c> instruction.
154///
155/// \param dst
156/// The destination tile. Max size is 1024 Bytes.
157/// \param src0
158/// The 1st source tile. Max size is 1024 Bytes.
159/// \param src1
160/// The 2nd source tile. Max size is 1024 Bytes.
161__DEFAULT_FN_ATTRS_COMPLEX
162static void __tile_cmmrlfp16ps(__tile1024i *dst, __tile1024i src0,
163 __tile1024i src1) {
164 dst->tile = _tile_cmmrlfp16ps_internal(src0.row, src1.col, src0.col,
165 dst->tile, src0.tile, src1.tile);
166}
167
168#endif // __x86_64__
169#endif // __AMX_COMPLEXINTRIN_H
lib/include/arm_acle.h+13-9
......@@ -138,28 +138,32 @@ __rorl(unsigned long __x, uint32_t __y) {
138138
139139
140140/* CLZ */
141static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
141static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
142142__clz(uint32_t __t) {
143 return (uint32_t)__builtin_clz(__t);
143 return __builtin_arm_clz(__t);
144144}
145145
146static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
146static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
147147__clzl(unsigned long __t) {
148 return (unsigned long)__builtin_clzl(__t);
148#if __SIZEOF_LONG__ == 4
149 return __builtin_arm_clz(__t);
150#else
151 return __builtin_arm_clz64(__t);
152#endif
149153}
150154
151static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
155static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
152156__clzll(uint64_t __t) {
153 return (uint64_t)__builtin_clzll(__t);
157 return __builtin_arm_clz64(__t);
154158}
155159
156160/* CLS */
157static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
161static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
158162__cls(uint32_t __t) {
159163 return __builtin_arm_cls(__t);
160164}
161165
162static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
166static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
163167__clsl(unsigned long __t) {
164168#if __SIZEOF_LONG__ == 4
165169 return __builtin_arm_cls(__t);
......@@ -168,7 +172,7 @@ __clsl(unsigned long __t) {
168172#endif
169173}
170174
171static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
175static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
172176__clsll(uint64_t __t) {
173177 return __builtin_arm_cls64(__t);
174178}
lib/include/arm_neon.h+164-1
......@@ -35,7 +35,6 @@
3535#include <stdint.h>
3636
3737#include <arm_bf16.h>
38typedef __bf16 bfloat16_t;
3938typedef float float32_t;
4039typedef __fp16 float16_t;
4140#ifdef __aarch64__
......@@ -64938,6 +64937,170 @@ int8x16_t __reint_786 = __rev2_786; \
6493864937})
6493964938#endif
6494064939
64940#define vldap1_lane_p64(__p0, __p1, __p2) __extension__ ({ \
64941 poly64x1_t __ret; \
64942 poly64x1_t __s1 = __p1; \
64943 __ret = (poly64x1_t) __builtin_neon_vldap1_lane_p64(__p0, (int8x8_t)__s1, __p2, 6); \
64944 __ret; \
64945})
64946#ifdef __LITTLE_ENDIAN__
64947#define vldap1q_lane_p64(__p0, __p1, __p2) __extension__ ({ \
64948 poly64x2_t __ret; \
64949 poly64x2_t __s1 = __p1; \
64950 __ret = (poly64x2_t) __builtin_neon_vldap1q_lane_p64(__p0, (int8x16_t)__s1, __p2, 38); \
64951 __ret; \
64952})
64953#else
64954#define vldap1q_lane_p64(__p0, __p1, __p2) __extension__ ({ \
64955 poly64x2_t __ret; \
64956 poly64x2_t __s1 = __p1; \
64957 poly64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
64958 __ret = (poly64x2_t) __builtin_neon_vldap1q_lane_p64(__p0, (int8x16_t)__rev1, __p2, 38); \
64959 __ret = __builtin_shufflevector(__ret, __ret, 1, 0); \
64960 __ret; \
64961})
64962#endif
64963
64964#ifdef __LITTLE_ENDIAN__
64965#define vldap1q_lane_u64(__p0, __p1, __p2) __extension__ ({ \
64966 uint64x2_t __ret; \
64967 uint64x2_t __s1 = __p1; \
64968 __ret = (uint64x2_t) __builtin_neon_vldap1q_lane_u64(__p0, (int8x16_t)__s1, __p2, 51); \
64969 __ret; \
64970})
64971#else
64972#define vldap1q_lane_u64(__p0, __p1, __p2) __extension__ ({ \
64973 uint64x2_t __ret; \
64974 uint64x2_t __s1 = __p1; \
64975 uint64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
64976 __ret = (uint64x2_t) __builtin_neon_vldap1q_lane_u64(__p0, (int8x16_t)__rev1, __p2, 51); \
64977 __ret = __builtin_shufflevector(__ret, __ret, 1, 0); \
64978 __ret; \
64979})
64980#endif
64981
64982#ifdef __LITTLE_ENDIAN__
64983#define vldap1q_lane_f64(__p0, __p1, __p2) __extension__ ({ \
64984 float64x2_t __ret; \
64985 float64x2_t __s1 = __p1; \
64986 __ret = (float64x2_t) __builtin_neon_vldap1q_lane_f64(__p0, (int8x16_t)__s1, __p2, 42); \
64987 __ret; \
64988})
64989#else
64990#define vldap1q_lane_f64(__p0, __p1, __p2) __extension__ ({ \
64991 float64x2_t __ret; \
64992 float64x2_t __s1 = __p1; \
64993 float64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
64994 __ret = (float64x2_t) __builtin_neon_vldap1q_lane_f64(__p0, (int8x16_t)__rev1, __p2, 42); \
64995 __ret = __builtin_shufflevector(__ret, __ret, 1, 0); \
64996 __ret; \
64997})
64998#endif
64999
65000#ifdef __LITTLE_ENDIAN__
65001#define vldap1q_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65002 int64x2_t __ret; \
65003 int64x2_t __s1 = __p1; \
65004 __ret = (int64x2_t) __builtin_neon_vldap1q_lane_s64(__p0, (int8x16_t)__s1, __p2, 35); \
65005 __ret; \
65006})
65007#else
65008#define vldap1q_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65009 int64x2_t __ret; \
65010 int64x2_t __s1 = __p1; \
65011 int64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
65012 __ret = (int64x2_t) __builtin_neon_vldap1q_lane_s64(__p0, (int8x16_t)__rev1, __p2, 35); \
65013 __ret = __builtin_shufflevector(__ret, __ret, 1, 0); \
65014 __ret; \
65015})
65016#endif
65017
65018#define vldap1_lane_u64(__p0, __p1, __p2) __extension__ ({ \
65019 uint64x1_t __ret; \
65020 uint64x1_t __s1 = __p1; \
65021 __ret = (uint64x1_t) __builtin_neon_vldap1_lane_u64(__p0, (int8x8_t)__s1, __p2, 19); \
65022 __ret; \
65023})
65024#define vldap1_lane_f64(__p0, __p1, __p2) __extension__ ({ \
65025 float64x1_t __ret; \
65026 float64x1_t __s1 = __p1; \
65027 __ret = (float64x1_t) __builtin_neon_vldap1_lane_f64(__p0, (int8x8_t)__s1, __p2, 10); \
65028 __ret; \
65029})
65030#define vldap1_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65031 int64x1_t __ret; \
65032 int64x1_t __s1 = __p1; \
65033 __ret = (int64x1_t) __builtin_neon_vldap1_lane_s64(__p0, (int8x8_t)__s1, __p2, 3); \
65034 __ret; \
65035})
65036#define vstl1_lane_p64(__p0, __p1, __p2) __extension__ ({ \
65037 poly64x1_t __s1 = __p1; \
65038 __builtin_neon_vstl1_lane_p64(__p0, (int8x8_t)__s1, __p2, 6); \
65039})
65040#ifdef __LITTLE_ENDIAN__
65041#define vstl1q_lane_p64(__p0, __p1, __p2) __extension__ ({ \
65042 poly64x2_t __s1 = __p1; \
65043 __builtin_neon_vstl1q_lane_p64(__p0, (int8x16_t)__s1, __p2, 38); \
65044})
65045#else
65046#define vstl1q_lane_p64(__p0, __p1, __p2) __extension__ ({ \
65047 poly64x2_t __s1 = __p1; \
65048 poly64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
65049 __builtin_neon_vstl1q_lane_p64(__p0, (int8x16_t)__rev1, __p2, 38); \
65050})
65051#endif
65052
65053#ifdef __LITTLE_ENDIAN__
65054#define vstl1q_lane_u64(__p0, __p1, __p2) __extension__ ({ \
65055 uint64x2_t __s1 = __p1; \
65056 __builtin_neon_vstl1q_lane_u64(__p0, (int8x16_t)__s1, __p2, 51); \
65057})
65058#else
65059#define vstl1q_lane_u64(__p0, __p1, __p2) __extension__ ({ \
65060 uint64x2_t __s1 = __p1; \
65061 uint64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
65062 __builtin_neon_vstl1q_lane_u64(__p0, (int8x16_t)__rev1, __p2, 51); \
65063})
65064#endif
65065
65066#ifdef __LITTLE_ENDIAN__
65067#define vstl1q_lane_f64(__p0, __p1, __p2) __extension__ ({ \
65068 float64x2_t __s1 = __p1; \
65069 __builtin_neon_vstl1q_lane_f64(__p0, (int8x16_t)__s1, __p2, 42); \
65070})
65071#else
65072#define vstl1q_lane_f64(__p0, __p1, __p2) __extension__ ({ \
65073 float64x2_t __s1 = __p1; \
65074 float64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
65075 __builtin_neon_vstl1q_lane_f64(__p0, (int8x16_t)__rev1, __p2, 42); \
65076})
65077#endif
65078
65079#ifdef __LITTLE_ENDIAN__
65080#define vstl1q_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65081 int64x2_t __s1 = __p1; \
65082 __builtin_neon_vstl1q_lane_s64(__p0, (int8x16_t)__s1, __p2, 35); \
65083})
65084#else
65085#define vstl1q_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65086 int64x2_t __s1 = __p1; \
65087 int64x2_t __rev1; __rev1 = __builtin_shufflevector(__s1, __s1, 1, 0); \
65088 __builtin_neon_vstl1q_lane_s64(__p0, (int8x16_t)__rev1, __p2, 35); \
65089})
65090#endif
65091
65092#define vstl1_lane_u64(__p0, __p1, __p2) __extension__ ({ \
65093 uint64x1_t __s1 = __p1; \
65094 __builtin_neon_vstl1_lane_u64(__p0, (int8x8_t)__s1, __p2, 19); \
65095})
65096#define vstl1_lane_f64(__p0, __p1, __p2) __extension__ ({ \
65097 float64x1_t __s1 = __p1; \
65098 __builtin_neon_vstl1_lane_f64(__p0, (int8x8_t)__s1, __p2, 10); \
65099})
65100#define vstl1_lane_s64(__p0, __p1, __p2) __extension__ ({ \
65101 int64x1_t __s1 = __p1; \
65102 __builtin_neon_vstl1_lane_s64(__p0, (int8x8_t)__s1, __p2, 3); \
65103})
6494165104#ifdef __LITTLE_ENDIAN__
6494265105__ai __attribute__((target("sha3"))) uint8x16_t vbcaxq_u8(uint8x16_t __p0, uint8x16_t __p1, uint8x16_t __p2) {
6494365106 uint8x16_t __ret;
lib/include/arm_sme_draft_spec_subject_to_change.h created+642
......@@ -0,0 +1,642 @@
1/*===---- arm_sme_draft_spec_subject_to_change.h - ARM SME intrinsics ------===
2 *
3 *
4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *
8 *===-----------------------------------------------------------------------===
9 */
10
11#ifndef __ARM_SME_H
12#define __ARM_SME_H
13
14#if !defined(__LITTLE_ENDIAN__)
15#error "Big endian is currently not supported for arm_sme_draft_spec_subject_to_change.h"
16#endif
17#include <arm_sve.h>
18
19/* Function attributes */
20#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__))
21
22#define __aio static __inline__ __attribute__((__always_inline__, __nodebug__, __overloadable__))
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za32_u32_m), arm_streaming, arm_shared_za))
29void svaddha_za32_u32_m(uint64_t, svbool_t, svbool_t, svuint32_t);
30__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za32_s32_m), arm_streaming, arm_shared_za))
31void svaddha_za32_s32_m(uint64_t, svbool_t, svbool_t, svint32_t);
32__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za32_u32_m), arm_streaming, arm_shared_za))
33void svaddva_za32_u32_m(uint64_t, svbool_t, svbool_t, svuint32_t);
34__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za32_s32_m), arm_streaming, arm_shared_za))
35void svaddva_za32_s32_m(uint64_t, svbool_t, svbool_t, svint32_t);
36__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svcntsb), arm_streaming_compatible, arm_preserves_za))
37uint64_t svcntsb(void);
38__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svcntsd), arm_streaming_compatible, arm_preserves_za))
39uint64_t svcntsd(void);
40__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svcntsh), arm_streaming_compatible, arm_preserves_za))
41uint64_t svcntsh(void);
42__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svcntsw), arm_streaming_compatible, arm_preserves_za))
43uint64_t svcntsw(void);
44__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_vnum_za128), arm_streaming, arm_shared_za))
45void svld1_hor_vnum_za128(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
46__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_vnum_za16), arm_streaming, arm_shared_za))
47void svld1_hor_vnum_za16(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
48__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_vnum_za32), arm_streaming, arm_shared_za))
49void svld1_hor_vnum_za32(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
50__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_vnum_za64), arm_streaming, arm_shared_za))
51void svld1_hor_vnum_za64(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
52__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_vnum_za8), arm_streaming, arm_shared_za))
53void svld1_hor_vnum_za8(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
54__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_za128), arm_streaming, arm_shared_za))
55void svld1_hor_za128(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
56__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_za16), arm_streaming, arm_shared_za))
57void svld1_hor_za16(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
58__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_za32), arm_streaming, arm_shared_za))
59void svld1_hor_za32(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
60__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_za64), arm_streaming, arm_shared_za))
61void svld1_hor_za64(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
62__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_hor_za8), arm_streaming, arm_shared_za))
63void svld1_hor_za8(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
64__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_vnum_za128), arm_streaming, arm_shared_za))
65void svld1_ver_vnum_za128(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
66__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_vnum_za16), arm_streaming, arm_shared_za))
67void svld1_ver_vnum_za16(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
68__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_vnum_za32), arm_streaming, arm_shared_za))
69void svld1_ver_vnum_za32(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
70__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_vnum_za64), arm_streaming, arm_shared_za))
71void svld1_ver_vnum_za64(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
72__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_vnum_za8), arm_streaming, arm_shared_za))
73void svld1_ver_vnum_za8(uint64_t, uint32_t, uint64_t, svbool_t, void const *, int64_t);
74__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_za128), arm_streaming, arm_shared_za))
75void svld1_ver_za128(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
76__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_za16), arm_streaming, arm_shared_za))
77void svld1_ver_za16(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
78__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_za32), arm_streaming, arm_shared_za))
79void svld1_ver_za32(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
80__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_za64), arm_streaming, arm_shared_za))
81void svld1_ver_za64(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
82__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svld1_ver_za8), arm_streaming, arm_shared_za))
83void svld1_ver_za8(uint64_t, uint32_t, uint64_t, svbool_t, void const *);
84__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_f16_m), arm_streaming, arm_shared_za))
85void svmopa_za32_f16_m(uint64_t, svbool_t, svbool_t, svfloat16_t, svfloat16_t);
86__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_bf16_m), arm_streaming, arm_shared_za))
87void svmopa_za32_bf16_m(uint64_t, svbool_t, svbool_t, svbfloat16_t, svbfloat16_t);
88__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_f32_m), arm_streaming, arm_shared_za))
89void svmopa_za32_f32_m(uint64_t, svbool_t, svbool_t, svfloat32_t, svfloat32_t);
90__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_s8_m), arm_streaming, arm_shared_za))
91void svmopa_za32_s8_m(uint64_t, svbool_t, svbool_t, svint8_t, svint8_t);
92__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_u8_m), arm_streaming, arm_shared_za))
93void svmopa_za32_u8_m(uint64_t, svbool_t, svbool_t, svuint8_t, svuint8_t);
94__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_f16_m), arm_streaming, arm_shared_za))
95void svmops_za32_f16_m(uint64_t, svbool_t, svbool_t, svfloat16_t, svfloat16_t);
96__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_bf16_m), arm_streaming, arm_shared_za))
97void svmops_za32_bf16_m(uint64_t, svbool_t, svbool_t, svbfloat16_t, svbfloat16_t);
98__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_f32_m), arm_streaming, arm_shared_za))
99void svmops_za32_f32_m(uint64_t, svbool_t, svbool_t, svfloat32_t, svfloat32_t);
100__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_s8_m), arm_streaming, arm_shared_za))
101void svmops_za32_s8_m(uint64_t, svbool_t, svbool_t, svint8_t, svint8_t);
102__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_u8_m), arm_streaming, arm_shared_za))
103void svmops_za32_u8_m(uint64_t, svbool_t, svbool_t, svuint8_t, svuint8_t);
104__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
105svuint8_t svread_hor_za128_u8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
106__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
107svuint32_t svread_hor_za128_u32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
108__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
109svuint64_t svread_hor_za128_u64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
110__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
111svuint16_t svread_hor_za128_u16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
112__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
113svbfloat16_t svread_hor_za128_bf16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
114__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
115svint8_t svread_hor_za128_s8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
116__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
117svfloat64_t svread_hor_za128_f64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
118__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
119svfloat32_t svread_hor_za128_f32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
120__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
121svfloat16_t svread_hor_za128_f16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
122__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
123svint32_t svread_hor_za128_s32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
124__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
125svint64_t svread_hor_za128_s64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
126__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
127svint16_t svread_hor_za128_s16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
128__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
129svuint16_t svread_hor_za16_u16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
130__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
131svbfloat16_t svread_hor_za16_bf16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
132__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
133svfloat16_t svread_hor_za16_f16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
134__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
135svint16_t svread_hor_za16_s16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
136__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
137svuint32_t svread_hor_za32_u32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
138__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
139svfloat32_t svread_hor_za32_f32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
140__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
141svint32_t svread_hor_za32_s32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
142__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
143svuint64_t svread_hor_za64_u64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
144__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
145svfloat64_t svread_hor_za64_f64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
146__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
147svint64_t svread_hor_za64_s64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
148__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za8_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
149svuint8_t svread_hor_za8_u8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
150__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za8_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
151svint8_t svread_hor_za8_s8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
152__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
153svuint8_t svread_ver_za128_u8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
154__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
155svuint32_t svread_ver_za128_u32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
156__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
157svuint64_t svread_ver_za128_u64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
158__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
159svuint16_t svread_ver_za128_u16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
160__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
161svbfloat16_t svread_ver_za128_bf16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
162__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
163svint8_t svread_ver_za128_s8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
164__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
165svfloat64_t svread_ver_za128_f64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
166__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
167svfloat32_t svread_ver_za128_f32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
168__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
169svfloat16_t svread_ver_za128_f16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
170__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
171svint32_t svread_ver_za128_s32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
172__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
173svint64_t svread_ver_za128_s64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
174__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
175svint16_t svread_ver_za128_s16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
176__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
177svuint16_t svread_ver_za16_u16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
178__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
179svbfloat16_t svread_ver_za16_bf16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
180__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
181svfloat16_t svread_ver_za16_f16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
182__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
183svint16_t svread_ver_za16_s16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
184__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
185svuint32_t svread_ver_za32_u32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
186__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
187svfloat32_t svread_ver_za32_f32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
188__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
189svint32_t svread_ver_za32_s32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
190__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
191svuint64_t svread_ver_za64_u64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
192__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
193svfloat64_t svread_ver_za64_f64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
194__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
195svint64_t svread_ver_za64_s64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
196__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za8_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
197svuint8_t svread_ver_za8_u8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
198__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za8_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
199svint8_t svread_ver_za8_s8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
200__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_vnum_za128), arm_streaming, arm_shared_za, arm_preserves_za))
201void svst1_hor_vnum_za128(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
202__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_vnum_za16), arm_streaming, arm_shared_za, arm_preserves_za))
203void svst1_hor_vnum_za16(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
204__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_vnum_za32), arm_streaming, arm_shared_za, arm_preserves_za))
205void svst1_hor_vnum_za32(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
206__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_vnum_za64), arm_streaming, arm_shared_za, arm_preserves_za))
207void svst1_hor_vnum_za64(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
208__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_vnum_za8), arm_streaming, arm_shared_za, arm_preserves_za))
209void svst1_hor_vnum_za8(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
210__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_za128), arm_streaming, arm_shared_za, arm_preserves_za))
211void svst1_hor_za128(uint64_t, uint32_t, uint64_t, svbool_t, void *);
212__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_za16), arm_streaming, arm_shared_za, arm_preserves_za))
213void svst1_hor_za16(uint64_t, uint32_t, uint64_t, svbool_t, void *);
214__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_za32), arm_streaming, arm_shared_za, arm_preserves_za))
215void svst1_hor_za32(uint64_t, uint32_t, uint64_t, svbool_t, void *);
216__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_za64), arm_streaming, arm_shared_za, arm_preserves_za))
217void svst1_hor_za64(uint64_t, uint32_t, uint64_t, svbool_t, void *);
218__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_hor_za8), arm_streaming, arm_shared_za, arm_preserves_za))
219void svst1_hor_za8(uint64_t, uint32_t, uint64_t, svbool_t, void *);
220__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_vnum_za128), arm_streaming, arm_shared_za, arm_preserves_za))
221void svst1_ver_vnum_za128(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
222__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_vnum_za16), arm_streaming, arm_shared_za, arm_preserves_za))
223void svst1_ver_vnum_za16(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
224__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_vnum_za32), arm_streaming, arm_shared_za, arm_preserves_za))
225void svst1_ver_vnum_za32(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
226__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_vnum_za64), arm_streaming, arm_shared_za, arm_preserves_za))
227void svst1_ver_vnum_za64(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
228__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_vnum_za8), arm_streaming, arm_shared_za, arm_preserves_za))
229void svst1_ver_vnum_za8(uint64_t, uint32_t, uint64_t, svbool_t, void *, int64_t);
230__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_za128), arm_streaming, arm_shared_za, arm_preserves_za))
231void svst1_ver_za128(uint64_t, uint32_t, uint64_t, svbool_t, void *);
232__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_za16), arm_streaming, arm_shared_za, arm_preserves_za))
233void svst1_ver_za16(uint64_t, uint32_t, uint64_t, svbool_t, void *);
234__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_za32), arm_streaming, arm_shared_za, arm_preserves_za))
235void svst1_ver_za32(uint64_t, uint32_t, uint64_t, svbool_t, void *);
236__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_za64), arm_streaming, arm_shared_za, arm_preserves_za))
237void svst1_ver_za64(uint64_t, uint32_t, uint64_t, svbool_t, void *);
238__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svst1_ver_za8), arm_streaming, arm_shared_za, arm_preserves_za))
239void svst1_ver_za8(uint64_t, uint32_t, uint64_t, svbool_t, void *);
240__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumopa_za32_s8_m), arm_streaming, arm_shared_za))
241void svsumopa_za32_s8_m(uint64_t, svbool_t, svbool_t, svint8_t, svuint8_t);
242__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumops_za32_s8_m), arm_streaming, arm_shared_za))
243void svsumops_za32_s8_m(uint64_t, svbool_t, svbool_t, svint8_t, svuint8_t);
244__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmopa_za32_u8_m), arm_streaming, arm_shared_za))
245void svusmopa_za32_u8_m(uint64_t, svbool_t, svbool_t, svuint8_t, svint8_t);
246__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmops_za32_u8_m), arm_streaming, arm_shared_za))
247void svusmops_za32_u8_m(uint64_t, svbool_t, svbool_t, svuint8_t, svint8_t);
248__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u8_m), arm_streaming, arm_shared_za))
249void svwrite_hor_za128_u8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
250__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u32_m), arm_streaming, arm_shared_za))
251void svwrite_hor_za128_u32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
252__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u64_m), arm_streaming, arm_shared_za))
253void svwrite_hor_za128_u64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
254__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u16_m), arm_streaming, arm_shared_za))
255void svwrite_hor_za128_u16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
256__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_bf16_m), arm_streaming, arm_shared_za))
257void svwrite_hor_za128_bf16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
258__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s8_m), arm_streaming, arm_shared_za))
259void svwrite_hor_za128_s8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
260__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f64_m), arm_streaming, arm_shared_za))
261void svwrite_hor_za128_f64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
262__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f32_m), arm_streaming, arm_shared_za))
263void svwrite_hor_za128_f32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
264__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f16_m), arm_streaming, arm_shared_za))
265void svwrite_hor_za128_f16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
266__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s32_m), arm_streaming, arm_shared_za))
267void svwrite_hor_za128_s32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
268__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s64_m), arm_streaming, arm_shared_za))
269void svwrite_hor_za128_s64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
270__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s16_m), arm_streaming, arm_shared_za))
271void svwrite_hor_za128_s16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
272__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_u16_m), arm_streaming, arm_shared_za))
273void svwrite_hor_za16_u16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
274__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_bf16_m), arm_streaming, arm_shared_za))
275void svwrite_hor_za16_bf16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
276__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_f16_m), arm_streaming, arm_shared_za))
277void svwrite_hor_za16_f16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
278__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_s16_m), arm_streaming, arm_shared_za))
279void svwrite_hor_za16_s16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
280__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_u32_m), arm_streaming, arm_shared_za))
281void svwrite_hor_za32_u32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
282__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_f32_m), arm_streaming, arm_shared_za))
283void svwrite_hor_za32_f32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
284__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_s32_m), arm_streaming, arm_shared_za))
285void svwrite_hor_za32_s32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
286__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_u64_m), arm_streaming, arm_shared_za))
287void svwrite_hor_za64_u64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
288__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_f64_m), arm_streaming, arm_shared_za))
289void svwrite_hor_za64_f64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
290__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_s64_m), arm_streaming, arm_shared_za))
291void svwrite_hor_za64_s64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
292__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za8_u8_m), arm_streaming, arm_shared_za))
293void svwrite_hor_za8_u8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
294__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za8_s8_m), arm_streaming, arm_shared_za))
295void svwrite_hor_za8_s8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
296__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u8_m), arm_streaming, arm_shared_za))
297void svwrite_ver_za128_u8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
298__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u32_m), arm_streaming, arm_shared_za))
299void svwrite_ver_za128_u32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
300__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u64_m), arm_streaming, arm_shared_za))
301void svwrite_ver_za128_u64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
302__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u16_m), arm_streaming, arm_shared_za))
303void svwrite_ver_za128_u16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
304__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_bf16_m), arm_streaming, arm_shared_za))
305void svwrite_ver_za128_bf16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
306__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s8_m), arm_streaming, arm_shared_za))
307void svwrite_ver_za128_s8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
308__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f64_m), arm_streaming, arm_shared_za))
309void svwrite_ver_za128_f64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
310__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f32_m), arm_streaming, arm_shared_za))
311void svwrite_ver_za128_f32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
312__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f16_m), arm_streaming, arm_shared_za))
313void svwrite_ver_za128_f16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
314__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s32_m), arm_streaming, arm_shared_za))
315void svwrite_ver_za128_s32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
316__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s64_m), arm_streaming, arm_shared_za))
317void svwrite_ver_za128_s64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
318__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s16_m), arm_streaming, arm_shared_za))
319void svwrite_ver_za128_s16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
320__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_u16_m), arm_streaming, arm_shared_za))
321void svwrite_ver_za16_u16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
322__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_bf16_m), arm_streaming, arm_shared_za))
323void svwrite_ver_za16_bf16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
324__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_f16_m), arm_streaming, arm_shared_za))
325void svwrite_ver_za16_f16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
326__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_s16_m), arm_streaming, arm_shared_za))
327void svwrite_ver_za16_s16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
328__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_u32_m), arm_streaming, arm_shared_za))
329void svwrite_ver_za32_u32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
330__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_f32_m), arm_streaming, arm_shared_za))
331void svwrite_ver_za32_f32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
332__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_s32_m), arm_streaming, arm_shared_za))
333void svwrite_ver_za32_s32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
334__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_u64_m), arm_streaming, arm_shared_za))
335void svwrite_ver_za64_u64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
336__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_f64_m), arm_streaming, arm_shared_za))
337void svwrite_ver_za64_f64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
338__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_s64_m), arm_streaming, arm_shared_za))
339void svwrite_ver_za64_s64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
340__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za8_u8_m), arm_streaming, arm_shared_za))
341void svwrite_ver_za8_u8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
342__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za8_s8_m), arm_streaming, arm_shared_za))
343void svwrite_ver_za8_s8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
344__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svzero_mask_za), arm_streaming_compatible, arm_shared_za))
345void svzero_mask_za(uint64_t);
346__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svzero_za), arm_streaming_compatible, arm_shared_za))
347void svzero_za();
348__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za32_u32_m), arm_streaming, arm_shared_za))
349void svaddha_za32_m(uint64_t, svbool_t, svbool_t, svuint32_t);
350__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za32_s32_m), arm_streaming, arm_shared_za))
351void svaddha_za32_m(uint64_t, svbool_t, svbool_t, svint32_t);
352__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za32_u32_m), arm_streaming, arm_shared_za))
353void svaddva_za32_m(uint64_t, svbool_t, svbool_t, svuint32_t);
354__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za32_s32_m), arm_streaming, arm_shared_za))
355void svaddva_za32_m(uint64_t, svbool_t, svbool_t, svint32_t);
356__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_f16_m), arm_streaming, arm_shared_za))
357void svmopa_za32_m(uint64_t, svbool_t, svbool_t, svfloat16_t, svfloat16_t);
358__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_bf16_m), arm_streaming, arm_shared_za))
359void svmopa_za32_m(uint64_t, svbool_t, svbool_t, svbfloat16_t, svbfloat16_t);
360__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_f32_m), arm_streaming, arm_shared_za))
361void svmopa_za32_m(uint64_t, svbool_t, svbool_t, svfloat32_t, svfloat32_t);
362__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_s8_m), arm_streaming, arm_shared_za))
363void svmopa_za32_m(uint64_t, svbool_t, svbool_t, svint8_t, svint8_t);
364__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za32_u8_m), arm_streaming, arm_shared_za))
365void svmopa_za32_m(uint64_t, svbool_t, svbool_t, svuint8_t, svuint8_t);
366__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_f16_m), arm_streaming, arm_shared_za))
367void svmops_za32_m(uint64_t, svbool_t, svbool_t, svfloat16_t, svfloat16_t);
368__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_bf16_m), arm_streaming, arm_shared_za))
369void svmops_za32_m(uint64_t, svbool_t, svbool_t, svbfloat16_t, svbfloat16_t);
370__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_f32_m), arm_streaming, arm_shared_za))
371void svmops_za32_m(uint64_t, svbool_t, svbool_t, svfloat32_t, svfloat32_t);
372__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_s8_m), arm_streaming, arm_shared_za))
373void svmops_za32_m(uint64_t, svbool_t, svbool_t, svint8_t, svint8_t);
374__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za32_u8_m), arm_streaming, arm_shared_za))
375void svmops_za32_m(uint64_t, svbool_t, svbool_t, svuint8_t, svuint8_t);
376__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
377svuint8_t svread_hor_za128_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
378__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
379svuint32_t svread_hor_za128_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
380__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
381svuint64_t svread_hor_za128_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
382__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
383svuint16_t svread_hor_za128_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
384__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
385svbfloat16_t svread_hor_za128_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
386__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
387svint8_t svread_hor_za128_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
388__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
389svfloat64_t svread_hor_za128_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
390__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
391svfloat32_t svread_hor_za128_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
392__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
393svfloat16_t svread_hor_za128_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
394__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
395svint32_t svread_hor_za128_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
396__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
397svint64_t svread_hor_za128_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
398__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za128_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
399svint16_t svread_hor_za128_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
400__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
401svuint16_t svread_hor_za16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
402__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
403svbfloat16_t svread_hor_za16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
404__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
405svfloat16_t svread_hor_za16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
406__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za16_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
407svint16_t svread_hor_za16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
408__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
409svuint32_t svread_hor_za32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
410__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
411svfloat32_t svread_hor_za32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
412__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za32_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
413svint32_t svread_hor_za32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
414__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
415svuint64_t svread_hor_za64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
416__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
417svfloat64_t svread_hor_za64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
418__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za64_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
419svint64_t svread_hor_za64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
420__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za8_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
421svuint8_t svread_hor_za8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
422__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_hor_za8_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
423svint8_t svread_hor_za8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
424__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
425svuint8_t svread_ver_za128_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
426__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
427svuint32_t svread_ver_za128_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
428__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
429svuint64_t svread_ver_za128_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
430__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
431svuint16_t svread_ver_za128_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
432__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
433svbfloat16_t svread_ver_za128_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
434__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
435svint8_t svread_ver_za128_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
436__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
437svfloat64_t svread_ver_za128_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
438__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
439svfloat32_t svread_ver_za128_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
440__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
441svfloat16_t svread_ver_za128_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
442__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
443svint32_t svread_ver_za128_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
444__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
445svint64_t svread_ver_za128_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
446__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za128_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
447svint16_t svread_ver_za128_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
448__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_u16_m), arm_streaming, arm_shared_za, arm_preserves_za))
449svuint16_t svread_ver_za16_m(svuint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
450__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_bf16_m), arm_streaming, arm_shared_za, arm_preserves_za))
451svbfloat16_t svread_ver_za16_m(svbfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
452__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_f16_m), arm_streaming, arm_shared_za, arm_preserves_za))
453svfloat16_t svread_ver_za16_m(svfloat16_t, svbool_t, uint64_t, uint32_t, uint64_t);
454__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za16_s16_m), arm_streaming, arm_shared_za, arm_preserves_za))
455svint16_t svread_ver_za16_m(svint16_t, svbool_t, uint64_t, uint32_t, uint64_t);
456__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_u32_m), arm_streaming, arm_shared_za, arm_preserves_za))
457svuint32_t svread_ver_za32_m(svuint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
458__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_f32_m), arm_streaming, arm_shared_za, arm_preserves_za))
459svfloat32_t svread_ver_za32_m(svfloat32_t, svbool_t, uint64_t, uint32_t, uint64_t);
460__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za32_s32_m), arm_streaming, arm_shared_za, arm_preserves_za))
461svint32_t svread_ver_za32_m(svint32_t, svbool_t, uint64_t, uint32_t, uint64_t);
462__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_u64_m), arm_streaming, arm_shared_za, arm_preserves_za))
463svuint64_t svread_ver_za64_m(svuint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
464__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_f64_m), arm_streaming, arm_shared_za, arm_preserves_za))
465svfloat64_t svread_ver_za64_m(svfloat64_t, svbool_t, uint64_t, uint32_t, uint64_t);
466__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za64_s64_m), arm_streaming, arm_shared_za, arm_preserves_za))
467svint64_t svread_ver_za64_m(svint64_t, svbool_t, uint64_t, uint32_t, uint64_t);
468__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za8_u8_m), arm_streaming, arm_shared_za, arm_preserves_za))
469svuint8_t svread_ver_za8_m(svuint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
470__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svread_ver_za8_s8_m), arm_streaming, arm_shared_za, arm_preserves_za))
471svint8_t svread_ver_za8_m(svint8_t, svbool_t, uint64_t, uint32_t, uint64_t);
472__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumopa_za32_s8_m), arm_streaming, arm_shared_za))
473void svsumopa_za32_m(uint64_t, svbool_t, svbool_t, svint8_t, svuint8_t);
474__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumops_za32_s8_m), arm_streaming, arm_shared_za))
475void svsumops_za32_m(uint64_t, svbool_t, svbool_t, svint8_t, svuint8_t);
476__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmopa_za32_u8_m), arm_streaming, arm_shared_za))
477void svusmopa_za32_m(uint64_t, svbool_t, svbool_t, svuint8_t, svint8_t);
478__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmops_za32_u8_m), arm_streaming, arm_shared_za))
479void svusmops_za32_m(uint64_t, svbool_t, svbool_t, svuint8_t, svint8_t);
480__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u8_m), arm_streaming, arm_shared_za))
481void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
482__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u32_m), arm_streaming, arm_shared_za))
483void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
484__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u64_m), arm_streaming, arm_shared_za))
485void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
486__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_u16_m), arm_streaming, arm_shared_za))
487void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
488__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_bf16_m), arm_streaming, arm_shared_za))
489void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
490__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s8_m), arm_streaming, arm_shared_za))
491void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
492__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f64_m), arm_streaming, arm_shared_za))
493void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
494__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f32_m), arm_streaming, arm_shared_za))
495void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
496__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_f16_m), arm_streaming, arm_shared_za))
497void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
498__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s32_m), arm_streaming, arm_shared_za))
499void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
500__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s64_m), arm_streaming, arm_shared_za))
501void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
502__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za128_s16_m), arm_streaming, arm_shared_za))
503void svwrite_hor_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
504__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_u16_m), arm_streaming, arm_shared_za))
505void svwrite_hor_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
506__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_bf16_m), arm_streaming, arm_shared_za))
507void svwrite_hor_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
508__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_f16_m), arm_streaming, arm_shared_za))
509void svwrite_hor_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
510__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za16_s16_m), arm_streaming, arm_shared_za))
511void svwrite_hor_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
512__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_u32_m), arm_streaming, arm_shared_za))
513void svwrite_hor_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
514__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_f32_m), arm_streaming, arm_shared_za))
515void svwrite_hor_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
516__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za32_s32_m), arm_streaming, arm_shared_za))
517void svwrite_hor_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
518__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_u64_m), arm_streaming, arm_shared_za))
519void svwrite_hor_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
520__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_f64_m), arm_streaming, arm_shared_za))
521void svwrite_hor_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
522__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za64_s64_m), arm_streaming, arm_shared_za))
523void svwrite_hor_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
524__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za8_u8_m), arm_streaming, arm_shared_za))
525void svwrite_hor_za8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
526__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_hor_za8_s8_m), arm_streaming, arm_shared_za))
527void svwrite_hor_za8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
528__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u8_m), arm_streaming, arm_shared_za))
529void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
530__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u32_m), arm_streaming, arm_shared_za))
531void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
532__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u64_m), arm_streaming, arm_shared_za))
533void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
534__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_u16_m), arm_streaming, arm_shared_za))
535void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
536__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_bf16_m), arm_streaming, arm_shared_za))
537void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
538__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s8_m), arm_streaming, arm_shared_za))
539void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
540__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f64_m), arm_streaming, arm_shared_za))
541void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
542__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f32_m), arm_streaming, arm_shared_za))
543void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
544__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_f16_m), arm_streaming, arm_shared_za))
545void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
546__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s32_m), arm_streaming, arm_shared_za))
547void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
548__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s64_m), arm_streaming, arm_shared_za))
549void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
550__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za128_s16_m), arm_streaming, arm_shared_za))
551void svwrite_ver_za128_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
552__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_u16_m), arm_streaming, arm_shared_za))
553void svwrite_ver_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint16_t);
554__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_bf16_m), arm_streaming, arm_shared_za))
555void svwrite_ver_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svbfloat16_t);
556__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_f16_m), arm_streaming, arm_shared_za))
557void svwrite_ver_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat16_t);
558__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za16_s16_m), arm_streaming, arm_shared_za))
559void svwrite_ver_za16_m(uint64_t, uint32_t, uint64_t, svbool_t, svint16_t);
560__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_u32_m), arm_streaming, arm_shared_za))
561void svwrite_ver_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint32_t);
562__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_f32_m), arm_streaming, arm_shared_za))
563void svwrite_ver_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat32_t);
564__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za32_s32_m), arm_streaming, arm_shared_za))
565void svwrite_ver_za32_m(uint64_t, uint32_t, uint64_t, svbool_t, svint32_t);
566__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_u64_m), arm_streaming, arm_shared_za))
567void svwrite_ver_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint64_t);
568__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_f64_m), arm_streaming, arm_shared_za))
569void svwrite_ver_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svfloat64_t);
570__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za64_s64_m), arm_streaming, arm_shared_za))
571void svwrite_ver_za64_m(uint64_t, uint32_t, uint64_t, svbool_t, svint64_t);
572__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za8_u8_m), arm_streaming, arm_shared_za))
573void svwrite_ver_za8_m(uint64_t, uint32_t, uint64_t, svbool_t, svuint8_t);
574__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svwrite_ver_za8_s8_m), arm_streaming, arm_shared_za))
575void svwrite_ver_za8_m(uint64_t, uint32_t, uint64_t, svbool_t, svint8_t);
576__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_f64_m), arm_streaming, arm_shared_za))
577void svmopa_za64_f64_m(uint64_t, svbool_t, svbool_t, svfloat64_t, svfloat64_t);
578__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_f64_m), arm_streaming, arm_shared_za))
579void svmops_za64_f64_m(uint64_t, svbool_t, svbool_t, svfloat64_t, svfloat64_t);
580__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_f64_m), arm_streaming, arm_shared_za))
581void svmopa_za64_m(uint64_t, svbool_t, svbool_t, svfloat64_t, svfloat64_t);
582__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_f64_m), arm_streaming, arm_shared_za))
583void svmops_za64_m(uint64_t, svbool_t, svbool_t, svfloat64_t, svfloat64_t);
584__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za64_u64_m), arm_streaming, arm_shared_za))
585void svaddha_za64_u64_m(uint64_t, svbool_t, svbool_t, svuint64_t);
586__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za64_s64_m), arm_streaming, arm_shared_za))
587void svaddha_za64_s64_m(uint64_t, svbool_t, svbool_t, svint64_t);
588__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za64_u64_m), arm_streaming, arm_shared_za))
589void svaddva_za64_u64_m(uint64_t, svbool_t, svbool_t, svuint64_t);
590__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za64_s64_m), arm_streaming, arm_shared_za))
591void svaddva_za64_s64_m(uint64_t, svbool_t, svbool_t, svint64_t);
592__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_s16_m), arm_streaming, arm_shared_za))
593void svmopa_za64_s16_m(uint64_t, svbool_t, svbool_t, svint16_t, svint16_t);
594__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_u16_m), arm_streaming, arm_shared_za))
595void svmopa_za64_u16_m(uint64_t, svbool_t, svbool_t, svuint16_t, svuint16_t);
596__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_s16_m), arm_streaming, arm_shared_za))
597void svmops_za64_s16_m(uint64_t, svbool_t, svbool_t, svint16_t, svint16_t);
598__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_u16_m), arm_streaming, arm_shared_za))
599void svmops_za64_u16_m(uint64_t, svbool_t, svbool_t, svuint16_t, svuint16_t);
600__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumopa_za64_s16_m), arm_streaming, arm_shared_za))
601void svsumopa_za64_s16_m(uint64_t, svbool_t, svbool_t, svint16_t, svuint16_t);
602__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumops_za64_s16_m), arm_streaming, arm_shared_za))
603void svsumops_za64_s16_m(uint64_t, svbool_t, svbool_t, svint16_t, svuint16_t);
604__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmopa_za64_u16_m), arm_streaming, arm_shared_za))
605void svusmopa_za64_u16_m(uint64_t, svbool_t, svbool_t, svuint16_t, svint16_t);
606__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmops_za64_u16_m), arm_streaming, arm_shared_za))
607void svusmops_za64_u16_m(uint64_t, svbool_t, svbool_t, svuint16_t, svint16_t);
608__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za64_u64_m), arm_streaming, arm_shared_za))
609void svaddha_za64_m(uint64_t, svbool_t, svbool_t, svuint64_t);
610__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddha_za64_s64_m), arm_streaming, arm_shared_za))
611void svaddha_za64_m(uint64_t, svbool_t, svbool_t, svint64_t);
612__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za64_u64_m), arm_streaming, arm_shared_za))
613void svaddva_za64_m(uint64_t, svbool_t, svbool_t, svuint64_t);
614__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svaddva_za64_s64_m), arm_streaming, arm_shared_za))
615void svaddva_za64_m(uint64_t, svbool_t, svbool_t, svint64_t);
616__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_s16_m), arm_streaming, arm_shared_za))
617void svmopa_za64_m(uint64_t, svbool_t, svbool_t, svint16_t, svint16_t);
618__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmopa_za64_u16_m), arm_streaming, arm_shared_za))
619void svmopa_za64_m(uint64_t, svbool_t, svbool_t, svuint16_t, svuint16_t);
620__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_s16_m), arm_streaming, arm_shared_za))
621void svmops_za64_m(uint64_t, svbool_t, svbool_t, svint16_t, svint16_t);
622__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svmops_za64_u16_m), arm_streaming, arm_shared_za))
623void svmops_za64_m(uint64_t, svbool_t, svbool_t, svuint16_t, svuint16_t);
624__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumopa_za64_s16_m), arm_streaming, arm_shared_za))
625void svsumopa_za64_m(uint64_t, svbool_t, svbool_t, svint16_t, svuint16_t);
626__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svsumops_za64_s16_m), arm_streaming, arm_shared_za))
627void svsumops_za64_m(uint64_t, svbool_t, svbool_t, svint16_t, svuint16_t);
628__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmopa_za64_u16_m), arm_streaming, arm_shared_za))
629void svusmopa_za64_m(uint64_t, svbool_t, svbool_t, svuint16_t, svint16_t);
630__aio __attribute__((__clang_arm_builtin_alias(__builtin_sme_svusmops_za64_u16_m), arm_streaming, arm_shared_za))
631void svusmops_za64_m(uint64_t, svbool_t, svbool_t, svuint16_t, svint16_t);
632__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svldr_vnum_za), arm_streaming_compatible, arm_shared_za))
633void svldr_vnum_za(uint32_t, uint64_t, void const *);
634__ai __attribute__((__clang_arm_builtin_alias(__builtin_sme_svstr_vnum_za), arm_streaming_compatible, arm_shared_za, arm_preserves_za))
635void svstr_vnum_za(uint32_t, uint64_t, void *);
636#ifdef __cplusplus
637} // extern "C"
638#endif
639
640#undef __ai
641
642#endif /* __ARM_SME_H */
lib/include/arm_sve.h+68-13
......@@ -37,7 +37,6 @@ typedef __SVFloat16_t svfloat16_t;
3737
3838typedef __SVBFloat16_t svbfloat16_t;
3939#include <arm_bf16.h>
40typedef __bf16 bfloat16_t;
4140typedef __SVFloat32_t svfloat32_t;
4241typedef __SVFloat64_t svfloat64_t;
4342typedef __clang_svint8x2_t svint8x2_t;
......@@ -74,10 +73,14 @@ typedef __clang_svfloat16x4_t svfloat16x4_t;
7473typedef __clang_svfloat32x4_t svfloat32x4_t;
7574typedef __clang_svfloat64x4_t svfloat64x4_t;
7675typedef __SVBool_t svbool_t;
76typedef __clang_svboolx2_t svboolx2_t;
77typedef __clang_svboolx4_t svboolx4_t;
7778
7879typedef __clang_svbfloat16x2_t svbfloat16x2_t;
7980typedef __clang_svbfloat16x3_t svbfloat16x3_t;
8081typedef __clang_svbfloat16x4_t svbfloat16x4_t;
82typedef __SVCount_t svcount_t;
83
8184enum svpattern
8285{
8386 SV_POW2 = 0,
......@@ -2914,6 +2917,10 @@ __ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_lane_s64)))
29142917svint64_t svdup_lane_s64(svint64_t, uint64_t);
29152918__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_lane_s16)))
29162919svint16_t svdup_lane_s16(svint16_t, uint16_t);
2920__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u8)))
2921svuint8_t svdupq_n_u8(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
2922__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s8)))
2923svint8_t svdupq_n_s8(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t);
29172924__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u16)))
29182925svuint16_t svdupq_n_u16(uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t);
29192926__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_f16)))
......@@ -2932,18 +2939,14 @@ __ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_f64)))
29322939svfloat64_t svdupq_n_f64(float64_t, float64_t);
29332940__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s64)))
29342941svint64_t svdupq_n_s64(int64_t, int64_t);
2935__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u8)))
2936svuint8_t svdupq_n_u8(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
2937__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s8)))
2938svint8_t svdupq_n_s8(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t);
2942__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b8)))
2943svbool_t svdupq_n_b8(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool);
29392944__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b16)))
29402945svbool_t svdupq_n_b16(bool, bool, bool, bool, bool, bool, bool, bool);
29412946__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b32)))
29422947svbool_t svdupq_n_b32(bool, bool, bool, bool);
29432948__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b64)))
29442949svbool_t svdupq_n_b64(bool, bool);
2945__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b8)))
2946svbool_t svdupq_n_b8(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool);
29472950__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_lane_u8)))
29482951svuint8_t svdupq_lane_u8(svuint8_t, uint64_t);
29492952__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_lane_u32)))
......@@ -10528,6 +10531,10 @@ __aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_lane_s64)))
1052810531svint64_t svdup_lane(svint64_t, uint64_t);
1052910532__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_lane_s16)))
1053010533svint16_t svdup_lane(svint16_t, uint16_t);
10534__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u8)))
10535svuint8_t svdupq_u8(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
10536__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s8)))
10537svint8_t svdupq_s8(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t);
1053110538__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u16)))
1053210539svuint16_t svdupq_u16(uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t);
1053310540__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_f16)))
......@@ -10546,18 +10553,14 @@ __aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_f64)))
1054610553svfloat64_t svdupq_f64(float64_t, float64_t);
1054710554__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s64)))
1054810555svint64_t svdupq_s64(int64_t, int64_t);
10549__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_u8)))
10550svuint8_t svdupq_u8(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
10551__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_s8)))
10552svint8_t svdupq_s8(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t);
10556__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b8)))
10557svbool_t svdupq_b8(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool);
1055310558__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b16)))
1055410559svbool_t svdupq_b16(bool, bool, bool, bool, bool, bool, bool, bool);
1055510560__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b32)))
1055610561svbool_t svdupq_b32(bool, bool, bool, bool);
1055710562__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b64)))
1055810563svbool_t svdupq_b64(bool, bool);
10559__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_n_b8)))
10560svbool_t svdupq_b8(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool);
1056110564__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_lane_u8)))
1056210565svuint8_t svdupq_lane(svuint8_t, uint64_t);
1056310566__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdupq_lane_u32)))
......@@ -23874,6 +23877,58 @@ __aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svsm4e_u32)))
2387423877svuint32_t svsm4e(svuint32_t, svuint32_t);
2387523878__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svsm4ekey_u32)))
2387623879svuint32_t svsm4ekey(svuint32_t, svuint32_t);
23880__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f64)))
23881svfloat64_t svclamp_f64(svfloat64_t, svfloat64_t, svfloat64_t);
23882__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f32)))
23883svfloat32_t svclamp_f32(svfloat32_t, svfloat32_t, svfloat32_t);
23884__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f16)))
23885svfloat16_t svclamp_f16(svfloat16_t, svfloat16_t, svfloat16_t);
23886__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s8)))
23887svint8_t svclamp_s8(svint8_t, svint8_t, svint8_t);
23888__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s32)))
23889svint32_t svclamp_s32(svint32_t, svint32_t, svint32_t);
23890__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s64)))
23891svint64_t svclamp_s64(svint64_t, svint64_t, svint64_t);
23892__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s16)))
23893svint16_t svclamp_s16(svint16_t, svint16_t, svint16_t);
23894__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u8)))
23895svuint8_t svclamp_u8(svuint8_t, svuint8_t, svuint8_t);
23896__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u32)))
23897svuint32_t svclamp_u32(svuint32_t, svuint32_t, svuint32_t);
23898__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u64)))
23899svuint64_t svclamp_u64(svuint64_t, svuint64_t, svuint64_t);
23900__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u16)))
23901svuint16_t svclamp_u16(svuint16_t, svuint16_t, svuint16_t);
23902__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svptrue_c8)))
23903svcount_t svptrue_c8(void);
23904__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svptrue_c32)))
23905svcount_t svptrue_c32(void);
23906__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svptrue_c64)))
23907svcount_t svptrue_c64(void);
23908__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svptrue_c16)))
23909svcount_t svptrue_c16(void);
23910__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f64)))
23911svfloat64_t svclamp(svfloat64_t, svfloat64_t, svfloat64_t);
23912__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f32)))
23913svfloat32_t svclamp(svfloat32_t, svfloat32_t, svfloat32_t);
23914__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_f16)))
23915svfloat16_t svclamp(svfloat16_t, svfloat16_t, svfloat16_t);
23916__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s8)))
23917svint8_t svclamp(svint8_t, svint8_t, svint8_t);
23918__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s32)))
23919svint32_t svclamp(svint32_t, svint32_t, svint32_t);
23920__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s64)))
23921svint64_t svclamp(svint64_t, svint64_t, svint64_t);
23922__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_s16)))
23923svint16_t svclamp(svint16_t, svint16_t, svint16_t);
23924__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u8)))
23925svuint8_t svclamp(svuint8_t, svuint8_t, svuint8_t);
23926__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u32)))
23927svuint32_t svclamp(svuint32_t, svuint32_t, svuint32_t);
23928__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u64)))
23929svuint64_t svclamp(svuint64_t, svuint64_t, svuint64_t);
23930__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svclamp_u16)))
23931svuint16_t svclamp(svuint16_t, svuint16_t, svuint16_t);
2387723932#define svcvtnt_bf16_x svcvtnt_bf16_m
2387823933#define svcvtnt_bf16_f32_x svcvtnt_bf16_f32_m
2387923934#define svcvtnt_f16_x svcvtnt_f16_m
lib/include/avx2intrin.h+4116-1
......@@ -19,128 +19,539 @@
1919#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("avx2"), __min_vector_width__(128)))
2020
2121/* SSE4 Multiple Packed Sums of Absolute Difference. */
22/// Computes sixteen sum of absolute difference (SAD) operations on sets of
23/// four unsigned 8-bit integers from the 256-bit integer vectors \a X and
24/// \a Y.
25///
26/// Eight SAD results are computed using the lower half of the input
27/// vectors, and another eight using the upper half. These 16-bit values
28/// are returned in the lower and upper halves of the 256-bit result,
29/// respectively.
30///
31/// A single SAD operation selects four bytes from \a X and four bytes from
32/// \a Y as input. It computes the differences between each \a X byte and
33/// the corresponding \a Y byte, takes the absolute value of each
34/// difference, and sums these four values to form one 16-bit result. The
35/// intrinsic computes 16 of these results with different sets of input
36/// bytes.
37///
38/// For each set of eight results, the SAD operations use the same four
39/// bytes from \a Y; the starting bit position for these four bytes is
40/// specified by \a M[1:0] times 32. The eight operations use successive
41/// sets of four bytes from \a X; the starting bit position for the first
42/// set of four bytes is specified by \a M[2] times 32. These bit positions
43/// are all relative to the 128-bit lane for each set of eight operations.
44///
45/// \code{.operation}
46/// r := 0
47/// FOR i := 0 TO 1
48/// j := i*3
49/// Ybase := M[j+1:j]*32 + i*128
50/// Xbase := M[j+2]*32 + i*128
51/// FOR k := 0 TO 3
52/// temp0 := ABS(X[Xbase+7:Xbase] - Y[Ybase+7:Ybase])
53/// temp1 := ABS(X[Xbase+15:Xbase+8] - Y[Ybase+15:Ybase+8])
54/// temp2 := ABS(X[Xbase+23:Xbase+16] - Y[Ybase+23:Ybase+16])
55/// temp3 := ABS(X[Xbase+31:Xbase+24] - Y[Ybase+31:Ybase+24])
56/// result[r+15:r] := temp0 + temp1 + temp2 + temp3
57/// Xbase := Xbase + 8
58/// r := r + 16
59/// ENDFOR
60/// ENDFOR
61/// \endcode
62///
63/// \headerfile <immintrin.h>
64///
65/// \code
66/// __m256i _mm256_mpsadbw_epu8(__m256i X, __m256i Y, const int M);
67/// \endcode
68///
69/// This intrinsic corresponds to the \c VMPSADBW instruction.
70///
71/// \param X
72/// A 256-bit integer vector containing one of the inputs.
73/// \param Y
74/// A 256-bit integer vector containing one of the inputs.
75/// \param M
76/// An unsigned immediate value specifying the starting positions of the
77/// bytes to operate on.
78/// \returns A 256-bit vector of [16 x i16] containing the result.
2279#define _mm256_mpsadbw_epu8(X, Y, M) \
2380 ((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \
2481 (__v32qi)(__m256i)(Y), (int)(M)))
2582
83/// Computes the absolute value of each signed byte in the 256-bit integer
84/// vector \a __a and returns each value in the corresponding byte of
85/// the result.
86///
87/// \headerfile <immintrin.h>
88///
89/// This intrinsic corresponds to the \c VPABSB instruction.
90///
91/// \param __a
92/// A 256-bit integer vector.
93/// \returns A 256-bit integer vector containing the result.
2694static __inline__ __m256i __DEFAULT_FN_ATTRS256
2795_mm256_abs_epi8(__m256i __a)
2896{
2997 return (__m256i)__builtin_elementwise_abs((__v32qs)__a);
3098}
3199
100/// Computes the absolute value of each signed 16-bit element in the 256-bit
101/// vector of [16 x i16] in \a __a and returns each value in the
102/// corresponding element of the result.
103///
104/// \headerfile <immintrin.h>
105///
106/// This intrinsic corresponds to the \c VPABSW instruction.
107///
108/// \param __a
109/// A 256-bit vector of [16 x i16].
110/// \returns A 256-bit vector of [16 x i16] containing the result.
32111static __inline__ __m256i __DEFAULT_FN_ATTRS256
33112_mm256_abs_epi16(__m256i __a)
34113{
35114 return (__m256i)__builtin_elementwise_abs((__v16hi)__a);
36115}
37116
117/// Computes the absolute value of each signed 32-bit element in the 256-bit
118/// vector of [8 x i32] in \a __a and returns each value in the
119/// corresponding element of the result.
120///
121/// \headerfile <immintrin.h>
122///
123/// This intrinsic corresponds to the \c VPABSD instruction.
124///
125/// \param __a
126/// A 256-bit vector of [8 x i32].
127/// \returns A 256-bit vector of [8 x i32] containing the result.
38128static __inline__ __m256i __DEFAULT_FN_ATTRS256
39129_mm256_abs_epi32(__m256i __a)
40130{
41131 return (__m256i)__builtin_elementwise_abs((__v8si)__a);
42132}
43133
134/// Converts the elements of two 256-bit vectors of [16 x i16] to 8-bit
135/// integers using signed saturation, and returns the 256-bit result.
136///
137/// \code{.operation}
138/// FOR i := 0 TO 7
139/// j := i*16
140/// k := i*8
141/// result[7+k:k] := SATURATE8(__a[15+j:j])
142/// result[71+k:64+k] := SATURATE8(__b[15+j:j])
143/// result[135+k:128+k] := SATURATE8(__a[143+j:128+j])
144/// result[199+k:192+k] := SATURATE8(__b[143+j:128+j])
145/// ENDFOR
146/// \endcode
147///
148/// \headerfile <immintrin.h>
149///
150/// This intrinsic corresponds to the \c VPACKSSWB instruction.
151///
152/// \param __a
153/// A 256-bit vector of [16 x i16] used to generate result[63:0] and
154/// result[191:128].
155/// \param __b
156/// A 256-bit vector of [16 x i16] used to generate result[127:64] and
157/// result[255:192].
158/// \returns A 256-bit integer vector containing the result.
44159static __inline__ __m256i __DEFAULT_FN_ATTRS256
45160_mm256_packs_epi16(__m256i __a, __m256i __b)
46161{
47162 return (__m256i)__builtin_ia32_packsswb256((__v16hi)__a, (__v16hi)__b);
48163}
49164
165/// Converts the elements of two 256-bit vectors of [8 x i32] to 16-bit
166/// integers using signed saturation, and returns the resulting 256-bit
167/// vector of [16 x i16].
168///
169/// \code{.operation}
170/// FOR i := 0 TO 3
171/// j := i*32
172/// k := i*16
173/// result[15+k:k] := SATURATE16(__a[31+j:j])
174/// result[79+k:64+k] := SATURATE16(__b[31+j:j])
175/// result[143+k:128+k] := SATURATE16(__a[159+j:128+j])
176/// result[207+k:192+k] := SATURATE16(__b[159+j:128+j])
177/// ENDFOR
178/// \endcode
179///
180/// \headerfile <immintrin.h>
181///
182/// This intrinsic corresponds to the \c VPACKSSDW instruction.
183///
184/// \param __a
185/// A 256-bit vector of [8 x i32] used to generate result[63:0] and
186/// result[191:128].
187/// \param __b
188/// A 256-bit vector of [8 x i32] used to generate result[127:64] and
189/// result[255:192].
190/// \returns A 256-bit vector of [16 x i16] containing the result.
50191static __inline__ __m256i __DEFAULT_FN_ATTRS256
51192_mm256_packs_epi32(__m256i __a, __m256i __b)
52193{
53194 return (__m256i)__builtin_ia32_packssdw256((__v8si)__a, (__v8si)__b);
54195}
55196
197/// Converts elements from two 256-bit vectors of [16 x i16] to 8-bit integers
198/// using unsigned saturation, and returns the 256-bit result.
199///
200/// \code{.operation}
201/// FOR i := 0 TO 7
202/// j := i*16
203/// k := i*8
204/// result[7+k:k] := SATURATE8U(__a[15+j:j])
205/// result[71+k:64+k] := SATURATE8U(__b[15+j:j])
206/// result[135+k:128+k] := SATURATE8U(__a[143+j:128+j])
207/// result[199+k:192+k] := SATURATE8U(__b[143+j:128+j])
208/// ENDFOR
209/// \endcode
210///
211/// \headerfile <immintrin.h>
212///
213/// This intrinsic corresponds to the \c VPACKUSWB instruction.
214///
215/// \param __a
216/// A 256-bit vector of [16 x i16] used to generate result[63:0] and
217/// result[191:128].
218/// \param __b
219/// A 256-bit vector of [16 x i16] used to generate result[127:64] and
220/// result[255:192].
221/// \returns A 256-bit integer vector containing the result.
56222static __inline__ __m256i __DEFAULT_FN_ATTRS256
57223_mm256_packus_epi16(__m256i __a, __m256i __b)
58224{
59225 return (__m256i)__builtin_ia32_packuswb256((__v16hi)__a, (__v16hi)__b);
60226}
61227
228/// Converts elements from two 256-bit vectors of [8 x i32] to 16-bit integers
229/// using unsigned saturation, and returns the resulting 256-bit vector of
230/// [16 x i16].
231///
232/// \code{.operation}
233/// FOR i := 0 TO 3
234/// j := i*32
235/// k := i*16
236/// result[15+k:k] := SATURATE16U(__V1[31+j:j])
237/// result[79+k:64+k] := SATURATE16U(__V2[31+j:j])
238/// result[143+k:128+k] := SATURATE16U(__V1[159+j:128+j])
239/// result[207+k:192+k] := SATURATE16U(__V2[159+j:128+j])
240/// ENDFOR
241/// \endcode
242///
243/// \headerfile <immintrin.h>
244///
245/// This intrinsic corresponds to the \c VPACKUSDW instruction.
246///
247/// \param __V1
248/// A 256-bit vector of [8 x i32] used to generate result[63:0] and
249/// result[191:128].
250/// \param __V2
251/// A 256-bit vector of [8 x i32] used to generate result[127:64] and
252/// result[255:192].
253/// \returns A 256-bit vector of [16 x i16] containing the result.
62254static __inline__ __m256i __DEFAULT_FN_ATTRS256
63255_mm256_packus_epi32(__m256i __V1, __m256i __V2)
64256{
65257 return (__m256i) __builtin_ia32_packusdw256((__v8si)__V1, (__v8si)__V2);
66258}
67259
260/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
261/// vectors and returns the lower 8 bits of each sum in the corresponding
262/// byte of the 256-bit integer vector result (overflow is ignored).
263///
264/// \headerfile <immintrin.h>
265///
266/// This intrinsic corresponds to the \c VPADDB instruction.
267///
268/// \param __a
269/// A 256-bit integer vector containing one of the source operands.
270/// \param __b
271/// A 256-bit integer vector containing one of the source operands.
272/// \returns A 256-bit integer vector containing the sums.
68273static __inline__ __m256i __DEFAULT_FN_ATTRS256
69274_mm256_add_epi8(__m256i __a, __m256i __b)
70275{
71276 return (__m256i)((__v32qu)__a + (__v32qu)__b);
72277}
73278
279/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
280/// [16 x i16] and returns the lower 16 bits of each sum in the
281/// corresponding element of the [16 x i16] result (overflow is ignored).
282///
283/// \headerfile <immintrin.h>
284///
285/// This intrinsic corresponds to the \c VPADDW instruction.
286///
287/// \param __a
288/// A 256-bit vector of [16 x i16] containing one of the source operands.
289/// \param __b
290/// A 256-bit vector of [16 x i16] containing one of the source operands.
291/// \returns A 256-bit vector of [16 x i16] containing the sums.
74292static __inline__ __m256i __DEFAULT_FN_ATTRS256
75293_mm256_add_epi16(__m256i __a, __m256i __b)
76294{
77295 return (__m256i)((__v16hu)__a + (__v16hu)__b);
78296}
79297
298/// Adds 32-bit integers from corresponding elements of two 256-bit vectors of
299/// [8 x i32] and returns the lower 32 bits of each sum in the corresponding
300/// element of the [8 x i32] result (overflow is ignored).
301///
302/// \headerfile <immintrin.h>
303///
304/// This intrinsic corresponds to the \c VPADDD instruction.
305///
306/// \param __a
307/// A 256-bit vector of [8 x i32] containing one of the source operands.
308/// \param __b
309/// A 256-bit vector of [8 x i32] containing one of the source operands.
310/// \returns A 256-bit vector of [8 x i32] containing the sums.
80311static __inline__ __m256i __DEFAULT_FN_ATTRS256
81312_mm256_add_epi32(__m256i __a, __m256i __b)
82313{
83314 return (__m256i)((__v8su)__a + (__v8su)__b);
84315}
85316
317/// Adds 64-bit integers from corresponding elements of two 256-bit vectors of
318/// [4 x i64] and returns the lower 64 bits of each sum in the corresponding
319/// element of the [4 x i64] result (overflow is ignored).
320///
321/// \headerfile <immintrin.h>
322///
323/// This intrinsic corresponds to the \c VPADDQ instruction.
324///
325/// \param __a
326/// A 256-bit vector of [4 x i64] containing one of the source operands.
327/// \param __b
328/// A 256-bit vector of [4 x i64] containing one of the source operands.
329/// \returns A 256-bit vector of [4 x i64] containing the sums.
86330static __inline__ __m256i __DEFAULT_FN_ATTRS256
87331_mm256_add_epi64(__m256i __a, __m256i __b)
88332{
89333 return (__m256i)((__v4du)__a + (__v4du)__b);
90334}
91335
336/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
337/// vectors using signed saturation, and returns each sum in the
338/// corresponding byte of the 256-bit integer vector result.
339///
340/// \headerfile <immintrin.h>
341///
342/// This intrinsic corresponds to the \c VPADDSB instruction.
343///
344/// \param __a
345/// A 256-bit integer vector containing one of the source operands.
346/// \param __b
347/// A 256-bit integer vector containing one of the source operands.
348/// \returns A 256-bit integer vector containing the sums.
92349static __inline__ __m256i __DEFAULT_FN_ATTRS256
93350_mm256_adds_epi8(__m256i __a, __m256i __b)
94351{
95352 return (__m256i)__builtin_elementwise_add_sat((__v32qs)__a, (__v32qs)__b);
96353}
97354
355/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
356/// [16 x i16] using signed saturation, and returns the [16 x i16] result.
357///
358/// \headerfile <immintrin.h>
359///
360/// This intrinsic corresponds to the \c VPADDSW instruction.
361///
362/// \param __a
363/// A 256-bit vector of [16 x i16] containing one of the source operands.
364/// \param __b
365/// A 256-bit vector of [16 x i16] containing one of the source operands.
366/// \returns A 256-bit vector of [16 x i16] containing the sums.
98367static __inline__ __m256i __DEFAULT_FN_ATTRS256
99368_mm256_adds_epi16(__m256i __a, __m256i __b)
100369{
101370 return (__m256i)__builtin_elementwise_add_sat((__v16hi)__a, (__v16hi)__b);
102371}
103372
373/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
374/// vectors using unsigned saturation, and returns each sum in the
375/// corresponding byte of the 256-bit integer vector result.
376///
377/// \headerfile <immintrin.h>
378///
379/// This intrinsic corresponds to the \c VPADDUSB instruction.
380///
381/// \param __a
382/// A 256-bit integer vector containing one of the source operands.
383/// \param __b
384/// A 256-bit integer vector containing one of the source operands.
385/// \returns A 256-bit integer vector containing the sums.
104386static __inline__ __m256i __DEFAULT_FN_ATTRS256
105387_mm256_adds_epu8(__m256i __a, __m256i __b)
106388{
107389 return (__m256i)__builtin_elementwise_add_sat((__v32qu)__a, (__v32qu)__b);
108390}
109391
392/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
393/// [16 x i16] using unsigned saturation, and returns the [16 x i16] result.
394///
395/// \headerfile <immintrin.h>
396///
397/// This intrinsic corresponds to the \c VPADDUSW instruction.
398///
399/// \param __a
400/// A 256-bit vector of [16 x i16] containing one of the source operands.
401/// \param __b
402/// A 256-bit vector of [16 x i16] containing one of the source operands.
403/// \returns A 256-bit vector of [16 x i16] containing the sums.
110404static __inline__ __m256i __DEFAULT_FN_ATTRS256
111405_mm256_adds_epu16(__m256i __a, __m256i __b)
112406{
113407 return (__m256i)__builtin_elementwise_add_sat((__v16hu)__a, (__v16hu)__b);
114408}
115409
410/// Uses the lower half of the 256-bit vector \a a as the upper half of a
411/// temporary 256-bit value, and the lower half of the 256-bit vector \a b
412/// as the lower half of the temporary value. Right-shifts the temporary
413/// value by \a n bytes, and uses the lower 16 bytes of the shifted value
414/// as the lower 16 bytes of the result. Uses the upper halves of \a a and
415/// \a b to make another temporary value, right shifts by \a n, and uses
416/// the lower 16 bytes of the shifted value as the upper 16 bytes of the
417/// result.
418///
419/// \headerfile <immintrin.h>
420///
421/// \code
422/// __m256i _mm256_alignr_epi8(__m256i a, __m256i b, const int n);
423/// \endcode
424///
425/// This intrinsic corresponds to the \c VPALIGNR instruction.
426///
427/// \param a
428/// A 256-bit integer vector containing source values.
429/// \param b
430/// A 256-bit integer vector containing source values.
431/// \param n
432/// An immediate value specifying the number of bytes to shift.
433/// \returns A 256-bit integer vector containing the result.
116434#define _mm256_alignr_epi8(a, b, n) \
117435 ((__m256i)__builtin_ia32_palignr256((__v32qi)(__m256i)(a), \
118436 (__v32qi)(__m256i)(b), (n)))
119437
438/// Computes the bitwise AND of the 256-bit integer vectors in \a __a and
439/// \a __b.
440///
441/// \headerfile <immintrin.h>
442///
443/// This intrinsic corresponds to the \c VPAND instruction.
444///
445/// \param __a
446/// A 256-bit integer vector.
447/// \param __b
448/// A 256-bit integer vector.
449/// \returns A 256-bit integer vector containing the result.
120450static __inline__ __m256i __DEFAULT_FN_ATTRS256
121451_mm256_and_si256(__m256i __a, __m256i __b)
122452{
123453 return (__m256i)((__v4du)__a & (__v4du)__b);
124454}
125455
456/// Computes the bitwise AND of the 256-bit integer vector in \a __b with
457/// the bitwise NOT of the 256-bit integer vector in \a __a.
458///
459/// \headerfile <immintrin.h>
460///
461/// This intrinsic corresponds to the \c VPANDN instruction.
462///
463/// \param __a
464/// A 256-bit integer vector.
465/// \param __b
466/// A 256-bit integer vector.
467/// \returns A 256-bit integer vector containing the result.
126468static __inline__ __m256i __DEFAULT_FN_ATTRS256
127469_mm256_andnot_si256(__m256i __a, __m256i __b)
128470{
129471 return (__m256i)(~(__v4du)__a & (__v4du)__b);
130472}
131473
474/// Computes the averages of the corresponding unsigned bytes in the two
475/// 256-bit integer vectors in \a __a and \a __b and returns each
476/// average in the corresponding byte of the 256-bit result.
477///
478/// \code{.operation}
479/// FOR i := 0 TO 31
480/// j := i*8
481/// result[j+7:j] := (__a[j+7:j] + __b[j+7:j] + 1) >> 1
482/// ENDFOR
483/// \endcode
484///
485/// \headerfile <immintrin.h>
486///
487/// This intrinsic corresponds to the \c VPAVGB instruction.
488///
489/// \param __a
490/// A 256-bit integer vector.
491/// \param __b
492/// A 256-bit integer vector.
493/// \returns A 256-bit integer vector containing the result.
132494static __inline__ __m256i __DEFAULT_FN_ATTRS256
133495_mm256_avg_epu8(__m256i __a, __m256i __b)
134496{
135497 return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b);
136498}
137499
500/// Computes the averages of the corresponding unsigned 16-bit integers in
501/// the two 256-bit vectors of [16 x i16] in \a __a and \a __b and returns
502/// each average in the corresponding element of the 256-bit result.
503///
504/// \code{.operation}
505/// FOR i := 0 TO 15
506/// j := i*16
507/// result[j+15:j] := (__a[j+15:j] + __b[j+15:j] + 1) >> 1
508/// ENDFOR
509/// \endcode
510///
511/// \headerfile <immintrin.h>
512///
513/// This intrinsic corresponds to the \c VPAVGW instruction.
514///
515/// \param __a
516/// A 256-bit vector of [16 x i16].
517/// \param __b
518/// A 256-bit vector of [16 x i16].
519/// \returns A 256-bit vector of [16 x i16] containing the result.
138520static __inline__ __m256i __DEFAULT_FN_ATTRS256
139521_mm256_avg_epu16(__m256i __a, __m256i __b)
140522{
141523 return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b);
142524}
143525
526/// Merges 8-bit integer values from either of the two 256-bit vectors
527/// \a __V1 or \a __V2, as specified by the 256-bit mask \a __M and returns
528/// the resulting 256-bit integer vector.
529///
530/// \code{.operation}
531/// FOR i := 0 TO 31
532/// j := i*8
533/// IF __M[7+i] == 0
534/// result[7+j:j] := __V1[7+j:j]
535/// ELSE
536/// result[7+j:j] := __V2[7+j:j]
537/// FI
538/// ENDFOR
539/// \endcode
540///
541/// \headerfile <immintrin.h>
542///
543/// This intrinsic corresponds to the \c VPBLENDVB instruction.
544///
545/// \param __V1
546/// A 256-bit integer vector containing source values.
547/// \param __V2
548/// A 256-bit integer vector containing source values.
549/// \param __M
550/// A 256-bit integer vector, with bit [7] of each byte specifying the
551/// source for each corresponding byte of the result. When the mask bit
552/// is 0, the byte is copied from \a __V1; otherwise, it is copied from
553/// \a __V2.
554/// \returns A 256-bit integer vector containing the result.
144555static __inline__ __m256i __DEFAULT_FN_ATTRS256
145556_mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
146557{
......@@ -148,34 +559,171 @@ _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
148559 (__v32qi)__M);
149560}
150561
562/// Merges 16-bit integer values from either of the two 256-bit vectors
563/// \a V1 or \a V2, as specified by the immediate integer operand \a M,
564/// and returns the resulting 256-bit vector of [16 x i16].
565///
566/// \code{.operation}
567/// FOR i := 0 TO 7
568/// j := i*16
569/// IF M[i] == 0
570/// result[7+j:j] := V1[7+j:j]
571/// result[135+j:128+j] := V1[135+j:128+j]
572/// ELSE
573/// result[7+j:j] := V2[7+j:j]
574/// result[135+j:128+j] := V2[135+j:128+j]
575/// FI
576/// ENDFOR
577/// \endcode
578///
579/// \headerfile <immintrin.h>
580///
581/// \code
582/// __m256i _mm256_blend_epi16(__m256i V1, __m256i V2, const int M);
583/// \endcode
584///
585/// This intrinsic corresponds to the \c VPBLENDW instruction.
586///
587/// \param V1
588/// A 256-bit vector of [16 x i16] containing source values.
589/// \param V2
590/// A 256-bit vector of [16 x i16] containing source values.
591/// \param M
592/// An immediate 8-bit integer operand, with bits [7:0] specifying the
593/// source for each element of the result. The position of the mask bit
594/// corresponds to the index of a copied value. When a mask bit is 0, the
595/// element is copied from \a V1; otherwise, it is copied from \a V2.
596/// \a M[0] determines the source for elements 0 and 8, \a M[1] for
597/// elements 1 and 9, and so forth.
598/// \returns A 256-bit vector of [16 x i16] containing the result.
151599#define _mm256_blend_epi16(V1, V2, M) \
152600 ((__m256i)__builtin_ia32_pblendw256((__v16hi)(__m256i)(V1), \
153601 (__v16hi)(__m256i)(V2), (int)(M)))
154602
603/// Compares corresponding bytes in the 256-bit integer vectors in \a __a and
604/// \a __b for equality and returns the outcomes in the corresponding
605/// bytes of the 256-bit result.
606///
607/// \code{.operation}
608/// FOR i := 0 TO 31
609/// j := i*8
610/// result[j+7:j] := (__a[j+7:j] == __b[j+7:j]) ? 0xFF : 0
611/// ENDFOR
612/// \endcode
613///
614/// \headerfile <immintrin.h>
615///
616/// This intrinsic corresponds to the \c VPCMPEQB instruction.
617///
618/// \param __a
619/// A 256-bit integer vector containing one of the inputs.
620/// \param __b
621/// A 256-bit integer vector containing one of the inputs.
622/// \returns A 256-bit integer vector containing the result.
155623static __inline__ __m256i __DEFAULT_FN_ATTRS256
156624_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
157625{
158626 return (__m256i)((__v32qi)__a == (__v32qi)__b);
159627}
160628
629/// Compares corresponding elements in the 256-bit vectors of [16 x i16] in
630/// \a __a and \a __b for equality and returns the outcomes in the
631/// corresponding elements of the 256-bit result.
632///
633/// \code{.operation}
634/// FOR i := 0 TO 15
635/// j := i*16
636/// result[j+15:j] := (__a[j+15:j] == __b[j+15:j]) ? 0xFFFF : 0
637/// ENDFOR
638/// \endcode
639///
640/// \headerfile <immintrin.h>
641///
642/// This intrinsic corresponds to the \c VPCMPEQW instruction.
643///
644/// \param __a
645/// A 256-bit vector of [16 x i16] containing one of the inputs.
646/// \param __b
647/// A 256-bit vector of [16 x i16] containing one of the inputs.
648/// \returns A 256-bit vector of [16 x i16] containing the result.
161649static __inline__ __m256i __DEFAULT_FN_ATTRS256
162650_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
163651{
164652 return (__m256i)((__v16hi)__a == (__v16hi)__b);
165653}
166654
655/// Compares corresponding elements in the 256-bit vectors of [8 x i32] in
656/// \a __a and \a __b for equality and returns the outcomes in the
657/// corresponding elements of the 256-bit result.
658///
659/// \code{.operation}
660/// FOR i := 0 TO 7
661/// j := i*32
662/// result[j+31:j] := (__a[j+31:j] == __b[j+31:j]) ? 0xFFFFFFFF : 0
663/// ENDFOR
664/// \endcode
665///
666/// \headerfile <immintrin.h>
667///
668/// This intrinsic corresponds to the \c VPCMPEQD instruction.
669///
670/// \param __a
671/// A 256-bit vector of [8 x i32] containing one of the inputs.
672/// \param __b
673/// A 256-bit vector of [8 x i32] containing one of the inputs.
674/// \returns A 256-bit vector of [8 x i32] containing the result.
167675static __inline__ __m256i __DEFAULT_FN_ATTRS256
168676_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
169677{
170678 return (__m256i)((__v8si)__a == (__v8si)__b);
171679}
172680
681/// Compares corresponding elements in the 256-bit vectors of [4 x i64] in
682/// \a __a and \a __b for equality and returns the outcomes in the
683/// corresponding elements of the 256-bit result.
684///
685/// \code{.operation}
686/// FOR i := 0 TO 3
687/// j := i*64
688/// result[j+63:j] := (__a[j+63:j] == __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0
689/// ENDFOR
690/// \endcode
691///
692/// \headerfile <immintrin.h>
693///
694/// This intrinsic corresponds to the \c VPCMPEQQ instruction.
695///
696/// \param __a
697/// A 256-bit vector of [4 x i64] containing one of the inputs.
698/// \param __b
699/// A 256-bit vector of [4 x i64] containing one of the inputs.
700/// \returns A 256-bit vector of [4 x i64] containing the result.
173701static __inline__ __m256i __DEFAULT_FN_ATTRS256
174702_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
175703{
176704 return (__m256i)((__v4di)__a == (__v4di)__b);
177705}
178706
707/// Compares corresponding signed bytes in the 256-bit integer vectors in
708/// \a __a and \a __b for greater-than and returns the outcomes in the
709/// corresponding bytes of the 256-bit result.
710///
711/// \code{.operation}
712/// FOR i := 0 TO 31
713/// j := i*8
714/// result[j+7:j] := (__a[j+7:j] > __b[j+7:j]) ? 0xFF : 0
715/// ENDFOR
716/// \endcode
717///
718/// \headerfile <immintrin.h>
719///
720/// This intrinsic corresponds to the \c VPCMPGTB instruction.
721///
722/// \param __a
723/// A 256-bit integer vector containing one of the inputs.
724/// \param __b
725/// A 256-bit integer vector containing one of the inputs.
726/// \returns A 256-bit integer vector containing the result.
179727static __inline__ __m256i __DEFAULT_FN_ATTRS256
180728_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
181729{
......@@ -184,138 +732,575 @@ _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
184732 return (__m256i)((__v32qs)__a > (__v32qs)__b);
185733}
186734
735/// Compares corresponding signed elements in the 256-bit vectors of
736/// [16 x i16] in \a __a and \a __b for greater-than and returns the
737/// outcomes in the corresponding elements of the 256-bit result.
738///
739/// \code{.operation}
740/// FOR i := 0 TO 15
741/// j := i*16
742/// result[j+15:j] := (__a[j+15:j] > __b[j+15:j]) ? 0xFFFF : 0
743/// ENDFOR
744/// \endcode
745///
746/// \headerfile <immintrin.h>
747///
748/// This intrinsic corresponds to the \c VPCMPGTW instruction.
749///
750/// \param __a
751/// A 256-bit vector of [16 x i16] containing one of the inputs.
752/// \param __b
753/// A 256-bit vector of [16 x i16] containing one of the inputs.
754/// \returns A 256-bit vector of [16 x i16] containing the result.
187755static __inline__ __m256i __DEFAULT_FN_ATTRS256
188756_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
189757{
190758 return (__m256i)((__v16hi)__a > (__v16hi)__b);
191759}
192760
761/// Compares corresponding signed elements in the 256-bit vectors of
762/// [8 x i32] in \a __a and \a __b for greater-than and returns the
763/// outcomes in the corresponding elements of the 256-bit result.
764///
765/// \code{.operation}
766/// FOR i := 0 TO 7
767/// j := i*32
768/// result[j+31:j] := (__a[j+31:j] > __b[j+31:j]) ? 0xFFFFFFFF : 0
769/// ENDFOR
770/// \endcode
771///
772/// \headerfile <immintrin.h>
773///
774/// This intrinsic corresponds to the \c VPCMPGTD instruction.
775///
776/// \param __a
777/// A 256-bit vector of [8 x i32] containing one of the inputs.
778/// \param __b
779/// A 256-bit vector of [8 x i32] containing one of the inputs.
780/// \returns A 256-bit vector of [8 x i32] containing the result.
193781static __inline__ __m256i __DEFAULT_FN_ATTRS256
194782_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
195783{
196784 return (__m256i)((__v8si)__a > (__v8si)__b);
197785}
198786
787/// Compares corresponding signed elements in the 256-bit vectors of
788/// [4 x i64] in \a __a and \a __b for greater-than and returns the
789/// outcomes in the corresponding elements of the 256-bit result.
790///
791/// \code{.operation}
792/// FOR i := 0 TO 3
793/// j := i*64
794/// result[j+63:j] := (__a[j+63:j] > __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0
795/// ENDFOR
796/// \endcode
797///
798/// \headerfile <immintrin.h>
799///
800/// This intrinsic corresponds to the \c VPCMPGTQ instruction.
801///
802/// \param __a
803/// A 256-bit vector of [4 x i64] containing one of the inputs.
804/// \param __b
805/// A 256-bit vector of [4 x i64] containing one of the inputs.
806/// \returns A 256-bit vector of [4 x i64] containing the result.
199807static __inline__ __m256i __DEFAULT_FN_ATTRS256
200808_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
201809{
202810 return (__m256i)((__v4di)__a > (__v4di)__b);
203811}
204812
813/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit
814/// vectors of [16 x i16] and returns the lower 16 bits of each sum in an
815/// element of the [16 x i16] result (overflow is ignored). Sums from
816/// \a __a are returned in the lower 64 bits of each 128-bit half of the
817/// result; sums from \a __b are returned in the upper 64 bits of each
818/// 128-bit half of the result.
819///
820/// \code{.operation}
821/// FOR i := 0 TO 1
822/// j := i*128
823/// result[j+15:j] := __a[j+15:j] + __a[j+31:j+16]
824/// result[j+31:j+16] := __a[j+47:j+32] + __a[j+63:j+48]
825/// result[j+47:j+32] := __a[j+79:j+64] + __a[j+95:j+80]
826/// result[j+63:j+48] := __a[j+111:j+96] + __a[j+127:j+112]
827/// result[j+79:j+64] := __b[j+15:j] + __b[j+31:j+16]
828/// result[j+95:j+80] := __b[j+47:j+32] + __b[j+63:j+48]
829/// result[j+111:j+96] := __b[j+79:j+64] + __b[j+95:j+80]
830/// result[j+127:j+112] := __b[j+111:j+96] + __b[j+127:j+112]
831/// ENDFOR
832/// \endcode
833///
834/// \headerfile <immintrin.h>
835///
836/// This intrinsic corresponds to the \c VPHADDW instruction.
837///
838/// \param __a
839/// A 256-bit vector of [16 x i16] containing one of the source operands.
840/// \param __b
841/// A 256-bit vector of [16 x i16] containing one of the source operands.
842/// \returns A 256-bit vector of [16 x i16] containing the sums.
205843static __inline__ __m256i __DEFAULT_FN_ATTRS256
206844_mm256_hadd_epi16(__m256i __a, __m256i __b)
207845{
208846 return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b);
209847}
210848
849/// Horizontally adds the adjacent pairs of 32-bit integers from two 256-bit
850/// vectors of [8 x i32] and returns the lower 32 bits of each sum in an
851/// element of the [8 x i32] result (overflow is ignored). Sums from \a __a
852/// are returned in the lower 64 bits of each 128-bit half of the result;
853/// sums from \a __b are returned in the upper 64 bits of each 128-bit half
854/// of the result.
855///
856/// \code{.operation}
857/// FOR i := 0 TO 1
858/// j := i*128
859/// result[j+31:j] := __a[j+31:j] + __a[j+63:j+32]
860/// result[j+63:j+32] := __a[j+95:j+64] + __a[j+127:j+96]
861/// result[j+95:j+64] := __b[j+31:j] + __b[j+63:j+32]
862/// result[j+127:j+96] := __b[j+95:j+64] + __b[j+127:j+96]
863/// ENDFOR
864/// \endcode
865///
866/// \headerfile <immintrin.h>
867///
868/// This intrinsic corresponds to the \c VPHADDD instruction.
869///
870/// \param __a
871/// A 256-bit vector of [8 x i32] containing one of the source operands.
872/// \param __b
873/// A 256-bit vector of [8 x i32] containing one of the source operands.
874/// \returns A 256-bit vector of [8 x i32] containing the sums.
211875static __inline__ __m256i __DEFAULT_FN_ATTRS256
212876_mm256_hadd_epi32(__m256i __a, __m256i __b)
213877{
214878 return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b);
215879}
216880
881/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit
882/// vectors of [16 x i16] using signed saturation and returns each sum in
883/// an element of the [16 x i16] result. Sums from \a __a are returned in
884/// the lower 64 bits of each 128-bit half of the result; sums from \a __b
885/// are returned in the upper 64 bits of each 128-bit half of the result.
886///
887/// \code{.operation}
888/// FOR i := 0 TO 1
889/// j := i*128
890/// result[j+15:j] := SATURATE16(__a[j+15:j] + __a[j+31:j+16])
891/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] + __a[j+63:j+48])
892/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] + __a[j+95:j+80])
893/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] + __a[j+127:j+112])
894/// result[j+79:j+64] := SATURATE16(__b[j+15:j] + __b[j+31:j+16])
895/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] + __b[j+63:j+48])
896/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] + __b[j+95:j+80])
897/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] + __b[j+127:j+112])
898/// ENDFOR
899/// \endcode
900///
901/// \headerfile <immintrin.h>
902///
903/// This intrinsic corresponds to the \c VPHADDSW instruction.
904///
905/// \param __a
906/// A 256-bit vector of [16 x i16] containing one of the source operands.
907/// \param __b
908/// A 256-bit vector of [16 x i16] containing one of the source operands.
909/// \returns A 256-bit vector of [16 x i16] containing the sums.
217910static __inline__ __m256i __DEFAULT_FN_ATTRS256
218911_mm256_hadds_epi16(__m256i __a, __m256i __b)
219912{
220913 return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b);
221914}
222915
916/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit
917/// vectors of [16 x i16] and returns the lower 16 bits of each difference
918/// in an element of the [16 x i16] result (overflow is ignored).
919/// Differences from \a __a are returned in the lower 64 bits of each
920/// 128-bit half of the result; differences from \a __b are returned in the
921/// upper 64 bits of each 128-bit half of the result.
922///
923/// \code{.operation}
924/// FOR i := 0 TO 1
925/// j := i*128
926/// result[j+15:j] := __a[j+15:j] - __a[j+31:j+16]
927/// result[j+31:j+16] := __a[j+47:j+32] - __a[j+63:j+48]
928/// result[j+47:j+32] := __a[j+79:j+64] - __a[j+95:j+80]
929/// result[j+63:j+48] := __a[j+111:j+96] - __a[j+127:j+112]
930/// result[j+79:j+64] := __b[j+15:j] - __b[j+31:j+16]
931/// result[j+95:j+80] := __b[j+47:j+32] - __b[j+63:j+48]
932/// result[j+111:j+96] := __b[j+79:j+64] - __b[j+95:j+80]
933/// result[j+127:j+112] := __b[j+111:j+96] - __b[j+127:j+112]
934/// ENDFOR
935/// \endcode
936///
937/// \headerfile <immintrin.h>
938///
939/// This intrinsic corresponds to the \c VPHSUBW instruction.
940///
941/// \param __a
942/// A 256-bit vector of [16 x i16] containing one of the source operands.
943/// \param __b
944/// A 256-bit vector of [16 x i16] containing one of the source operands.
945/// \returns A 256-bit vector of [16 x i16] containing the differences.
223946static __inline__ __m256i __DEFAULT_FN_ATTRS256
224947_mm256_hsub_epi16(__m256i __a, __m256i __b)
225948{
226949 return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b);
227950}
228951
952/// Horizontally subtracts adjacent pairs of 32-bit integers from two 256-bit
953/// vectors of [8 x i32] and returns the lower 32 bits of each difference in
954/// an element of the [8 x i32] result (overflow is ignored). Differences
955/// from \a __a are returned in the lower 64 bits of each 128-bit half of
956/// the result; differences from \a __b are returned in the upper 64 bits
957/// of each 128-bit half of the result.
958///
959/// \code{.operation}
960/// FOR i := 0 TO 1
961/// j := i*128
962/// result[j+31:j] := __a[j+31:j] - __a[j+63:j+32]
963/// result[j+63:j+32] := __a[j+95:j+64] - __a[j+127:j+96]
964/// result[j+95:j+64] := __b[j+31:j] - __b[j+63:j+32]
965/// result[j+127:j+96] := __b[j+95:j+64] - __b[j+127:j+96]
966/// ENDFOR
967/// \endcode
968///
969/// \headerfile <immintrin.h>
970///
971/// This intrinsic corresponds to the \c VPHSUBD instruction.
972///
973/// \param __a
974/// A 256-bit vector of [8 x i32] containing one of the source operands.
975/// \param __b
976/// A 256-bit vector of [8 x i32] containing one of the source operands.
977/// \returns A 256-bit vector of [8 x i32] containing the differences.
229978static __inline__ __m256i __DEFAULT_FN_ATTRS256
230979_mm256_hsub_epi32(__m256i __a, __m256i __b)
231980{
232981 return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b);
233982}
234983
984/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit
985/// vectors of [16 x i16] using signed saturation and returns each sum in
986/// an element of the [16 x i16] result. Differences from \a __a are
987/// returned in the lower 64 bits of each 128-bit half of the result;
988/// differences from \a __b are returned in the upper 64 bits of each
989/// 128-bit half of the result.
990///
991/// \code{.operation}
992/// FOR i := 0 TO 1
993/// j := i*128
994/// result[j+15:j] := SATURATE16(__a[j+15:j] - __a[j+31:j+16])
995/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] - __a[j+63:j+48])
996/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] - __a[j+95:j+80])
997/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] - __a[j+127:j+112])
998/// result[j+79:j+64] := SATURATE16(__b[j+15:j] - __b[j+31:j+16])
999/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] - __b[j+63:j+48])
1000/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] - __b[j+95:j+80])
1001/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] - __b[j+127:j+112])
1002/// ENDFOR
1003/// \endcode
1004///
1005/// \headerfile <immintrin.h>
1006///
1007/// This intrinsic corresponds to the \c VPHSUBSW instruction.
1008///
1009/// \param __a
1010/// A 256-bit vector of [16 x i16] containing one of the source operands.
1011/// \param __b
1012/// A 256-bit vector of [16 x i16] containing one of the source operands.
1013/// \returns A 256-bit vector of [16 x i16] containing the differences.
2351014static __inline__ __m256i __DEFAULT_FN_ATTRS256
2361015_mm256_hsubs_epi16(__m256i __a, __m256i __b)
2371016{
2381017 return (__m256i)__builtin_ia32_phsubsw256((__v16hi)__a, (__v16hi)__b);
2391018}
2401019
1020/// Multiplies each unsigned byte from the 256-bit integer vector in \a __a
1021/// with the corresponding signed byte from the 256-bit integer vector in
1022/// \a __b, forming signed 16-bit intermediate products. Adds adjacent
1023/// pairs of those products using signed saturation to form 16-bit sums
1024/// returned as elements of the [16 x i16] result.
1025///
1026/// \code{.operation}
1027/// FOR i := 0 TO 15
1028/// j := i*16
1029/// temp1 := __a[j+7:j] * __b[j+7:j]
1030/// temp2 := __a[j+15:j+8] * __b[j+15:j+8]
1031/// result[j+15:j] := SATURATE16(temp1 + temp2)
1032/// ENDFOR
1033/// \endcode
1034///
1035/// \headerfile <immintrin.h>
1036///
1037/// This intrinsic corresponds to the \c VPMADDUBSW instruction.
1038///
1039/// \param __a
1040/// A 256-bit vector containing one of the source operands.
1041/// \param __b
1042/// A 256-bit vector containing one of the source operands.
1043/// \returns A 256-bit vector of [16 x i16] containing the result.
2411044static __inline__ __m256i __DEFAULT_FN_ATTRS256
2421045_mm256_maddubs_epi16(__m256i __a, __m256i __b)
2431046{
2441047 return (__m256i)__builtin_ia32_pmaddubsw256((__v32qi)__a, (__v32qi)__b);
2451048}
2461049
1050/// Multiplies corresponding 16-bit elements of two 256-bit vectors of
1051/// [16 x i16], forming 32-bit intermediate products, and adds pairs of
1052/// those products to form 32-bit sums returned as elements of the
1053/// [8 x i32] result.
1054///
1055/// There is only one wraparound case: when all four of the 16-bit sources
1056/// are \c 0x8000, the result will be \c 0x80000000.
1057///
1058/// \code{.operation}
1059/// FOR i := 0 TO 7
1060/// j := i*32
1061/// temp1 := __a[j+15:j] * __b[j+15:j]
1062/// temp2 := __a[j+31:j+16] * __b[j+31:j+16]
1063/// result[j+31:j] := temp1 + temp2
1064/// ENDFOR
1065/// \endcode
1066///
1067/// \headerfile <immintrin.h>
1068///
1069/// This intrinsic corresponds to the \c VPMADDWD instruction.
1070///
1071/// \param __a
1072/// A 256-bit vector of [16 x i16] containing one of the source operands.
1073/// \param __b
1074/// A 256-bit vector of [16 x i16] containing one of the source operands.
1075/// \returns A 256-bit vector of [8 x i32] containing the result.
2471076static __inline__ __m256i __DEFAULT_FN_ATTRS256
2481077_mm256_madd_epi16(__m256i __a, __m256i __b)
2491078{
2501079 return (__m256i)__builtin_ia32_pmaddwd256((__v16hi)__a, (__v16hi)__b);
2511080}
2521081
1082/// Compares the corresponding signed bytes in the two 256-bit integer vectors
1083/// in \a __a and \a __b and returns the larger of each pair in the
1084/// corresponding byte of the 256-bit result.
1085///
1086/// \headerfile <immintrin.h>
1087///
1088/// This intrinsic corresponds to the \c VPMAXSB instruction.
1089///
1090/// \param __a
1091/// A 256-bit integer vector.
1092/// \param __b
1093/// A 256-bit integer vector.
1094/// \returns A 256-bit integer vector containing the result.
2531095static __inline__ __m256i __DEFAULT_FN_ATTRS256
2541096_mm256_max_epi8(__m256i __a, __m256i __b)
2551097{
2561098 return (__m256i)__builtin_elementwise_max((__v32qs)__a, (__v32qs)__b);
2571099}
2581100
1101/// Compares the corresponding signed 16-bit integers in the two 256-bit
1102/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of
1103/// each pair in the corresponding element of the 256-bit result.
1104///
1105/// \headerfile <immintrin.h>
1106///
1107/// This intrinsic corresponds to the \c VPMAXSW instruction.
1108///
1109/// \param __a
1110/// A 256-bit vector of [16 x i16].
1111/// \param __b
1112/// A 256-bit vector of [16 x i16].
1113/// \returns A 256-bit vector of [16 x i16] containing the result.
2591114static __inline__ __m256i __DEFAULT_FN_ATTRS256
2601115_mm256_max_epi16(__m256i __a, __m256i __b)
2611116{
2621117 return (__m256i)__builtin_elementwise_max((__v16hi)__a, (__v16hi)__b);
2631118}
2641119
1120/// Compares the corresponding signed 32-bit integers in the two 256-bit
1121/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of
1122/// each pair in the corresponding element of the 256-bit result.
1123///
1124/// \headerfile <immintrin.h>
1125///
1126/// This intrinsic corresponds to the \c VPMAXSD instruction.
1127///
1128/// \param __a
1129/// A 256-bit vector of [8 x i32].
1130/// \param __b
1131/// A 256-bit vector of [8 x i32].
1132/// \returns A 256-bit vector of [8 x i32] containing the result.
2651133static __inline__ __m256i __DEFAULT_FN_ATTRS256
2661134_mm256_max_epi32(__m256i __a, __m256i __b)
2671135{
2681136 return (__m256i)__builtin_elementwise_max((__v8si)__a, (__v8si)__b);
2691137}
2701138
1139/// Compares the corresponding unsigned bytes in the two 256-bit integer
1140/// vectors in \a __a and \a __b and returns the larger of each pair in
1141/// the corresponding byte of the 256-bit result.
1142///
1143/// \headerfile <immintrin.h>
1144///
1145/// This intrinsic corresponds to the \c VPMAXUB instruction.
1146///
1147/// \param __a
1148/// A 256-bit integer vector.
1149/// \param __b
1150/// A 256-bit integer vector.
1151/// \returns A 256-bit integer vector containing the result.
2711152static __inline__ __m256i __DEFAULT_FN_ATTRS256
2721153_mm256_max_epu8(__m256i __a, __m256i __b)
2731154{
2741155 return (__m256i)__builtin_elementwise_max((__v32qu)__a, (__v32qu)__b);
2751156}
2761157
1158/// Compares the corresponding unsigned 16-bit integers in the two 256-bit
1159/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of
1160/// each pair in the corresponding element of the 256-bit result.
1161///
1162/// \headerfile <immintrin.h>
1163///
1164/// This intrinsic corresponds to the \c VPMAXUW instruction.
1165///
1166/// \param __a
1167/// A 256-bit vector of [16 x i16].
1168/// \param __b
1169/// A 256-bit vector of [16 x i16].
1170/// \returns A 256-bit vector of [16 x i16] containing the result.
2771171static __inline__ __m256i __DEFAULT_FN_ATTRS256
2781172_mm256_max_epu16(__m256i __a, __m256i __b)
2791173{
2801174 return (__m256i)__builtin_elementwise_max((__v16hu)__a, (__v16hu)__b);
2811175}
2821176
1177/// Compares the corresponding unsigned 32-bit integers in the two 256-bit
1178/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of
1179/// each pair in the corresponding element of the 256-bit result.
1180///
1181/// \headerfile <immintrin.h>
1182///
1183/// This intrinsic corresponds to the \c VPMAXUD instruction.
1184///
1185/// \param __a
1186/// A 256-bit vector of [8 x i32].
1187/// \param __b
1188/// A 256-bit vector of [8 x i32].
1189/// \returns A 256-bit vector of [8 x i32] containing the result.
2831190static __inline__ __m256i __DEFAULT_FN_ATTRS256
2841191_mm256_max_epu32(__m256i __a, __m256i __b)
2851192{
2861193 return (__m256i)__builtin_elementwise_max((__v8su)__a, (__v8su)__b);
2871194}
2881195
1196/// Compares the corresponding signed bytes in the two 256-bit integer vectors
1197/// in \a __a and \a __b and returns the smaller of each pair in the
1198/// corresponding byte of the 256-bit result.
1199///
1200/// \headerfile <immintrin.h>
1201///
1202/// This intrinsic corresponds to the \c VPMINSB instruction.
1203///
1204/// \param __a
1205/// A 256-bit integer vector.
1206/// \param __b
1207/// A 256-bit integer vector.
1208/// \returns A 256-bit integer vector containing the result.
2891209static __inline__ __m256i __DEFAULT_FN_ATTRS256
2901210_mm256_min_epi8(__m256i __a, __m256i __b)
2911211{
2921212 return (__m256i)__builtin_elementwise_min((__v32qs)__a, (__v32qs)__b);
2931213}
2941214
1215/// Compares the corresponding signed 16-bit integers in the two 256-bit
1216/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of
1217/// each pair in the corresponding element of the 256-bit result.
1218///
1219/// \headerfile <immintrin.h>
1220///
1221/// This intrinsic corresponds to the \c VPMINSW instruction.
1222///
1223/// \param __a
1224/// A 256-bit vector of [16 x i16].
1225/// \param __b
1226/// A 256-bit vector of [16 x i16].
1227/// \returns A 256-bit vector of [16 x i16] containing the result.
2951228static __inline__ __m256i __DEFAULT_FN_ATTRS256
2961229_mm256_min_epi16(__m256i __a, __m256i __b)
2971230{
2981231 return (__m256i)__builtin_elementwise_min((__v16hi)__a, (__v16hi)__b);
2991232}
3001233
1234/// Compares the corresponding signed 32-bit integers in the two 256-bit
1235/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of
1236/// each pair in the corresponding element of the 256-bit result.
1237///
1238/// \headerfile <immintrin.h>
1239///
1240/// This intrinsic corresponds to the \c VPMINSD instruction.
1241///
1242/// \param __a
1243/// A 256-bit vector of [8 x i32].
1244/// \param __b
1245/// A 256-bit vector of [8 x i32].
1246/// \returns A 256-bit vector of [8 x i32] containing the result.
3011247static __inline__ __m256i __DEFAULT_FN_ATTRS256
3021248_mm256_min_epi32(__m256i __a, __m256i __b)
3031249{
3041250 return (__m256i)__builtin_elementwise_min((__v8si)__a, (__v8si)__b);
3051251}
3061252
1253/// Compares the corresponding unsigned bytes in the two 256-bit integer
1254/// vectors in \a __a and \a __b and returns the smaller of each pair in
1255/// the corresponding byte of the 256-bit result.
1256///
1257/// \headerfile <immintrin.h>
1258///
1259/// This intrinsic corresponds to the \c VPMINUB instruction.
1260///
1261/// \param __a
1262/// A 256-bit integer vector.
1263/// \param __b
1264/// A 256-bit integer vector.
1265/// \returns A 256-bit integer vector containing the result.
3071266static __inline__ __m256i __DEFAULT_FN_ATTRS256
3081267_mm256_min_epu8(__m256i __a, __m256i __b)
3091268{
3101269 return (__m256i)__builtin_elementwise_min((__v32qu)__a, (__v32qu)__b);
3111270}
3121271
1272/// Compares the corresponding unsigned 16-bit integers in the two 256-bit
1273/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of
1274/// each pair in the corresponding element of the 256-bit result.
1275///
1276/// \headerfile <immintrin.h>
1277///
1278/// This intrinsic corresponds to the \c VPMINUW instruction.
1279///
1280/// \param __a
1281/// A 256-bit vector of [16 x i16].
1282/// \param __b
1283/// A 256-bit vector of [16 x i16].
1284/// \returns A 256-bit vector of [16 x i16] containing the result.
3131285static __inline__ __m256i __DEFAULT_FN_ATTRS256
3141286_mm256_min_epu16(__m256i __a, __m256i __b)
3151287{
3161288 return (__m256i)__builtin_elementwise_min((__v16hu)__a, (__v16hu)__b);
3171289}
3181290
1291/// Compares the corresponding unsigned 32-bit integers in the two 256-bit
1292/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of
1293/// each pair in the corresponding element of the 256-bit result.
1294///
1295/// \headerfile <immintrin.h>
1296///
1297/// This intrinsic corresponds to the \c VPMINUD instruction.
1298///
1299/// \param __a
1300/// A 256-bit vector of [8 x i32].
1301/// \param __b
1302/// A 256-bit vector of [8 x i32].
1303/// \returns A 256-bit vector of [8 x i32] containing the result.
3191304static __inline__ __m256i __DEFAULT_FN_ATTRS256
3201305_mm256_min_epu32(__m256i __a, __m256i __b)
3211306{
......@@ -328,6 +1313,26 @@ _mm256_movemask_epi8(__m256i __a)
3281313 return __builtin_ia32_pmovmskb256((__v32qi)__a);
3291314}
3301315
1316/// Sign-extends bytes from the 128-bit integer vector in \a __V and returns
1317/// the 16-bit values in the corresponding elements of a 256-bit vector
1318/// of [16 x i16].
1319///
1320/// \code{.operation}
1321/// FOR i := 0 TO 15
1322/// j := i*8
1323/// k := i*16
1324/// result[k+15:k] := SignExtend(__V[j+7:j])
1325/// ENDFOR
1326/// \endcode
1327///
1328/// \headerfile <immintrin.h>
1329///
1330/// This intrinsic corresponds to the \c VPMOVSXBW instruction.
1331///
1332/// \param __V
1333/// A 128-bit integer vector containing the source bytes.
1334/// \returns A 256-bit vector of [16 x i16] containing the sign-extended
1335/// values.
3311336static __inline__ __m256i __DEFAULT_FN_ATTRS256
3321337_mm256_cvtepi8_epi16(__m128i __V)
3331338{
......@@ -336,6 +1341,26 @@ _mm256_cvtepi8_epi16(__m128i __V)
3361341 return (__m256i)__builtin_convertvector((__v16qs)__V, __v16hi);
3371342}
3381343
1344/// Sign-extends bytes from the lower half of the 128-bit integer vector in
1345/// \a __V and returns the 32-bit values in the corresponding elements of a
1346/// 256-bit vector of [8 x i32].
1347///
1348/// \code{.operation}
1349/// FOR i := 0 TO 7
1350/// j := i*8
1351/// k := i*32
1352/// result[k+31:k] := SignExtend(__V[j+7:j])
1353/// ENDFOR
1354/// \endcode
1355///
1356/// \headerfile <immintrin.h>
1357///
1358/// This intrinsic corresponds to the \c VPMOVSXBD instruction.
1359///
1360/// \param __V
1361/// A 128-bit integer vector containing the source bytes.
1362/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
1363/// values.
3391364static __inline__ __m256i __DEFAULT_FN_ATTRS256
3401365_mm256_cvtepi8_epi32(__m128i __V)
3411366{
......@@ -344,6 +1369,25 @@ _mm256_cvtepi8_epi32(__m128i __V)
3441369 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
3451370}
3461371
1372/// Sign-extends the first four bytes from the 128-bit integer vector in
1373/// \a __V and returns the 64-bit values in the corresponding elements of a
1374/// 256-bit vector of [4 x i64].
1375///
1376/// \code{.operation}
1377/// result[63:0] := SignExtend(__V[7:0])
1378/// result[127:64] := SignExtend(__V[15:8])
1379/// result[191:128] := SignExtend(__V[23:16])
1380/// result[255:192] := SignExtend(__V[31:24])
1381/// \endcode
1382///
1383/// \headerfile <immintrin.h>
1384///
1385/// This intrinsic corresponds to the \c VPMOVSXBQ instruction.
1386///
1387/// \param __V
1388/// A 128-bit integer vector containing the source bytes.
1389/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1390/// values.
3471391static __inline__ __m256i __DEFAULT_FN_ATTRS256
3481392_mm256_cvtepi8_epi64(__m128i __V)
3491393{
......@@ -352,357 +1396,1571 @@ _mm256_cvtepi8_epi64(__m128i __V)
3521396 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4di);
3531397}
3541398
1399/// Sign-extends 16-bit elements from the 128-bit vector of [8 x i16] in
1400/// \a __V and returns the 32-bit values in the corresponding elements of a
1401/// 256-bit vector of [8 x i32].
1402///
1403/// \code{.operation}
1404/// FOR i := 0 TO 7
1405/// j := i*16
1406/// k := i*32
1407/// result[k+31:k] := SignExtend(__V[j+15:j])
1408/// ENDFOR
1409/// \endcode
1410///
1411/// \headerfile <immintrin.h>
1412///
1413/// This intrinsic corresponds to the \c VPMOVSXWD instruction.
1414///
1415/// \param __V
1416/// A 128-bit vector of [8 x i16] containing the source values.
1417/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
1418/// values.
3551419static __inline__ __m256i __DEFAULT_FN_ATTRS256
3561420_mm256_cvtepi16_epi32(__m128i __V)
3571421{
3581422 return (__m256i)__builtin_convertvector((__v8hi)__V, __v8si);
3591423}
3601424
1425/// Sign-extends 16-bit elements from the lower half of the 128-bit vector of
1426/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding
1427/// elements of a 256-bit vector of [4 x i64].
1428///
1429/// \code{.operation}
1430/// result[63:0] := SignExtend(__V[15:0])
1431/// result[127:64] := SignExtend(__V[31:16])
1432/// result[191:128] := SignExtend(__V[47:32])
1433/// result[255:192] := SignExtend(__V[64:48])
1434/// \endcode
1435///
1436/// \headerfile <immintrin.h>
1437///
1438/// This intrinsic corresponds to the \c VPMOVSXWQ instruction.
1439///
1440/// \param __V
1441/// A 128-bit vector of [8 x i16] containing the source values.
1442/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1443/// values.
3611444static __inline__ __m256i __DEFAULT_FN_ATTRS256
3621445_mm256_cvtepi16_epi64(__m128i __V)
3631446{
3641447 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4di);
3651448}
3661449
1450/// Sign-extends 32-bit elements from the 128-bit vector of [4 x i32] in
1451/// \a __V and returns the 64-bit values in the corresponding elements of a
1452/// 256-bit vector of [4 x i64].
1453///
1454/// \code{.operation}
1455/// result[63:0] := SignExtend(__V[31:0])
1456/// result[127:64] := SignExtend(__V[63:32])
1457/// result[191:128] := SignExtend(__V[95:64])
1458/// result[255:192] := SignExtend(__V[127:96])
1459/// \endcode
1460///
1461/// \headerfile <immintrin.h>
1462///
1463/// This intrinsic corresponds to the \c VPMOVSXDQ instruction.
1464///
1465/// \param __V
1466/// A 128-bit vector of [4 x i32] containing the source values.
1467/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1468/// values.
3671469static __inline__ __m256i __DEFAULT_FN_ATTRS256
3681470_mm256_cvtepi32_epi64(__m128i __V)
3691471{
3701472 return (__m256i)__builtin_convertvector((__v4si)__V, __v4di);
3711473}
3721474
1475/// Zero-extends bytes from the 128-bit integer vector in \a __V and returns
1476/// the 16-bit values in the corresponding elements of a 256-bit vector
1477/// of [16 x i16].
1478///
1479/// \code{.operation}
1480/// FOR i := 0 TO 15
1481/// j := i*8
1482/// k := i*16
1483/// result[k+15:k] := ZeroExtend(__V[j+7:j])
1484/// ENDFOR
1485/// \endcode
1486///
1487/// \headerfile <immintrin.h>
1488///
1489/// This intrinsic corresponds to the \c VPMOVZXBW instruction.
1490///
1491/// \param __V
1492/// A 128-bit integer vector containing the source bytes.
1493/// \returns A 256-bit vector of [16 x i16] containing the zero-extended
1494/// values.
3731495static __inline__ __m256i __DEFAULT_FN_ATTRS256
3741496_mm256_cvtepu8_epi16(__m128i __V)
3751497{
3761498 return (__m256i)__builtin_convertvector((__v16qu)__V, __v16hi);
3771499}
3781500
1501/// Zero-extends bytes from the lower half of the 128-bit integer vector in
1502/// \a __V and returns the 32-bit values in the corresponding elements of a
1503/// 256-bit vector of [8 x i32].
1504///
1505/// \code{.operation}
1506/// FOR i := 0 TO 7
1507/// j := i*8
1508/// k := i*32
1509/// result[k+31:k] := ZeroExtend(__V[j+7:j])
1510/// ENDFOR
1511/// \endcode
1512///
1513/// \headerfile <immintrin.h>
1514///
1515/// This intrinsic corresponds to the \c VPMOVZXBD instruction.
1516///
1517/// \param __V
1518/// A 128-bit integer vector containing the source bytes.
1519/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
1520/// values.
3791521static __inline__ __m256i __DEFAULT_FN_ATTRS256
3801522_mm256_cvtepu8_epi32(__m128i __V)
3811523{
3821524 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
3831525}
3841526
1527/// Zero-extends the first four bytes from the 128-bit integer vector in
1528/// \a __V and returns the 64-bit values in the corresponding elements of a
1529/// 256-bit vector of [4 x i64].
1530///
1531/// \code{.operation}
1532/// result[63:0] := ZeroExtend(__V[7:0])
1533/// result[127:64] := ZeroExtend(__V[15:8])
1534/// result[191:128] := ZeroExtend(__V[23:16])
1535/// result[255:192] := ZeroExtend(__V[31:24])
1536/// \endcode
1537///
1538/// \headerfile <immintrin.h>
1539///
1540/// This intrinsic corresponds to the \c VPMOVZXBQ instruction.
1541///
1542/// \param __V
1543/// A 128-bit integer vector containing the source bytes.
1544/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1545/// values.
3851546static __inline__ __m256i __DEFAULT_FN_ATTRS256
3861547_mm256_cvtepu8_epi64(__m128i __V)
3871548{
3881549 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4di);
3891550}
3901551
1552/// Zero-extends 16-bit elements from the 128-bit vector of [8 x i16] in
1553/// \a __V and returns the 32-bit values in the corresponding elements of a
1554/// 256-bit vector of [8 x i32].
1555///
1556/// \code{.operation}
1557/// FOR i := 0 TO 7
1558/// j := i*16
1559/// k := i*32
1560/// result[k+31:k] := ZeroExtend(__V[j+15:j])
1561/// ENDFOR
1562/// \endcode
1563///
1564/// \headerfile <immintrin.h>
1565///
1566/// This intrinsic corresponds to the \c VPMOVZXWD instruction.
1567///
1568/// \param __V
1569/// A 128-bit vector of [8 x i16] containing the source values.
1570/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
1571/// values.
3911572static __inline__ __m256i __DEFAULT_FN_ATTRS256
3921573_mm256_cvtepu16_epi32(__m128i __V)
3931574{
3941575 return (__m256i)__builtin_convertvector((__v8hu)__V, __v8si);
3951576}
3961577
1578/// Zero-extends 16-bit elements from the lower half of the 128-bit vector of
1579/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding
1580/// elements of a 256-bit vector of [4 x i64].
1581///
1582/// \code{.operation}
1583/// result[63:0] := ZeroExtend(__V[15:0])
1584/// result[127:64] := ZeroExtend(__V[31:16])
1585/// result[191:128] := ZeroExtend(__V[47:32])
1586/// result[255:192] := ZeroExtend(__V[64:48])
1587/// \endcode
1588///
1589/// \headerfile <immintrin.h>
1590///
1591/// This intrinsic corresponds to the \c VPMOVSXWQ instruction.
1592///
1593/// \param __V
1594/// A 128-bit vector of [8 x i16] containing the source values.
1595/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1596/// values.
3971597static __inline__ __m256i __DEFAULT_FN_ATTRS256
3981598_mm256_cvtepu16_epi64(__m128i __V)
3991599{
4001600 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4di);
4011601}
4021602
1603/// Zero-extends 32-bit elements from the 128-bit vector of [4 x i32] in
1604/// \a __V and returns the 64-bit values in the corresponding elements of a
1605/// 256-bit vector of [4 x i64].
1606///
1607/// \code{.operation}
1608/// result[63:0] := ZeroExtend(__V[31:0])
1609/// result[127:64] := ZeroExtend(__V[63:32])
1610/// result[191:128] := ZeroExtend(__V[95:64])
1611/// result[255:192] := ZeroExtend(__V[127:96])
1612/// \endcode
1613///
1614/// \headerfile <immintrin.h>
1615///
1616/// This intrinsic corresponds to the \c VPMOVZXDQ instruction.
1617///
1618/// \param __V
1619/// A 128-bit vector of [4 x i32] containing the source values.
1620/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1621/// values.
4031622static __inline__ __m256i __DEFAULT_FN_ATTRS256
4041623_mm256_cvtepu32_epi64(__m128i __V)
4051624{
4061625 return (__m256i)__builtin_convertvector((__v4su)__V, __v4di);
4071626}
4081627
1628/// Multiplies signed 32-bit integers from even-numbered elements of two
1629/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the
1630/// [4 x i64] result.
1631///
1632/// \code{.operation}
1633/// result[63:0] := __a[31:0] * __b[31:0]
1634/// result[127:64] := __a[95:64] * __b[95:64]
1635/// result[191:128] := __a[159:128] * __b[159:128]
1636/// result[255:192] := __a[223:192] * __b[223:192]
1637/// \endcode
1638///
1639/// \headerfile <immintrin.h>
1640///
1641/// This intrinsic corresponds to the \c VPMULDQ instruction.
1642///
1643/// \param __a
1644/// A 256-bit vector of [8 x i32] containing one of the source operands.
1645/// \param __b
1646/// A 256-bit vector of [8 x i32] containing one of the source operands.
1647/// \returns A 256-bit vector of [4 x i64] containing the products.
4091648static __inline__ __m256i __DEFAULT_FN_ATTRS256
4101649_mm256_mul_epi32(__m256i __a, __m256i __b)
4111650{
4121651 return (__m256i)__builtin_ia32_pmuldq256((__v8si)__a, (__v8si)__b);
4131652}
4141653
1654/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1655/// [16 x i16], truncates the 32-bit results to the most significant 18
1656/// bits, rounds by adding 1, and returns bits [16:1] of each rounded
1657/// product in the [16 x i16] result.
1658///
1659/// \code{.operation}
1660/// FOR i := 0 TO 15
1661/// j := i*16
1662/// temp := ((__a[j+15:j] * __b[j+15:j]) >> 14) + 1
1663/// result[j+15:j] := temp[16:1]
1664/// \endcode
1665///
1666/// \headerfile <immintrin.h>
1667///
1668/// This intrinsic corresponds to the \c VPMULHRSW instruction.
1669///
1670/// \param __a
1671/// A 256-bit vector of [16 x i16] containing one of the source operands.
1672/// \param __b
1673/// A 256-bit vector of [16 x i16] containing one of the source operands.
1674/// \returns A 256-bit vector of [16 x i16] containing the rounded products.
4151675static __inline__ __m256i __DEFAULT_FN_ATTRS256
4161676_mm256_mulhrs_epi16(__m256i __a, __m256i __b)
4171677{
4181678 return (__m256i)__builtin_ia32_pmulhrsw256((__v16hi)__a, (__v16hi)__b);
4191679}
4201680
1681/// Multiplies unsigned 16-bit integer elements of two 256-bit vectors of
1682/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the
1683/// [16 x i16] result.
1684///
1685/// \headerfile <immintrin.h>
1686///
1687/// This intrinsic corresponds to the \c VPMULHUW instruction.
1688///
1689/// \param __a
1690/// A 256-bit vector of [16 x i16] containing one of the source operands.
1691/// \param __b
1692/// A 256-bit vector of [16 x i16] containing one of the source operands.
1693/// \returns A 256-bit vector of [16 x i16] containing the products.
4211694static __inline__ __m256i __DEFAULT_FN_ATTRS256
4221695_mm256_mulhi_epu16(__m256i __a, __m256i __b)
4231696{
4241697 return (__m256i)__builtin_ia32_pmulhuw256((__v16hi)__a, (__v16hi)__b);
4251698}
4261699
1700/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1701/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the
1702/// [16 x i16] result.
1703///
1704/// \headerfile <immintrin.h>
1705///
1706/// This intrinsic corresponds to the \c VPMULHW instruction.
1707///
1708/// \param __a
1709/// A 256-bit vector of [16 x i16] containing one of the source operands.
1710/// \param __b
1711/// A 256-bit vector of [16 x i16] containing one of the source operands.
1712/// \returns A 256-bit vector of [16 x i16] containing the products.
4271713static __inline__ __m256i __DEFAULT_FN_ATTRS256
4281714_mm256_mulhi_epi16(__m256i __a, __m256i __b)
4291715{
4301716 return (__m256i)__builtin_ia32_pmulhw256((__v16hi)__a, (__v16hi)__b);
4311717}
4321718
1719/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1720/// [16 x i16], and returns the lower 16 bits of each 32-bit product in the
1721/// [16 x i16] result.
1722///
1723/// \headerfile <immintrin.h>
1724///
1725/// This intrinsic corresponds to the \c VPMULLW instruction.
1726///
1727/// \param __a
1728/// A 256-bit vector of [16 x i16] containing one of the source operands.
1729/// \param __b
1730/// A 256-bit vector of [16 x i16] containing one of the source operands.
1731/// \returns A 256-bit vector of [16 x i16] containing the products.
4331732static __inline__ __m256i __DEFAULT_FN_ATTRS256
4341733_mm256_mullo_epi16(__m256i __a, __m256i __b)
4351734{
4361735 return (__m256i)((__v16hu)__a * (__v16hu)__b);
4371736}
4381737
1738/// Multiplies signed 32-bit integer elements of two 256-bit vectors of
1739/// [8 x i32], and returns the lower 32 bits of each 64-bit product in the
1740/// [8 x i32] result.
1741///
1742/// \headerfile <immintrin.h>
1743///
1744/// This intrinsic corresponds to the \c VPMULLD instruction.
1745///
1746/// \param __a
1747/// A 256-bit vector of [8 x i32] containing one of the source operands.
1748/// \param __b
1749/// A 256-bit vector of [8 x i32] containing one of the source operands.
1750/// \returns A 256-bit vector of [8 x i32] containing the products.
4391751static __inline__ __m256i __DEFAULT_FN_ATTRS256
4401752_mm256_mullo_epi32 (__m256i __a, __m256i __b)
4411753{
4421754 return (__m256i)((__v8su)__a * (__v8su)__b);
4431755}
4441756
1757/// Multiplies unsigned 32-bit integers from even-numered elements of two
1758/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the
1759/// [4 x i64] result.
1760///
1761/// \code{.operation}
1762/// result[63:0] := __a[31:0] * __b[31:0]
1763/// result[127:64] := __a[95:64] * __b[95:64]
1764/// result[191:128] := __a[159:128] * __b[159:128]
1765/// result[255:192] := __a[223:192] * __b[223:192]
1766/// \endcode
1767///
1768/// \headerfile <immintrin.h>
1769///
1770/// This intrinsic corresponds to the \c VPMULUDQ instruction.
1771///
1772/// \param __a
1773/// A 256-bit vector of [8 x i32] containing one of the source operands.
1774/// \param __b
1775/// A 256-bit vector of [8 x i32] containing one of the source operands.
1776/// \returns A 256-bit vector of [4 x i64] containing the products.
4451777static __inline__ __m256i __DEFAULT_FN_ATTRS256
4461778_mm256_mul_epu32(__m256i __a, __m256i __b)
4471779{
4481780 return __builtin_ia32_pmuludq256((__v8si)__a, (__v8si)__b);
4491781}
4501782
1783/// Computes the bitwise OR of the 256-bit integer vectors in \a __a and
1784/// \a __b.
1785///
1786/// \headerfile <immintrin.h>
1787///
1788/// This intrinsic corresponds to the \c VPOR instruction.
1789///
1790/// \param __a
1791/// A 256-bit integer vector.
1792/// \param __b
1793/// A 256-bit integer vector.
1794/// \returns A 256-bit integer vector containing the result.
4511795static __inline__ __m256i __DEFAULT_FN_ATTRS256
4521796_mm256_or_si256(__m256i __a, __m256i __b)
4531797{
4541798 return (__m256i)((__v4du)__a | (__v4du)__b);
4551799}
4561800
1801/// Computes four sum of absolute difference (SAD) operations on sets of eight
1802/// unsigned 8-bit integers from the 256-bit integer vectors \a __a and
1803/// \a __b.
1804///
1805/// One SAD result is computed for each set of eight bytes from \a __a and
1806/// eight bytes from \a __b. The zero-extended SAD value is returned in the
1807/// corresponding 64-bit element of the result.
1808///
1809/// A single SAD operation takes the differences between the corresponding
1810/// bytes of \a __a and \a __b, takes the absolute value of each difference,
1811/// and sums these eight values to form one 16-bit result. This operation
1812/// is repeated four times with successive sets of eight bytes.
1813///
1814/// \code{.operation}
1815/// FOR i := 0 TO 3
1816/// j := i*64
1817/// temp0 := ABS(__a[j+7:j] - __b[j+7:j])
1818/// temp1 := ABS(__a[j+15:j+8] - __b[j+15:j+8])
1819/// temp2 := ABS(__a[j+23:j+16] - __b[j+23:j+16])
1820/// temp3 := ABS(__a[j+31:j+24] - __b[j+31:j+24])
1821/// temp4 := ABS(__a[j+39:j+32] - __b[j+39:j+32])
1822/// temp5 := ABS(__a[j+47:j+40] - __b[j+47:j+40])
1823/// temp6 := ABS(__a[j+55:j+48] - __b[j+55:j+48])
1824/// temp7 := ABS(__a[j+63:j+56] - __b[j+63:j+56])
1825/// result[j+15:j] := temp0 + temp1 + temp2 + temp3 +
1826/// temp4 + temp5 + temp6 + temp7
1827/// result[j+63:j+16] := 0
1828/// ENDFOR
1829/// \endcode
1830///
1831/// \headerfile <immintrin.h>
1832///
1833/// This intrinsic corresponds to the \c VPSADBW instruction.
1834///
1835/// \param __a
1836/// A 256-bit integer vector.
1837/// \param __b
1838/// A 256-bit integer vector.
1839/// \returns A 256-bit integer vector containing the result.
4571840static __inline__ __m256i __DEFAULT_FN_ATTRS256
4581841_mm256_sad_epu8(__m256i __a, __m256i __b)
4591842{
4601843 return __builtin_ia32_psadbw256((__v32qi)__a, (__v32qi)__b);
4611844}
4621845
1846/// Shuffles 8-bit integers in the 256-bit integer vector \a __a according
1847/// to control information in the 256-bit integer vector \a __b, and
1848/// returns the 256-bit result. In effect there are two separate 128-bit
1849/// shuffles in the lower and upper halves.
1850///
1851/// \code{.operation}
1852/// FOR i := 0 TO 31
1853/// j := i*8
1854/// IF __b[j+7] == 1
1855/// result[j+7:j] := 0
1856/// ELSE
1857/// k := __b[j+3:j] * 8
1858/// IF i > 15
1859/// k := k + 128
1860/// FI
1861/// result[j+7:j] := __a[k+7:k]
1862/// FI
1863/// ENDFOR
1864/// \endcode
1865///
1866/// \headerfile <immintrin.h>
1867///
1868/// This intrinsic corresponds to the \c VPSHUFB instruction.
1869///
1870/// \param __a
1871/// A 256-bit integer vector containing source values.
1872/// \param __b
1873/// A 256-bit integer vector containing control information to determine
1874/// what goes into the corresponding byte of the result. If bit 7 of the
1875/// control byte is 1, the result byte is 0; otherwise, bits 3:0 of the
1876/// control byte specify the index (within the same 128-bit half) of \a __a
1877/// to copy to the result byte.
1878/// \returns A 256-bit integer vector containing the result.
4631879static __inline__ __m256i __DEFAULT_FN_ATTRS256
4641880_mm256_shuffle_epi8(__m256i __a, __m256i __b)
4651881{
4661882 return (__m256i)__builtin_ia32_pshufb256((__v32qi)__a, (__v32qi)__b);
4671883}
4681884
1885/// Shuffles 32-bit integers from the 256-bit vector of [8 x i32] in \a a
1886/// according to control information in the integer literal \a imm, and
1887/// returns the 256-bit result. In effect there are two parallel 128-bit
1888/// shuffles in the lower and upper halves.
1889///
1890/// \code{.operation}
1891/// FOR i := 0 to 3
1892/// j := i*32
1893/// k := (imm >> i*2)[1:0] * 32
1894/// result[j+31:j] := a[k+31:k]
1895/// result[128+j+31:128+j] := a[128+k+31:128+k]
1896/// ENDFOR
1897/// \endcode
1898///
1899/// \headerfile <immintrin.h>
1900///
1901/// \code
1902/// __m256i _mm256_shuffle_epi32(__m256i a, const int imm);
1903/// \endcode
1904///
1905/// This intrinsic corresponds to the \c VPSHUFB instruction.
1906///
1907/// \param a
1908/// A 256-bit vector of [8 x i32] containing source values.
1909/// \param imm
1910/// An immediate 8-bit value specifying which elements to copy from \a a.
1911/// \a imm[1:0] specifies the index in \a a for elements 0 and 4 of the
1912/// result, \a imm[3:2] specifies the index for elements 1 and 5, and so
1913/// forth.
1914/// \returns A 256-bit vector of [8 x i32] containing the result.
4691915#define _mm256_shuffle_epi32(a, imm) \
4701916 ((__m256i)__builtin_ia32_pshufd256((__v8si)(__m256i)(a), (int)(imm)))
4711917
1918/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] in \a a
1919/// according to control information in the integer literal \a imm, and
1920/// returns the 256-bit result. The upper 64 bits of each 128-bit half
1921/// are shuffled in parallel; the lower 64 bits of each 128-bit half are
1922/// copied from \a a unchanged.
1923///
1924/// \code{.operation}
1925/// result[63:0] := a[63:0]
1926/// result[191:128] := a[191:128]
1927/// FOR i := 0 TO 3
1928/// j := i * 16 + 64
1929/// k := (imm >> i*2)[1:0] * 16 + 64
1930/// result[j+15:j] := a[k+15:k]
1931/// result[128+j+15:128+j] := a[128+k+15:128+k]
1932/// ENDFOR
1933/// \endcode
1934///
1935/// \headerfile <immintrin.h>
1936///
1937/// \code
1938/// __m256i _mm256_shufflehi_epi16(__m256i a, const int imm);
1939/// \endcode
1940///
1941/// This intrinsic corresponds to the \c VPSHUFHW instruction.
1942///
1943/// \param a
1944/// A 256-bit vector of [16 x i16] containing source values.
1945/// \param imm
1946/// An immediate 8-bit value specifying which elements to copy from \a a.
1947/// \a imm[1:0] specifies the index in \a a for elements 4 and 8 of the
1948/// result, \a imm[3:2] specifies the index for elements 5 and 9, and so
1949/// forth. Indexes are offset by 4 (so 0 means index 4, and so forth).
1950/// \returns A 256-bit vector of [16 x i16] containing the result.
4721951#define _mm256_shufflehi_epi16(a, imm) \
4731952 ((__m256i)__builtin_ia32_pshufhw256((__v16hi)(__m256i)(a), (int)(imm)))
4741953
1954/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] \a a
1955/// according to control information in the integer literal \a imm, and
1956/// returns the 256-bit [16 x i16] result. The lower 64 bits of each
1957/// 128-bit half are shuffled; the upper 64 bits of each 128-bit half are
1958/// copied from \a a unchanged.
1959///
1960/// \code{.operation}
1961/// result[127:64] := a[127:64]
1962/// result[255:192] := a[255:192]
1963/// FOR i := 0 TO 3
1964/// j := i * 16
1965/// k := (imm >> i*2)[1:0] * 16
1966/// result[j+15:j] := a[k+15:k]
1967/// result[128+j+15:128+j] := a[128+k+15:128+k]
1968/// ENDFOR
1969/// \endcode
1970///
1971/// \headerfile <immintrin.h>
1972///
1973/// \code
1974/// __m256i _mm256_shufflelo_epi16(__m256i a, const int imm);
1975/// \endcode
1976///
1977/// This intrinsic corresponds to the \c VPSHUFLW instruction.
1978///
1979/// \param a
1980/// A 256-bit vector of [16 x i16] to use as a source of data for the
1981/// result.
1982/// \param imm
1983/// An immediate 8-bit value specifying which elements to copy from \a a.
1984/// \a imm[1:0] specifies the index in \a a for elements 0 and 8 of the
1985/// result, \a imm[3:2] specifies the index for elements 1 and 9, and so
1986/// forth.
1987/// \returns A 256-bit vector of [16 x i16] containing the result.
4751988#define _mm256_shufflelo_epi16(a, imm) \
4761989 ((__m256i)__builtin_ia32_pshuflw256((__v16hi)(__m256i)(a), (int)(imm)))
4771990
1991/// Sets each byte of the result to the corresponding byte of the 256-bit
1992/// integer vector in \a __a, the negative of that byte, or zero, depending
1993/// on whether the corresponding byte of the 256-bit integer vector in
1994/// \a __b is greater than zero, less than zero, or equal to zero,
1995/// respectively.
1996///
1997/// \headerfile <immintrin.h>
1998///
1999/// This intrinsic corresponds to the \c VPSIGNB instruction.
2000///
2001/// \param __a
2002/// A 256-bit integer vector.
2003/// \param __b
2004/// A 256-bit integer vector].
2005/// \returns A 256-bit integer vector containing the result.
4782006static __inline__ __m256i __DEFAULT_FN_ATTRS256
4792007_mm256_sign_epi8(__m256i __a, __m256i __b)
4802008{
4812009 return (__m256i)__builtin_ia32_psignb256((__v32qi)__a, (__v32qi)__b);
4822010}
4832011
2012/// Sets each element of the result to the corresponding element of the
2013/// 256-bit vector of [16 x i16] in \a __a, the negative of that element,
2014/// or zero, depending on whether the corresponding element of the 256-bit
2015/// vector of [16 x i16] in \a __b is greater than zero, less than zero, or
2016/// equal to zero, respectively.
2017///
2018/// \headerfile <immintrin.h>
2019///
2020/// This intrinsic corresponds to the \c VPSIGNW instruction.
2021///
2022/// \param __a
2023/// A 256-bit vector of [16 x i16].
2024/// \param __b
2025/// A 256-bit vector of [16 x i16].
2026/// \returns A 256-bit vector of [16 x i16] containing the result.
4842027static __inline__ __m256i __DEFAULT_FN_ATTRS256
4852028_mm256_sign_epi16(__m256i __a, __m256i __b)
4862029{
4872030 return (__m256i)__builtin_ia32_psignw256((__v16hi)__a, (__v16hi)__b);
4882031}
4892032
2033/// Sets each element of the result to the corresponding element of the
2034/// 256-bit vector of [8 x i32] in \a __a, the negative of that element, or
2035/// zero, depending on whether the corresponding element of the 256-bit
2036/// vector of [8 x i32] in \a __b is greater than zero, less than zero, or
2037/// equal to zero, respectively.
2038///
2039/// \headerfile <immintrin.h>
2040///
2041/// This intrinsic corresponds to the \c VPSIGND instruction.
2042///
2043/// \param __a
2044/// A 256-bit vector of [8 x i32].
2045/// \param __b
2046/// A 256-bit vector of [8 x i32].
2047/// \returns A 256-bit vector of [8 x i32] containing the result.
4902048static __inline__ __m256i __DEFAULT_FN_ATTRS256
4912049_mm256_sign_epi32(__m256i __a, __m256i __b)
4922050{
4932051 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
4942052}
4952053
2054/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
2055/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm
2056/// is greater than 15, the returned result is all zeroes.
2057///
2058/// \headerfile <immintrin.h>
2059///
2060/// \code
2061/// __m256i _mm256_slli_si256(__m256i a, const int imm);
2062/// \endcode
2063///
2064/// This intrinsic corresponds to the \c VPSLLDQ instruction.
2065///
2066/// \param a
2067/// A 256-bit integer vector to be shifted.
2068/// \param imm
2069/// An unsigned immediate value specifying the shift count (in bytes).
2070/// \returns A 256-bit integer vector containing the result.
4962071#define _mm256_slli_si256(a, imm) \
4972072 ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
4982073
2074/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
2075/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm
2076/// is greater than 15, the returned result is all zeroes.
2077///
2078/// \headerfile <immintrin.h>
2079///
2080/// \code
2081/// __m256i _mm256_bslli_epi128(__m256i a, const int imm);
2082/// \endcode
2083///
2084/// This intrinsic corresponds to the \c VPSLLDQ instruction.
2085///
2086/// \param a
2087/// A 256-bit integer vector to be shifted.
2088/// \param imm
2089/// An unsigned immediate value specifying the shift count (in bytes).
2090/// \returns A 256-bit integer vector containing the result.
4992091#define _mm256_bslli_epi128(a, imm) \
5002092 ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
5012093
2094/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2095/// left by \a __count bits, shifting in zero bits, and returns the result.
2096/// If \a __count is greater than 15, the returned result is all zeroes.
2097///
2098/// \headerfile <immintrin.h>
2099///
2100/// This intrinsic corresponds to the \c VPSLLW instruction.
2101///
2102/// \param __a
2103/// A 256-bit vector of [16 x i16] to be shifted.
2104/// \param __count
2105/// An unsigned integer value specifying the shift count (in bits).
2106/// \returns A 256-bit vector of [16 x i16] containing the result.
5022107static __inline__ __m256i __DEFAULT_FN_ATTRS256
5032108_mm256_slli_epi16(__m256i __a, int __count)
5042109{
5052110 return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
5062111}
5072112
2113/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2114/// left by the number of bits specified by the lower 64 bits of \a __count,
2115/// shifting in zero bits, and returns the result. If \a __count is greater
2116/// than 15, the returned result is all zeroes.
2117///
2118/// \headerfile <immintrin.h>
2119///
2120/// This intrinsic corresponds to the \c VPSLLW instruction.
2121///
2122/// \param __a
2123/// A 256-bit vector of [16 x i16] to be shifted.
2124/// \param __count
2125/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2126/// shift count (in bits). The upper element is ignored.
2127/// \returns A 256-bit vector of [16 x i16] containing the result.
5082128static __inline__ __m256i __DEFAULT_FN_ATTRS256
5092129_mm256_sll_epi16(__m256i __a, __m128i __count)
5102130{
5112131 return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
5122132}
5132133
2134/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2135/// left by \a __count bits, shifting in zero bits, and returns the result.
2136/// If \a __count is greater than 31, the returned result is all zeroes.
2137///
2138/// \headerfile <immintrin.h>
2139///
2140/// This intrinsic corresponds to the \c VPSLLD instruction.
2141///
2142/// \param __a
2143/// A 256-bit vector of [8 x i32] to be shifted.
2144/// \param __count
2145/// An unsigned integer value specifying the shift count (in bits).
2146/// \returns A 256-bit vector of [8 x i32] containing the result.
5142147static __inline__ __m256i __DEFAULT_FN_ATTRS256
5152148_mm256_slli_epi32(__m256i __a, int __count)
5162149{
5172150 return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
5182151}
5192152
2153/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2154/// left by the number of bits given in the lower 64 bits of \a __count,
2155/// shifting in zero bits, and returns the result. If \a __count is greater
2156/// than 31, the returned result is all zeroes.
2157///
2158/// \headerfile <immintrin.h>
2159///
2160/// This intrinsic corresponds to the \c VPSLLD instruction.
2161///
2162/// \param __a
2163/// A 256-bit vector of [8 x i32] to be shifted.
2164/// \param __count
2165/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2166/// shift count (in bits). The upper element is ignored.
2167/// \returns A 256-bit vector of [8 x i32] containing the result.
5202168static __inline__ __m256i __DEFAULT_FN_ATTRS256
5212169_mm256_sll_epi32(__m256i __a, __m128i __count)
5222170{
5232171 return (__m256i)__builtin_ia32_pslld256((__v8si)__a, (__v4si)__count);
5242172}
5252173
2174/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2175/// left by \a __count bits, shifting in zero bits, and returns the result.
2176/// If \a __count is greater than 63, the returned result is all zeroes.
2177///
2178/// \headerfile <immintrin.h>
2179///
2180/// This intrinsic corresponds to the \c VPSLLQ instruction.
2181///
2182/// \param __a
2183/// A 256-bit vector of [4 x i64] to be shifted.
2184/// \param __count
2185/// An unsigned integer value specifying the shift count (in bits).
2186/// \returns A 256-bit vector of [4 x i64] containing the result.
5262187static __inline__ __m256i __DEFAULT_FN_ATTRS256
5272188_mm256_slli_epi64(__m256i __a, int __count)
5282189{
5292190 return __builtin_ia32_psllqi256((__v4di)__a, __count);
5302191}
5312192
2193/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2194/// left by the number of bits given in the lower 64 bits of \a __count,
2195/// shifting in zero bits, and returns the result. If \a __count is greater
2196/// than 63, the returned result is all zeroes.
2197///
2198/// \headerfile <immintrin.h>
2199///
2200/// This intrinsic corresponds to the \c VPSLLQ instruction.
2201///
2202/// \param __a
2203/// A 256-bit vector of [4 x i64] to be shifted.
2204/// \param __count
2205/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2206/// shift count (in bits). The upper element is ignored.
2207/// \returns A 256-bit vector of [4 x i64] containing the result.
5322208static __inline__ __m256i __DEFAULT_FN_ATTRS256
5332209_mm256_sll_epi64(__m256i __a, __m128i __count)
5342210{
5352211 return __builtin_ia32_psllq256((__v4di)__a, __count);
5362212}
5372213
2214/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2215/// right by \a __count bits, shifting in sign bits, and returns the result.
2216/// If \a __count is greater than 15, each element of the result is either
2217/// 0 or -1 according to the corresponding input sign bit.
2218///
2219/// \headerfile <immintrin.h>
2220///
2221/// This intrinsic corresponds to the \c VPSRAW instruction.
2222///
2223/// \param __a
2224/// A 256-bit vector of [16 x i16] to be shifted.
2225/// \param __count
2226/// An unsigned integer value specifying the shift count (in bits).
2227/// \returns A 256-bit vector of [16 x i16] containing the result.
5382228static __inline__ __m256i __DEFAULT_FN_ATTRS256
5392229_mm256_srai_epi16(__m256i __a, int __count)
5402230{
5412231 return (__m256i)__builtin_ia32_psrawi256((__v16hi)__a, __count);
5422232}
5432233
2234/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2235/// right by the number of bits given in the lower 64 bits of \a __count,
2236/// shifting in sign bits, and returns the result. If \a __count is greater
2237/// than 15, each element of the result is either 0 or -1 according to the
2238/// corresponding input sign bit.
2239///
2240/// \headerfile <immintrin.h>
2241///
2242/// This intrinsic corresponds to the \c VPSRAW instruction.
2243///
2244/// \param __a
2245/// A 256-bit vector of [16 x i16] to be shifted.
2246/// \param __count
2247/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2248/// shift count (in bits). The upper element is ignored.
2249/// \returns A 256-bit vector of [16 x i16] containing the result.
5442250static __inline__ __m256i __DEFAULT_FN_ATTRS256
5452251_mm256_sra_epi16(__m256i __a, __m128i __count)
5462252{
5472253 return (__m256i)__builtin_ia32_psraw256((__v16hi)__a, (__v8hi)__count);
5482254}
5492255
2256/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2257/// right by \a __count bits, shifting in sign bits, and returns the result.
2258/// If \a __count is greater than 31, each element of the result is either
2259/// 0 or -1 according to the corresponding input sign bit.
2260///
2261/// \headerfile <immintrin.h>
2262///
2263/// This intrinsic corresponds to the \c VPSRAD instruction.
2264///
2265/// \param __a
2266/// A 256-bit vector of [8 x i32] to be shifted.
2267/// \param __count
2268/// An unsigned integer value specifying the shift count (in bits).
2269/// \returns A 256-bit vector of [8 x i32] containing the result.
5502270static __inline__ __m256i __DEFAULT_FN_ATTRS256
5512271_mm256_srai_epi32(__m256i __a, int __count)
5522272{
5532273 return (__m256i)__builtin_ia32_psradi256((__v8si)__a, __count);
5542274}
5552275
2276/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2277/// right by the number of bits given in the lower 64 bits of \a __count,
2278/// shifting in sign bits, and returns the result. If \a __count is greater
2279/// than 31, each element of the result is either 0 or -1 according to the
2280/// corresponding input sign bit.
2281///
2282/// \headerfile <immintrin.h>
2283///
2284/// This intrinsic corresponds to the \c VPSRAD instruction.
2285///
2286/// \param __a
2287/// A 256-bit vector of [8 x i32] to be shifted.
2288/// \param __count
2289/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2290/// shift count (in bits). The upper element is ignored.
2291/// \returns A 256-bit vector of [8 x i32] containing the result.
5562292static __inline__ __m256i __DEFAULT_FN_ATTRS256
5572293_mm256_sra_epi32(__m256i __a, __m128i __count)
5582294{
5592295 return (__m256i)__builtin_ia32_psrad256((__v8si)__a, (__v4si)__count);
5602296}
5612297
2298/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by
2299/// \a imm bytes, shifting in zero bytes, and returns the result. If
2300/// \a imm is greater than 15, the returned result is all zeroes.
2301///
2302/// \headerfile <immintrin.h>
2303///
2304/// \code
2305/// __m256i _mm256_srli_si256(__m256i a, const int imm);
2306/// \endcode
2307///
2308/// This intrinsic corresponds to the \c VPSRLDQ instruction.
2309///
2310/// \param a
2311/// A 256-bit integer vector to be shifted.
2312/// \param imm
2313/// An unsigned immediate value specifying the shift count (in bytes).
2314/// \returns A 256-bit integer vector containing the result.
5622315#define _mm256_srli_si256(a, imm) \
5632316 ((__m256i)__builtin_ia32_psrldqi256_byteshift((__m256i)(a), (int)(imm)))
5642317
2318/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by
2319/// \a imm bytes, shifting in zero bytes, and returns the result. If
2320/// \a imm is greater than 15, the returned result is all zeroes.
2321///
2322/// \headerfile <immintrin.h>
2323///
2324/// \code
2325/// __m256i _mm256_bsrli_epi128(__m256i a, const int imm);
2326/// \endcode
2327///
2328/// This intrinsic corresponds to the \c VPSRLDQ instruction.
2329///
2330/// \param a
2331/// A 256-bit integer vector to be shifted.
2332/// \param imm
2333/// An unsigned immediate value specifying the shift count (in bytes).
2334/// \returns A 256-bit integer vector containing the result.
5652335#define _mm256_bsrli_epi128(a, imm) \
5662336 ((__m256i)__builtin_ia32_psrldqi256_byteshift((__m256i)(a), (int)(imm)))
5672337
2338/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2339/// right by \a __count bits, shifting in zero bits, and returns the result.
2340/// If \a __count is greater than 15, the returned result is all zeroes.
2341///
2342/// \headerfile <immintrin.h>
2343///
2344/// This intrinsic corresponds to the \c VPSRLW instruction.
2345///
2346/// \param __a
2347/// A 256-bit vector of [16 x i16] to be shifted.
2348/// \param __count
2349/// An unsigned integer value specifying the shift count (in bits).
2350/// \returns A 256-bit vector of [16 x i16] containing the result.
5682351static __inline__ __m256i __DEFAULT_FN_ATTRS256
5692352_mm256_srli_epi16(__m256i __a, int __count)
5702353{
5712354 return (__m256i)__builtin_ia32_psrlwi256((__v16hi)__a, __count);
5722355}
5732356
2357/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2358/// right by the number of bits given in the lower 64 bits of \a __count,
2359/// shifting in zero bits, and returns the result. If \a __count is greater
2360/// than 15, the returned result is all zeroes.
2361///
2362/// \headerfile <immintrin.h>
2363///
2364/// This intrinsic corresponds to the \c VPSRLW instruction.
2365///
2366/// \param __a
2367/// A 256-bit vector of [16 x i16] to be shifted.
2368/// \param __count
2369/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2370/// shift count (in bits). The upper element is ignored.
2371/// \returns A 256-bit vector of [16 x i16] containing the result.
5742372static __inline__ __m256i __DEFAULT_FN_ATTRS256
5752373_mm256_srl_epi16(__m256i __a, __m128i __count)
5762374{
5772375 return (__m256i)__builtin_ia32_psrlw256((__v16hi)__a, (__v8hi)__count);
5782376}
5792377
2378/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2379/// right by \a __count bits, shifting in zero bits, and returns the result.
2380/// If \a __count is greater than 31, the returned result is all zeroes.
2381///
2382/// \headerfile <immintrin.h>
2383///
2384/// This intrinsic corresponds to the \c VPSRLD instruction.
2385///
2386/// \param __a
2387/// A 256-bit vector of [8 x i32] to be shifted.
2388/// \param __count
2389/// An unsigned integer value specifying the shift count (in bits).
2390/// \returns A 256-bit vector of [8 x i32] containing the result.
5802391static __inline__ __m256i __DEFAULT_FN_ATTRS256
5812392_mm256_srli_epi32(__m256i __a, int __count)
5822393{
5832394 return (__m256i)__builtin_ia32_psrldi256((__v8si)__a, __count);
5842395}
5852396
2397/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2398/// right by the number of bits given in the lower 64 bits of \a __count,
2399/// shifting in zero bits, and returns the result. If \a __count is greater
2400/// than 31, the returned result is all zeroes.
2401///
2402/// \headerfile <immintrin.h>
2403///
2404/// This intrinsic corresponds to the \c VPSRLD instruction.
2405///
2406/// \param __a
2407/// A 256-bit vector of [8 x i32] to be shifted.
2408/// \param __count
2409/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2410/// shift count (in bits). The upper element is ignored.
2411/// \returns A 256-bit vector of [8 x i32] containing the result.
5862412static __inline__ __m256i __DEFAULT_FN_ATTRS256
5872413_mm256_srl_epi32(__m256i __a, __m128i __count)
5882414{
5892415 return (__m256i)__builtin_ia32_psrld256((__v8si)__a, (__v4si)__count);
5902416}
5912417
2418/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2419/// right by \a __count bits, shifting in zero bits, and returns the result.
2420/// If \a __count is greater than 63, the returned result is all zeroes.
2421///
2422/// \headerfile <immintrin.h>
2423///
2424/// This intrinsic corresponds to the \c VPSRLQ instruction.
2425///
2426/// \param __a
2427/// A 256-bit vector of [4 x i64] to be shifted.
2428/// \param __count
2429/// An unsigned integer value specifying the shift count (in bits).
2430/// \returns A 256-bit vector of [4 x i64] containing the result.
5922431static __inline__ __m256i __DEFAULT_FN_ATTRS256
5932432_mm256_srli_epi64(__m256i __a, int __count)
5942433{
5952434 return __builtin_ia32_psrlqi256((__v4di)__a, __count);
5962435}
5972436
2437/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2438/// right by the number of bits given in the lower 64 bits of \a __count,
2439/// shifting in zero bits, and returns the result. If \a __count is greater
2440/// than 63, the returned result is all zeroes.
2441///
2442/// \headerfile <immintrin.h>
2443///
2444/// This intrinsic corresponds to the \c VPSRLQ instruction.
2445///
2446/// \param __a
2447/// A 256-bit vector of [4 x i64] to be shifted.
2448/// \param __count
2449/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2450/// shift count (in bits). The upper element is ignored.
2451/// \returns A 256-bit vector of [4 x i64] containing the result.
5982452static __inline__ __m256i __DEFAULT_FN_ATTRS256
5992453_mm256_srl_epi64(__m256i __a, __m128i __count)
6002454{
6012455 return __builtin_ia32_psrlq256((__v4di)__a, __count);
6022456}
6032457
2458/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2459/// vectors. Returns the lower 8 bits of each difference in the
2460/// corresponding byte of the 256-bit integer vector result (overflow is
2461/// ignored).
2462///
2463/// \code{.operation}
2464/// FOR i := 0 TO 31
2465/// j := i*8
2466/// result[j+7:j] := __a[j+7:j] - __b[j+7:j]
2467/// ENDFOR
2468/// \endcode
2469///
2470/// \headerfile <immintrin.h>
2471///
2472/// This intrinsic corresponds to the \c VPSUBB instruction.
2473///
2474/// \param __a
2475/// A 256-bit integer vector containing the minuends.
2476/// \param __b
2477/// A 256-bit integer vector containing the subtrahends.
2478/// \returns A 256-bit integer vector containing the differences.
6042479static __inline__ __m256i __DEFAULT_FN_ATTRS256
6052480_mm256_sub_epi8(__m256i __a, __m256i __b)
6062481{
6072482 return (__m256i)((__v32qu)__a - (__v32qu)__b);
6082483}
6092484
2485/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2486/// vectors of [16 x i16]. Returns the lower 16 bits of each difference in
2487/// the corresponding element of the [16 x i16] result (overflow is
2488/// ignored).
2489///
2490/// \code{.operation}
2491/// FOR i := 0 TO 15
2492/// j := i*16
2493/// result[j+15:j] := __a[j+15:j] - __b[j+15:j]
2494/// ENDFOR
2495/// \endcode
2496///
2497/// \headerfile <immintrin.h>
2498///
2499/// This intrinsic corresponds to the \c VPSUBW instruction.
2500///
2501/// \param __a
2502/// A 256-bit vector of [16 x i16] containing the minuends.
2503/// \param __b
2504/// A 256-bit vector of [16 x i16] containing the subtrahends.
2505/// \returns A 256-bit vector of [16 x i16] containing the differences.
6102506static __inline__ __m256i __DEFAULT_FN_ATTRS256
6112507_mm256_sub_epi16(__m256i __a, __m256i __b)
6122508{
6132509 return (__m256i)((__v16hu)__a - (__v16hu)__b);
6142510}
6152511
2512/// Subtracts 32-bit integers from corresponding elements of two 256-bit
2513/// vectors of [8 x i32]. Returns the lower 32 bits of each difference in
2514/// the corresponding element of the [8 x i32] result (overflow is ignored).
2515///
2516/// \code{.operation}
2517/// FOR i := 0 TO 7
2518/// j := i*32
2519/// result[j+31:j] := __a[j+31:j] - __b[j+31:j]
2520/// ENDFOR
2521/// \endcode
2522///
2523/// \headerfile <immintrin.h>
2524///
2525/// This intrinsic corresponds to the \c VPSUBD instruction.
2526///
2527/// \param __a
2528/// A 256-bit vector of [8 x i32] containing the minuends.
2529/// \param __b
2530/// A 256-bit vector of [8 x i32] containing the subtrahends.
2531/// \returns A 256-bit vector of [8 x i32] containing the differences.
6162532static __inline__ __m256i __DEFAULT_FN_ATTRS256
6172533_mm256_sub_epi32(__m256i __a, __m256i __b)
6182534{
6192535 return (__m256i)((__v8su)__a - (__v8su)__b);
6202536}
6212537
2538/// Subtracts 64-bit integers from corresponding elements of two 256-bit
2539/// vectors of [4 x i64]. Returns the lower 64 bits of each difference in
2540/// the corresponding element of the [4 x i64] result (overflow is ignored).
2541///
2542/// \code{.operation}
2543/// FOR i := 0 TO 3
2544/// j := i*64
2545/// result[j+63:j] := __a[j+63:j] - __b[j+63:j]
2546/// ENDFOR
2547/// \endcode
2548///
2549/// \headerfile <immintrin.h>
2550///
2551/// This intrinsic corresponds to the \c VPSUBQ instruction.
2552///
2553/// \param __a
2554/// A 256-bit vector of [4 x i64] containing the minuends.
2555/// \param __b
2556/// A 256-bit vector of [4 x i64] containing the subtrahends.
2557/// \returns A 256-bit vector of [4 x i64] containing the differences.
6222558static __inline__ __m256i __DEFAULT_FN_ATTRS256
6232559_mm256_sub_epi64(__m256i __a, __m256i __b)
6242560{
6252561 return (__m256i)((__v4du)__a - (__v4du)__b);
6262562}
6272563
2564/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2565/// vectors using signed saturation, and returns each differences in the
2566/// corresponding byte of the 256-bit integer vector result.
2567///
2568/// \code{.operation}
2569/// FOR i := 0 TO 31
2570/// j := i*8
2571/// result[j+7:j] := SATURATE8(__a[j+7:j] - __b[j+7:j])
2572/// ENDFOR
2573/// \endcode
2574///
2575/// \headerfile <immintrin.h>
2576///
2577/// This intrinsic corresponds to the \c VPSUBSB instruction.
2578///
2579/// \param __a
2580/// A 256-bit integer vector containing the minuends.
2581/// \param __b
2582/// A 256-bit integer vector containing the subtrahends.
2583/// \returns A 256-bit integer vector containing the differences.
6282584static __inline__ __m256i __DEFAULT_FN_ATTRS256
6292585_mm256_subs_epi8(__m256i __a, __m256i __b)
6302586{
6312587 return (__m256i)__builtin_elementwise_sub_sat((__v32qs)__a, (__v32qs)__b);
6322588}
6332589
2590/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2591/// vectors of [16 x i16] using signed saturation, and returns each
2592/// difference in the corresponding element of the [16 x i16] result.
2593///
2594/// \code{.operation}
2595/// FOR i := 0 TO 15
2596/// j := i*16
2597/// result[j+7:j] := SATURATE16(__a[j+7:j] - __b[j+7:j])
2598/// ENDFOR
2599/// \endcode
2600///
2601/// \headerfile <immintrin.h>
2602///
2603/// This intrinsic corresponds to the \c VPSUBSW instruction.
2604///
2605/// \param __a
2606/// A 256-bit vector of [16 x i16] containing the minuends.
2607/// \param __b
2608/// A 256-bit vector of [16 x i16] containing the subtrahends.
2609/// \returns A 256-bit vector of [16 x i16] containing the differences.
6342610static __inline__ __m256i __DEFAULT_FN_ATTRS256
6352611_mm256_subs_epi16(__m256i __a, __m256i __b)
6362612{
6372613 return (__m256i)__builtin_elementwise_sub_sat((__v16hi)__a, (__v16hi)__b);
6382614}
6392615
2616/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2617/// vectors using unsigned saturation, and returns each difference in the
2618/// corresponding byte of the 256-bit integer vector result. For each byte,
2619/// computes <c> result = __a - __b </c>.
2620///
2621/// \code{.operation}
2622/// FOR i := 0 TO 31
2623/// j := i*8
2624/// result[j+7:j] := SATURATE8U(__a[j+7:j] - __b[j+7:j])
2625/// ENDFOR
2626/// \endcode
2627///
2628/// \headerfile <immintrin.h>
2629///
2630/// This intrinsic corresponds to the \c VPSUBUSB instruction.
2631///
2632/// \param __a
2633/// A 256-bit integer vector containing the minuends.
2634/// \param __b
2635/// A 256-bit integer vector containing the subtrahends.
2636/// \returns A 256-bit integer vector containing the differences.
6402637static __inline__ __m256i __DEFAULT_FN_ATTRS256
6412638_mm256_subs_epu8(__m256i __a, __m256i __b)
6422639{
6432640 return (__m256i)__builtin_elementwise_sub_sat((__v32qu)__a, (__v32qu)__b);
6442641}
6452642
2643/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2644/// vectors of [16 x i16] using unsigned saturation, and returns each
2645/// difference in the corresponding element of the [16 x i16] result.
2646///
2647/// \code{.operation}
2648/// FOR i := 0 TO 15
2649/// j := i*16
2650/// result[j+15:j] := SATURATE16U(__a[j+15:j] - __b[j+15:j])
2651/// ENDFOR
2652/// \endcode
2653///
2654/// \headerfile <immintrin.h>
2655///
2656/// This intrinsic corresponds to the \c VPSUBUSW instruction.
2657///
2658/// \param __a
2659/// A 256-bit vector of [16 x i16] containing the minuends.
2660/// \param __b
2661/// A 256-bit vector of [16 x i16] containing the subtrahends.
2662/// \returns A 256-bit vector of [16 x i16] containing the differences.
6462663static __inline__ __m256i __DEFAULT_FN_ATTRS256
6472664_mm256_subs_epu16(__m256i __a, __m256i __b)
6482665{
6492666 return (__m256i)__builtin_elementwise_sub_sat((__v16hu)__a, (__v16hu)__b);
6502667}
6512668
2669/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer
2670/// vectors in \a __a and \a __b to form the 256-bit result. Specifically,
2671/// uses the upper 64 bits of each 128-bit half of \a __a and \a __b as
2672/// input; other bits in these parameters are ignored.
2673///
2674/// \code{.operation}
2675/// result[7:0] := __a[71:64]
2676/// result[15:8] := __b[71:64]
2677/// result[23:16] := __a[79:72]
2678/// result[31:24] := __b[79:72]
2679/// . . .
2680/// result[127:120] := __b[127:120]
2681/// result[135:128] := __a[199:192]
2682/// . . .
2683/// result[255:248] := __b[255:248]
2684/// \endcode
2685///
2686/// \headerfile <immintrin.h>
2687///
2688/// This intrinsic corresponds to the \c VPUNPCKHBW instruction.
2689///
2690/// \param __a
2691/// A 256-bit integer vector used as the source for the even-numbered bytes
2692/// of the result.
2693/// \param __b
2694/// A 256-bit integer vector used as the source for the odd-numbered bytes
2695/// of the result.
2696/// \returns A 256-bit integer vector containing the result.
6522697static __inline__ __m256i __DEFAULT_FN_ATTRS256
6532698_mm256_unpackhi_epi8(__m256i __a, __m256i __b)
6542699{
6552700 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 8, 32+8, 9, 32+9, 10, 32+10, 11, 32+11, 12, 32+12, 13, 32+13, 14, 32+14, 15, 32+15, 24, 32+24, 25, 32+25, 26, 32+26, 27, 32+27, 28, 32+28, 29, 32+29, 30, 32+30, 31, 32+31);
6562701}
6572702
2703/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors
2704/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit
2705/// vector of [16 x i16]. Specifically, uses the upper 64 bits of each
2706/// 128-bit half of \a __a and \a __b as input; other bits in these
2707/// parameters are ignored.
2708///
2709/// \code{.operation}
2710/// result[15:0] := __a[79:64]
2711/// result[31:16] := __b[79:64]
2712/// result[47:32] := __a[95:80]
2713/// result[63:48] := __b[95:80]
2714/// . . .
2715/// result[127:112] := __b[127:112]
2716/// result[143:128] := __a[211:196]
2717/// . . .
2718/// result[255:240] := __b[255:240]
2719/// \endcode
2720///
2721/// \headerfile <immintrin.h>
2722///
2723/// This intrinsic corresponds to the \c VPUNPCKHWD instruction.
2724///
2725/// \param __a
2726/// A 256-bit vector of [16 x i16] used as the source for the even-numbered
2727/// elements of the result.
2728/// \param __b
2729/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered
2730/// elements of the result.
2731/// \returns A 256-bit vector of [16 x i16] containing the result.
6582732static __inline__ __m256i __DEFAULT_FN_ATTRS256
6592733_mm256_unpackhi_epi16(__m256i __a, __m256i __b)
6602734{
6612735 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);
6622736}
6632737
2738/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors
2739/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector
2740/// of [8 x i32]. Specifically, uses the upper 64 bits of each 128-bit half
2741/// of \a __a and \a __b as input; other bits in these parameters are
2742/// ignored.
2743///
2744/// \code{.operation}
2745/// result[31:0] := __a[95:64]
2746/// result[63:32] := __b[95:64]
2747/// result[95:64] := __a[127:96]
2748/// result[127:96] := __b[127:96]
2749/// result[159:128] := __a[223:192]
2750/// result[191:160] := __b[223:192]
2751/// result[223:192] := __a[255:224]
2752/// result[255:224] := __b[255:224]
2753/// \endcode
2754///
2755/// \headerfile <immintrin.h>
2756///
2757/// This intrinsic corresponds to the \c VPUNPCKHDQ instruction.
2758///
2759/// \param __a
2760/// A 256-bit vector of [8 x i32] used as the source for the even-numbered
2761/// elements of the result.
2762/// \param __b
2763/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered
2764/// elements of the result.
2765/// \returns A 256-bit vector of [8 x i32] containing the result.
6642766static __inline__ __m256i __DEFAULT_FN_ATTRS256
6652767_mm256_unpackhi_epi32(__m256i __a, __m256i __b)
6662768{
6672769 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 2, 8+2, 3, 8+3, 6, 8+6, 7, 8+7);
6682770}
6692771
2772/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors
2773/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector
2774/// of [4 x i64]. Specifically, uses the upper 64 bits of each 128-bit half
2775/// of \a __a and \a __b as input; other bits in these parameters are
2776/// ignored.
2777///
2778/// \code{.operation}
2779/// result[63:0] := __a[127:64]
2780/// result[127:64] := __b[127:64]
2781/// result[191:128] := __a[255:192]
2782/// result[255:192] := __b[255:192]
2783/// \endcode
2784///
2785/// \headerfile <immintrin.h>
2786///
2787/// This intrinsic corresponds to the \c VPUNPCKHQDQ instruction.
2788///
2789/// \param __a
2790/// A 256-bit vector of [4 x i64] used as the source for the even-numbered
2791/// elements of the result.
2792/// \param __b
2793/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered
2794/// elements of the result.
2795/// \returns A 256-bit vector of [4 x i64] containing the result.
6702796static __inline__ __m256i __DEFAULT_FN_ATTRS256
6712797_mm256_unpackhi_epi64(__m256i __a, __m256i __b)
6722798{
6732799 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 1, 4+1, 3, 4+3);
6742800}
6752801
2802/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer
2803/// vectors in \a __a and \a __b to form the 256-bit result. Specifically,
2804/// uses the lower 64 bits of each 128-bit half of \a __a and \a __b as
2805/// input; other bits in these parameters are ignored.
2806///
2807/// \code{.operation}
2808/// result[7:0] := __a[7:0]
2809/// result[15:8] := __b[7:0]
2810/// result[23:16] := __a[15:8]
2811/// result[31:24] := __b[15:8]
2812/// . . .
2813/// result[127:120] := __b[63:56]
2814/// result[135:128] := __a[135:128]
2815/// . . .
2816/// result[255:248] := __b[191:184]
2817/// \endcode
2818///
2819/// \headerfile <immintrin.h>
2820///
2821/// This intrinsic corresponds to the \c VPUNPCKLBW instruction.
2822///
2823/// \param __a
2824/// A 256-bit integer vector used as the source for the even-numbered bytes
2825/// of the result.
2826/// \param __b
2827/// A 256-bit integer vector used as the source for the odd-numbered bytes
2828/// of the result.
2829/// \returns A 256-bit integer vector containing the result.
6762830static __inline__ __m256i __DEFAULT_FN_ATTRS256
6772831_mm256_unpacklo_epi8(__m256i __a, __m256i __b)
6782832{
6792833 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 0, 32+0, 1, 32+1, 2, 32+2, 3, 32+3, 4, 32+4, 5, 32+5, 6, 32+6, 7, 32+7, 16, 32+16, 17, 32+17, 18, 32+18, 19, 32+19, 20, 32+20, 21, 32+21, 22, 32+22, 23, 32+23);
6802834}
6812835
2836/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors
2837/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit
2838/// vector of [16 x i16]. Specifically, uses the lower 64 bits of each
2839/// 128-bit half of \a __a and \a __b as input; other bits in these
2840/// parameters are ignored.
2841///
2842/// \code{.operation}
2843/// result[15:0] := __a[15:0]
2844/// result[31:16] := __b[15:0]
2845/// result[47:32] := __a[31:16]
2846/// result[63:48] := __b[31:16]
2847/// . . .
2848/// result[127:112] := __b[63:48]
2849/// result[143:128] := __a[143:128]
2850/// . . .
2851/// result[255:239] := __b[191:176]
2852/// \endcode
2853///
2854/// \headerfile <immintrin.h>
2855///
2856/// This intrinsic corresponds to the \c VPUNPCKLWD instruction.
2857///
2858/// \param __a
2859/// A 256-bit vector of [16 x i16] used as the source for the even-numbered
2860/// elements of the result.
2861/// \param __b
2862/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered
2863/// elements of the result.
2864/// \returns A 256-bit vector of [16 x i16] containing the result.
6822865static __inline__ __m256i __DEFAULT_FN_ATTRS256
6832866_mm256_unpacklo_epi16(__m256i __a, __m256i __b)
6842867{
6852868 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11);
6862869}
6872870
2871/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors
2872/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector
2873/// of [8 x i32]. Specifically, uses the lower 64 bits of each 128-bit half
2874/// of \a __a and \a __b as input; other bits in these parameters are
2875/// ignored.
2876///
2877/// \code{.operation}
2878/// result[31:0] := __a[31:0]
2879/// result[63:32] := __b[31:0]
2880/// result[95:64] := __a[63:32]
2881/// result[127:96] := __b[63:32]
2882/// result[159:128] := __a[159:128]
2883/// result[191:160] := __b[159:128]
2884/// result[223:192] := __a[191:160]
2885/// result[255:224] := __b[191:190]
2886/// \endcode
2887///
2888/// \headerfile <immintrin.h>
2889///
2890/// This intrinsic corresponds to the \c VPUNPCKLDQ instruction.
2891///
2892/// \param __a
2893/// A 256-bit vector of [8 x i32] used as the source for the even-numbered
2894/// elements of the result.
2895/// \param __b
2896/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered
2897/// elements of the result.
2898/// \returns A 256-bit vector of [8 x i32] containing the result.
6882899static __inline__ __m256i __DEFAULT_FN_ATTRS256
6892900_mm256_unpacklo_epi32(__m256i __a, __m256i __b)
6902901{
6912902 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 0, 8+0, 1, 8+1, 4, 8+4, 5, 8+5);
6922903}
6932904
2905/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors
2906/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector
2907/// of [4 x i64]. Specifically, uses the lower 64 bits of each 128-bit half
2908/// of \a __a and \a __b as input; other bits in these parameters are
2909/// ignored.
2910///
2911/// \code{.operation}
2912/// result[63:0] := __a[63:0]
2913/// result[127:64] := __b[63:0]
2914/// result[191:128] := __a[191:128]
2915/// result[255:192] := __b[191:128]
2916/// \endcode
2917///
2918/// \headerfile <immintrin.h>
2919///
2920/// This intrinsic corresponds to the \c VPUNPCKLQDQ instruction.
2921///
2922/// \param __a
2923/// A 256-bit vector of [4 x i64] used as the source for the even-numbered
2924/// elements of the result.
2925/// \param __b
2926/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered
2927/// elements of the result.
2928/// \returns A 256-bit vector of [4 x i64] containing the result.
6942929static __inline__ __m256i __DEFAULT_FN_ATTRS256
6952930_mm256_unpacklo_epi64(__m256i __a, __m256i __b)
6962931{
6972932 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 0, 4+0, 2, 4+2);
6982933}
6992934
2935/// Computes the bitwise XOR of the 256-bit integer vectors in \a __a and
2936/// \a __b.
2937///
2938/// \headerfile <immintrin.h>
2939///
2940/// This intrinsic corresponds to the \c VPXOR instruction.
2941///
2942/// \param __a
2943/// A 256-bit integer vector.
2944/// \param __b
2945/// A 256-bit integer vector.
2946/// \returns A 256-bit integer vector containing the result.
7002947static __inline__ __m256i __DEFAULT_FN_ATTRS256
7012948_mm256_xor_si256(__m256i __a, __m256i __b)
7022949{
7032950 return (__m256i)((__v4du)__a ^ (__v4du)__b);
7042951}
7052952
2953/// Loads the 256-bit integer vector from memory \a __V using a non-temporal
2954/// memory hint and returns the vector. \a __V must be aligned on a 32-byte
2955/// boundary.
2956///
2957/// \headerfile <immintrin.h>
2958///
2959/// This intrinsic corresponds to the \c VMOVNTDQA instruction.
2960///
2961/// \param __V
2962/// A pointer to the 32-byte aligned memory containing the vector to load.
2963/// \returns A 256-bit integer vector loaded from memory.
7062964static __inline__ __m256i __DEFAULT_FN_ATTRS256
7072965_mm256_stream_load_si256(__m256i const *__V)
7082966{
......@@ -710,30 +2968,84 @@ _mm256_stream_load_si256(__m256i const *__V)
7102968 return (__m256i)__builtin_nontemporal_load((const __v4di_aligned *)__V);
7112969}
7122970
2971/// Broadcasts the 32-bit floating-point value from the low element of the
2972/// 128-bit vector of [4 x float] in \a __X to all elements of the result's
2973/// 128-bit vector of [4 x float].
2974///
2975/// \headerfile <immintrin.h>
2976///
2977/// This intrinsic corresponds to the \c VBROADCASTSS instruction.
2978///
2979/// \param __X
2980/// A 128-bit vector of [4 x float] whose low element will be broadcast.
2981/// \returns A 128-bit vector of [4 x float] containing the result.
7132982static __inline__ __m128 __DEFAULT_FN_ATTRS128
7142983_mm_broadcastss_ps(__m128 __X)
7152984{
7162985 return (__m128)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0);
7172986}
7182987
2988/// Broadcasts the 64-bit floating-point value from the low element of the
2989/// 128-bit vector of [2 x double] in \a __a to both elements of the
2990/// result's 128-bit vector of [2 x double].
2991///
2992/// \headerfile <immintrin.h>
2993///
2994/// This intrinsic corresponds to the \c MOVDDUP instruction.
2995///
2996/// \param __a
2997/// A 128-bit vector of [2 x double] whose low element will be broadcast.
2998/// \returns A 128-bit vector of [2 x double] containing the result.
7192999static __inline__ __m128d __DEFAULT_FN_ATTRS128
7203000_mm_broadcastsd_pd(__m128d __a)
7213001{
7223002 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
7233003}
7243004
3005/// Broadcasts the 32-bit floating-point value from the low element of the
3006/// 128-bit vector of [4 x float] in \a __X to all elements of the
3007/// result's 256-bit vector of [8 x float].
3008///
3009/// \headerfile <immintrin.h>
3010///
3011/// This intrinsic corresponds to the \c VBROADCASTSS instruction.
3012///
3013/// \param __X
3014/// A 128-bit vector of [4 x float] whose low element will be broadcast.
3015/// \returns A 256-bit vector of [8 x float] containing the result.
7253016static __inline__ __m256 __DEFAULT_FN_ATTRS256
7263017_mm256_broadcastss_ps(__m128 __X)
7273018{
7283019 return (__m256)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0, 0, 0, 0, 0);
7293020}
7303021
3022/// Broadcasts the 64-bit floating-point value from the low element of the
3023/// 128-bit vector of [2 x double] in \a __X to all elements of the
3024/// result's 256-bit vector of [4 x double].
3025///
3026/// \headerfile <immintrin.h>
3027///
3028/// This intrinsic corresponds to the \c VBROADCASTSD instruction.
3029///
3030/// \param __X
3031/// A 128-bit vector of [2 x double] whose low element will be broadcast.
3032/// \returns A 256-bit vector of [4 x double] containing the result.
7313033static __inline__ __m256d __DEFAULT_FN_ATTRS256
7323034_mm256_broadcastsd_pd(__m128d __X)
7333035{
7343036 return (__m256d)__builtin_shufflevector((__v2df)__X, (__v2df)__X, 0, 0, 0, 0);
7353037}
7363038
3039/// Broadcasts the 128-bit integer data from \a __X to both the lower and
3040/// upper halves of the 256-bit result.
3041///
3042/// \headerfile <immintrin.h>
3043///
3044/// This intrinsic corresponds to the \c VBROADCASTI128 instruction.
3045///
3046/// \param __X
3047/// A 128-bit integer vector to be broadcast.
3048/// \returns A 256-bit integer vector containing the result.
7373049static __inline__ __m256i __DEFAULT_FN_ATTRS256
7383050_mm256_broadcastsi128_si256(__m128i __X)
7393051{
......@@ -742,295 +3054,1688 @@ _mm256_broadcastsi128_si256(__m128i __X)
7423054
7433055#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
7443056
3057/// Merges 32-bit integer elements from either of the two 128-bit vectors of
3058/// [4 x i32] in \a V1 or \a V2 to the result's 128-bit vector of [4 x i32],
3059/// as specified by the immediate integer operand \a M.
3060///
3061/// \code{.operation}
3062/// FOR i := 0 TO 3
3063/// j := i*32
3064/// IF M[i] == 0
3065/// result[31+j:j] := V1[31+j:j]
3066/// ELSE
3067/// result[31+j:j] := V2[32+j:j]
3068/// FI
3069/// ENDFOR
3070/// \endcode
3071///
3072/// \headerfile <immintrin.h>
3073///
3074/// \code
3075/// __m128i _mm_blend_epi32(__m128i V1, __m128i V2, const int M);
3076/// \endcode
3077///
3078/// This intrinsic corresponds to the \c VPBLENDDD instruction.
3079///
3080/// \param V1
3081/// A 128-bit vector of [4 x i32] containing source values.
3082/// \param V2
3083/// A 128-bit vector of [4 x i32] containing source values.
3084/// \param M
3085/// An immediate 8-bit integer operand, with bits [3:0] specifying the
3086/// source for each element of the result. The position of the mask bit
3087/// corresponds to the index of a copied value. When a mask bit is 0, the
3088/// element is copied from \a V1; otherwise, it is copied from \a V2.
3089/// \returns A 128-bit vector of [4 x i32] containing the result.
7453090#define _mm_blend_epi32(V1, V2, M) \
7463091 ((__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
7473092 (__v4si)(__m128i)(V2), (int)(M)))
7483093
3094/// Merges 32-bit integer elements from either of the two 256-bit vectors of
3095/// [8 x i32] in \a V1 or \a V2 to return a 256-bit vector of [8 x i32],
3096/// as specified by the immediate integer operand \a M.
3097///
3098/// \code{.operation}
3099/// FOR i := 0 TO 7
3100/// j := i*32
3101/// IF M[i] == 0
3102/// result[31+j:j] := V1[31+j:j]
3103/// ELSE
3104/// result[31+j:j] := V2[32+j:j]
3105/// FI
3106/// ENDFOR
3107/// \endcode
3108///
3109/// \headerfile <immintrin.h>
3110///
3111/// \code
3112/// __m256i _mm256_blend_epi32(__m256i V1, __m256i V2, const int M);
3113/// \endcode
3114///
3115/// This intrinsic corresponds to the \c VPBLENDDD instruction.
3116///
3117/// \param V1
3118/// A 256-bit vector of [8 x i32] containing source values.
3119/// \param V2
3120/// A 256-bit vector of [8 x i32] containing source values.
3121/// \param M
3122/// An immediate 8-bit integer operand, with bits [7:0] specifying the
3123/// source for each element of the result. The position of the mask bit
3124/// corresponds to the index of a copied value. When a mask bit is 0, the
3125/// element is copied from \a V1; otherwise, it is is copied from \a V2.
3126/// \returns A 256-bit vector of [8 x i32] containing the result.
7493127#define _mm256_blend_epi32(V1, V2, M) \
7503128 ((__m256i)__builtin_ia32_pblendd256((__v8si)(__m256i)(V1), \
7513129 (__v8si)(__m256i)(V2), (int)(M)))
7523130
3131/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all
3132/// bytes of the 256-bit result.
3133///
3134/// \headerfile <immintrin.h>
3135///
3136/// This intrinsic corresponds to the \c VPBROADCASTB instruction.
3137///
3138/// \param __X
3139/// A 128-bit integer vector whose low byte will be broadcast.
3140/// \returns A 256-bit integer vector containing the result.
7533141static __inline__ __m256i __DEFAULT_FN_ATTRS256
7543142_mm256_broadcastb_epi8(__m128i __X)
7553143{
7563144 return (__m256i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
7573145}
7583146
3147/// Broadcasts the low element from the 128-bit vector of [8 x i16] in \a __X
3148/// to all elements of the result's 256-bit vector of [16 x i16].
3149///
3150/// \headerfile <immintrin.h>
3151///
3152/// This intrinsic corresponds to the \c VPBROADCASTW instruction.
3153///
3154/// \param __X
3155/// A 128-bit vector of [8 x i16] whose low element will be broadcast.
3156/// \returns A 256-bit vector of [16 x i16] containing the result.
7593157static __inline__ __m256i __DEFAULT_FN_ATTRS256
7603158_mm256_broadcastw_epi16(__m128i __X)
7613159{
7623160 return (__m256i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
7633161}
7643162
3163/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X
3164/// to all elements of the result's 256-bit vector of [8 x i32].
3165///
3166/// \headerfile <immintrin.h>
3167///
3168/// This intrinsic corresponds to the \c VPBROADCASTD instruction.
3169///
3170/// \param __X
3171/// A 128-bit vector of [4 x i32] whose low element will be broadcast.
3172/// \returns A 256-bit vector of [8 x i32] containing the result.
7653173static __inline__ __m256i __DEFAULT_FN_ATTRS256
7663174_mm256_broadcastd_epi32(__m128i __X)
7673175{
7683176 return (__m256i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0, 0, 0, 0, 0);
7693177}
7703178
3179/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X
3180/// to all elements of the result's 256-bit vector of [4 x i64].
3181///
3182/// \headerfile <immintrin.h>
3183///
3184/// This intrinsic corresponds to the \c VPBROADCASTQ instruction.
3185///
3186/// \param __X
3187/// A 128-bit vector of [2 x i64] whose low element will be broadcast.
3188/// \returns A 256-bit vector of [4 x i64] containing the result.
7713189static __inline__ __m256i __DEFAULT_FN_ATTRS256
7723190_mm256_broadcastq_epi64(__m128i __X)
7733191{
7743192 return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0, 0, 0);
7753193}
7763194
3195/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all
3196/// bytes of the 128-bit result.
3197///
3198/// \headerfile <immintrin.h>
3199///
3200/// This intrinsic corresponds to the \c VPBROADCASTB instruction.
3201///
3202/// \param __X
3203/// A 128-bit integer vector whose low byte will be broadcast.
3204/// \returns A 128-bit integer vector containing the result.
7773205static __inline__ __m128i __DEFAULT_FN_ATTRS128
7783206_mm_broadcastb_epi8(__m128i __X)
7793207{
7803208 return (__m128i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
7813209}
7823210
3211/// Broadcasts the low element from the 128-bit vector of [8 x i16] in
3212/// \a __X to all elements of the result's 128-bit vector of [8 x i16].
3213///
3214/// \headerfile <immintrin.h>
3215///
3216/// This intrinsic corresponds to the \c VPBROADCASTW instruction.
3217///
3218/// \param __X
3219/// A 128-bit vector of [8 x i16] whose low element will be broadcast.
3220/// \returns A 128-bit vector of [8 x i16] containing the result.
7833221static __inline__ __m128i __DEFAULT_FN_ATTRS128
7843222_mm_broadcastw_epi16(__m128i __X)
7853223{
7863224 return (__m128i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0);
7873225}
7883226
789
3227/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X
3228/// to all elements of the result's vector of [4 x i32].
3229///
3230/// \headerfile <immintrin.h>
3231///
3232/// This intrinsic corresponds to the \c VPBROADCASTD instruction.
3233///
3234/// \param __X
3235/// A 128-bit vector of [4 x i32] whose low element will be broadcast.
3236/// \returns A 128-bit vector of [4 x i32] containing the result.
7903237static __inline__ __m128i __DEFAULT_FN_ATTRS128
7913238_mm_broadcastd_epi32(__m128i __X)
7923239{
7933240 return (__m128i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0);
7943241}
7953242
3243/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X
3244/// to both elements of the result's 128-bit vector of [2 x i64].
3245///
3246/// \headerfile <immintrin.h>
3247///
3248/// This intrinsic corresponds to the \c VPBROADCASTQ instruction.
3249///
3250/// \param __X
3251/// A 128-bit vector of [2 x i64] whose low element will be broadcast.
3252/// \returns A 128-bit vector of [2 x i64] containing the result.
7963253static __inline__ __m128i __DEFAULT_FN_ATTRS128
7973254_mm_broadcastq_epi64(__m128i __X)
7983255{
7993256 return (__m128i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0);
8003257}
8013258
3259/// Sets the result's 256-bit vector of [8 x i32] to copies of elements of the
3260/// 256-bit vector of [8 x i32] in \a __a as specified by indexes in the
3261/// elements of the 256-bit vector of [8 x i32] in \a __b.
3262///
3263/// \code{.operation}
3264/// FOR i := 0 TO 7
3265/// j := i*32
3266/// k := __b[j+2:j] * 32
3267/// result[j+31:j] := __a[k+31:k]
3268/// ENDFOR
3269/// \endcode
3270///
3271/// \headerfile <immintrin.h>
3272///
3273/// This intrinsic corresponds to the \c VPERMD instruction.
3274///
3275/// \param __a
3276/// A 256-bit vector of [8 x i32] containing the source values.
3277/// \param __b
3278/// A 256-bit vector of [8 x i32] containing indexes of values to use from
3279/// \a __a.
3280/// \returns A 256-bit vector of [8 x i32] containing the result.
8023281static __inline__ __m256i __DEFAULT_FN_ATTRS256
8033282_mm256_permutevar8x32_epi32(__m256i __a, __m256i __b)
8043283{
8053284 return (__m256i)__builtin_ia32_permvarsi256((__v8si)__a, (__v8si)__b);
8063285}
8073286
3287/// Sets the result's 256-bit vector of [4 x double] to copies of elements of
3288/// the 256-bit vector of [4 x double] in \a V as specified by the
3289/// immediate value \a M.
3290///
3291/// \code{.operation}
3292/// FOR i := 0 TO 3
3293/// j := i*64
3294/// k := (M >> i*2)[1:0] * 64
3295/// result[j+63:j] := V[k+63:k]
3296/// ENDFOR
3297/// \endcode
3298///
3299/// \headerfile <immintrin.h>
3300///
3301/// \code
3302/// __m256d _mm256_permute4x64_pd(__m256d V, const int M);
3303/// \endcode
3304///
3305/// This intrinsic corresponds to the \c VPERMPD instruction.
3306///
3307/// \param V
3308/// A 256-bit vector of [4 x double] containing the source values.
3309/// \param M
3310/// An immediate 8-bit value specifying which elements to copy from \a V.
3311/// \a M[1:0] specifies the index in \a a for element 0 of the result,
3312/// \a M[3:2] specifies the index for element 1, and so forth.
3313/// \returns A 256-bit vector of [4 x double] containing the result.
8083314#define _mm256_permute4x64_pd(V, M) \
8093315 ((__m256d)__builtin_ia32_permdf256((__v4df)(__m256d)(V), (int)(M)))
8103316
3317/// Sets the result's 256-bit vector of [8 x float] to copies of elements of
3318/// the 256-bit vector of [8 x float] in \a __a as specified by indexes in
3319/// the elements of the 256-bit vector of [8 x i32] in \a __b.
3320///
3321/// \code{.operation}
3322/// FOR i := 0 TO 7
3323/// j := i*32
3324/// k := __b[j+2:j] * 32
3325/// result[j+31:j] := __a[k+31:k]
3326/// ENDFOR
3327/// \endcode
3328///
3329/// \headerfile <immintrin.h>
3330///
3331/// This intrinsic corresponds to the \c VPERMPS instruction.
3332///
3333/// \param __a
3334/// A 256-bit vector of [8 x float] containing the source values.
3335/// \param __b
3336/// A 256-bit vector of [8 x i32] containing indexes of values to use from
3337/// \a __a.
3338/// \returns A 256-bit vector of [8 x float] containing the result.
8113339static __inline__ __m256 __DEFAULT_FN_ATTRS256
8123340_mm256_permutevar8x32_ps(__m256 __a, __m256i __b)
8133341{
8143342 return (__m256)__builtin_ia32_permvarsf256((__v8sf)__a, (__v8si)__b);
8153343}
8163344
3345/// Sets the result's 256-bit vector of [4 x i64] result to copies of elements
3346/// of the 256-bit vector of [4 x i64] in \a V as specified by the
3347/// immediate value \a M.
3348///
3349/// \code{.operation}
3350/// FOR i := 0 TO 3
3351/// j := i*64
3352/// k := (M >> i*2)[1:0] * 64
3353/// result[j+63:j] := V[k+63:k]
3354/// ENDFOR
3355/// \endcode
3356///
3357/// \headerfile <immintrin.h>
3358///
3359/// \code
3360/// __m256i _mm256_permute4x64_epi64(__m256i V, const int M);
3361/// \endcode
3362///
3363/// This intrinsic corresponds to the \c VPERMQ instruction.
3364///
3365/// \param V
3366/// A 256-bit vector of [4 x i64] containing the source values.
3367/// \param M
3368/// An immediate 8-bit value specifying which elements to copy from \a V.
3369/// \a M[1:0] specifies the index in \a a for element 0 of the result,
3370/// \a M[3:2] specifies the index for element 1, and so forth.
3371/// \returns A 256-bit vector of [4 x i64] containing the result.
8173372#define _mm256_permute4x64_epi64(V, M) \
8183373 ((__m256i)__builtin_ia32_permdi256((__v4di)(__m256i)(V), (int)(M)))
8193374
3375/// Sets each half of the 256-bit result either to zero or to one of the
3376/// four possible 128-bit halves of the 256-bit vectors \a V1 and \a V2,
3377/// as specified by the immediate value \a M.
3378///
3379/// \code{.operation}
3380/// FOR i := 0 TO 1
3381/// j := i*128
3382/// k := M >> (i*4)
3383/// IF k[3] == 0
3384/// CASE (k[1:0]) OF
3385/// 0: result[127+j:j] := V1[127:0]
3386/// 1: result[127+j:j] := V1[255:128]
3387/// 2: result[127+j:j] := V2[127:0]
3388/// 3: result[127+j:j] := V2[255:128]
3389/// ESAC
3390/// ELSE
3391/// result[127+j:j] := 0
3392/// FI
3393/// ENDFOR
3394/// \endcode
3395///
3396/// \headerfile <immintrin.h>
3397///
3398/// \code
3399/// __m256i _mm256_permute2x128_si256(__m256i V1, __m256i V2, const int M);
3400/// \endcode
3401///
3402/// This intrinsic corresponds to the \c VPERM2I128 instruction.
3403///
3404/// \param V1
3405/// A 256-bit integer vector containing source values.
3406/// \param V2
3407/// A 256-bit integer vector containing source values.
3408/// \param M
3409/// An immediate value specifying how to form the result. Bits [3:0]
3410/// control the lower half of the result, bits [7:4] control the upper half.
3411/// Within each 4-bit control value, if bit 3 is 1, the result is zero,
3412/// otherwise bits [1:0] determine the source as follows. \n
3413/// 0: the lower half of \a V1 \n
3414/// 1: the upper half of \a V1 \n
3415/// 2: the lower half of \a V2 \n
3416/// 3: the upper half of \a V2
3417/// \returns A 256-bit integer vector containing the result.
8203418#define _mm256_permute2x128_si256(V1, V2, M) \
8213419 ((__m256i)__builtin_ia32_permti256((__m256i)(V1), (__m256i)(V2), (int)(M)))
8223420
3421/// Extracts half of the 256-bit vector \a V to the 128-bit result. If bit 0
3422/// of the immediate \a M is zero, extracts the lower half of the result;
3423/// otherwise, extracts the upper half.
3424///
3425/// \headerfile <immintrin.h>
3426///
3427/// \code
3428/// __m128i _mm256_extracti128_si256(__m256i V, const int M);
3429/// \endcode
3430///
3431/// This intrinsic corresponds to the \c VEXTRACTI128 instruction.
3432///
3433/// \param V
3434/// A 256-bit integer vector containing the source values.
3435/// \param M
3436/// An immediate value specifying which half of \a V to extract.
3437/// \returns A 128-bit integer vector containing the result.
8233438#define _mm256_extracti128_si256(V, M) \
8243439 ((__m128i)__builtin_ia32_extract128i256((__v4di)(__m256i)(V), (int)(M)))
8253440
3441/// Copies the 256-bit vector \a V1 to the result, then overwrites half of the
3442/// result with the 128-bit vector \a V2. If bit 0 of the immediate \a M
3443/// is zero, overwrites the lower half of the result; otherwise,
3444/// overwrites the upper half.
3445///
3446/// \headerfile <immintrin.h>
3447///
3448/// \code
3449/// __m256i _mm256_inserti128_si256(__m256i V1, __m128i V2, const int M);
3450/// \endcode
3451///
3452/// This intrinsic corresponds to the \c VINSERTI128 instruction.
3453///
3454/// \param V1
3455/// A 256-bit integer vector containing a source value.
3456/// \param V2
3457/// A 128-bit integer vector containing a source value.
3458/// \param M
3459/// An immediate value specifying where to put \a V2 in the result.
3460/// \returns A 256-bit integer vector containing the result.
8263461#define _mm256_inserti128_si256(V1, V2, M) \
8273462 ((__m256i)__builtin_ia32_insert128i256((__v4di)(__m256i)(V1), \
8283463 (__v2di)(__m128i)(V2), (int)(M)))
8293464
3465/// Conditionally loads eight 32-bit integer elements from memory \a __X, if
3466/// the most significant bit of the corresponding element in the mask
3467/// \a __M is set; otherwise, sets that element of the result to zero.
3468/// Returns the 256-bit [8 x i32] result.
3469///
3470/// \code{.operation}
3471/// FOR i := 0 TO 7
3472/// j := i*32
3473/// IF __M[j+31] == 1
3474/// result[j+31:j] := Load32(__X+(i*4))
3475/// ELSE
3476/// result[j+31:j] := 0
3477/// FI
3478/// ENDFOR
3479/// \endcode
3480///
3481/// \headerfile <immintrin.h>
3482///
3483/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3484///
3485/// \param __X
3486/// A pointer to the memory used for loading values.
3487/// \param __M
3488/// A 256-bit vector of [8 x i32] containing the mask bits.
3489/// \returns A 256-bit vector of [8 x i32] containing the loaded or zeroed
3490/// elements.
8303491static __inline__ __m256i __DEFAULT_FN_ATTRS256
8313492_mm256_maskload_epi32(int const *__X, __m256i __M)
8323493{
8333494 return (__m256i)__builtin_ia32_maskloadd256((const __v8si *)__X, (__v8si)__M);
8343495}
8353496
3497/// Conditionally loads four 64-bit integer elements from memory \a __X, if
3498/// the most significant bit of the corresponding element in the mask
3499/// \a __M is set; otherwise, sets that element of the result to zero.
3500/// Returns the 256-bit [4 x i64] result.
3501///
3502/// \code{.operation}
3503/// FOR i := 0 TO 3
3504/// j := i*64
3505/// IF __M[j+63] == 1
3506/// result[j+63:j] := Load64(__X+(i*8))
3507/// ELSE
3508/// result[j+63:j] := 0
3509/// FI
3510/// ENDFOR
3511/// \endcode
3512///
3513/// \headerfile <immintrin.h>
3514///
3515/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3516///
3517/// \param __X
3518/// A pointer to the memory used for loading values.
3519/// \param __M
3520/// A 256-bit vector of [4 x i64] containing the mask bits.
3521/// \returns A 256-bit vector of [4 x i64] containing the loaded or zeroed
3522/// elements.
8363523static __inline__ __m256i __DEFAULT_FN_ATTRS256
8373524_mm256_maskload_epi64(long long const *__X, __m256i __M)
8383525{
8393526 return (__m256i)__builtin_ia32_maskloadq256((const __v4di *)__X, (__v4di)__M);
8403527}
8413528
3529/// Conditionally loads four 32-bit integer elements from memory \a __X, if
3530/// the most significant bit of the corresponding element in the mask
3531/// \a __M is set; otherwise, sets that element of the result to zero.
3532/// Returns the 128-bit [4 x i32] result.
3533///
3534/// \code{.operation}
3535/// FOR i := 0 TO 3
3536/// j := i*32
3537/// IF __M[j+31] == 1
3538/// result[j+31:j] := Load32(__X+(i*4))
3539/// ELSE
3540/// result[j+31:j] := 0
3541/// FI
3542/// ENDFOR
3543/// \endcode
3544///
3545/// \headerfile <immintrin.h>
3546///
3547/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3548///
3549/// \param __X
3550/// A pointer to the memory used for loading values.
3551/// \param __M
3552/// A 128-bit vector of [4 x i32] containing the mask bits.
3553/// \returns A 128-bit vector of [4 x i32] containing the loaded or zeroed
3554/// elements.
8423555static __inline__ __m128i __DEFAULT_FN_ATTRS128
8433556_mm_maskload_epi32(int const *__X, __m128i __M)
8443557{
8453558 return (__m128i)__builtin_ia32_maskloadd((const __v4si *)__X, (__v4si)__M);
8463559}
8473560
3561/// Conditionally loads two 64-bit integer elements from memory \a __X, if
3562/// the most significant bit of the corresponding element in the mask
3563/// \a __M is set; otherwise, sets that element of the result to zero.
3564/// Returns the 128-bit [2 x i64] result.
3565///
3566/// \code{.operation}
3567/// FOR i := 0 TO 1
3568/// j := i*64
3569/// IF __M[j+63] == 1
3570/// result[j+63:j] := Load64(__X+(i*8))
3571/// ELSE
3572/// result[j+63:j] := 0
3573/// FI
3574/// ENDFOR
3575/// \endcode
3576///
3577/// \headerfile <immintrin.h>
3578///
3579/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3580///
3581/// \param __X
3582/// A pointer to the memory used for loading values.
3583/// \param __M
3584/// A 128-bit vector of [2 x i64] containing the mask bits.
3585/// \returns A 128-bit vector of [2 x i64] containing the loaded or zeroed
3586/// elements.
8483587static __inline__ __m128i __DEFAULT_FN_ATTRS128
8493588_mm_maskload_epi64(long long const *__X, __m128i __M)
8503589{
8513590 return (__m128i)__builtin_ia32_maskloadq((const __v2di *)__X, (__v2di)__M);
8523591}
8533592
3593/// Conditionally stores eight 32-bit integer elements from the 256-bit vector
3594/// of [8 x i32] in \a __Y to memory \a __X, if the most significant bit of
3595/// the corresponding element in the mask \a __M is set; otherwise, the
3596/// memory element is unchanged.
3597///
3598/// \code{.operation}
3599/// FOR i := 0 TO 7
3600/// j := i*32
3601/// IF __M[j+31] == 1
3602/// Store32(__X+(i*4), __Y[j+31:j])
3603/// FI
3604/// ENDFOR
3605/// \endcode
3606///
3607/// \headerfile <immintrin.h>
3608///
3609/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3610///
3611/// \param __X
3612/// A pointer to the memory used for storing values.
3613/// \param __M
3614/// A 256-bit vector of [8 x i32] containing the mask bits.
3615/// \param __Y
3616/// A 256-bit vector of [8 x i32] containing the values to store.
8543617static __inline__ void __DEFAULT_FN_ATTRS256
8553618_mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y)
8563619{
8573620 __builtin_ia32_maskstored256((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
8583621}
8593622
3623/// Conditionally stores four 64-bit integer elements from the 256-bit vector
3624/// of [4 x i64] in \a __Y to memory \a __X, if the most significant bit of
3625/// the corresponding element in the mask \a __M is set; otherwise, the
3626/// memory element is unchanged.
3627///
3628/// \code{.operation}
3629/// FOR i := 0 TO 3
3630/// j := i*64
3631/// IF __M[j+63] == 1
3632/// Store64(__X+(i*8), __Y[j+63:j])
3633/// FI
3634/// ENDFOR
3635/// \endcode
3636///
3637/// \headerfile <immintrin.h>
3638///
3639/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3640///
3641/// \param __X
3642/// A pointer to the memory used for storing values.
3643/// \param __M
3644/// A 256-bit vector of [4 x i64] containing the mask bits.
3645/// \param __Y
3646/// A 256-bit vector of [4 x i64] containing the values to store.
8603647static __inline__ void __DEFAULT_FN_ATTRS256
8613648_mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y)
8623649{
8633650 __builtin_ia32_maskstoreq256((__v4di *)__X, (__v4di)__M, (__v4di)__Y);
8643651}
8653652
3653/// Conditionally stores four 32-bit integer elements from the 128-bit vector
3654/// of [4 x i32] in \a __Y to memory \a __X, if the most significant bit of
3655/// the corresponding element in the mask \a __M is set; otherwise, the
3656/// memory element is unchanged.
3657///
3658/// \code{.operation}
3659/// FOR i := 0 TO 3
3660/// j := i*32
3661/// IF __M[j+31] == 1
3662/// Store32(__X+(i*4), __Y[j+31:j])
3663/// FI
3664/// ENDFOR
3665/// \endcode
3666///
3667/// \headerfile <immintrin.h>
3668///
3669/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3670///
3671/// \param __X
3672/// A pointer to the memory used for storing values.
3673/// \param __M
3674/// A 128-bit vector of [4 x i32] containing the mask bits.
3675/// \param __Y
3676/// A 128-bit vector of [4 x i32] containing the values to store.
8663677static __inline__ void __DEFAULT_FN_ATTRS128
8673678_mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y)
8683679{
8693680 __builtin_ia32_maskstored((__v4si *)__X, (__v4si)__M, (__v4si)__Y);
8703681}
8713682
3683/// Conditionally stores two 64-bit integer elements from the 128-bit vector
3684/// of [2 x i64] in \a __Y to memory \a __X, if the most significant bit of
3685/// the corresponding element in the mask \a __M is set; otherwise, the
3686/// memory element is unchanged.
3687///
3688/// \code{.operation}
3689/// FOR i := 0 TO 1
3690/// j := i*64
3691/// IF __M[j+63] == 1
3692/// Store64(__X+(i*8), __Y[j+63:j])
3693/// FI
3694/// ENDFOR
3695/// \endcode
3696///
3697/// \headerfile <immintrin.h>
3698///
3699/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3700///
3701/// \param __X
3702/// A pointer to the memory used for storing values.
3703/// \param __M
3704/// A 128-bit vector of [2 x i64] containing the mask bits.
3705/// \param __Y
3706/// A 128-bit vector of [2 x i64] containing the values to store.
8723707static __inline__ void __DEFAULT_FN_ATTRS128
8733708_mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y)
8743709{
8753710 __builtin_ia32_maskstoreq(( __v2di *)__X, (__v2di)__M, (__v2di)__Y);
8763711}
8773712
3713/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3714/// left by the number of bits given in the corresponding element of the
3715/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and
3716/// returns the result. If the shift count for any element is greater than
3717/// 31, the result for that element is zero.
3718///
3719/// \headerfile <immintrin.h>
3720///
3721/// This intrinsic corresponds to the \c VPSLLVD instruction.
3722///
3723/// \param __X
3724/// A 256-bit vector of [8 x i32] to be shifted.
3725/// \param __Y
3726/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3727/// bits).
3728/// \returns A 256-bit vector of [8 x i32] containing the result.
8783729static __inline__ __m256i __DEFAULT_FN_ATTRS256
8793730_mm256_sllv_epi32(__m256i __X, __m256i __Y)
8803731{
8813732 return (__m256i)__builtin_ia32_psllv8si((__v8si)__X, (__v8si)__Y);
8823733}
8833734
3735/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3736/// left by the number of bits given in the corresponding element of the
3737/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and
3738/// returns the result. If the shift count for any element is greater than
3739/// 31, the result for that element is zero.
3740///
3741/// \headerfile <immintrin.h>
3742///
3743/// This intrinsic corresponds to the \c VPSLLVD instruction.
3744///
3745/// \param __X
3746/// A 128-bit vector of [4 x i32] to be shifted.
3747/// \param __Y
3748/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3749/// bits).
3750/// \returns A 128-bit vector of [4 x i32] containing the result.
8843751static __inline__ __m128i __DEFAULT_FN_ATTRS128
8853752_mm_sllv_epi32(__m128i __X, __m128i __Y)
8863753{
8873754 return (__m128i)__builtin_ia32_psllv4si((__v4si)__X, (__v4si)__Y);
8883755}
8893756
3757/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X
3758/// left by the number of bits given in the corresponding element of the
3759/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and
3760/// returns the result. If the shift count for any element is greater than
3761/// 63, the result for that element is zero.
3762///
3763/// \headerfile <immintrin.h>
3764///
3765/// This intrinsic corresponds to the \c VPSLLVQ instruction.
3766///
3767/// \param __X
3768/// A 256-bit vector of [4 x i64] to be shifted.
3769/// \param __Y
3770/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in
3771/// bits).
3772/// \returns A 256-bit vector of [4 x i64] containing the result.
8903773static __inline__ __m256i __DEFAULT_FN_ATTRS256
8913774_mm256_sllv_epi64(__m256i __X, __m256i __Y)
8923775{
8933776 return (__m256i)__builtin_ia32_psllv4di((__v4di)__X, (__v4di)__Y);
8943777}
8953778
3779/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X
3780/// left by the number of bits given in the corresponding element of the
3781/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and
3782/// returns the result. If the shift count for any element is greater than
3783/// 63, the result for that element is zero.
3784///
3785/// \headerfile <immintrin.h>
3786///
3787/// This intrinsic corresponds to the \c VPSLLVQ instruction.
3788///
3789/// \param __X
3790/// A 128-bit vector of [2 x i64] to be shifted.
3791/// \param __Y
3792/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in
3793/// bits).
3794/// \returns A 128-bit vector of [2 x i64] containing the result.
8963795static __inline__ __m128i __DEFAULT_FN_ATTRS128
8973796_mm_sllv_epi64(__m128i __X, __m128i __Y)
8983797{
8993798 return (__m128i)__builtin_ia32_psllv2di((__v2di)__X, (__v2di)__Y);
9003799}
9013800
3801/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3802/// right by the number of bits given in the corresponding element of the
3803/// 256-bit vector of [8 x i32] in \a __Y, shifting in sign bits, and
3804/// returns the result. If the shift count for any element is greater than
3805/// 31, the result for that element is 0 or -1 according to the sign bit
3806/// for that element.
3807///
3808/// \headerfile <immintrin.h>
3809///
3810/// This intrinsic corresponds to the \c VPSRAVD instruction.
3811///
3812/// \param __X
3813/// A 256-bit vector of [8 x i32] to be shifted.
3814/// \param __Y
3815/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3816/// bits).
3817/// \returns A 256-bit vector of [8 x i32] containing the result.
9023818static __inline__ __m256i __DEFAULT_FN_ATTRS256
9033819_mm256_srav_epi32(__m256i __X, __m256i __Y)
9043820{
9053821 return (__m256i)__builtin_ia32_psrav8si((__v8si)__X, (__v8si)__Y);
9063822}
9073823
3824/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3825/// right by the number of bits given in the corresponding element of the
3826/// 128-bit vector of [4 x i32] in \a __Y, shifting in sign bits, and
3827/// returns the result. If the shift count for any element is greater than
3828/// 31, the result for that element is 0 or -1 according to the sign bit
3829/// for that element.
3830///
3831/// \headerfile <immintrin.h>
3832///
3833/// This intrinsic corresponds to the \c VPSRAVD instruction.
3834///
3835/// \param __X
3836/// A 128-bit vector of [4 x i32] to be shifted.
3837/// \param __Y
3838/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3839/// bits).
3840/// \returns A 128-bit vector of [4 x i32] containing the result.
9083841static __inline__ __m128i __DEFAULT_FN_ATTRS128
9093842_mm_srav_epi32(__m128i __X, __m128i __Y)
9103843{
9113844 return (__m128i)__builtin_ia32_psrav4si((__v4si)__X, (__v4si)__Y);
9123845}
9133846
3847/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3848/// right by the number of bits given in the corresponding element of the
3849/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and
3850/// returns the result. If the shift count for any element is greater than
3851/// 31, the result for that element is zero.
3852///
3853/// \headerfile <immintrin.h>
3854///
3855/// This intrinsic corresponds to the \c VPSRLVD instruction.
3856///
3857/// \param __X
3858/// A 256-bit vector of [8 x i32] to be shifted.
3859/// \param __Y
3860/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3861/// bits).
3862/// \returns A 256-bit vector of [8 x i32] containing the result.
9143863static __inline__ __m256i __DEFAULT_FN_ATTRS256
9153864_mm256_srlv_epi32(__m256i __X, __m256i __Y)
9163865{
9173866 return (__m256i)__builtin_ia32_psrlv8si((__v8si)__X, (__v8si)__Y);
9183867}
9193868
3869/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3870/// right by the number of bits given in the corresponding element of the
3871/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and
3872/// returns the result. If the shift count for any element is greater than
3873/// 31, the result for that element is zero.
3874///
3875/// \headerfile <immintrin.h>
3876///
3877/// This intrinsic corresponds to the \c VPSRLVD instruction.
3878///
3879/// \param __X
3880/// A 128-bit vector of [4 x i32] to be shifted.
3881/// \param __Y
3882/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3883/// bits).
3884/// \returns A 128-bit vector of [4 x i32] containing the result.
9203885static __inline__ __m128i __DEFAULT_FN_ATTRS128
9213886_mm_srlv_epi32(__m128i __X, __m128i __Y)
9223887{
9233888 return (__m128i)__builtin_ia32_psrlv4si((__v4si)__X, (__v4si)__Y);
9243889}
9253890
3891/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X
3892/// right by the number of bits given in the corresponding element of the
3893/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and
3894/// returns the result. If the shift count for any element is greater than
3895/// 63, the result for that element is zero.
3896///
3897/// \headerfile <immintrin.h>
3898///
3899/// This intrinsic corresponds to the \c VPSRLVQ instruction.
3900///
3901/// \param __X
3902/// A 256-bit vector of [4 x i64] to be shifted.
3903/// \param __Y
3904/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in
3905/// bits).
3906/// \returns A 256-bit vector of [4 x i64] containing the result.
9263907static __inline__ __m256i __DEFAULT_FN_ATTRS256
9273908_mm256_srlv_epi64(__m256i __X, __m256i __Y)
9283909{
9293910 return (__m256i)__builtin_ia32_psrlv4di((__v4di)__X, (__v4di)__Y);
9303911}
9313912
3913/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X
3914/// right by the number of bits given in the corresponding element of the
3915/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and
3916/// returns the result. If the shift count for any element is greater than
3917/// 63, the result for that element is zero.
3918///
3919/// \headerfile <immintrin.h>
3920///
3921/// This intrinsic corresponds to the \c VPSRLVQ instruction.
3922///
3923/// \param __X
3924/// A 128-bit vector of [2 x i64] to be shifted.
3925/// \param __Y
3926/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in
3927/// bits).
3928/// \returns A 128-bit vector of [2 x i64] containing the result.
9323929static __inline__ __m128i __DEFAULT_FN_ATTRS128
9333930_mm_srlv_epi64(__m128i __X, __m128i __Y)
9343931{
9353932 return (__m128i)__builtin_ia32_psrlv2di((__v2di)__X, (__v2di)__Y);
9363933}
9373934
3935/// Conditionally gathers two 64-bit floating-point values, either from the
3936/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
3937/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
3938/// of [2 x double] in \a mask determines the source for each element.
3939///
3940/// \code{.operation}
3941/// FOR element := 0 to 1
3942/// j := element*64
3943/// k := element*32
3944/// IF mask[j+63] == 0
3945/// result[j+63:j] := a[j+63:j]
3946/// ELSE
3947/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
3948/// FI
3949/// ENDFOR
3950/// \endcode
3951///
3952/// \headerfile <immintrin.h>
3953///
3954/// \code
3955/// __m128d _mm_mask_i32gather_pd(__m128d a, const double *m, __m128i i,
3956/// __m128d mask, const int s);
3957/// \endcode
3958///
3959/// This intrinsic corresponds to the \c VGATHERDPD instruction.
3960///
3961/// \param a
3962/// A 128-bit vector of [2 x double] used as the source when a mask bit is
3963/// zero.
3964/// \param m
3965/// A pointer to the memory used for loading values.
3966/// \param i
3967/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
3968/// the first two elements are used.
3969/// \param mask
3970/// A 128-bit vector of [2 x double] containing the mask. The most
3971/// significant bit of each element in the mask vector represents the mask
3972/// bits. If a mask bit is zero, the corresponding value from vector \a a
3973/// is gathered; otherwise the value is loaded from memory.
3974/// \param s
3975/// A literal constant scale factor for the indexes in \a i. Must be
3976/// 1, 2, 4, or 8.
3977/// \returns A 128-bit vector of [2 x double] containing the gathered values.
9383978#define _mm_mask_i32gather_pd(a, m, i, mask, s) \
9393979 ((__m128d)__builtin_ia32_gatherd_pd((__v2df)(__m128i)(a), \
9403980 (double const *)(m), \
9413981 (__v4si)(__m128i)(i), \
9423982 (__v2df)(__m128d)(mask), (s)))
9433983
3984/// Conditionally gathers four 64-bit floating-point values, either from the
3985/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled
3986/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector
3987/// of [4 x double] in \a mask determines the source for each element.
3988///
3989/// \code{.operation}
3990/// FOR element := 0 to 3
3991/// j := element*64
3992/// k := element*32
3993/// IF mask[j+63] == 0
3994/// result[j+63:j] := a[j+63:j]
3995/// ELSE
3996/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
3997/// FI
3998/// ENDFOR
3999/// \endcode
4000///
4001/// \headerfile <immintrin.h>
4002///
4003/// \code
4004/// __m256d _mm256_mask_i32gather_pd(__m256d a, const double *m, __m128i i,
4005/// __m256d mask, const int s);
4006/// \endcode
4007///
4008/// This intrinsic corresponds to the \c VGATHERDPD instruction.
4009///
4010/// \param a
4011/// A 256-bit vector of [4 x double] used as the source when a mask bit is
4012/// zero.
4013/// \param m
4014/// A pointer to the memory used for loading values.
4015/// \param i
4016/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4017/// \param mask
4018/// A 256-bit vector of [4 x double] containing the mask. The most
4019/// significant bit of each element in the mask vector represents the mask
4020/// bits. If a mask bit is zero, the corresponding value from vector \a a
4021/// is gathered; otherwise the value is loaded from memory.
4022/// \param s
4023/// A literal constant scale factor for the indexes in \a i. Must be
4024/// 1, 2, 4, or 8.
4025/// \returns A 256-bit vector of [4 x double] containing the gathered values.
9444026#define _mm256_mask_i32gather_pd(a, m, i, mask, s) \
9454027 ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)(__m256d)(a), \
9464028 (double const *)(m), \
9474029 (__v4si)(__m128i)(i), \
9484030 (__v4df)(__m256d)(mask), (s)))
9494031
4032/// Conditionally gathers two 64-bit floating-point values, either from the
4033/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
4034/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4035/// of [2 x double] in \a mask determines the source for each element.
4036///
4037/// \code{.operation}
4038/// FOR element := 0 to 1
4039/// j := element*64
4040/// k := element*64
4041/// IF mask[j+63] == 0
4042/// result[j+63:j] := a[j+63:j]
4043/// ELSE
4044/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4045/// FI
4046/// ENDFOR
4047/// \endcode
4048///
4049/// \headerfile <immintrin.h>
4050///
4051/// \code
4052/// __m128d _mm_mask_i64gather_pd(__m128d a, const double *m, __m128i i,
4053/// __m128d mask, const int s);
4054/// \endcode
4055///
4056/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4057///
4058/// \param a
4059/// A 128-bit vector of [2 x double] used as the source when a mask bit is
4060/// zero.
4061/// \param m
4062/// A pointer to the memory used for loading values.
4063/// \param i
4064/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4065/// \param mask
4066/// A 128-bit vector of [2 x double] containing the mask. The most
4067/// significant bit of each element in the mask vector represents the mask
4068/// bits. If a mask bit is zero, the corresponding value from vector \a a
4069/// is gathered; otherwise the value is loaded from memory.
4070/// \param s
4071/// A literal constant scale factor for the indexes in \a i. Must be
4072/// 1, 2, 4, or 8.
4073/// \returns A 128-bit vector of [2 x double] containing the gathered values.
9504074#define _mm_mask_i64gather_pd(a, m, i, mask, s) \
9514075 ((__m128d)__builtin_ia32_gatherq_pd((__v2df)(__m128d)(a), \
9524076 (double const *)(m), \
9534077 (__v2di)(__m128i)(i), \
9544078 (__v2df)(__m128d)(mask), (s)))
9554079
4080/// Conditionally gathers four 64-bit floating-point values, either from the
4081/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled
4082/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector
4083/// of [4 x double] in \a mask determines the source for each element.
4084///
4085/// \code{.operation}
4086/// FOR element := 0 to 3
4087/// j := element*64
4088/// k := element*64
4089/// IF mask[j+63] == 0
4090/// result[j+63:j] := a[j+63:j]
4091/// ELSE
4092/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4093/// FI
4094/// ENDFOR
4095/// \endcode
4096///
4097/// \headerfile <immintrin.h>
4098///
4099/// \code
4100/// __m256d _mm256_mask_i64gather_pd(__m256d a, const double *m, __m256i i,
4101/// __m256d mask, const int s);
4102/// \endcode
4103///
4104/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4105///
4106/// \param a
4107/// A 256-bit vector of [4 x double] used as the source when a mask bit is
4108/// zero.
4109/// \param m
4110/// A pointer to the memory used for loading values.
4111/// \param i
4112/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4113/// \param mask
4114/// A 256-bit vector of [4 x double] containing the mask. The most
4115/// significant bit of each element in the mask vector represents the mask
4116/// bits. If a mask bit is zero, the corresponding value from vector \a a
4117/// is gathered; otherwise the value is loaded from memory.
4118/// \param s
4119/// A literal constant scale factor for the indexes in \a i. Must be
4120/// 1, 2, 4, or 8.
4121/// \returns A 256-bit vector of [4 x double] containing the gathered values.
9564122#define _mm256_mask_i64gather_pd(a, m, i, mask, s) \
9574123 ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)(__m256d)(a), \
9584124 (double const *)(m), \
9594125 (__v4di)(__m256i)(i), \
9604126 (__v4df)(__m256d)(mask), (s)))
9614127
4128/// Conditionally gathers four 32-bit floating-point values, either from the
4129/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4130/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4131/// of [4 x float] in \a mask determines the source for each element.
4132///
4133/// \code{.operation}
4134/// FOR element := 0 to 3
4135/// j := element*32
4136/// k := element*32
4137/// IF mask[j+31] == 0
4138/// result[j+31:j] := a[j+31:j]
4139/// ELSE
4140/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4141/// FI
4142/// ENDFOR
4143/// \endcode
4144///
4145/// \headerfile <immintrin.h>
4146///
4147/// \code
4148/// __m128 _mm_mask_i32gather_ps(__m128 a, const float *m, __m128i i,
4149/// __m128 mask, const int s);
4150/// \endcode
4151///
4152/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4153///
4154/// \param a
4155/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4156/// zero.
4157/// \param m
4158/// A pointer to the memory used for loading values.
4159/// \param i
4160/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4161/// \param mask
4162/// A 128-bit vector of [4 x float] containing the mask. The most
4163/// significant bit of each element in the mask vector represents the mask
4164/// bits. If a mask bit is zero, the corresponding value from vector \a a
4165/// is gathered; otherwise the value is loaded from memory.
4166/// \param s
4167/// A literal constant scale factor for the indexes in \a i. Must be
4168/// 1, 2, 4, or 8.
4169/// \returns A 128-bit vector of [4 x float] containing the gathered values.
9624170#define _mm_mask_i32gather_ps(a, m, i, mask, s) \
9634171 ((__m128)__builtin_ia32_gatherd_ps((__v4sf)(__m128)(a), \
9644172 (float const *)(m), \
9654173 (__v4si)(__m128i)(i), \
9664174 (__v4sf)(__m128)(mask), (s)))
9674175
4176/// Conditionally gathers eight 32-bit floating-point values, either from the
4177/// 256-bit vector of [8 x float] in \a a, or from memory \a m using scaled
4178/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector
4179/// of [8 x float] in \a mask determines the source for each element.
4180///
4181/// \code{.operation}
4182/// FOR element := 0 to 7
4183/// j := element*32
4184/// k := element*32
4185/// IF mask[j+31] == 0
4186/// result[j+31:j] := a[j+31:j]
4187/// ELSE
4188/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4189/// FI
4190/// ENDFOR
4191/// \endcode
4192///
4193/// \headerfile <immintrin.h>
4194///
4195/// \code
4196/// __m256 _mm256_mask_i32gather_ps(__m256 a, const float *m, __m256i i,
4197/// __m256 mask, const int s);
4198/// \endcode
4199///
4200/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4201///
4202/// \param a
4203/// A 256-bit vector of [8 x float] used as the source when a mask bit is
4204/// zero.
4205/// \param m
4206/// A pointer to the memory used for loading values.
4207/// \param i
4208/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4209/// \param mask
4210/// A 256-bit vector of [8 x float] containing the mask. The most
4211/// significant bit of each element in the mask vector represents the mask
4212/// bits. If a mask bit is zero, the corresponding value from vector \a a
4213/// is gathered; otherwise the value is loaded from memory.
4214/// \param s
4215/// A literal constant scale factor for the indexes in \a i. Must be
4216/// 1, 2, 4, or 8.
4217/// \returns A 256-bit vector of [8 x float] containing the gathered values.
9684218#define _mm256_mask_i32gather_ps(a, m, i, mask, s) \
9694219 ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)(__m256)(a), \
9704220 (float const *)(m), \
9714221 (__v8si)(__m256i)(i), \
9724222 (__v8sf)(__m256)(mask), (s)))
9734223
4224/// Conditionally gathers two 32-bit floating-point values, either from the
4225/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4226/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4227/// of [4 x float] in \a mask determines the source for the lower two
4228/// elements. The upper two elements of the result are zeroed.
4229///
4230/// \code{.operation}
4231/// FOR element := 0 to 1
4232/// j := element*32
4233/// k := element*64
4234/// IF mask[j+31] == 0
4235/// result[j+31:j] := a[j+31:j]
4236/// ELSE
4237/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4238/// FI
4239/// ENDFOR
4240/// result[127:64] := 0
4241/// \endcode
4242///
4243/// \headerfile <immintrin.h>
4244///
4245/// \code
4246/// __m128 _mm_mask_i64gather_ps(__m128 a, const float *m, __m128i i,
4247/// __m128 mask, const int s);
4248/// \endcode
4249///
4250/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4251///
4252/// \param a
4253/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4254/// zero. Only the first two elements are used.
4255/// \param m
4256/// A pointer to the memory used for loading values.
4257/// \param i
4258/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4259/// \param mask
4260/// A 128-bit vector of [4 x float] containing the mask. The most
4261/// significant bit of each element in the mask vector represents the mask
4262/// bits. If a mask bit is zero, the corresponding value from vector \a a
4263/// is gathered; otherwise the value is loaded from memory. Only the first
4264/// two elements are used.
4265/// \param s
4266/// A literal constant scale factor for the indexes in \a i. Must be
4267/// 1, 2, 4, or 8.
4268/// \returns A 128-bit vector of [4 x float] containing the gathered values.
9744269#define _mm_mask_i64gather_ps(a, m, i, mask, s) \
9754270 ((__m128)__builtin_ia32_gatherq_ps((__v4sf)(__m128)(a), \
9764271 (float const *)(m), \
9774272 (__v2di)(__m128i)(i), \
9784273 (__v4sf)(__m128)(mask), (s)))
9794274
4275/// Conditionally gathers four 32-bit floating-point values, either from the
4276/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4277/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector
4278/// of [4 x float] in \a mask determines the source for each element.
4279///
4280/// \code{.operation}
4281/// FOR element := 0 to 3
4282/// j := element*32
4283/// k := element*64
4284/// IF mask[j+31] == 0
4285/// result[j+31:j] := a[j+31:j]
4286/// ELSE
4287/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4288/// FI
4289/// ENDFOR
4290/// \endcode
4291///
4292/// \headerfile <immintrin.h>
4293///
4294/// \code
4295/// __m128 _mm256_mask_i64gather_ps(__m128 a, const float *m, __m256i i,
4296/// __m128 mask, const int s);
4297/// \endcode
4298///
4299/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4300///
4301/// \param a
4302/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4303/// zero.
4304/// \param m
4305/// A pointer to the memory used for loading values.
4306/// \param i
4307/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4308/// \param mask
4309/// A 128-bit vector of [4 x float] containing the mask. The most
4310/// significant bit of each element in the mask vector represents the mask
4311/// bits. If a mask bit is zero, the corresponding value from vector \a a
4312/// is gathered; otherwise the value is loaded from memory.
4313/// \param s
4314/// A literal constant scale factor for the indexes in \a i. Must be
4315/// 1, 2, 4, or 8.
4316/// \returns A 128-bit vector of [4 x float] containing the gathered values.
9804317#define _mm256_mask_i64gather_ps(a, m, i, mask, s) \
9814318 ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)(__m128)(a), \
9824319 (float const *)(m), \
9834320 (__v4di)(__m256i)(i), \
9844321 (__v4sf)(__m128)(mask), (s)))
9854322
4323/// Conditionally gathers four 32-bit integer values, either from the
4324/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4325/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4326/// of [4 x i32] in \a mask determines the source for each element.
4327///
4328/// \code{.operation}
4329/// FOR element := 0 to 3
4330/// j := element*32
4331/// k := element*32
4332/// IF mask[j+31] == 0
4333/// result[j+31:j] := a[j+31:j]
4334/// ELSE
4335/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4336/// FI
4337/// ENDFOR
4338/// \endcode
4339///
4340/// \headerfile <immintrin.h>
4341///
4342/// \code
4343/// __m128i _mm_mask_i32gather_epi32(__m128i a, const int *m, __m128i i,
4344/// __m128i mask, const int s);
4345/// \endcode
4346///
4347/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4348///
4349/// \param a
4350/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4351/// zero.
4352/// \param m
4353/// A pointer to the memory used for loading values.
4354/// \param i
4355/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4356/// \param mask
4357/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4358/// bit of each element in the mask vector represents the mask bits. If a
4359/// mask bit is zero, the corresponding value from vector \a a is gathered;
4360/// otherwise the value is loaded from memory.
4361/// \param s
4362/// A literal constant scale factor for the indexes in \a i. Must be
4363/// 1, 2, 4, or 8.
4364/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
9864365#define _mm_mask_i32gather_epi32(a, m, i, mask, s) \
9874366 ((__m128i)__builtin_ia32_gatherd_d((__v4si)(__m128i)(a), \
9884367 (int const *)(m), \
9894368 (__v4si)(__m128i)(i), \
9904369 (__v4si)(__m128i)(mask), (s)))
9914370
4371/// Conditionally gathers eight 32-bit integer values, either from the
4372/// 256-bit vector of [8 x i32] in \a a, or from memory \a m using scaled
4373/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector
4374/// of [8 x i32] in \a mask determines the source for each element.
4375///
4376/// \code{.operation}
4377/// FOR element := 0 to 7
4378/// j := element*32
4379/// k := element*32
4380/// IF mask[j+31] == 0
4381/// result[j+31:j] := a[j+31:j]
4382/// ELSE
4383/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4384/// FI
4385/// ENDFOR
4386/// \endcode
4387///
4388/// \headerfile <immintrin.h>
4389///
4390/// \code
4391/// __m256i _mm256_mask_i32gather_epi32(__m256i a, const int *m, __m256i i,
4392/// __m256i mask, const int s);
4393/// \endcode
4394///
4395/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4396///
4397/// \param a
4398/// A 256-bit vector of [8 x i32] used as the source when a mask bit is
4399/// zero.
4400/// \param m
4401/// A pointer to the memory used for loading values.
4402/// \param i
4403/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4404/// \param mask
4405/// A 256-bit vector of [8 x i32] containing the mask. The most significant
4406/// bit of each element in the mask vector represents the mask bits. If a
4407/// mask bit is zero, the corresponding value from vector \a a is gathered;
4408/// otherwise the value is loaded from memory.
4409/// \param s
4410/// A literal constant scale factor for the indexes in \a i. Must be
4411/// 1, 2, 4, or 8.
4412/// \returns A 256-bit vector of [8 x i32] containing the gathered values.
9924413#define _mm256_mask_i32gather_epi32(a, m, i, mask, s) \
9934414 ((__m256i)__builtin_ia32_gatherd_d256((__v8si)(__m256i)(a), \
9944415 (int const *)(m), \
9954416 (__v8si)(__m256i)(i), \
9964417 (__v8si)(__m256i)(mask), (s)))
9974418
4419/// Conditionally gathers two 32-bit integer values, either from the
4420/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4421/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4422/// of [4 x i32] in \a mask determines the source for the lower two
4423/// elements. The upper two elements of the result are zeroed.
4424///
4425/// \code{.operation}
4426/// FOR element := 0 to 1
4427/// j := element*32
4428/// k := element*64
4429/// IF mask[j+31] == 0
4430/// result[j+31:j] := a[j+31:j]
4431/// ELSE
4432/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4433/// FI
4434/// ENDFOR
4435/// result[127:64] := 0
4436/// \endcode
4437///
4438/// \headerfile <immintrin.h>
4439///
4440/// \code
4441/// __m128i _mm_mask_i64gather_epi32(__m128i a, const int *m, __m128i i,
4442/// __m128i mask, const int s);
4443/// \endcode
4444///
4445/// This intrinsic corresponds to the \c VPGATHERQD instruction.
4446///
4447/// \param a
4448/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4449/// zero. Only the first two elements are used.
4450/// \param m
4451/// A pointer to the memory used for loading values.
4452/// \param i
4453/// A 128-bit vector of [2 x i64] containing indexes into \a m.
4454/// \param mask
4455/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4456/// bit of each element in the mask vector represents the mask bits. If a
4457/// mask bit is zero, the corresponding value from vector \a a is gathered;
4458/// otherwise the value is loaded from memory. Only the first two elements
4459/// are used.
4460/// \param s
4461/// A literal constant scale factor for the indexes in \a i. Must be
4462/// 1, 2, 4, or 8.
4463/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
9984464#define _mm_mask_i64gather_epi32(a, m, i, mask, s) \
9994465 ((__m128i)__builtin_ia32_gatherq_d((__v4si)(__m128i)(a), \
10004466 (int const *)(m), \
10014467 (__v2di)(__m128i)(i), \
10024468 (__v4si)(__m128i)(mask), (s)))
10034469
4470/// Conditionally gathers four 32-bit integer values, either from the
4471/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4472/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector
4473/// of [4 x i32] in \a mask determines the source for each element.
4474///
4475/// \code{.operation}
4476/// FOR element := 0 to 3
4477/// j := element*32
4478/// k := element*64
4479/// IF mask[j+31] == 0
4480/// result[j+31:j] := a[j+31:j]
4481/// ELSE
4482/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4483/// FI
4484/// ENDFOR
4485/// \endcode
4486///
4487/// \headerfile <immintrin.h>
4488///
4489/// \code
4490/// __m128i _mm256_mask_i64gather_epi32(__m128i a, const int *m, __m256i i,
4491/// __m128i mask, const int s);
4492/// \endcode
4493///
4494/// This intrinsic corresponds to the \c VPGATHERQD instruction.
4495///
4496/// \param a
4497/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4498/// zero.
4499/// \param m
4500/// A pointer to the memory used for loading values.
4501/// \param i
4502/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4503/// \param mask
4504/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4505/// bit of each element in the mask vector represents the mask bits. If a
4506/// mask bit is zero, the corresponding value from vector \a a is gathered;
4507/// otherwise the value is loaded from memory.
4508/// \param s
4509/// A literal constant scale factor for the indexes in \a i. Must be
4510/// 1, 2, 4, or 8.
4511/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
10044512#define _mm256_mask_i64gather_epi32(a, m, i, mask, s) \
10054513 ((__m128i)__builtin_ia32_gatherq_d256((__v4si)(__m128i)(a), \
10064514 (int const *)(m), \
10074515 (__v4di)(__m256i)(i), \
10084516 (__v4si)(__m128i)(mask), (s)))
10094517
4518/// Conditionally gathers two 64-bit integer values, either from the
4519/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled
4520/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4521/// of [2 x i64] in \a mask determines the source for each element.
4522///
4523/// \code{.operation}
4524/// FOR element := 0 to 1
4525/// j := element*64
4526/// k := element*32
4527/// IF mask[j+63] == 0
4528/// result[j+63:j] := a[j+63:j]
4529/// ELSE
4530/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4531/// FI
4532/// ENDFOR
4533/// \endcode
4534///
4535/// \headerfile <immintrin.h>
4536///
4537/// \code
4538/// __m128i _mm_mask_i32gather_epi64(__m128i a, const long long *m, __m128i i,
4539/// __m128i mask, const int s);
4540/// \endcode
4541///
4542/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
4543///
4544/// \param a
4545/// A 128-bit vector of [2 x i64] used as the source when a mask bit is
4546/// zero.
4547/// \param m
4548/// A pointer to the memory used for loading values.
4549/// \param i
4550/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
4551/// the first two elements are used.
4552/// \param mask
4553/// A 128-bit vector of [2 x i64] containing the mask. The most significant
4554/// bit of each element in the mask vector represents the mask bits. If a
4555/// mask bit is zero, the corresponding value from vector \a a is gathered;
4556/// otherwise the value is loaded from memory.
4557/// \param s
4558/// A literal constant scale factor for the indexes in \a i. Must be
4559/// 1, 2, 4, or 8.
4560/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
10104561#define _mm_mask_i32gather_epi64(a, m, i, mask, s) \
10114562 ((__m128i)__builtin_ia32_gatherd_q((__v2di)(__m128i)(a), \
10124563 (long long const *)(m), \
10134564 (__v4si)(__m128i)(i), \
10144565 (__v2di)(__m128i)(mask), (s)))
10154566
4567/// Conditionally gathers four 64-bit integer values, either from the
4568/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled
4569/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector
4570/// of [4 x i64] in \a mask determines the source for each element.
4571///
4572/// \code{.operation}
4573/// FOR element := 0 to 3
4574/// j := element*64
4575/// k := element*32
4576/// IF mask[j+63] == 0
4577/// result[j+63:j] := a[j+63:j]
4578/// ELSE
4579/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4580/// FI
4581/// ENDFOR
4582/// \endcode
4583///
4584/// \headerfile <immintrin.h>
4585///
4586/// \code
4587/// __m256i _mm256_mask_i32gather_epi64(__m256i a, const long long *m,
4588/// __m128i i, __m256i mask, const int s);
4589/// \endcode
4590///
4591/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
4592///
4593/// \param a
4594/// A 256-bit vector of [4 x i64] used as the source when a mask bit is
4595/// zero.
4596/// \param m
4597/// A pointer to the memory used for loading values.
4598/// \param i
4599/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4600/// \param mask
4601/// A 256-bit vector of [4 x i64] containing the mask. The most significant
4602/// bit of each element in the mask vector represents the mask bits. If a
4603/// mask bit is zero, the corresponding value from vector \a a is gathered;
4604/// otherwise the value is loaded from memory.
4605/// \param s
4606/// A literal constant scale factor for the indexes in \a i. Must be
4607/// 1, 2, 4, or 8.
4608/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
10164609#define _mm256_mask_i32gather_epi64(a, m, i, mask, s) \
10174610 ((__m256i)__builtin_ia32_gatherd_q256((__v4di)(__m256i)(a), \
10184611 (long long const *)(m), \
10194612 (__v4si)(__m128i)(i), \
10204613 (__v4di)(__m256i)(mask), (s)))
10214614
4615/// Conditionally gathers two 64-bit integer values, either from the
4616/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled
4617/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4618/// of [2 x i64] in \a mask determines the source for each element.
4619///
4620/// \code{.operation}
4621/// FOR element := 0 to 1
4622/// j := element*64
4623/// k := element*64
4624/// IF mask[j+63] == 0
4625/// result[j+63:j] := a[j+63:j]
4626/// ELSE
4627/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4628/// FI
4629/// ENDFOR
4630/// \endcode
4631///
4632/// \headerfile <immintrin.h>
4633///
4634/// \code
4635/// __m128i _mm_mask_i64gather_epi64(__m128i a, const long long *m, __m128i i,
4636/// __m128i mask, const int s);
4637/// \endcode
4638///
4639/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
4640///
4641/// \param a
4642/// A 128-bit vector of [2 x i64] used as the source when a mask bit is
4643/// zero.
4644/// \param m
4645/// A pointer to the memory used for loading values.
4646/// \param i
4647/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4648/// \param mask
4649/// A 128-bit vector of [2 x i64] containing the mask. The most significant
4650/// bit of each element in the mask vector represents the mask bits. If a
4651/// mask bit is zero, the corresponding value from vector \a a is gathered;
4652/// otherwise the value is loaded from memory.
4653/// \param s
4654/// A literal constant scale factor for the indexes in \a i. Must be
4655/// 1, 2, 4, or 8.
4656/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
10224657#define _mm_mask_i64gather_epi64(a, m, i, mask, s) \
10234658 ((__m128i)__builtin_ia32_gatherq_q((__v2di)(__m128i)(a), \
10244659 (long long const *)(m), \
10254660 (__v2di)(__m128i)(i), \
10264661 (__v2di)(__m128i)(mask), (s)))
10274662
4663/// Conditionally gathers four 64-bit integer values, either from the
4664/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled
4665/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector
4666/// of [4 x i64] in \a mask determines the source for each element.
4667///
4668/// \code{.operation}
4669/// FOR element := 0 to 3
4670/// j := element*64
4671/// k := element*64
4672/// IF mask[j+63] == 0
4673/// result[j+63:j] := a[j+63:j]
4674/// ELSE
4675/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4676/// FI
4677/// ENDFOR
4678/// \endcode
4679///
4680/// \headerfile <immintrin.h>
4681///
4682/// \code
4683/// __m256i _mm256_mask_i64gather_epi64(__m256i a, const long long *m,
4684/// __m256i i, __m256i mask, const int s);
4685/// \endcode
4686///
4687/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
4688///
4689/// \param a
4690/// A 256-bit vector of [4 x i64] used as the source when a mask bit is
4691/// zero.
4692/// \param m
4693/// A pointer to the memory used for loading values.
4694/// \param i
4695/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4696/// \param mask
4697/// A 256-bit vector of [4 x i64] containing the mask. The most significant
4698/// bit of each element in the mask vector represents the mask bits. If a
4699/// mask bit is zero, the corresponding value from vector \a a is gathered;
4700/// otherwise the value is loaded from memory.
4701/// \param s
4702/// A literal constant scale factor for the indexes in \a i. Must be
4703/// 1, 2, 4, or 8.
4704/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
10284705#define _mm256_mask_i64gather_epi64(a, m, i, mask, s) \
10294706 ((__m256i)__builtin_ia32_gatherq_q256((__v4di)(__m256i)(a), \
10304707 (long long const *)(m), \
10314708 (__v4di)(__m256i)(i), \
10324709 (__v4di)(__m256i)(mask), (s)))
10334710
4711/// Gathers two 64-bit floating-point values from memory \a m using scaled
4712/// indexes from the 128-bit vector of [4 x i32] in \a i.
4713///
4714/// \code{.operation}
4715/// FOR element := 0 to 1
4716/// j := element*64
4717/// k := element*32
4718/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4719/// ENDFOR
4720/// \endcode
4721///
4722/// \headerfile <immintrin.h>
4723///
4724/// \code
4725/// __m128d _mm_i32gather_pd(const double *m, __m128i i, const int s);
4726/// \endcode
4727///
4728/// This intrinsic corresponds to the \c VGATHERDPD instruction.
4729///
4730/// \param m
4731/// A pointer to the memory used for loading values.
4732/// \param i
4733/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
4734/// the first two elements are used.
4735/// \param s
4736/// A literal constant scale factor for the indexes in \a i. Must be
4737/// 1, 2, 4, or 8.
4738/// \returns A 128-bit vector of [2 x double] containing the gathered values.
10344739#define _mm_i32gather_pd(m, i, s) \
10354740 ((__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_undefined_pd(), \
10364741 (double const *)(m), \
......@@ -1039,6 +4744,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10394744 _mm_setzero_pd()), \
10404745 (s)))
10414746
4747/// Gathers four 64-bit floating-point values from memory \a m using scaled
4748/// indexes from the 128-bit vector of [4 x i32] in \a i.
4749///
4750/// \code{.operation}
4751/// FOR element := 0 to 3
4752/// j := element*64
4753/// k := element*32
4754/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4755/// ENDFOR
4756/// \endcode
4757///
4758/// \headerfile <immintrin.h>
4759///
4760/// \code
4761/// __m256d _mm256_i32gather_pd(const double *m, __m128i i, const int s);
4762/// \endcode
4763///
4764/// This intrinsic corresponds to the \c VGATHERDPD instruction.
4765///
4766/// \param m
4767/// A pointer to the memory used for loading values.
4768/// \param i
4769/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4770/// \param s
4771/// A literal constant scale factor for the indexes in \a i. Must be
4772/// 1, 2, 4, or 8.
4773/// \returns A 256-bit vector of [4 x double] containing the gathered values.
10424774#define _mm256_i32gather_pd(m, i, s) \
10434775 ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_undefined_pd(), \
10444776 (double const *)(m), \
......@@ -1048,6 +4780,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10484780 _CMP_EQ_OQ), \
10494781 (s)))
10504782
4783/// Gathers two 64-bit floating-point values from memory \a m using scaled
4784/// indexes from the 128-bit vector of [2 x i64] in \a i.
4785///
4786/// \code{.operation}
4787/// FOR element := 0 to 1
4788/// j := element*64
4789/// k := element*64
4790/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4791/// ENDFOR
4792/// \endcode
4793///
4794/// \headerfile <immintrin.h>
4795///
4796/// \code
4797/// __m128d _mm_i64gather_pd(const double *m, __m128i i, const int s);
4798/// \endcode
4799///
4800/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4801///
4802/// \param m
4803/// A pointer to the memory used for loading values.
4804/// \param i
4805/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4806/// \param s
4807/// A literal constant scale factor for the indexes in \a i. Must be
4808/// 1, 2, 4, or 8.
4809/// \returns A 128-bit vector of [2 x double] containing the gathered values.
10514810#define _mm_i64gather_pd(m, i, s) \
10524811 ((__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_undefined_pd(), \
10534812 (double const *)(m), \
......@@ -1056,6 +4815,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10564815 _mm_setzero_pd()), \
10574816 (s)))
10584817
4818/// Gathers four 64-bit floating-point values from memory \a m using scaled
4819/// indexes from the 256-bit vector of [4 x i64] in \a i.
4820///
4821/// \code{.operation}
4822/// FOR element := 0 to 3
4823/// j := element*64
4824/// k := element*64
4825/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4826/// ENDFOR
4827/// \endcode
4828///
4829/// \headerfile <immintrin.h>
4830///
4831/// \code
4832/// __m256d _mm256_i64gather_pd(const double *m, __m256i i, const int s);
4833/// \endcode
4834///
4835/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4836///
4837/// \param m
4838/// A pointer to the memory used for loading values.
4839/// \param i
4840/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4841/// \param s
4842/// A literal constant scale factor for the indexes in \a i. Must be
4843/// 1, 2, 4, or 8.
4844/// \returns A 256-bit vector of [4 x double] containing the gathered values.
10594845#define _mm256_i64gather_pd(m, i, s) \
10604846 ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_undefined_pd(), \
10614847 (double const *)(m), \
......@@ -1065,6 +4851,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10654851 _CMP_EQ_OQ), \
10664852 (s)))
10674853
4854/// Gathers four 32-bit floating-point values from memory \a m using scaled
4855/// indexes from the 128-bit vector of [4 x i32] in \a i.
4856///
4857/// \code{.operation}
4858/// FOR element := 0 to 3
4859/// j := element*32
4860/// k := element*32
4861/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4862/// ENDFOR
4863/// \endcode
4864///
4865/// \headerfile <immintrin.h>
4866///
4867/// \code
4868/// __m128 _mm_i32gather_ps(const float *m, __m128i i, const int s);
4869/// \endcode
4870///
4871/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4872///
4873/// \param m
4874/// A pointer to the memory used for loading values.
4875/// \param i
4876/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4877/// \param s
4878/// A literal constant scale factor for the indexes in \a i. Must be
4879/// 1, 2, 4, or 8.
4880/// \returns A 128-bit vector of [4 x float] containing the gathered values.
10684881#define _mm_i32gather_ps(m, i, s) \
10694882 ((__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_undefined_ps(), \
10704883 (float const *)(m), \
......@@ -1073,6 +4886,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10734886 _mm_setzero_ps()), \
10744887 (s)))
10754888
4889/// Gathers eight 32-bit floating-point values from memory \a m using scaled
4890/// indexes from the 256-bit vector of [8 x i32] in \a i.
4891///
4892/// \code{.operation}
4893/// FOR element := 0 to 7
4894/// j := element*32
4895/// k := element*32
4896/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4897/// ENDFOR
4898/// \endcode
4899///
4900/// \headerfile <immintrin.h>
4901///
4902/// \code
4903/// __m256 _mm256_i32gather_ps(const float *m, __m256i i, const int s);
4904/// \endcode
4905///
4906/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4907///
4908/// \param m
4909/// A pointer to the memory used for loading values.
4910/// \param i
4911/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4912/// \param s
4913/// A literal constant scale factor for the indexes in \a i. Must be
4914/// 1, 2, 4, or 8.
4915/// \returns A 256-bit vector of [8 x float] containing the gathered values.
10764916#define _mm256_i32gather_ps(m, i, s) \
10774917 ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_undefined_ps(), \
10784918 (float const *)(m), \
......@@ -1082,6 +4922,35 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10824922 _CMP_EQ_OQ), \
10834923 (s)))
10844924
4925/// Gathers two 32-bit floating-point values from memory \a m using scaled
4926/// indexes from the 128-bit vector of [2 x i64] in \a i. The upper two
4927/// elements of the result are zeroed.
4928///
4929/// \code{.operation}
4930/// FOR element := 0 to 1
4931/// j := element*32
4932/// k := element*64
4933/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4934/// ENDFOR
4935/// result[127:64] := 0
4936/// \endcode
4937///
4938/// \headerfile <immintrin.h>
4939///
4940/// \code
4941/// __m128 _mm_i64gather_ps(const float *m, __m128i i, const int s);
4942/// \endcode
4943///
4944/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4945///
4946/// \param m
4947/// A pointer to the memory used for loading values.
4948/// \param i
4949/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4950/// \param s
4951/// A literal constant scale factor for the indexes in \a i. Must be
4952/// 1, 2, 4, or 8.
4953/// \returns A 128-bit vector of [4 x float] containing the gathered values.
10854954#define _mm_i64gather_ps(m, i, s) \
10864955 ((__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_undefined_ps(), \
10874956 (float const *)(m), \
......@@ -1090,6 +4959,33 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10904959 _mm_setzero_ps()), \
10914960 (s)))
10924961
4962/// Gathers four 32-bit floating-point values from memory \a m using scaled
4963/// indexes from the 256-bit vector of [4 x i64] in \a i.
4964///
4965/// \code{.operation}
4966/// FOR element := 0 to 3
4967/// j := element*32
4968/// k := element*64
4969/// result[j+31:j] := Load32(m + SignExtend(i[k+64:k])*s)
4970/// ENDFOR
4971/// \endcode
4972///
4973/// \headerfile <immintrin.h>
4974///
4975/// \code
4976/// __m128 _mm256_i64gather_ps(const float *m, __m256i i, const int s);
4977/// \endcode
4978///
4979/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4980///
4981/// \param m
4982/// A pointer to the memory used for loading values.
4983/// \param i
4984/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4985/// \param s
4986/// A literal constant scale factor for the indexes in \a i. Must be
4987/// 1, 2, 4, or 8.
4988/// \returns A 128-bit vector of [4 x float] containing the gathered values.
10934989#define _mm256_i64gather_ps(m, i, s) \
10944990 ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_undefined_ps(), \
10954991 (float const *)(m), \
......@@ -1098,44 +4994,263 @@ _mm_srlv_epi64(__m128i __X, __m128i __Y)
10984994 _mm_setzero_ps()), \
10994995 (s)))
11004996
4997/// Gathers four 32-bit floating-point values from memory \a m using scaled
4998/// indexes from the 128-bit vector of [4 x i32] in \a i.
4999///
5000/// \code{.operation}
5001/// FOR element := 0 to 3
5002/// j := element*32
5003/// k := element*32
5004/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
5005/// ENDFOR
5006/// \endcode
5007///
5008/// \headerfile <immintrin.h>
5009///
5010/// \code
5011/// __m128i _mm_i32gather_epi32(const int *m, __m128i i, const int s);
5012/// \endcode
5013///
5014/// This intrinsic corresponds to the \c VPGATHERDD instruction.
5015///
5016/// \param m
5017/// A pointer to the memory used for loading values.
5018/// \param i
5019/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
5020/// \param s
5021/// A literal constant scale factor for the indexes in \a i. Must be
5022/// 1, 2, 4, or 8.
5023/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
11015024#define _mm_i32gather_epi32(m, i, s) \
11025025 ((__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_undefined_si128(), \
11035026 (int const *)(m), (__v4si)(__m128i)(i), \
11045027 (__v4si)_mm_set1_epi32(-1), (s)))
11055028
5029/// Gathers eight 32-bit floating-point values from memory \a m using scaled
5030/// indexes from the 256-bit vector of [8 x i32] in \a i.
5031///
5032/// \code{.operation}
5033/// FOR element := 0 to 7
5034/// j := element*32
5035/// k := element*32
5036/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
5037/// ENDFOR
5038/// \endcode
5039///
5040/// \headerfile <immintrin.h>
5041///
5042/// \code
5043/// __m256i _mm256_i32gather_epi32(const int *m, __m256i i, const int s);
5044/// \endcode
5045///
5046/// This intrinsic corresponds to the \c VPGATHERDD instruction.
5047///
5048/// \param m
5049/// A pointer to the memory used for loading values.
5050/// \param i
5051/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
5052/// \param s
5053/// A literal constant scale factor for the indexes in \a i. Must be
5054/// 1, 2, 4, or 8.
5055/// \returns A 256-bit vector of [8 x i32] containing the gathered values.
11065056#define _mm256_i32gather_epi32(m, i, s) \
11075057 ((__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_undefined_si256(), \
11085058 (int const *)(m), (__v8si)(__m256i)(i), \
11095059 (__v8si)_mm256_set1_epi32(-1), (s)))
11105060
5061/// Gathers two 32-bit integer values from memory \a m using scaled indexes
5062/// from the 128-bit vector of [2 x i64] in \a i. The upper two elements
5063/// of the result are zeroed.
5064///
5065/// \code{.operation}
5066/// FOR element := 0 to 1
5067/// j := element*32
5068/// k := element*64
5069/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
5070/// ENDFOR
5071/// result[127:64] := 0
5072/// \endcode
5073///
5074/// \headerfile <immintrin.h>
5075///
5076/// \code
5077/// __m128i _mm_i64gather_epi32(const int *m, __m128i i, const int s);
5078/// \endcode
5079///
5080/// This intrinsic corresponds to the \c VPGATHERQD instruction.
5081///
5082/// \param m
5083/// A pointer to the memory used for loading values.
5084/// \param i
5085/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
5086/// \param s
5087/// A literal constant scale factor for the indexes in \a i. Must be
5088/// 1, 2, 4, or 8.
5089/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
11115090#define _mm_i64gather_epi32(m, i, s) \
11125091 ((__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_undefined_si128(), \
11135092 (int const *)(m), (__v2di)(__m128i)(i), \
11145093 (__v4si)_mm_set1_epi32(-1), (s)))
11155094
5095/// Gathers four 32-bit integer values from memory \a m using scaled indexes
5096/// from the 256-bit vector of [4 x i64] in \a i.
5097///
5098/// \code{.operation}
5099/// FOR element := 0 to 3
5100/// j := element*32
5101/// k := element*64
5102/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
5103/// ENDFOR
5104/// \endcode
5105///
5106/// \headerfile <immintrin.h>
5107///
5108/// \code
5109/// __m128i _mm256_i64gather_epi32(const int *m, __m256i i, const int s);
5110/// \endcode
5111///
5112/// This intrinsic corresponds to the \c VPGATHERQD instruction.
5113///
5114/// \param m
5115/// A pointer to the memory used for loading values.
5116/// \param i
5117/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
5118/// \param s
5119/// A literal constant scale factor for the indexes in \a i. Must be
5120/// 1, 2, 4, or 8.
5121/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
11165122#define _mm256_i64gather_epi32(m, i, s) \
11175123 ((__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_undefined_si128(), \
11185124 (int const *)(m), (__v4di)(__m256i)(i), \
11195125 (__v4si)_mm_set1_epi32(-1), (s)))
11205126
5127/// Gathers two 64-bit integer values from memory \a m using scaled indexes
5128/// from the 128-bit vector of [4 x i32] in \a i.
5129///
5130/// \code{.operation}
5131/// FOR element := 0 to 1
5132/// j := element*64
5133/// k := element*32
5134/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
5135/// ENDFOR
5136/// \endcode
5137///
5138/// \headerfile <immintrin.h>
5139///
5140/// \code
5141/// __m128i _mm_i32gather_epi64(const long long *m, __m128i i, const int s);
5142/// \endcode
5143///
5144/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
5145///
5146/// \param m
5147/// A pointer to the memory used for loading values.
5148/// \param i
5149/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
5150/// the first two elements are used.
5151/// \param s
5152/// A literal constant scale factor for the indexes in \a i. Must be
5153/// 1, 2, 4, or 8.
5154/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
11215155#define _mm_i32gather_epi64(m, i, s) \
11225156 ((__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_undefined_si128(), \
11235157 (long long const *)(m), \
11245158 (__v4si)(__m128i)(i), \
11255159 (__v2di)_mm_set1_epi64x(-1), (s)))
11265160
5161/// Gathers four 64-bit integer values from memory \a m using scaled indexes
5162/// from the 128-bit vector of [4 x i32] in \a i.
5163///
5164/// \code{.operation}
5165/// FOR element := 0 to 3
5166/// j := element*64
5167/// k := element*32
5168/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
5169/// ENDFOR
5170/// \endcode
5171///
5172/// \headerfile <immintrin.h>
5173///
5174/// \code
5175/// __m256i _mm256_i32gather_epi64(const long long *m, __m128i i, const int s);
5176/// \endcode
5177///
5178/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
5179///
5180/// \param m
5181/// A pointer to the memory used for loading values.
5182/// \param i
5183/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
5184/// \param s
5185/// A literal constant scale factor for the indexes in \a i. Must be
5186/// 1, 2, 4, or 8.
5187/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
11275188#define _mm256_i32gather_epi64(m, i, s) \
11285189 ((__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_undefined_si256(), \
11295190 (long long const *)(m), \
11305191 (__v4si)(__m128i)(i), \
11315192 (__v4di)_mm256_set1_epi64x(-1), (s)))
11325193
5194/// Gathers two 64-bit integer values from memory \a m using scaled indexes
5195/// from the 128-bit vector of [2 x i64] in \a i.
5196///
5197/// \code{.operation}
5198/// FOR element := 0 to 1
5199/// j := element*64
5200/// k := element*64
5201/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
5202/// ENDFOR
5203/// \endcode
5204///
5205/// \headerfile <immintrin.h>
5206///
5207/// \code
5208/// __m128i _mm_i64gather_epi64(const long long *m, __m128i i, const int s);
5209/// \endcode
5210///
5211/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
5212///
5213/// \param m
5214/// A pointer to the memory used for loading values.
5215/// \param i
5216/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
5217/// \param s
5218/// A literal constant scale factor for the indexes in \a i. Must be
5219/// 1, 2, 4, or 8.
5220/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
11335221#define _mm_i64gather_epi64(m, i, s) \
11345222 ((__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_undefined_si128(), \
11355223 (long long const *)(m), \
11365224 (__v2di)(__m128i)(i), \
11375225 (__v2di)_mm_set1_epi64x(-1), (s)))
11385226
5227/// Gathers four 64-bit integer values from memory \a m using scaled indexes
5228/// from the 256-bit vector of [4 x i64] in \a i.
5229///
5230/// \code{.operation}
5231/// FOR element := 0 to 3
5232/// j := element*64
5233/// k := element*64
5234/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
5235/// ENDFOR
5236/// \endcode
5237///
5238/// \headerfile <immintrin.h>
5239///
5240/// \code
5241/// __m256i _mm256_i64gather_epi64(const long long *m, __m256i i, const int s);
5242/// \endcode
5243///
5244/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
5245///
5246/// \param m
5247/// A pointer to the memory used for loading values.
5248/// \param i
5249/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
5250/// \param s
5251/// A literal constant scale factor for the indexes in \a i. Must be
5252/// 1, 2, 4, or 8.
5253/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
11395254#define _mm256_i64gather_epi64(m, i, s) \
11405255 ((__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_undefined_si256(), \
11415256 (long long const *)(m), \
lib/include/avx512fintrin.h+17-7
......@@ -397,14 +397,15 @@ _mm512_broadcastsd_pd(__m128d __A)
397397static __inline __m512d __DEFAULT_FN_ATTRS512
398398_mm512_castpd256_pd512(__m256d __a)
399399{
400 return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, -1, -1, -1, -1);
400 return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0,
401 1, 2, 3, 4, 5, 6, 7);
401402}
402403
403404static __inline __m512 __DEFAULT_FN_ATTRS512
404405_mm512_castps256_ps512(__m256 __a)
405406{
406 return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7,
407 -1, -1, -1, -1, -1, -1, -1, -1);
407 return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0,
408 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
408409}
409410
410411static __inline __m128d __DEFAULT_FN_ATTRS512
......@@ -446,7 +447,10 @@ _mm512_castpd_si512 (__m512d __A)
446447static __inline__ __m512d __DEFAULT_FN_ATTRS512
447448_mm512_castpd128_pd512 (__m128d __A)
448449{
449 return __builtin_shufflevector( __A, __A, 0, 1, -1, -1, -1, -1, -1, -1);
450 __m256d __B = __builtin_nondeterministic_value(__B);
451 return __builtin_shufflevector(
452 __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3),
453 __B, 0, 1, 2, 3, 4, 5, 6, 7);
450454}
451455
452456static __inline __m512d __DEFAULT_FN_ATTRS512
......@@ -464,19 +468,25 @@ _mm512_castps_si512 (__m512 __A)
464468static __inline__ __m512 __DEFAULT_FN_ATTRS512
465469_mm512_castps128_ps512 (__m128 __A)
466470{
467 return __builtin_shufflevector( __A, __A, 0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
471 __m256 __B = __builtin_nondeterministic_value(__B);
472 return __builtin_shufflevector(
473 __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3, 4, 5, 6, 7),
474 __B, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
468475}
469476
470477static __inline__ __m512i __DEFAULT_FN_ATTRS512
471478_mm512_castsi128_si512 (__m128i __A)
472479{
473 return __builtin_shufflevector( __A, __A, 0, 1, -1, -1, -1, -1, -1, -1);
480 __m256i __B = __builtin_nondeterministic_value(__B);
481 return __builtin_shufflevector(
482 __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3),
483 __B, 0, 1, 2, 3, 4, 5, 6, 7);
474484}
475485
476486static __inline__ __m512i __DEFAULT_FN_ATTRS512
477487_mm512_castsi256_si512 (__m256i __A)
478488{
479 return __builtin_shufflevector( __A, __A, 0, 1, 2, 3, -1, -1, -1, -1);
489 return __builtin_shufflevector( __A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3, 4, 5, 6, 7);
480490}
481491
482492static __inline __m512 __DEFAULT_FN_ATTRS512
lib/include/avx512fp16intrin.h+12-8
......@@ -192,22 +192,26 @@ _mm512_castph512_ph256(__m512h __a) {
192192
193193static __inline__ __m256h __DEFAULT_FN_ATTRS256
194194_mm256_castph128_ph256(__m128h __a) {
195 return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1,
196 -1, -1, -1, -1, -1);
195 return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a),
196 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
197197}
198198
199199static __inline__ __m512h __DEFAULT_FN_ATTRS512
200200_mm512_castph128_ph512(__m128h __a) {
201 return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1,
202 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
203 -1, -1, -1, -1, -1, -1, -1, -1, -1);
201 __m256h __b = __builtin_nondeterministic_value(__b);
202 return __builtin_shufflevector(
203 __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a),
204 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
205 __b, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
206 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
204207}
205208
206209static __inline__ __m512h __DEFAULT_FN_ATTRS512
207210_mm512_castph256_ph512(__m256h __a) {
208 return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
209 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1,
210 -1, -1, -1, -1, -1, -1, -1, -1);
211 return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0,
212 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
213 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
214 27, 28, 29, 30, 31);
211215}
212216
213217/// Constructs a 256-bit floating-point vector of [16 x half] from a
lib/include/avxintrin.h+20-7
......@@ -3017,8 +3017,11 @@ _mm256_zeroupper(void)
30173017static __inline __m128 __DEFAULT_FN_ATTRS128
30183018_mm_broadcast_ss(float const *__a)
30193019{
3020 float __f = *__a;
3021 return __extension__ (__m128)(__v4sf){ __f, __f, __f, __f };
3020 struct __mm_broadcast_ss_struct {
3021 float __f;
3022 } __attribute__((__packed__, __may_alias__));
3023 float __f = ((const struct __mm_broadcast_ss_struct*)__a)->__f;
3024 return __extension__ (__m128){ __f, __f, __f, __f };
30223025}
30233026
30243027/// Loads a scalar double-precision floating point value from the
......@@ -3036,7 +3039,10 @@ _mm_broadcast_ss(float const *__a)
30363039static __inline __m256d __DEFAULT_FN_ATTRS
30373040_mm256_broadcast_sd(double const *__a)
30383041{
3039 double __d = *__a;
3042 struct __mm256_broadcast_sd_struct {
3043 double __d;
3044 } __attribute__((__packed__, __may_alias__));
3045 double __d = ((const struct __mm256_broadcast_sd_struct*)__a)->__d;
30403046 return __extension__ (__m256d)(__v4df){ __d, __d, __d, __d };
30413047}
30423048
......@@ -3055,7 +3061,10 @@ _mm256_broadcast_sd(double const *__a)
30553061static __inline __m256 __DEFAULT_FN_ATTRS
30563062_mm256_broadcast_ss(float const *__a)
30573063{
3058 float __f = *__a;
3064 struct __mm256_broadcast_ss_struct {
3065 float __f;
3066 } __attribute__((__packed__, __may_alias__));
3067 float __f = ((const struct __mm256_broadcast_ss_struct*)__a)->__f;
30593068 return __extension__ (__m256)(__v8sf){ __f, __f, __f, __f, __f, __f, __f, __f };
30603069}
30613070
......@@ -4499,7 +4508,8 @@ _mm256_castsi256_si128(__m256i __a)
44994508static __inline __m256d __DEFAULT_FN_ATTRS
45004509_mm256_castpd128_pd256(__m128d __a)
45014510{
4502 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 1, -1, -1);
4511 return __builtin_shufflevector(
4512 (__v2df)__a, (__v2df)__builtin_nondeterministic_value(__a), 0, 1, 2, 3);
45034513}
45044514
45054515/// Constructs a 256-bit floating-point vector of [8 x float] from a
......@@ -4520,7 +4530,9 @@ _mm256_castpd128_pd256(__m128d __a)
45204530static __inline __m256 __DEFAULT_FN_ATTRS
45214531_mm256_castps128_ps256(__m128 __a)
45224532{
4523 return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1, 2, 3, -1, -1, -1, -1);
4533 return __builtin_shufflevector((__v4sf)__a,
4534 (__v4sf)__builtin_nondeterministic_value(__a),
4535 0, 1, 2, 3, 4, 5, 6, 7);
45244536}
45254537
45264538/// Constructs a 256-bit integer vector from a 128-bit integer vector.
......@@ -4539,7 +4551,8 @@ _mm256_castps128_ps256(__m128 __a)
45394551static __inline __m256i __DEFAULT_FN_ATTRS
45404552_mm256_castsi128_si256(__m128i __a)
45414553{
4542 return __builtin_shufflevector((__v2di)__a, (__v2di)__a, 0, 1, -1, -1);
4554 return __builtin_shufflevector(
4555 (__v2di)__a, (__v2di)__builtin_nondeterministic_value(__a), 0, 1, 2, 3);
45434556}
45444557
45454558/// Constructs a 256-bit floating-point vector of [4 x double] from a
lib/include/avxvnniint16intrin.h created+473
......@@ -0,0 +1,473 @@
1/*===----------- avxvnniint16intrin.h - AVXVNNIINT16 intrinsics-------------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __IMMINTRIN_H
11#error \
12 "Never use <avxvnniint16intrin.h> directly; include <immintrin.h> instead."
13#endif // __IMMINTRIN_H
14
15#ifndef __AVXVNNIINT16INTRIN_H
16#define __AVXVNNIINT16INTRIN_H
17
18/* Define the default attributes for the functions in this file. */
19#define __DEFAULT_FN_ATTRS128 \
20 __attribute__((__always_inline__, __nodebug__, __target__("avxvnniint16"), \
21 __min_vector_width__(128)))
22#define __DEFAULT_FN_ATTRS256 \
23 __attribute__((__always_inline__, __nodebug__, __target__("avxvnniint16"), \
24 __min_vector_width__(256)))
25
26/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
27/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
28/// signed 16-bit results. Sum these 2 results with the corresponding
29/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
30///
31/// \headerfile <immintrin.h>
32///
33/// \code
34/// __m128i _mm_dpwsud_epi32(__m128i __W, __m128i __A, __m128i __B)
35/// \endcode
36///
37/// This intrinsic corresponds to the \c VPDPWSUD instruction.
38///
39/// \param __W
40/// A 128-bit vector of [4 x int].
41/// \param __A
42/// A 128-bit vector of [8 x short].
43/// \param __B
44/// A 128-bit vector of [8 x unsigned short].
45/// \returns
46/// A 128-bit vector of [4 x int].
47///
48/// \code{.operation}
49/// FOR j := 0 to 3
50/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
51/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
52/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
53/// ENDFOR
54/// dst[MAX:128] := 0
55/// \endcode
56static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwsud_epi32(__m128i __W,
57 __m128i __A,
58 __m128i __B) {
59 return (__m128i)__builtin_ia32_vpdpwsud128((__v4si)__W, (__v4si)__A,
60 (__v4si)__B);
61}
62
63/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
64/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
65/// signed 16-bit results. Sum these 2 results with the corresponding
66/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
67///
68/// \headerfile <immintrin.h>
69///
70/// \code
71/// __m256i _mm256_dpwsud_epi32(__m256i __W, __m256i __A, __m256i __B)
72/// \endcode
73///
74/// This intrinsic corresponds to the \c VPDPWSUD instruction.
75///
76/// \param __W
77/// A 256-bit vector of [8 x int].
78/// \param __A
79/// A 256-bit vector of [16 x short].
80/// \param __B
81/// A 256-bit vector of [16 x unsigned short].
82/// \returns
83/// A 256-bit vector of [8 x int].
84///
85/// \code{.operation}
86/// FOR j := 0 to 7
87/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
88/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
89/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
90/// ENDFOR
91/// dst[MAX:256] := 0
92/// \endcode
93static __inline__ __m256i __DEFAULT_FN_ATTRS256
94_mm256_dpwsud_epi32(__m256i __W, __m256i __A, __m256i __B) {
95 return (__m256i)__builtin_ia32_vpdpwsud256((__v8si)__W, (__v8si)__A,
96 (__v8si)__B);
97}
98
99/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
100/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
101/// signed 16-bit results. Sum these 2 results with the corresponding
102/// 32-bit integer in \a __W with signed saturation, and store the packed
103/// 32-bit results in \a dst.
104///
105/// \headerfile <immintrin.h>
106///
107/// \code
108/// __m128i _mm_dpwsuds_epi32(__m128i __W, __m128i __A, __m128i __B)
109/// \endcode
110///
111/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
112///
113/// \param __W
114/// A 128-bit vector of [4 x int].
115/// \param __A
116/// A 128-bit vector of [8 x short].
117/// \param __B
118/// A 128-bit vector of [8 x unsigned short].
119/// \returns
120/// A 128-bit vector of [4 x int].
121///
122/// \code{.operation}
123/// FOR j := 0 to 3
124/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
125/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
126/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
127/// ENDFOR
128/// dst[MAX:128] := 0
129/// \endcode
130static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwsuds_epi32(__m128i __W,
131 __m128i __A,
132 __m128i __B) {
133 return (__m128i)__builtin_ia32_vpdpwsuds128((__v4si)__W, (__v4si)__A,
134 (__v4si)__B);
135}
136
137/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
138/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
139/// signed 16-bit results. Sum these 2 results with the corresponding
140/// 32-bit integer in \a __W with signed saturation, and store the packed
141/// 32-bit results in \a dst.
142///
143/// \headerfile <immintrin.h>
144///
145/// \code
146/// __m256i _mm256_dpwsuds_epi32(__m256i __W, __m256i __A, __m256i __B)
147/// \endcode
148///
149/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
150///
151/// \param __W
152/// A 256-bit vector of [8 x int].
153/// \param __A
154/// A 256-bit vector of [16 x short].
155/// \param __B
156/// A 256-bit vector of [16 x unsigned short].
157/// \returns
158/// A 256-bit vector of [8 x int].
159///
160/// \code{.operation}
161/// FOR j := 0 to 7
162/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
163/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
164/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
165/// ENDFOR
166/// dst[MAX:256] := 0
167/// \endcode
168static __inline__ __m256i __DEFAULT_FN_ATTRS256
169_mm256_dpwsuds_epi32(__m256i __W, __m256i __A, __m256i __B) {
170 return (__m256i)__builtin_ia32_vpdpwsuds256((__v8si)__W, (__v8si)__A,
171 (__v8si)__B);
172}
173
174/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
175/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate
176/// signed 16-bit results. Sum these 2 results with the corresponding
177/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
178///
179/// \headerfile <immintrin.h>
180///
181/// \code
182/// __m128i _mm_dpbusd_epi32(__m128i __W, __m128i __A, __m128i __B)
183/// \endcode
184///
185/// This intrinsic corresponds to the \c VPDPWUSD instruction.
186///
187/// \param __W
188/// A 128-bit vector of [4 x int].
189/// \param __A
190/// A 128-bit vector of [8 x unsigned short].
191/// \param __B
192/// A 128-bit vector of [8 x short].
193/// \returns
194/// A 128-bit vector of [4 x int].
195///
196/// \code{.operation}
197/// FOR j := 0 to 3
198/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
199/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
200/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
201/// ENDFOR
202/// dst[MAX:128] := 0
203/// \endcode
204static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwusd_epi32(__m128i __W,
205 __m128i __A,
206 __m128i __B) {
207 return (__m128i)__builtin_ia32_vpdpwusd128((__v4si)__W, (__v4si)__A,
208 (__v4si)__B);
209}
210
211/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
212/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate
213/// signed 16-bit results. Sum these 2 results with the corresponding
214/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
215///
216/// \headerfile <immintrin.h>
217///
218/// \code
219/// __m256i _mm256_dpwusd_epi32(__m256i __W, __m256i __A, __m256i __B)
220/// \endcode
221///
222/// This intrinsic corresponds to the \c VPDPWUSD instruction.
223///
224/// \param __W
225/// A 256-bit vector of [8 x int].
226/// \param __A
227/// A 256-bit vector of [16 x unsigned short].
228/// \param __B
229/// A 256-bit vector of [16 x short].
230/// \returns
231/// A 256-bit vector of [8 x int].
232///
233/// \code{.operation}
234/// FOR j := 0 to 7
235/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
236/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
237/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
238/// ENDFOR
239/// dst[MAX:256] := 0
240/// \endcode
241static __inline__ __m256i __DEFAULT_FN_ATTRS256
242_mm256_dpwusd_epi32(__m256i __W, __m256i __A, __m256i __B) {
243 return (__m256i)__builtin_ia32_vpdpwusd256((__v8si)__W, (__v8si)__A,
244 (__v8si)__B);
245}
246
247/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
248/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate
249/// signed 16-bit results. Sum these 2 results with the corresponding
250/// 32-bit integer in \a __W with signed saturation, and store the packed
251/// 32-bit results in \a dst.
252///
253/// \headerfile <immintrin.h>
254///
255/// \code
256/// __m128i _mm_dpwusds_epi32(__m128i __W, __m128i __A, __m128i __B)
257/// \endcode
258///
259/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
260///
261/// \param __W
262/// A 128-bit vector of [4 x int].
263/// \param __A
264/// A 128-bit vector of [8 x unsigned short].
265/// \param __B
266/// A 128-bit vector of [8 x short].
267/// \returns
268/// A 128-bit vector of [4 x int].
269///
270/// \code{.operation}
271/// FOR j := 0 to 3
272/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
273/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
274/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
275/// ENDFOR
276/// dst[MAX:128] := 0
277/// \endcode
278static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwusds_epi32(__m128i __W,
279 __m128i __A,
280 __m128i __B) {
281 return (__m128i)__builtin_ia32_vpdpwusds128((__v4si)__W, (__v4si)__A,
282 (__v4si)__B);
283}
284
285/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
286/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate
287/// signed 16-bit results. Sum these 2 results with the corresponding
288/// 32-bit integer in \a __W with signed saturation, and store the packed
289/// 32-bit results in \a dst.
290///
291/// \headerfile <immintrin.h>
292///
293/// \code
294/// __m256i _mm256_dpwsuds_epi32(__m256i __W, __m256i __A, __m256i __B)
295/// \endcode
296///
297/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
298///
299/// \param __W
300/// A 256-bit vector of [8 x int].
301/// \param __A
302/// A 256-bit vector of [16 x unsigned short].
303/// \param __B
304/// A 256-bit vector of [16 x short].
305/// \returns
306/// A 256-bit vector of [8 x int].
307///
308/// \code{.operation}
309/// FOR j := 0 to 7
310/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
311/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
312/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
313/// ENDFOR
314/// dst[MAX:256] := 0
315/// \endcode
316static __inline__ __m256i __DEFAULT_FN_ATTRS256
317_mm256_dpwusds_epi32(__m256i __W, __m256i __A, __m256i __B) {
318 return (__m256i)__builtin_ia32_vpdpwusds256((__v8si)__W, (__v8si)__A,
319 (__v8si)__B);
320}
321
322/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
323/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
324/// signed 16-bit results. Sum these 2 results with the corresponding
325/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
326///
327/// \headerfile <immintrin.h>
328///
329/// \code
330/// __m128i _mm_dpwuud_epi32(__m128i __W, __m128i __A, __m128i __B)
331/// \endcode
332///
333/// This intrinsic corresponds to the \c VPDPWUUD instruction.
334///
335/// \param __W
336/// A 128-bit vector of [4 x unsigned int].
337/// \param __A
338/// A 128-bit vector of [8 x unsigned short].
339/// \param __B
340/// A 128-bit vector of [8 x unsigned short].
341/// \returns
342/// A 128-bit vector of [4 x unsigned int].
343///
344/// \code{.operation}
345/// FOR j := 0 to 3
346/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
347/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
348/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
349/// ENDFOR
350/// dst[MAX:128] := 0
351/// \endcode
352static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwuud_epi32(__m128i __W,
353 __m128i __A,
354 __m128i __B) {
355 return (__m128i)__builtin_ia32_vpdpwuud128((__v4si)__W, (__v4si)__A,
356 (__v4si)__B);
357}
358
359/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
360/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
361/// signed 16-bit results. Sum these 2 results with the corresponding
362/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst.
363///
364/// \headerfile <immintrin.h>
365///
366/// \code
367/// __m256i _mm256_dpwuud_epi32(__m256i __W, __m256i __A, __m256i __B)
368/// \endcode
369///
370/// This intrinsic corresponds to the \c VPDPWUUD instruction.
371///
372/// \param __W
373/// A 256-bit vector of [8 x unsigned int].
374/// \param __A
375/// A 256-bit vector of [16 x unsigned short].
376/// \param __B
377/// A 256-bit vector of [16 x unsigned short].
378/// \returns
379/// A 256-bit vector of [8 x unsigned int].
380///
381/// \code{.operation}
382/// FOR j := 0 to 7
383/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
384/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
385/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2
386/// ENDFOR
387/// dst[MAX:256] := 0
388/// \endcode
389static __inline__ __m256i __DEFAULT_FN_ATTRS256
390_mm256_dpwuud_epi32(__m256i __W, __m256i __A, __m256i __B) {
391 return (__m256i)__builtin_ia32_vpdpwuud256((__v8si)__W, (__v8si)__A,
392 (__v8si)__B);
393}
394
395/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
396/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
397/// signed 16-bit results. Sum these 2 results with the corresponding
398/// 32-bit integer in \a __W with signed saturation, and store the packed
399/// 32-bit results in \a dst.
400///
401/// \headerfile <immintrin.h>
402///
403/// \code
404/// __m128i _mm_dpwsuds_epi32(__m128i __W, __m128i __A, __m128i __B)
405/// \endcode
406///
407/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
408///
409/// \param __W
410/// A 128-bit vector of [4 x unsigned int].
411/// \param __A
412/// A 128-bit vector of [8 x unsigned short].
413/// \param __B
414/// A 128-bit vector of [8 x unsigned short].
415/// \returns
416/// A 128-bit vector of [4 x unsigned int].
417///
418/// \code{.operation}
419/// FOR j := 0 to 3
420/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
421/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
422/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
423/// ENDFOR
424/// dst[MAX:128] := 0
425/// \endcode
426static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_dpwuuds_epi32(__m128i __W,
427 __m128i __A,
428 __m128i __B) {
429 return (__m128i)__builtin_ia32_vpdpwuuds128((__v4si)__W, (__v4si)__A,
430 (__v4si)__B);
431}
432
433/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with
434/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate
435/// signed 16-bit results. Sum these 2 results with the corresponding
436/// 32-bit integer in \a __W with signed saturation, and store the packed
437/// 32-bit results in \a dst.
438///
439/// \headerfile <immintrin.h>
440///
441/// \code
442/// __m256i _mm256_dpwuuds_epi32(__m256i __W, __m256i __A, __m256i __B)
443/// \endcode
444///
445/// This intrinsic corresponds to the \c VPDPWSUDS instruction.
446///
447/// \param __W
448/// A 256-bit vector of [8 x unsigned int].
449/// \param __A
450/// A 256-bit vector of [16 x unsigned short].
451/// \param __B
452/// A 256-bit vector of [16 x unsigned short].
453/// \returns
454/// A 256-bit vector of [8 x unsigned int].
455///
456/// \code{.operation}
457/// FOR j := 0 to 7
458/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j])
459/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1])
460/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2)
461/// ENDFOR
462/// dst[MAX:256] := 0
463/// \endcode
464static __inline__ __m256i __DEFAULT_FN_ATTRS256
465_mm256_dpwuuds_epi32(__m256i __W, __m256i __A, __m256i __B) {
466 return (__m256i)__builtin_ia32_vpdpwuuds256((__v8si)__W, (__v8si)__A,
467 (__v8si)__B);
468}
469
470#undef __DEFAULT_FN_ATTRS128
471#undef __DEFAULT_FN_ATTRS256
472
473#endif // __AVXVNNIINT16INTRIN_H
lib/include/bmi2intrin.h+187-13
......@@ -7,8 +7,8 @@
77 *===-----------------------------------------------------------------------===
88 */
99
10#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11#error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
10#ifndef __IMMINTRIN_H
11#error "Never use <bmi2intrin.h> directly; include <immintrin.h> instead."
1212#endif
1313
1414#ifndef __BMI2INTRIN_H
......@@ -17,44 +17,228 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi2")))
1919
20/// Copies the unsigned 32-bit integer \a __X and zeroes the upper bits
21/// starting at bit number \a __Y.
22///
23/// \code{.operation}
24/// i := __Y[7:0]
25/// result := __X
26/// IF i < 32
27/// result[31:i] := 0
28/// FI
29/// \endcode
30///
31/// \headerfile <immintrin.h>
32///
33/// This intrinsic corresponds to the \c BZHI instruction.
34///
35/// \param __X
36/// The 32-bit source value to copy.
37/// \param __Y
38/// The lower 8 bits specify the bit number of the lowest bit to zero.
39/// \returns The partially zeroed 32-bit value.
2040static __inline__ unsigned int __DEFAULT_FN_ATTRS
2141_bzhi_u32(unsigned int __X, unsigned int __Y)
2242{
2343 return __builtin_ia32_bzhi_si(__X, __Y);
2444}
2545
46/// Deposit (scatter) low-order bits from the unsigned 32-bit integer \a __X
47/// into the 32-bit result, according to the mask in the unsigned 32-bit
48/// integer \a __Y. All other bits of the result are zero.
49///
50/// \code{.operation}
51/// i := 0
52/// result := 0
53/// FOR m := 0 TO 31
54/// IF __Y[m] == 1
55/// result[m] := __X[i]
56/// i := i + 1
57/// ENDIF
58/// ENDFOR
59/// \endcode
60///
61/// \headerfile <immintrin.h>
62///
63/// This intrinsic corresponds to the \c PDEP instruction.
64///
65/// \param __X
66/// The 32-bit source value to copy.
67/// \param __Y
68/// The 32-bit mask specifying where to deposit source bits.
69/// \returns The 32-bit result.
2670static __inline__ unsigned int __DEFAULT_FN_ATTRS
2771_pdep_u32(unsigned int __X, unsigned int __Y)
2872{
2973 return __builtin_ia32_pdep_si(__X, __Y);
3074}
3175
76/// Extract (gather) bits from the unsigned 32-bit integer \a __X into the
77/// low-order bits of the 32-bit result, according to the mask in the
78/// unsigned 32-bit integer \a __Y. All other bits of the result are zero.
79///
80/// \code{.operation}
81/// i := 0
82/// result := 0
83/// FOR m := 0 TO 31
84/// IF __Y[m] == 1
85/// result[i] := __X[m]
86/// i := i + 1
87/// ENDIF
88/// ENDFOR
89/// \endcode
90///
91/// \headerfile <immintrin.h>
92///
93/// This intrinsic corresponds to the \c PEXT instruction.
94///
95/// \param __X
96/// The 32-bit source value to copy.
97/// \param __Y
98/// The 32-bit mask specifying which source bits to extract.
99/// \returns The 32-bit result.
32100static __inline__ unsigned int __DEFAULT_FN_ATTRS
33101_pext_u32(unsigned int __X, unsigned int __Y)
34102{
35103 return __builtin_ia32_pext_si(__X, __Y);
36104}
37105
106/// Multiplies the unsigned 32-bit integers \a __X and \a __Y to form a
107/// 64-bit product. Stores the upper 32 bits of the product in the
108/// memory at \a __P and returns the lower 32 bits.
109///
110/// \code{.operation}
111/// Store32(__P, (__X * __Y)[63:32])
112/// result := (__X * __Y)[31:0]
113/// \endcode
114///
115/// \headerfile <immintrin.h>
116///
117/// This intrinsic corresponds to the \c MULX instruction.
118///
119/// \param __X
120/// An unsigned 32-bit multiplicand.
121/// \param __Y
122/// An unsigned 32-bit multiplicand.
123/// \param __P
124/// A pointer to memory for storing the upper half of the product.
125/// \returns The lower half of the product.
126static __inline__ unsigned int __DEFAULT_FN_ATTRS
127_mulx_u32(unsigned int __X, unsigned int __Y, unsigned int *__P)
128{
129 unsigned long long __res = (unsigned long long) __X * __Y;
130 *__P = (unsigned int)(__res >> 32);
131 return (unsigned int)__res;
132}
133
38134#ifdef __x86_64__
39135
136/// Copies the unsigned 64-bit integer \a __X and zeroes the upper bits
137/// starting at bit number \a __Y.
138///
139/// \code{.operation}
140/// i := __Y[7:0]
141/// result := __X
142/// IF i < 64
143/// result[63:i] := 0
144/// FI
145/// \endcode
146///
147/// \headerfile <immintrin.h>
148///
149/// This intrinsic corresponds to the \c BZHI instruction.
150///
151/// \param __X
152/// The 64-bit source value to copy.
153/// \param __Y
154/// The lower 8 bits specify the bit number of the lowest bit to zero.
155/// \returns The partially zeroed 64-bit value.
40156static __inline__ unsigned long long __DEFAULT_FN_ATTRS
41157_bzhi_u64(unsigned long long __X, unsigned long long __Y)
42158{
43159 return __builtin_ia32_bzhi_di(__X, __Y);
44160}
45161
162/// Deposit (scatter) low-order bits from the unsigned 64-bit integer \a __X
163/// into the 64-bit result, according to the mask in the unsigned 64-bit
164/// integer \a __Y. All other bits of the result are zero.
165///
166/// \code{.operation}
167/// i := 0
168/// result := 0
169/// FOR m := 0 TO 63
170/// IF __Y[m] == 1
171/// result[m] := __X[i]
172/// i := i + 1
173/// ENDIF
174/// ENDFOR
175/// \endcode
176///
177/// \headerfile <immintrin.h>
178///
179/// This intrinsic corresponds to the \c PDEP instruction.
180///
181/// \param __X
182/// The 64-bit source value to copy.
183/// \param __Y
184/// The 64-bit mask specifying where to deposit source bits.
185/// \returns The 64-bit result.
46186static __inline__ unsigned long long __DEFAULT_FN_ATTRS
47187_pdep_u64(unsigned long long __X, unsigned long long __Y)
48188{
49189 return __builtin_ia32_pdep_di(__X, __Y);
50190}
51191
192/// Extract (gather) bits from the unsigned 64-bit integer \a __X into the
193/// low-order bits of the 64-bit result, according to the mask in the
194/// unsigned 64-bit integer \a __Y. All other bits of the result are zero.
195///
196/// \code{.operation}
197/// i := 0
198/// result := 0
199/// FOR m := 0 TO 63
200/// IF __Y[m] == 1
201/// result[i] := __X[m]
202/// i := i + 1
203/// ENDIF
204/// ENDFOR
205/// \endcode
206///
207/// \headerfile <immintrin.h>
208///
209/// This intrinsic corresponds to the \c PEXT instruction.
210///
211/// \param __X
212/// The 64-bit source value to copy.
213/// \param __Y
214/// The 64-bit mask specifying which source bits to extract.
215/// \returns The 64-bit result.
52216static __inline__ unsigned long long __DEFAULT_FN_ATTRS
53217_pext_u64(unsigned long long __X, unsigned long long __Y)
54218{
55219 return __builtin_ia32_pext_di(__X, __Y);
56220}
57221
222/// Multiplies the unsigned 64-bit integers \a __X and \a __Y to form a
223/// 128-bit product. Stores the upper 64 bits of the product to the
224/// memory addressed by \a __P and returns the lower 64 bits.
225///
226/// \code{.operation}
227/// Store64(__P, (__X * __Y)[127:64])
228/// result := (__X * __Y)[63:0]
229/// \endcode
230///
231/// \headerfile <immintrin.h>
232///
233/// This intrinsic corresponds to the \c MULX instruction.
234///
235/// \param __X
236/// An unsigned 64-bit multiplicand.
237/// \param __Y
238/// An unsigned 64-bit multiplicand.
239/// \param __P
240/// A pointer to memory for storing the upper half of the product.
241/// \returns The lower half of the product.
58242static __inline__ unsigned long long __DEFAULT_FN_ATTRS
59243_mulx_u64 (unsigned long long __X, unsigned long long __Y,
60244 unsigned long long *__P)
......@@ -64,17 +248,7 @@ _mulx_u64 (unsigned long long __X, unsigned long long __Y,
64248 return (unsigned long long) __res;
65249}
66250
67#else /* !__x86_64__ */
68
69static __inline__ unsigned int __DEFAULT_FN_ATTRS
70_mulx_u32 (unsigned int __X, unsigned int __Y, unsigned int *__P)
71{
72 unsigned long long __res = (unsigned long long) __X * __Y;
73 *__P = (unsigned int) (__res >> 32);
74 return (unsigned int) __res;
75}
76
77#endif /* !__x86_64__ */
251#endif /* __x86_64__ */
78252
79253#undef __DEFAULT_FN_ATTRS
80254
lib/include/clflushoptintrin.h+9
......@@ -17,6 +17,15 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("clflushopt")))
1919
20/// Invalidates all levels of the cache hierarchy and flushes modified data to
21/// memory for the cache line specified by the address \a __m.
22///
23/// \headerfile <immintrin.h>
24///
25/// This intrinsic corresponds to the \c CLFLUSHOPT instruction.
26///
27/// \param __m
28/// An address within the cache line to flush and invalidate.
2029static __inline__ void __DEFAULT_FN_ATTRS
2130_mm_clflushopt(void const * __m) {
2231 __builtin_ia32_clflushopt(__m);
lib/include/clzerointrin.h+7-5
......@@ -6,7 +6,7 @@
66 *
77 *===-----------------------------------------------------------------------===
88 */
9#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
9#ifndef __X86INTRIN_H
1010#error "Never use <clzerointrin.h> directly; include <x86intrin.h> instead."
1111#endif
1212
......@@ -17,14 +17,16 @@
1717#define __DEFAULT_FN_ATTRS \
1818 __attribute__((__always_inline__, __nodebug__, __target__("clzero")))
1919
20/// Loads the cache line address and zero's out the cacheline
20/// Zeroes out the cache line for the address \a __line. This uses a
21/// non-temporal store. Calling \c _mm_sfence() afterward might be needed
22/// to enforce ordering.
2123///
22/// \headerfile <clzerointrin.h>
24/// \headerfile <x86intrin.h>
2325///
24/// This intrinsic corresponds to the <c> CLZERO </c> instruction.
26/// This intrinsic corresponds to the \c CLZERO instruction.
2527///
2628/// \param __line
27/// A pointer to a cacheline which needs to be zeroed out.
29/// An address within the cache line to zero out.
2830static __inline__ void __DEFAULT_FN_ATTRS
2931_mm_clzero (void * __line)
3032{
lib/include/cuda_wrappers/bits/shared_ptr_base.h created+9
......@@ -0,0 +1,9 @@
1// CUDA headers define __noinline__ which interferes with libstdc++'s use of
2// `__attribute((__noinline__))`. In order to avoid compilation error,
3// temporarily unset __noinline__ when we include affected libstdc++ header.
4
5#pragma push_macro("__noinline__")
6#undef __noinline__
7#include_next "bits/shared_ptr_base.h"
8
9#pragma pop_macro("__noinline__")
lib/include/fmaintrin.h+564
......@@ -18,192 +18,756 @@
1818#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("fma"), __min_vector_width__(128)))
1919#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("fma"), __min_vector_width__(256)))
2020
21/// Computes a multiply-add of 128-bit vectors of [4 x float].
22/// For each element, computes <c> (__A * __B) + __C </c>.
23///
24/// \headerfile <immintrin.h>
25///
26/// This intrinsic corresponds to the \c VFMADD213PS instruction.
27///
28/// \param __A
29/// A 128-bit vector of [4 x float] containing the multiplicand.
30/// \param __B
31/// A 128-bit vector of [4 x float] containing the multiplier.
32/// \param __C
33/// A 128-bit vector of [4 x float] containing the addend.
34/// \returns A 128-bit vector of [4 x float] containing the result.
2135static __inline__ __m128 __DEFAULT_FN_ATTRS128
2236_mm_fmadd_ps(__m128 __A, __m128 __B, __m128 __C)
2337{
2438 return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
2539}
2640
41/// Computes a multiply-add of 128-bit vectors of [2 x double].
42/// For each element, computes <c> (__A * __B) + __C </c>.
43///
44/// \headerfile <immintrin.h>
45///
46/// This intrinsic corresponds to the \c VFMADD213PD instruction.
47///
48/// \param __A
49/// A 128-bit vector of [2 x double] containing the multiplicand.
50/// \param __B
51/// A 128-bit vector of [2 x double] containing the multiplier.
52/// \param __C
53/// A 128-bit vector of [2 x double] containing the addend.
54/// \returns A 128-bit [2 x double] vector containing the result.
2755static __inline__ __m128d __DEFAULT_FN_ATTRS128
2856_mm_fmadd_pd(__m128d __A, __m128d __B, __m128d __C)
2957{
3058 return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, (__v2df)__C);
3159}
3260
61/// Computes a scalar multiply-add of the single-precision values in the
62/// low 32 bits of 128-bit vectors of [4 x float].
63/// \code
64/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]
65/// result[127:32] = __A[127:32]
66/// \endcode
67///
68/// \headerfile <immintrin.h>
69///
70/// This intrinsic corresponds to the \c VFMADD213SS instruction.
71///
72/// \param __A
73/// A 128-bit vector of [4 x float] containing the multiplicand in the low
74/// 32 bits.
75/// \param __B
76/// A 128-bit vector of [4 x float] containing the multiplier in the low
77/// 32 bits.
78/// \param __C
79/// A 128-bit vector of [4 x float] containing the addend in the low
80/// 32 bits.
81/// \returns A 128-bit vector of [4 x float] containing the result in the low
82/// 32 bits and a copy of \a __A[127:32] in the upper 96 bits.
3383static __inline__ __m128 __DEFAULT_FN_ATTRS128
3484_mm_fmadd_ss(__m128 __A, __m128 __B, __m128 __C)
3585{
3686 return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
3787}
3888
89/// Computes a scalar multiply-add of the double-precision values in the
90/// low 64 bits of 128-bit vectors of [2 x double].
91/// \code
92/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]
93/// result[127:64] = __A[127:64]
94/// \endcode
95///
96/// \headerfile <immintrin.h>
97///
98/// This intrinsic corresponds to the \c VFMADD213SD instruction.
99///
100/// \param __A
101/// A 128-bit vector of [2 x double] containing the multiplicand in the low
102/// 64 bits.
103/// \param __B
104/// A 128-bit vector of [2 x double] containing the multiplier in the low
105/// 64 bits.
106/// \param __C
107/// A 128-bit vector of [2 x double] containing the addend in the low
108/// 64 bits.
109/// \returns A 128-bit vector of [2 x double] containing the result in the low
110/// 64 bits and a copy of \a __A[127:64] in the upper 64 bits.
39111static __inline__ __m128d __DEFAULT_FN_ATTRS128
40112_mm_fmadd_sd(__m128d __A, __m128d __B, __m128d __C)
41113{
42114 return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, (__v2df)__B, (__v2df)__C);
43115}
44116
117/// Computes a multiply-subtract of 128-bit vectors of [4 x float].
118/// For each element, computes <c> (__A * __B) - __C </c>.
119///
120/// \headerfile <immintrin.h>
121///
122/// This intrinsic corresponds to the \c VFMSUB213PS instruction.
123///
124/// \param __A
125/// A 128-bit vector of [4 x float] containing the multiplicand.
126/// \param __B
127/// A 128-bit vector of [4 x float] containing the multiplier.
128/// \param __C
129/// A 128-bit vector of [4 x float] containing the subtrahend.
130/// \returns A 128-bit vector of [4 x float] containing the result.
45131static __inline__ __m128 __DEFAULT_FN_ATTRS128
46132_mm_fmsub_ps(__m128 __A, __m128 __B, __m128 __C)
47133{
48134 return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
49135}
50136
137/// Computes a multiply-subtract of 128-bit vectors of [2 x double].
138/// For each element, computes <c> (__A * __B) - __C </c>.
139///
140/// \headerfile <immintrin.h>
141///
142/// This intrinsic corresponds to the \c VFMSUB213PD instruction.
143///
144/// \param __A
145/// A 128-bit vector of [2 x double] containing the multiplicand.
146/// \param __B
147/// A 128-bit vector of [2 x double] containing the multiplier.
148/// \param __C
149/// A 128-bit vector of [2 x double] containing the addend.
150/// \returns A 128-bit vector of [2 x double] containing the result.
51151static __inline__ __m128d __DEFAULT_FN_ATTRS128
52152_mm_fmsub_pd(__m128d __A, __m128d __B, __m128d __C)
53153{
54154 return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, -(__v2df)__C);
55155}
56156
157/// Computes a scalar multiply-subtract of the single-precision values in
158/// the low 32 bits of 128-bit vectors of [4 x float].
159/// \code
160/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]
161/// result[127:32] = __A[127:32]
162/// \endcode
163///
164/// \headerfile <immintrin.h>
165///
166/// This intrinsic corresponds to the \c VFMSUB213SS instruction.
167///
168/// \param __A
169/// A 128-bit vector of [4 x float] containing the multiplicand in the low
170/// 32 bits.
171/// \param __B
172/// A 128-bit vector of [4 x float] containing the multiplier in the low
173/// 32 bits.
174/// \param __C
175/// A 128-bit vector of [4 x float] containing the subtrahend in the low
176/// 32 bits.
177/// \returns A 128-bit vector of [4 x float] containing the result in the low
178/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.
57179static __inline__ __m128 __DEFAULT_FN_ATTRS128
58180_mm_fmsub_ss(__m128 __A, __m128 __B, __m128 __C)
59181{
60182 return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
61183}
62184
185/// Computes a scalar multiply-subtract of the double-precision values in
186/// the low 64 bits of 128-bit vectors of [2 x double].
187/// \code
188/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]
189/// result[127:64] = __A[127:64]
190/// \endcode
191///
192/// \headerfile <immintrin.h>
193///
194/// This intrinsic corresponds to the \c VFMSUB213SD instruction.
195///
196/// \param __A
197/// A 128-bit vector of [2 x double] containing the multiplicand in the low
198/// 64 bits.
199/// \param __B
200/// A 128-bit vector of [2 x double] containing the multiplier in the low
201/// 64 bits.
202/// \param __C
203/// A 128-bit vector of [2 x double] containing the subtrahend in the low
204/// 64 bits.
205/// \returns A 128-bit vector of [2 x double] containing the result in the low
206/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.
63207static __inline__ __m128d __DEFAULT_FN_ATTRS128
64208_mm_fmsub_sd(__m128d __A, __m128d __B, __m128d __C)
65209{
66210 return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, (__v2df)__B, -(__v2df)__C);
67211}
68212
213/// Computes a negated multiply-add of 128-bit vectors of [4 x float].
214/// For each element, computes <c> -(__A * __B) + __C </c>.
215///
216/// \headerfile <immintrin.h>
217///
218/// This intrinsic corresponds to the \c VFNMADD213DPS instruction.
219///
220/// \param __A
221/// A 128-bit vector of [4 x float] containing the multiplicand.
222/// \param __B
223/// A 128-bit vector of [4 x float] containing the multiplier.
224/// \param __C
225/// A 128-bit vector of [4 x float] containing the addend.
226/// \returns A 128-bit [4 x float] vector containing the result.
69227static __inline__ __m128 __DEFAULT_FN_ATTRS128
70228_mm_fnmadd_ps(__m128 __A, __m128 __B, __m128 __C)
71229{
72230 return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
73231}
74232
233/// Computes a negated multiply-add of 128-bit vectors of [2 x double].
234/// For each element, computes <c> -(__A * __B) + __C </c>.
235///
236/// \headerfile <immintrin.h>
237///
238/// This intrinsic corresponds to the \c VFNMADD213PD instruction.
239///
240/// \param __A
241/// A 128-bit vector of [2 x double] containing the multiplicand.
242/// \param __B
243/// A 128-bit vector of [2 x double] containing the multiplier.
244/// \param __C
245/// A 128-bit vector of [2 x double] containing the addend.
246/// \returns A 128-bit vector of [2 x double] containing the result.
75247static __inline__ __m128d __DEFAULT_FN_ATTRS128
76248_mm_fnmadd_pd(__m128d __A, __m128d __B, __m128d __C)
77249{
78250 return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, (__v2df)__C);
79251}
80252
253/// Computes a scalar negated multiply-add of the single-precision values in
254/// the low 32 bits of 128-bit vectors of [4 x float].
255/// \code
256/// result[31:0] = -(__A[31:0] * __B[31:0]) + __C[31:0]
257/// result[127:32] = __A[127:32]
258/// \endcode
259///
260/// \headerfile <immintrin.h>
261///
262/// This intrinsic corresponds to the \c VFNMADD213SS instruction.
263///
264/// \param __A
265/// A 128-bit vector of [4 x float] containing the multiplicand in the low
266/// 32 bits.
267/// \param __B
268/// A 128-bit vector of [4 x float] containing the multiplier in the low
269/// 32 bits.
270/// \param __C
271/// A 128-bit vector of [4 x float] containing the addend in the low
272/// 32 bits.
273/// \returns A 128-bit vector of [4 x float] containing the result in the low
274/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.
81275static __inline__ __m128 __DEFAULT_FN_ATTRS128
82276_mm_fnmadd_ss(__m128 __A, __m128 __B, __m128 __C)
83277{
84278 return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, -(__v4sf)__B, (__v4sf)__C);
85279}
86280
281/// Computes a scalar negated multiply-add of the double-precision values
282/// in the low 64 bits of 128-bit vectors of [2 x double].
283/// \code
284/// result[63:0] = -(__A[63:0] * __B[63:0]) + __C[63:0]
285/// result[127:64] = __A[127:64]
286/// \endcode
287///
288/// \headerfile <immintrin.h>
289///
290/// This intrinsic corresponds to the \c VFNMADD213SD instruction.
291///
292/// \param __A
293/// A 128-bit vector of [2 x double] containing the multiplicand in the low
294/// 64 bits.
295/// \param __B
296/// A 128-bit vector of [2 x double] containing the multiplier in the low
297/// 64 bits.
298/// \param __C
299/// A 128-bit vector of [2 x double] containing the addend in the low
300/// 64 bits.
301/// \returns A 128-bit vector of [2 x double] containing the result in the low
302/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.
87303static __inline__ __m128d __DEFAULT_FN_ATTRS128
88304_mm_fnmadd_sd(__m128d __A, __m128d __B, __m128d __C)
89305{
90306 return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, -(__v2df)__B, (__v2df)__C);
91307}
92308
309/// Computes a negated multiply-subtract of 128-bit vectors of [4 x float].
310/// For each element, computes <c> -(__A * __B) - __C </c>.
311///
312/// \headerfile <immintrin.h>
313///
314/// This intrinsic corresponds to the \c VFNMSUB213PS instruction.
315///
316/// \param __A
317/// A 128-bit vector of [4 x float] containing the multiplicand.
318/// \param __B
319/// A 128-bit vector of [4 x float] containing the multiplier.
320/// \param __C
321/// A 128-bit vector of [4 x float] containing the subtrahend.
322/// \returns A 128-bit vector of [4 x float] containing the result.
93323static __inline__ __m128 __DEFAULT_FN_ATTRS128
94324_mm_fnmsub_ps(__m128 __A, __m128 __B, __m128 __C)
95325{
96326 return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
97327}
98328
329/// Computes a negated multiply-subtract of 128-bit vectors of [2 x double].
330/// For each element, computes <c> -(__A * __B) - __C </c>.
331///
332/// \headerfile <immintrin.h>
333///
334/// This intrinsic corresponds to the \c VFNMSUB213PD instruction.
335///
336/// \param __A
337/// A 128-bit vector of [2 x double] containing the multiplicand.
338/// \param __B
339/// A 128-bit vector of [2 x double] containing the multiplier.
340/// \param __C
341/// A 128-bit vector of [2 x double] containing the subtrahend.
342/// \returns A 128-bit vector of [2 x double] containing the result.
99343static __inline__ __m128d __DEFAULT_FN_ATTRS128
100344_mm_fnmsub_pd(__m128d __A, __m128d __B, __m128d __C)
101345{
102346 return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, -(__v2df)__C);
103347}
104348
349/// Computes a scalar negated multiply-subtract of the single-precision
350/// values in the low 32 bits of 128-bit vectors of [4 x float].
351/// \code
352/// result[31:0] = -(__A[31:0] * __B[31:0]) - __C[31:0]
353/// result[127:32] = __A[127:32]
354/// \endcode
355///
356/// \headerfile <immintrin.h>
357///
358/// This intrinsic corresponds to the \c VFNMSUB213SS instruction.
359///
360/// \param __A
361/// A 128-bit vector of [4 x float] containing the multiplicand in the low
362/// 32 bits.
363/// \param __B
364/// A 128-bit vector of [4 x float] containing the multiplier in the low
365/// 32 bits.
366/// \param __C
367/// A 128-bit vector of [4 x float] containing the subtrahend in the low
368/// 32 bits.
369/// \returns A 128-bit vector of [4 x float] containing the result in the low
370/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.
105371static __inline__ __m128 __DEFAULT_FN_ATTRS128
106372_mm_fnmsub_ss(__m128 __A, __m128 __B, __m128 __C)
107373{
108374 return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, -(__v4sf)__B, -(__v4sf)__C);
109375}
110376
377/// Computes a scalar negated multiply-subtract of the double-precision
378/// values in the low 64 bits of 128-bit vectors of [2 x double].
379/// \code
380/// result[63:0] = -(__A[63:0] * __B[63:0]) - __C[63:0]
381/// result[127:64] = __A[127:64]
382/// \endcode
383///
384/// \headerfile <immintrin.h>
385///
386/// This intrinsic corresponds to the \c VFNMSUB213SD instruction.
387///
388/// \param __A
389/// A 128-bit vector of [2 x double] containing the multiplicand in the low
390/// 64 bits.
391/// \param __B
392/// A 128-bit vector of [2 x double] containing the multiplier in the low
393/// 64 bits.
394/// \param __C
395/// A 128-bit vector of [2 x double] containing the subtrahend in the low
396/// 64 bits.
397/// \returns A 128-bit vector of [2 x double] containing the result in the low
398/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.
111399static __inline__ __m128d __DEFAULT_FN_ATTRS128
112400_mm_fnmsub_sd(__m128d __A, __m128d __B, __m128d __C)
113401{
114402 return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, -(__v2df)__B, -(__v2df)__C);
115403}
116404
405/// Computes a multiply with alternating add/subtract of 128-bit vectors of
406/// [4 x float].
407/// \code
408/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]
409/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32]
410/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64]
411/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96]
412/// \endcode
413///
414/// \headerfile <immintrin.h>
415///
416/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction.
417///
418/// \param __A
419/// A 128-bit vector of [4 x float] containing the multiplicand.
420/// \param __B
421/// A 128-bit vector of [4 x float] containing the multiplier.
422/// \param __C
423/// A 128-bit vector of [4 x float] containing the addend/subtrahend.
424/// \returns A 128-bit vector of [4 x float] containing the result.
117425static __inline__ __m128 __DEFAULT_FN_ATTRS128
118426_mm_fmaddsub_ps(__m128 __A, __m128 __B, __m128 __C)
119427{
120428 return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
121429}
122430
431/// Computes a multiply with alternating add/subtract of 128-bit vectors of
432/// [2 x double].
433/// \code
434/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]
435/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64]
436/// \endcode
437///
438/// \headerfile <immintrin.h>
439///
440/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.
441///
442/// \param __A
443/// A 128-bit vector of [2 x double] containing the multiplicand.
444/// \param __B
445/// A 128-bit vector of [2 x double] containing the multiplier.
446/// \param __C
447/// A 128-bit vector of [2 x double] containing the addend/subtrahend.
448/// \returns A 128-bit vector of [2 x double] containing the result.
123449static __inline__ __m128d __DEFAULT_FN_ATTRS128
124450_mm_fmaddsub_pd(__m128d __A, __m128d __B, __m128d __C)
125451{
126452 return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, (__v2df)__C);
127453}
128454
455/// Computes a multiply with alternating add/subtract of 128-bit vectors of
456/// [4 x float].
457/// \code
458/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]
459/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32]
460/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64]
461/// result[127:96 = (__A[127:96] * __B[127:96]) - __C[127:96]
462/// \endcode
463///
464/// \headerfile <immintrin.h>
465///
466/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction.
467///
468/// \param __A
469/// A 128-bit vector of [4 x float] containing the multiplicand.
470/// \param __B
471/// A 128-bit vector of [4 x float] containing the multiplier.
472/// \param __C
473/// A 128-bit vector of [4 x float] containing the addend/subtrahend.
474/// \returns A 128-bit vector of [4 x float] containing the result.
129475static __inline__ __m128 __DEFAULT_FN_ATTRS128
130476_mm_fmsubadd_ps(__m128 __A, __m128 __B, __m128 __C)
131477{
132478 return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
133479}
134480
481/// Computes a multiply with alternating add/subtract of 128-bit vectors of
482/// [2 x double].
483/// \code
484/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]
485/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64]
486/// \endcode
487///
488/// \headerfile <immintrin.h>
489///
490/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.
491///
492/// \param __A
493/// A 128-bit vector of [2 x double] containing the multiplicand.
494/// \param __B
495/// A 128-bit vector of [2 x double] containing the multiplier.
496/// \param __C
497/// A 128-bit vector of [2 x double] containing the addend/subtrahend.
498/// \returns A 128-bit vector of [2 x double] containing the result.
135499static __inline__ __m128d __DEFAULT_FN_ATTRS128
136500_mm_fmsubadd_pd(__m128d __A, __m128d __B, __m128d __C)
137501{
138502 return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, -(__v2df)__C);
139503}
140504
505/// Computes a multiply-add of 256-bit vectors of [8 x float].
506/// For each element, computes <c> (__A * __B) + __C </c>.
507///
508/// \headerfile <immintrin.h>
509///
510/// This intrinsic corresponds to the \c VFMADD213PS instruction.
511///
512/// \param __A
513/// A 256-bit vector of [8 x float] containing the multiplicand.
514/// \param __B
515/// A 256-bit vector of [8 x float] containing the multiplier.
516/// \param __C
517/// A 256-bit vector of [8 x float] containing the addend.
518/// \returns A 256-bit vector of [8 x float] containing the result.
141519static __inline__ __m256 __DEFAULT_FN_ATTRS256
142520_mm256_fmadd_ps(__m256 __A, __m256 __B, __m256 __C)
143521{
144522 return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
145523}
146524
525/// Computes a multiply-add of 256-bit vectors of [4 x double].
526/// For each element, computes <c> (__A * __B) + __C </c>.
527///
528/// \headerfile <immintrin.h>
529///
530/// This intrinsic corresponds to the \c VFMADD213PD instruction.
531///
532/// \param __A
533/// A 256-bit vector of [4 x double] containing the multiplicand.
534/// \param __B
535/// A 256-bit vector of [4 x double] containing the multiplier.
536/// \param __C
537/// A 256-bit vector of [4 x double] containing the addend.
538/// \returns A 256-bit vector of [4 x double] containing the result.
147539static __inline__ __m256d __DEFAULT_FN_ATTRS256
148540_mm256_fmadd_pd(__m256d __A, __m256d __B, __m256d __C)
149541{
150542 return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, (__v4df)__C);
151543}
152544
545/// Computes a multiply-subtract of 256-bit vectors of [8 x float].
546/// For each element, computes <c> (__A * __B) - __C </c>.
547///
548/// \headerfile <immintrin.h>
549///
550/// This intrinsic corresponds to the \c VFMSUB213PS instruction.
551///
552/// \param __A
553/// A 256-bit vector of [8 x float] containing the multiplicand.
554/// \param __B
555/// A 256-bit vector of [8 x float] containing the multiplier.
556/// \param __C
557/// A 256-bit vector of [8 x float] containing the subtrahend.
558/// \returns A 256-bit vector of [8 x float] containing the result.
153559static __inline__ __m256 __DEFAULT_FN_ATTRS256
154560_mm256_fmsub_ps(__m256 __A, __m256 __B, __m256 __C)
155561{
156562 return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
157563}
158564
565/// Computes a multiply-subtract of 256-bit vectors of [4 x double].
566/// For each element, computes <c> (__A * __B) - __C </c>.
567///
568/// \headerfile <immintrin.h>
569///
570/// This intrinsic corresponds to the \c VFMSUB213PD instruction.
571///
572/// \param __A
573/// A 256-bit vector of [4 x double] containing the multiplicand.
574/// \param __B
575/// A 256-bit vector of [4 x double] containing the multiplier.
576/// \param __C
577/// A 256-bit vector of [4 x double] containing the subtrahend.
578/// \returns A 256-bit vector of [4 x double] containing the result.
159579static __inline__ __m256d __DEFAULT_FN_ATTRS256
160580_mm256_fmsub_pd(__m256d __A, __m256d __B, __m256d __C)
161581{
162582 return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C);
163583}
164584
585/// Computes a negated multiply-add of 256-bit vectors of [8 x float].
586/// For each element, computes <c> -(__A * __B) + __C </c>.
587///
588/// \headerfile <immintrin.h>
589///
590/// This intrinsic corresponds to the \c VFNMADD213PS instruction.
591///
592/// \param __A
593/// A 256-bit vector of [8 x float] containing the multiplicand.
594/// \param __B
595/// A 256-bit vector of [8 x float] containing the multiplier.
596/// \param __C
597/// A 256-bit vector of [8 x float] containing the addend.
598/// \returns A 256-bit vector of [8 x float] containing the result.
165599static __inline__ __m256 __DEFAULT_FN_ATTRS256
166600_mm256_fnmadd_ps(__m256 __A, __m256 __B, __m256 __C)
167601{
168602 return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
169603}
170604
605/// Computes a negated multiply-add of 256-bit vectors of [4 x double].
606/// For each element, computes <c> -(__A * __B) + __C </c>.
607///
608/// \headerfile <immintrin.h>
609///
610/// This intrinsic corresponds to the \c VFNMADD213PD instruction.
611///
612/// \param __A
613/// A 256-bit vector of [4 x double] containing the multiplicand.
614/// \param __B
615/// A 256-bit vector of [4 x double] containing the multiplier.
616/// \param __C
617/// A 256-bit vector of [4 x double] containing the addend.
618/// \returns A 256-bit vector of [4 x double] containing the result.
171619static __inline__ __m256d __DEFAULT_FN_ATTRS256
172620_mm256_fnmadd_pd(__m256d __A, __m256d __B, __m256d __C)
173621{
174622 return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, (__v4df)__C);
175623}
176624
625/// Computes a negated multiply-subtract of 256-bit vectors of [8 x float].
626/// For each element, computes <c> -(__A * __B) - __C </c>.
627///
628/// \headerfile <immintrin.h>
629///
630/// This intrinsic corresponds to the \c VFNMSUB213PS instruction.
631///
632/// \param __A
633/// A 256-bit vector of [8 x float] containing the multiplicand.
634/// \param __B
635/// A 256-bit vector of [8 x float] containing the multiplier.
636/// \param __C
637/// A 256-bit vector of [8 x float] containing the subtrahend.
638/// \returns A 256-bit vector of [8 x float] containing the result.
177639static __inline__ __m256 __DEFAULT_FN_ATTRS256
178640_mm256_fnmsub_ps(__m256 __A, __m256 __B, __m256 __C)
179641{
180642 return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
181643}
182644
645/// Computes a negated multiply-subtract of 256-bit vectors of [4 x double].
646/// For each element, computes <c> -(__A * __B) - __C </c>.
647///
648/// \headerfile <immintrin.h>
649///
650/// This intrinsic corresponds to the \c VFNMSUB213PD instruction.
651///
652/// \param __A
653/// A 256-bit vector of [4 x double] containing the multiplicand.
654/// \param __B
655/// A 256-bit vector of [4 x double] containing the multiplier.
656/// \param __C
657/// A 256-bit vector of [4 x double] containing the subtrahend.
658/// \returns A 256-bit vector of [4 x double] containing the result.
183659static __inline__ __m256d __DEFAULT_FN_ATTRS256
184660_mm256_fnmsub_pd(__m256d __A, __m256d __B, __m256d __C)
185661{
186662 return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, -(__v4df)__C);
187663}
188664
665/// Computes a multiply with alternating add/subtract of 256-bit vectors of
666/// [8 x float].
667/// \code
668/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]
669/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32]
670/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64]
671/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96]
672/// result[159:128] = (__A[159:128] * __B[159:128]) - __C[159:128]
673/// result[191:160] = (__A[191:160] * __B[191:160]) + __C[191:160]
674/// result[223:192] = (__A[223:192] * __B[223:192]) - __C[223:192]
675/// result[255:224] = (__A[255:224] * __B[255:224]) + __C[255:224]
676/// \endcode
677///
678/// \headerfile <immintrin.h>
679///
680/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction.
681///
682/// \param __A
683/// A 256-bit vector of [8 x float] containing the multiplicand.
684/// \param __B
685/// A 256-bit vector of [8 x float] containing the multiplier.
686/// \param __C
687/// A 256-bit vector of [8 x float] containing the addend/subtrahend.
688/// \returns A 256-bit vector of [8 x float] containing the result.
189689static __inline__ __m256 __DEFAULT_FN_ATTRS256
190690_mm256_fmaddsub_ps(__m256 __A, __m256 __B, __m256 __C)
191691{
192692 return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
193693}
194694
695/// Computes a multiply with alternating add/subtract of 256-bit vectors of
696/// [4 x double].
697/// \code
698/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]
699/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64]
700/// result[191:128] = (__A[191:128] * __B[191:128]) - __C[191:128]
701/// result[255:192] = (__A[255:192] * __B[255:192]) + __C[255:192]
702/// \endcode
703///
704/// \headerfile <immintrin.h>
705///
706/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.
707///
708/// \param __A
709/// A 256-bit vector of [4 x double] containing the multiplicand.
710/// \param __B
711/// A 256-bit vector of [4 x double] containing the multiplier.
712/// \param __C
713/// A 256-bit vector of [4 x double] containing the addend/subtrahend.
714/// \returns A 256-bit vector of [4 x double] containing the result.
195715static __inline__ __m256d __DEFAULT_FN_ATTRS256
196716_mm256_fmaddsub_pd(__m256d __A, __m256d __B, __m256d __C)
197717{
198718 return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, (__v4df)__C);
199719}
200720
721/// Computes a vector multiply with alternating add/subtract of 256-bit
722/// vectors of [8 x float].
723/// \code
724/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]
725/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32]
726/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64]
727/// result[127:96] = (__A[127:96] * __B[127:96]) - __C[127:96]
728/// result[159:128] = (__A[159:128] * __B[159:128]) + __C[159:128]
729/// result[191:160] = (__A[191:160] * __B[191:160]) - __C[191:160]
730/// result[223:192] = (__A[223:192] * __B[223:192]) + __C[223:192]
731/// result[255:224] = (__A[255:224] * __B[255:224]) - __C[255:224]
732/// \endcode
733///
734/// \headerfile <immintrin.h>
735///
736/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction.
737///
738/// \param __A
739/// A 256-bit vector of [8 x float] containing the multiplicand.
740/// \param __B
741/// A 256-bit vector of [8 x float] containing the multiplier.
742/// \param __C
743/// A 256-bit vector of [8 x float] containing the addend/subtrahend.
744/// \returns A 256-bit vector of [8 x float] containing the result.
201745static __inline__ __m256 __DEFAULT_FN_ATTRS256
202746_mm256_fmsubadd_ps(__m256 __A, __m256 __B, __m256 __C)
203747{
204748 return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
205749}
206750
751/// Computes a vector multiply with alternating add/subtract of 256-bit
752/// vectors of [4 x double].
753/// \code
754/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]
755/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64]
756/// result[191:128] = (__A[191:128] * __B[191:128]) + __C[191:128]
757/// result[255:192] = (__A[255:192] * __B[255:192]) - __C[255:192]
758/// \endcode
759///
760/// \headerfile <immintrin.h>
761///
762/// This intrinsic corresponds to the \c VFMSUBADD213PD instruction.
763///
764/// \param __A
765/// A 256-bit vector of [4 x double] containing the multiplicand.
766/// \param __B
767/// A 256-bit vector of [4 x double] containing the multiplier.
768/// \param __C
769/// A 256-bit vector of [4 x double] containing the addend/subtrahend.
770/// \returns A 256-bit vector of [4 x double] containing the result.
207771static __inline__ __m256d __DEFAULT_FN_ATTRS256
208772_mm256_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C)
209773{
lib/include/immintrin.h+116-8
......@@ -269,6 +269,26 @@
269269#include <avxneconvertintrin.h>
270270#endif
271271
272#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
273 defined(__SHA512__)
274#include <sha512intrin.h>
275#endif
276
277#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
278 defined(__SM3__)
279#include <sm3intrin.h>
280#endif
281
282#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
283 defined(__SM4__)
284#include <sm4intrin.h>
285#endif
286
287#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
288 defined(__AVXVNNIINT16__)
289#include <avxvnniint16intrin.h>
290#endif
291
272292#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
273293 defined(__RDPID__)
274294/// Returns the value of the IA32_TSC_AUX MSR (0xc0000103).
......@@ -284,30 +304,53 @@ _rdpid_u32(void) {
284304
285305#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
286306 defined(__RDRND__)
307/// Returns a 16-bit hardware-generated random value.
308///
309/// \headerfile <immintrin.h>
310///
311/// This intrinsic corresponds to the <c> RDRAND </c> instruction.
312///
313/// \param __p
314/// A pointer to a 16-bit memory location to place the random value.
315/// \returns 1 if the value was successfully generated, 0 otherwise.
287316static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
288317_rdrand16_step(unsigned short *__p)
289318{
290319 return (int)__builtin_ia32_rdrand16_step(__p);
291320}
292321
322/// Returns a 32-bit hardware-generated random value.
323///
324/// \headerfile <immintrin.h>
325///
326/// This intrinsic corresponds to the <c> RDRAND </c> instruction.
327///
328/// \param __p
329/// A pointer to a 32-bit memory location to place the random value.
330/// \returns 1 if the value was successfully generated, 0 otherwise.
293331static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
294332_rdrand32_step(unsigned int *__p)
295333{
296334 return (int)__builtin_ia32_rdrand32_step(__p);
297335}
298336
299#ifdef __x86_64__
337/// Returns a 64-bit hardware-generated random value.
338///
339/// \headerfile <immintrin.h>
340///
341/// This intrinsic corresponds to the <c> RDRAND </c> instruction.
342///
343/// \param __p
344/// A pointer to a 64-bit memory location to place the random value.
345/// \returns 1 if the value was successfully generated, 0 otherwise.
300346static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
301347_rdrand64_step(unsigned long long *__p)
302348{
349#ifdef __x86_64__
303350 return (int)__builtin_ia32_rdrand64_step(__p);
304}
305351#else
306// We need to emulate the functionality of 64-bit rdrand with 2 32-bit
307// rdrand instructions.
308static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
309_rdrand64_step(unsigned long long *__p)
310{
352 // We need to emulate the functionality of 64-bit rdrand with 2 32-bit
353 // rdrand instructions.
311354 unsigned int __lo, __hi;
312355 unsigned int __res_lo = __builtin_ia32_rdrand32_step(&__lo);
313356 unsigned int __res_hi = __builtin_ia32_rdrand32_step(&__hi);
......@@ -318,55 +361,115 @@ _rdrand64_step(unsigned long long *__p)
318361 *__p = 0;
319362 return 0;
320363 }
321}
322364#endif
365}
323366#endif /* __RDRND__ */
324367
325368#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
326369 defined(__FSGSBASE__)
327370#ifdef __x86_64__
371/// Reads the FS base register.
372///
373/// \headerfile <immintrin.h>
374///
375/// This intrinsic corresponds to the <c> RDFSBASE </c> instruction.
376///
377/// \returns The lower 32 bits of the FS base register.
328378static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
329379_readfsbase_u32(void)
330380{
331381 return __builtin_ia32_rdfsbase32();
332382}
333383
384/// Reads the FS base register.
385///
386/// \headerfile <immintrin.h>
387///
388/// This intrinsic corresponds to the <c> RDFSBASE </c> instruction.
389///
390/// \returns The contents of the FS base register.
334391static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
335392_readfsbase_u64(void)
336393{
337394 return __builtin_ia32_rdfsbase64();
338395}
339396
397/// Reads the GS base register.
398///
399/// \headerfile <immintrin.h>
400///
401/// This intrinsic corresponds to the <c> RDGSBASE </c> instruction.
402///
403/// \returns The lower 32 bits of the GS base register.
340404static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
341405_readgsbase_u32(void)
342406{
343407 return __builtin_ia32_rdgsbase32();
344408}
345409
410/// Reads the GS base register.
411///
412/// \headerfile <immintrin.h>
413///
414/// This intrinsic corresponds to the <c> RDGSBASE </c> instruction.
415///
416/// \returns The contents of the GS base register.
346417static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
347418_readgsbase_u64(void)
348419{
349420 return __builtin_ia32_rdgsbase64();
350421}
351422
423/// Modifies the FS base register.
424///
425/// \headerfile <immintrin.h>
426///
427/// This intrinsic corresponds to the <c> WRFSBASE </c> instruction.
428///
429/// \param __V
430/// Value to use for the lower 32 bits of the FS base register.
352431static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
353432_writefsbase_u32(unsigned int __V)
354433{
355434 __builtin_ia32_wrfsbase32(__V);
356435}
357436
437/// Modifies the FS base register.
438///
439/// \headerfile <immintrin.h>
440///
441/// This intrinsic corresponds to the <c> WRFSBASE </c> instruction.
442///
443/// \param __V
444/// Value to use for the FS base register.
358445static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
359446_writefsbase_u64(unsigned long long __V)
360447{
361448 __builtin_ia32_wrfsbase64(__V);
362449}
363450
451/// Modifies the GS base register.
452///
453/// \headerfile <immintrin.h>
454///
455/// This intrinsic corresponds to the <c> WRGSBASE </c> instruction.
456///
457/// \param __V
458/// Value to use for the lower 32 bits of the GS base register.
364459static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
365460_writegsbase_u32(unsigned int __V)
366461{
367462 __builtin_ia32_wrgsbase32(__V);
368463}
369464
465/// Modifies the GS base register.
466///
467/// \headerfile <immintrin.h>
468///
469/// This intrinsic corresponds to the <c> WRFSBASE </c> instruction.
470///
471/// \param __V
472/// Value to use for GS base register.
370473static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
371474_writegsbase_u64(unsigned long long __V)
372475{
......@@ -538,6 +641,11 @@ _storebe_i64(void * __P, long long __D) {
538641#include <amxintrin.h>
539642#endif
540643
644#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
645 defined(__AMX_COMPLEX__)
646#include <amxcomplexintrin.h>
647#endif
648
541649#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
542650 defined(__AVX512VP2INTERSECT__)
543651#include <avx512vp2intersectintrin.h>
lib/include/limits.h+5-1
......@@ -52,7 +52,11 @@
5252#define LONG_MIN (-__LONG_MAX__ -1L)
5353
5454#define UCHAR_MAX (__SCHAR_MAX__*2 +1)
55#define USHRT_MAX (__SHRT_MAX__ *2 +1)
55#if __SHRT_WIDTH__ < __INT_WIDTH__
56#define USHRT_MAX (__SHRT_MAX__ * 2 + 1)
57#else
58#define USHRT_MAX (__SHRT_MAX__ * 2U + 1U)
59#endif
5660#define UINT_MAX (__INT_MAX__ *2U +1U)
5761#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
5862
lib/include/llvm_libc_wrappers/ctype.h created+85
......@@ -0,0 +1,85 @@
1//===-- Wrapper for C standard ctype.h declarations on the GPU ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
10#define __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
11
12#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13#error "This file is for GPU offloading compilation only"
14#endif
15
16#include_next <ctype.h>
17
18#if __has_include(<llvm-libc-decls/ctype.h>)
19
20#if defined(__HIP__) || defined(__CUDA__)
21#define __LIBC_ATTRS __attribute__((device))
22#endif
23
24// The GNU headers like to provide these as macros, we need to undefine them so
25// they do not conflict with the following definitions for the GPU.
26
27#pragma push_macro("isalnum")
28#pragma push_macro("isalpha")
29#pragma push_macro("isblank")
30#pragma push_macro("iscntrl")
31#pragma push_macro("isdigit")
32#pragma push_macro("isgraph")
33#pragma push_macro("islower")
34#pragma push_macro("isprint")
35#pragma push_macro("ispunct")
36#pragma push_macro("isspace")
37#pragma push_macro("isupper")
38#pragma push_macro("isxdigit")
39#pragma push_macro("tolower")
40#pragma push_macro("toupper")
41
42#undef isalnum
43#undef isalpha
44#undef iscntrl
45#undef isdigit
46#undef islower
47#undef isgraph
48#undef isprint
49#undef ispunct
50#undef isspace
51#undef isupper
52#undef isblank
53#undef isxdigit
54#undef tolower
55#undef toupper
56
57#pragma omp begin declare target
58
59#include <llvm-libc-decls/ctype.h>
60
61#pragma omp end declare target
62
63// Restore the original macros when compiling on the host.
64#if !defined(__NVPTX__) && !defined(__AMDGPU__)
65#pragma pop_macro("isalnum")
66#pragma pop_macro("isalpha")
67#pragma pop_macro("isblank")
68#pragma pop_macro("iscntrl")
69#pragma pop_macro("isdigit")
70#pragma pop_macro("isgraph")
71#pragma pop_macro("islower")
72#pragma pop_macro("isprint")
73#pragma pop_macro("ispunct")
74#pragma pop_macro("isspace")
75#pragma pop_macro("isupper")
76#pragma pop_macro("isxdigit")
77#pragma pop_macro("tolower")
78#pragma pop_macro("toupper")
79#endif
80
81#undef __LIBC_ATTRS
82
83#endif
84
85#endif // __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__
lib/include/llvm_libc_wrappers/inttypes.h created+34
......@@ -0,0 +1,34 @@
1//===-- Wrapper for C standard inttypes.h declarations on the GPU ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
10#define __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
11
12#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13#error "This file is for GPU offloading compilation only"
14#endif
15
16#include_next <inttypes.h>
17
18#if __has_include(<llvm-libc-decls/inttypes.h>)
19
20#if defined(__HIP__) || defined(__CUDA__)
21#define __LIBC_ATTRS __attribute__((device))
22#endif
23
24#pragma omp begin declare target
25
26#include <llvm-libc-decls/inttypes.h>
27
28#pragma omp end declare target
29
30#undef __LIBC_ATTRS
31
32#endif
33
34#endif // __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__
lib/include/llvm_libc_wrappers/stdio.h created+34
......@@ -0,0 +1,34 @@
1//===-- Wrapper for C standard stdio.h declarations on the GPU ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
10#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
11
12#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13#error "This file is for GPU offloading compilation only"
14#endif
15
16#include_next <stdio.h>
17
18#if __has_include(<llvm-libc-decls/stdio.h>)
19
20#if defined(__HIP__) || defined(__CUDA__)
21#define __LIBC_ATTRS __attribute__((device))
22#endif
23
24#pragma omp begin declare target
25
26#include <llvm-libc-decls/stdio.h>
27
28#pragma omp end declare target
29
30#undef __LIBC_ATTRS
31
32#endif
33
34#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
lib/include/llvm_libc_wrappers/stdlib.h created+42
......@@ -0,0 +1,42 @@
1//===-- Wrapper for C standard stdlib.h declarations on the GPU -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
10#define __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
11
12#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13#error "This file is for GPU offloading compilation only"
14#endif
15
16#include_next <stdlib.h>
17
18#if __has_include(<llvm-libc-decls/stdlib.h>)
19
20#if defined(__HIP__) || defined(__CUDA__)
21#define __LIBC_ATTRS __attribute__((device))
22#endif
23
24#pragma omp begin declare target
25
26// The LLVM C library uses this type so we forward declare it.
27typedef void (*__atexithandler_t)(void);
28
29// Enforce ABI compatibility with the structs used by the LLVM C library.
30_Static_assert(__builtin_offsetof(div_t, quot) == 0, "ABI mismatch!");
31_Static_assert(__builtin_offsetof(ldiv_t, quot) == 0, "ABI mismatch!");
32_Static_assert(__builtin_offsetof(lldiv_t, quot) == 0, "ABI mismatch!");
33
34#include <llvm-libc-decls/stdlib.h>
35
36#pragma omp end declare target
37
38#undef __LIBC_ATTRS
39
40#endif
41
42#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__
lib/include/llvm_libc_wrappers/string.h created+37
......@@ -0,0 +1,37 @@
1//===-- Wrapper for C standard string.h declarations on the GPU -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
10#define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
11
12#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13#error "This file is for GPU offloading compilation only"
14#endif
15
16// FIXME: The GNU headers provide C++ standard compliant headers when in C++
17// mode and the LLVM libc does not. We cannot enable memchr, strchr, strchrnul,
18// strpbrk, strrchr, strstr, or strcasestr until this is addressed.
19#include_next <string.h>
20
21#if __has_include(<llvm-libc-decls/string.h>)
22
23#if defined(__HIP__) || defined(__CUDA__)
24#define __LIBC_ATTRS __attribute__((device))
25#endif
26
27#pragma omp begin declare target
28
29#include <llvm-libc-decls/string.h>
30
31#pragma omp end declare target
32
33#undef __LIBC_ATTRS
34
35#endif
36
37#endif // __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
lib/include/mwaitxintrin.h+29
......@@ -16,12 +16,41 @@
1616
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("mwaitx")))
19
20/// Establishes a linear address memory range to be monitored and puts
21/// the processor in the monitor event pending state. Data stored in the
22/// monitored address range causes the processor to exit the pending state.
23///
24/// \headerfile <x86intrin.h>
25///
26/// This intrinsic corresponds to the \c MONITORX instruction.
27///
28/// \param __p
29/// The memory range to be monitored. The size of the range is determined by
30/// CPUID function 0000_0005h.
31/// \param __extensions
32/// Optional extensions for the monitoring state.
33/// \param __hints
34/// Optional hints for the monitoring state.
1935static __inline__ void __DEFAULT_FN_ATTRS
2036_mm_monitorx(void * __p, unsigned __extensions, unsigned __hints)
2137{
2238 __builtin_ia32_monitorx(__p, __extensions, __hints);
2339}
2440
41/// Used with the \c MONITORX instruction to wait while the processor is in
42/// the monitor event pending state. Data stored in the monitored address
43/// range, or an interrupt, causes the processor to exit the pending state.
44///
45/// \headerfile <x86intrin.h>
46///
47/// This intrinsic corresponds to the \c MWAITX instruction.
48///
49/// \param __extensions
50/// Optional extensions for the monitoring state, which can vary by
51/// processor.
52/// \param __hints
53/// Optional hints for the monitoring state, which can vary by processor.
2554static __inline__ void __DEFAULT_FN_ATTRS
2655_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock)
2756{
lib/include/opencl-c-base.h+3
......@@ -474,6 +474,9 @@ typedef enum memory_order
474474#define CLK_HALF_FLOAT 0x10DD
475475#define CLK_FLOAT 0x10DE
476476#define CLK_UNORM_INT24 0x10DF
477#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
478#define CLK_UNORM_INT_101010_2 0x10E0
479#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
477480
478481// Channel order, numbering must be aligned with cl_channel_order in cl.h
479482//
lib/include/openmp_wrappers/__clang_openmp_device_functions.h-1
......@@ -40,7 +40,6 @@ extern "C" {
4040
4141// Import types which will be used by __clang_hip_libdevice_declares.h
4242#ifndef __cplusplus
43#include <stdbool.h>
4443#include <stdint.h>
4544#endif
4645
lib/include/openmp_wrappers/new+1-1
......@@ -13,7 +13,7 @@
1313// which do not use nothrow_t are provided without the <new> header.
1414#include_next <new>
1515
16#if defined(__NVPTX__) && defined(_OPENMP)
16#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(_OPENMP)
1717
1818#include <cstdlib>
1919
lib/include/pmmintrin.h+12-6
......@@ -253,9 +253,12 @@ _mm_movedup_pd(__m128d __a)
253253/// the processor in the monitor event pending state. Data stored in the
254254/// monitored address range causes the processor to exit the pending state.
255255///
256/// The \c MONITOR instruction can be used in kernel mode, and in other modes
257/// if MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
258///
256259/// \headerfile <x86intrin.h>
257260///
258/// This intrinsic corresponds to the <c> MONITOR </c> instruction.
261/// This intrinsic corresponds to the \c MONITOR instruction.
259262///
260263/// \param __p
261264/// The memory range to be monitored. The size of the range is determined by
......@@ -270,19 +273,22 @@ _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
270273 __builtin_ia32_monitor(__p, __extensions, __hints);
271274}
272275
273/// Used with the MONITOR instruction to wait while the processor is in
276/// Used with the \c MONITOR instruction to wait while the processor is in
274277/// the monitor event pending state. Data stored in the monitored address
275/// range causes the processor to exit the pending state.
278/// range, or an interrupt, causes the processor to exit the pending state.
279///
280/// The \c MWAIT instruction can be used in kernel mode, and in other modes if
281/// MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
276282///
277283/// \headerfile <x86intrin.h>
278284///
279/// This intrinsic corresponds to the <c> MWAIT </c> instruction.
285/// This intrinsic corresponds to the \c MWAIT instruction.
280286///
281287/// \param __extensions
282/// Optional extensions for the monitoring state, which may vary by
288/// Optional extensions for the monitoring state, which can vary by
283289/// processor.
284290/// \param __hints
285/// Optional hints for the monitoring state, which may vary by processor.
291/// Optional hints for the monitoring state, which can vary by processor.
286292static __inline__ void __DEFAULT_FN_ATTRS
287293_mm_mwait(unsigned __extensions, unsigned __hints)
288294{
lib/include/ppc_wrappers/emmintrin.h+2-1
......@@ -46,6 +46,7 @@
4646
4747/* SSE2 */
4848typedef __vector double __v2df;
49typedef __vector float __v4f;
4950typedef __vector long long __v2di;
5051typedef __vector unsigned long long __v2du;
5152typedef __vector int __v4si;
......@@ -951,7 +952,7 @@ extern __inline __m128d
951952 _mm_cvtpi32_pd(__m64 __A) {
952953 __v4si __temp;
953954 __v2di __tmp2;
954 __v2df __result;
955 __v4f __result;
955956
956957 __temp = (__v4si)vec_splats(__A);
957958 __tmp2 = (__v2di)vec_unpackl(__temp);
lib/include/ppc_wrappers/smmintrin.h+2-2
......@@ -305,9 +305,9 @@ extern __inline int
305305extern __inline __m128i
306306 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
307307 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
308 __v16qi __charmask = vec_splats((signed char)__imm8);
308 __v16qu __charmask = vec_splats((unsigned char)__imm8);
309309 __charmask = vec_gb(__charmask);
310 __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
310 __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
311311#ifdef __BIG_ENDIAN__
312312 __shortmask = vec_reve(__shortmask);
313313#endif
lib/include/rdseedintrin.h+65-2
......@@ -7,8 +7,8 @@
77 *===-----------------------------------------------------------------------===
88 */
99
10#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11#error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead."
10#ifndef __IMMINTRIN_H
11#error "Never use <rdseedintrin.h> directly; include <immintrin.h> instead."
1212#endif
1313
1414#ifndef __RDSEEDINTRIN_H
......@@ -17,12 +17,54 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("rdseed")))
1919
20/// Stores a hardware-generated 16-bit random value in the memory at \a __p.
21///
22/// The random number generator complies with NIST SP800-90B and SP800-90C.
23///
24/// \code{.operation}
25/// IF HW_NRND_GEN.ready == 1
26/// Store16(__p, HW_NRND_GEN.data)
27/// result := 1
28/// ELSE
29/// Store16(__p, 0)
30/// result := 0
31/// END
32/// \endcode
33///
34/// \headerfile <immintrin.h>
35///
36/// This intrinsic corresponds to the \c RDSEED instruction.
37///
38/// \param __p
39/// Pointer to memory for storing the 16-bit random number.
40/// \returns 1 if a random number was generated, 0 if not.
2041static __inline__ int __DEFAULT_FN_ATTRS
2142_rdseed16_step(unsigned short *__p)
2243{
2344 return (int) __builtin_ia32_rdseed16_step(__p);
2445}
2546
47/// Stores a hardware-generated 32-bit random value in the memory at \a __p.
48///
49/// The random number generator complies with NIST SP800-90B and SP800-90C.
50///
51/// \code{.operation}
52/// IF HW_NRND_GEN.ready == 1
53/// Store32(__p, HW_NRND_GEN.data)
54/// result := 1
55/// ELSE
56/// Store32(__p, 0)
57/// result := 0
58/// END
59/// \endcode
60///
61/// \headerfile <immintrin.h>
62///
63/// This intrinsic corresponds to the \c RDSEED instruction.
64///
65/// \param __p
66/// Pointer to memory for storing the 32-bit random number.
67/// \returns 1 if a random number was generated, 0 if not.
2668static __inline__ int __DEFAULT_FN_ATTRS
2769_rdseed32_step(unsigned int *__p)
2870{
......@@ -30,6 +72,27 @@ _rdseed32_step(unsigned int *__p)
3072}
3173
3274#ifdef __x86_64__
75/// Stores a hardware-generated 64-bit random value in the memory at \a __p.
76///
77/// The random number generator complies with NIST SP800-90B and SP800-90C.
78///
79/// \code{.operation}
80/// IF HW_NRND_GEN.ready == 1
81/// Store64(__p, HW_NRND_GEN.data)
82/// result := 1
83/// ELSE
84/// Store64(__p, 0)
85/// result := 0
86/// END
87/// \endcode
88///
89/// \headerfile <immintrin.h>
90///
91/// This intrinsic corresponds to the \c RDSEED instruction.
92///
93/// \param __p
94/// Pointer to memory for storing the 64-bit random number.
95/// \returns 1 if a random number was generated, 0 if not.
3396static __inline__ int __DEFAULT_FN_ATTRS
3497_rdseed64_step(unsigned long long *__p)
3598{
lib/include/riscv_ntlh.h created+28
......@@ -0,0 +1,28 @@
1/*===---- riscv_ntlh.h - RISC-V NTLH intrinsics ----------------------------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __RISCV_NTLH_H
11#define __RISCV_NTLH_H
12
13#ifndef __riscv_zihintntl
14#error "NTLH intrinsics require the NTLH extension."
15#endif
16
17enum {
18 __RISCV_NTLH_INNERMOST_PRIVATE = 2,
19 __RISCV_NTLH_ALL_PRIVATE,
20 __RISCV_NTLH_INNERMOST_SHARED,
21 __RISCV_NTLH_ALL
22};
23
24#define __riscv_ntl_load(PTR, DOMAIN) __builtin_riscv_ntl_load((PTR), (DOMAIN))
25#define __riscv_ntl_store(PTR, VAL, DOMAIN) \
26 __builtin_riscv_ntl_store((PTR), (VAL), (DOMAIN))
27
28#endif
\ No newline at end of file
lib/include/riscv_vector.h+240-51
......@@ -25,52 +25,15 @@ extern "C" {
2525#pragma clang riscv intrinsic vector
2626
2727
28#define __riscv_vlenb() __builtin_rvv_vlenb()
29
30enum RVV_CSR {
31 RVV_VSTART = 0,
32 RVV_VXSAT,
33 RVV_VXRM,
34 RVV_VCSR,
28enum __RISCV_FRM {
29 __RISCV_FRM_RNE = 0,
30 __RISCV_FRM_RTZ = 1,
31 __RISCV_FRM_RDN = 2,
32 __RISCV_FRM_RUP = 3,
33 __RISCV_FRM_RMM = 4,
3534};
3635
37static __inline__ __attribute__((__always_inline__, __nodebug__))
38unsigned long __riscv_vread_csr(enum RVV_CSR __csr) {
39 unsigned long __rv = 0;
40 switch (__csr) {
41 case RVV_VSTART:
42 __asm__ __volatile__ ("csrr\t%0, vstart" : "=r"(__rv) : : "memory");
43 break;
44 case RVV_VXSAT:
45 __asm__ __volatile__ ("csrr\t%0, vxsat" : "=r"(__rv) : : "memory");
46 break;
47 case RVV_VXRM:
48 __asm__ __volatile__ ("csrr\t%0, vxrm" : "=r"(__rv) : : "memory");
49 break;
50 case RVV_VCSR:
51 __asm__ __volatile__ ("csrr\t%0, vcsr" : "=r"(__rv) : : "memory");
52 break;
53 }
54 return __rv;
55}
56
57static __inline__ __attribute__((__always_inline__, __nodebug__))
58void __riscv_vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
59 switch (__csr) {
60 case RVV_VSTART:
61 __asm__ __volatile__ ("csrw\tvstart, %z0" : : "rJ"(__value) : "memory");
62 break;
63 case RVV_VXSAT:
64 __asm__ __volatile__ ("csrw\tvxsat, %z0" : : "rJ"(__value) : "memory");
65 break;
66 case RVV_VXRM:
67 __asm__ __volatile__ ("csrw\tvxrm, %z0" : : "rJ"(__value) : "memory");
68 break;
69 case RVV_VCSR:
70 __asm__ __volatile__ ("csrw\tvcsr, %z0" : : "rJ"(__value) : "memory");
71 break;
72 }
73}
36#define __riscv_vlenb() __builtin_rvv_vlenb()
7437
7538#define __riscv_vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6)
7639#define __riscv_vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7)
......@@ -130,6 +93,13 @@ void __riscv_vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
13093#define __riscv_vsetvlmax_e64m8() __builtin_rvv_vsetvlimax(3, 3)
13194#endif
13295
96
97enum __RISCV_VXRM {
98 __RISCV_VXRM_RNU = 0,
99 __RISCV_VXRM_RNE = 1,
100 __RISCV_VXRM_RDN = 2,
101 __RISCV_VXRM_ROD = 3,
102};
133103typedef __rvv_bool64_t vbool64_t;
134104typedef __rvv_bool32_t vbool32_t;
135105typedef __rvv_bool16_t vbool16_t;
......@@ -139,70 +109,289 @@ typedef __rvv_bool2_t vbool2_t;
139109typedef __rvv_bool1_t vbool1_t;
140110typedef __rvv_int8mf8_t vint8mf8_t;
141111typedef __rvv_uint8mf8_t vuint8mf8_t;
112typedef __rvv_int8mf8x2_t vint8mf8x2_t;
113typedef __rvv_uint8mf8x2_t vuint8mf8x2_t;
114typedef __rvv_int8mf8x3_t vint8mf8x3_t;
115typedef __rvv_uint8mf8x3_t vuint8mf8x3_t;
116typedef __rvv_int8mf8x4_t vint8mf8x4_t;
117typedef __rvv_uint8mf8x4_t vuint8mf8x4_t;
118typedef __rvv_int8mf8x5_t vint8mf8x5_t;
119typedef __rvv_uint8mf8x5_t vuint8mf8x5_t;
120typedef __rvv_int8mf8x6_t vint8mf8x6_t;
121typedef __rvv_uint8mf8x6_t vuint8mf8x6_t;
122typedef __rvv_int8mf8x7_t vint8mf8x7_t;
123typedef __rvv_uint8mf8x7_t vuint8mf8x7_t;
124typedef __rvv_int8mf8x8_t vint8mf8x8_t;
125typedef __rvv_uint8mf8x8_t vuint8mf8x8_t;
142126typedef __rvv_int8mf4_t vint8mf4_t;
143127typedef __rvv_uint8mf4_t vuint8mf4_t;
128typedef __rvv_int8mf4x2_t vint8mf4x2_t;
129typedef __rvv_uint8mf4x2_t vuint8mf4x2_t;
130typedef __rvv_int8mf4x3_t vint8mf4x3_t;
131typedef __rvv_uint8mf4x3_t vuint8mf4x3_t;
132typedef __rvv_int8mf4x4_t vint8mf4x4_t;
133typedef __rvv_uint8mf4x4_t vuint8mf4x4_t;
134typedef __rvv_int8mf4x5_t vint8mf4x5_t;
135typedef __rvv_uint8mf4x5_t vuint8mf4x5_t;
136typedef __rvv_int8mf4x6_t vint8mf4x6_t;
137typedef __rvv_uint8mf4x6_t vuint8mf4x6_t;
138typedef __rvv_int8mf4x7_t vint8mf4x7_t;
139typedef __rvv_uint8mf4x7_t vuint8mf4x7_t;
140typedef __rvv_int8mf4x8_t vint8mf4x8_t;
141typedef __rvv_uint8mf4x8_t vuint8mf4x8_t;
144142typedef __rvv_int8mf2_t vint8mf2_t;
145143typedef __rvv_uint8mf2_t vuint8mf2_t;
144typedef __rvv_int8mf2x2_t vint8mf2x2_t;
145typedef __rvv_uint8mf2x2_t vuint8mf2x2_t;
146typedef __rvv_int8mf2x3_t vint8mf2x3_t;
147typedef __rvv_uint8mf2x3_t vuint8mf2x3_t;
148typedef __rvv_int8mf2x4_t vint8mf2x4_t;
149typedef __rvv_uint8mf2x4_t vuint8mf2x4_t;
150typedef __rvv_int8mf2x5_t vint8mf2x5_t;
151typedef __rvv_uint8mf2x5_t vuint8mf2x5_t;
152typedef __rvv_int8mf2x6_t vint8mf2x6_t;
153typedef __rvv_uint8mf2x6_t vuint8mf2x6_t;
154typedef __rvv_int8mf2x7_t vint8mf2x7_t;
155typedef __rvv_uint8mf2x7_t vuint8mf2x7_t;
156typedef __rvv_int8mf2x8_t vint8mf2x8_t;
157typedef __rvv_uint8mf2x8_t vuint8mf2x8_t;
146158typedef __rvv_int8m1_t vint8m1_t;
147159typedef __rvv_uint8m1_t vuint8m1_t;
160typedef __rvv_int8m1x2_t vint8m1x2_t;
161typedef __rvv_uint8m1x2_t vuint8m1x2_t;
162typedef __rvv_int8m1x3_t vint8m1x3_t;
163typedef __rvv_uint8m1x3_t vuint8m1x3_t;
164typedef __rvv_int8m1x4_t vint8m1x4_t;
165typedef __rvv_uint8m1x4_t vuint8m1x4_t;
166typedef __rvv_int8m1x5_t vint8m1x5_t;
167typedef __rvv_uint8m1x5_t vuint8m1x5_t;
168typedef __rvv_int8m1x6_t vint8m1x6_t;
169typedef __rvv_uint8m1x6_t vuint8m1x6_t;
170typedef __rvv_int8m1x7_t vint8m1x7_t;
171typedef __rvv_uint8m1x7_t vuint8m1x7_t;
172typedef __rvv_int8m1x8_t vint8m1x8_t;
173typedef __rvv_uint8m1x8_t vuint8m1x8_t;
148174typedef __rvv_int8m2_t vint8m2_t;
149175typedef __rvv_uint8m2_t vuint8m2_t;
176typedef __rvv_int8m2x2_t vint8m2x2_t;
177typedef __rvv_uint8m2x2_t vuint8m2x2_t;
178typedef __rvv_int8m2x3_t vint8m2x3_t;
179typedef __rvv_uint8m2x3_t vuint8m2x3_t;
180typedef __rvv_int8m2x4_t vint8m2x4_t;
181typedef __rvv_uint8m2x4_t vuint8m2x4_t;
150182typedef __rvv_int8m4_t vint8m4_t;
151183typedef __rvv_uint8m4_t vuint8m4_t;
184typedef __rvv_int8m4x2_t vint8m4x2_t;
185typedef __rvv_uint8m4x2_t vuint8m4x2_t;
152186typedef __rvv_int8m8_t vint8m8_t;
153187typedef __rvv_uint8m8_t vuint8m8_t;
154188typedef __rvv_int16mf4_t vint16mf4_t;
155189typedef __rvv_uint16mf4_t vuint16mf4_t;
190typedef __rvv_int16mf4x2_t vint16mf4x2_t;
191typedef __rvv_uint16mf4x2_t vuint16mf4x2_t;
192typedef __rvv_int16mf4x3_t vint16mf4x3_t;
193typedef __rvv_uint16mf4x3_t vuint16mf4x3_t;
194typedef __rvv_int16mf4x4_t vint16mf4x4_t;
195typedef __rvv_uint16mf4x4_t vuint16mf4x4_t;
196typedef __rvv_int16mf4x5_t vint16mf4x5_t;
197typedef __rvv_uint16mf4x5_t vuint16mf4x5_t;
198typedef __rvv_int16mf4x6_t vint16mf4x6_t;
199typedef __rvv_uint16mf4x6_t vuint16mf4x6_t;
200typedef __rvv_int16mf4x7_t vint16mf4x7_t;
201typedef __rvv_uint16mf4x7_t vuint16mf4x7_t;
202typedef __rvv_int16mf4x8_t vint16mf4x8_t;
203typedef __rvv_uint16mf4x8_t vuint16mf4x8_t;
156204typedef __rvv_int16mf2_t vint16mf2_t;
157205typedef __rvv_uint16mf2_t vuint16mf2_t;
206typedef __rvv_int16mf2x2_t vint16mf2x2_t;
207typedef __rvv_uint16mf2x2_t vuint16mf2x2_t;
208typedef __rvv_int16mf2x3_t vint16mf2x3_t;
209typedef __rvv_uint16mf2x3_t vuint16mf2x3_t;
210typedef __rvv_int16mf2x4_t vint16mf2x4_t;
211typedef __rvv_uint16mf2x4_t vuint16mf2x4_t;
212typedef __rvv_int16mf2x5_t vint16mf2x5_t;
213typedef __rvv_uint16mf2x5_t vuint16mf2x5_t;
214typedef __rvv_int16mf2x6_t vint16mf2x6_t;
215typedef __rvv_uint16mf2x6_t vuint16mf2x6_t;
216typedef __rvv_int16mf2x7_t vint16mf2x7_t;
217typedef __rvv_uint16mf2x7_t vuint16mf2x7_t;
218typedef __rvv_int16mf2x8_t vint16mf2x8_t;
219typedef __rvv_uint16mf2x8_t vuint16mf2x8_t;
158220typedef __rvv_int16m1_t vint16m1_t;
159221typedef __rvv_uint16m1_t vuint16m1_t;
222typedef __rvv_int16m1x2_t vint16m1x2_t;
223typedef __rvv_uint16m1x2_t vuint16m1x2_t;
224typedef __rvv_int16m1x3_t vint16m1x3_t;
225typedef __rvv_uint16m1x3_t vuint16m1x3_t;
226typedef __rvv_int16m1x4_t vint16m1x4_t;
227typedef __rvv_uint16m1x4_t vuint16m1x4_t;
228typedef __rvv_int16m1x5_t vint16m1x5_t;
229typedef __rvv_uint16m1x5_t vuint16m1x5_t;
230typedef __rvv_int16m1x6_t vint16m1x6_t;
231typedef __rvv_uint16m1x6_t vuint16m1x6_t;
232typedef __rvv_int16m1x7_t vint16m1x7_t;
233typedef __rvv_uint16m1x7_t vuint16m1x7_t;
234typedef __rvv_int16m1x8_t vint16m1x8_t;
235typedef __rvv_uint16m1x8_t vuint16m1x8_t;
160236typedef __rvv_int16m2_t vint16m2_t;
161237typedef __rvv_uint16m2_t vuint16m2_t;
238typedef __rvv_int16m2x2_t vint16m2x2_t;
239typedef __rvv_uint16m2x2_t vuint16m2x2_t;
240typedef __rvv_int16m2x3_t vint16m2x3_t;
241typedef __rvv_uint16m2x3_t vuint16m2x3_t;
242typedef __rvv_int16m2x4_t vint16m2x4_t;
243typedef __rvv_uint16m2x4_t vuint16m2x4_t;
162244typedef __rvv_int16m4_t vint16m4_t;
163245typedef __rvv_uint16m4_t vuint16m4_t;
246typedef __rvv_int16m4x2_t vint16m4x2_t;
247typedef __rvv_uint16m4x2_t vuint16m4x2_t;
164248typedef __rvv_int16m8_t vint16m8_t;
165249typedef __rvv_uint16m8_t vuint16m8_t;
166250typedef __rvv_int32mf2_t vint32mf2_t;
167251typedef __rvv_uint32mf2_t vuint32mf2_t;
252typedef __rvv_int32mf2x2_t vint32mf2x2_t;
253typedef __rvv_uint32mf2x2_t vuint32mf2x2_t;
254typedef __rvv_int32mf2x3_t vint32mf2x3_t;
255typedef __rvv_uint32mf2x3_t vuint32mf2x3_t;
256typedef __rvv_int32mf2x4_t vint32mf2x4_t;
257typedef __rvv_uint32mf2x4_t vuint32mf2x4_t;
258typedef __rvv_int32mf2x5_t vint32mf2x5_t;
259typedef __rvv_uint32mf2x5_t vuint32mf2x5_t;
260typedef __rvv_int32mf2x6_t vint32mf2x6_t;
261typedef __rvv_uint32mf2x6_t vuint32mf2x6_t;
262typedef __rvv_int32mf2x7_t vint32mf2x7_t;
263typedef __rvv_uint32mf2x7_t vuint32mf2x7_t;
264typedef __rvv_int32mf2x8_t vint32mf2x8_t;
265typedef __rvv_uint32mf2x8_t vuint32mf2x8_t;
168266typedef __rvv_int32m1_t vint32m1_t;
169267typedef __rvv_uint32m1_t vuint32m1_t;
268typedef __rvv_int32m1x2_t vint32m1x2_t;
269typedef __rvv_uint32m1x2_t vuint32m1x2_t;
270typedef __rvv_int32m1x3_t vint32m1x3_t;
271typedef __rvv_uint32m1x3_t vuint32m1x3_t;
272typedef __rvv_int32m1x4_t vint32m1x4_t;
273typedef __rvv_uint32m1x4_t vuint32m1x4_t;
274typedef __rvv_int32m1x5_t vint32m1x5_t;
275typedef __rvv_uint32m1x5_t vuint32m1x5_t;
276typedef __rvv_int32m1x6_t vint32m1x6_t;
277typedef __rvv_uint32m1x6_t vuint32m1x6_t;
278typedef __rvv_int32m1x7_t vint32m1x7_t;
279typedef __rvv_uint32m1x7_t vuint32m1x7_t;
280typedef __rvv_int32m1x8_t vint32m1x8_t;
281typedef __rvv_uint32m1x8_t vuint32m1x8_t;
170282typedef __rvv_int32m2_t vint32m2_t;
171283typedef __rvv_uint32m2_t vuint32m2_t;
284typedef __rvv_int32m2x2_t vint32m2x2_t;
285typedef __rvv_uint32m2x2_t vuint32m2x2_t;
286typedef __rvv_int32m2x3_t vint32m2x3_t;
287typedef __rvv_uint32m2x3_t vuint32m2x3_t;
288typedef __rvv_int32m2x4_t vint32m2x4_t;
289typedef __rvv_uint32m2x4_t vuint32m2x4_t;
172290typedef __rvv_int32m4_t vint32m4_t;
173291typedef __rvv_uint32m4_t vuint32m4_t;
292typedef __rvv_int32m4x2_t vint32m4x2_t;
293typedef __rvv_uint32m4x2_t vuint32m4x2_t;
174294typedef __rvv_int32m8_t vint32m8_t;
175295typedef __rvv_uint32m8_t vuint32m8_t;
176296typedef __rvv_int64m1_t vint64m1_t;
177297typedef __rvv_uint64m1_t vuint64m1_t;
298typedef __rvv_int64m1x2_t vint64m1x2_t;
299typedef __rvv_uint64m1x2_t vuint64m1x2_t;
300typedef __rvv_int64m1x3_t vint64m1x3_t;
301typedef __rvv_uint64m1x3_t vuint64m1x3_t;
302typedef __rvv_int64m1x4_t vint64m1x4_t;
303typedef __rvv_uint64m1x4_t vuint64m1x4_t;
304typedef __rvv_int64m1x5_t vint64m1x5_t;
305typedef __rvv_uint64m1x5_t vuint64m1x5_t;
306typedef __rvv_int64m1x6_t vint64m1x6_t;
307typedef __rvv_uint64m1x6_t vuint64m1x6_t;
308typedef __rvv_int64m1x7_t vint64m1x7_t;
309typedef __rvv_uint64m1x7_t vuint64m1x7_t;
310typedef __rvv_int64m1x8_t vint64m1x8_t;
311typedef __rvv_uint64m1x8_t vuint64m1x8_t;
178312typedef __rvv_int64m2_t vint64m2_t;
179313typedef __rvv_uint64m2_t vuint64m2_t;
314typedef __rvv_int64m2x2_t vint64m2x2_t;
315typedef __rvv_uint64m2x2_t vuint64m2x2_t;
316typedef __rvv_int64m2x3_t vint64m2x3_t;
317typedef __rvv_uint64m2x3_t vuint64m2x3_t;
318typedef __rvv_int64m2x4_t vint64m2x4_t;
319typedef __rvv_uint64m2x4_t vuint64m2x4_t;
180320typedef __rvv_int64m4_t vint64m4_t;
181321typedef __rvv_uint64m4_t vuint64m4_t;
322typedef __rvv_int64m4x2_t vint64m4x2_t;
323typedef __rvv_uint64m4x2_t vuint64m4x2_t;
182324typedef __rvv_int64m8_t vint64m8_t;
183325typedef __rvv_uint64m8_t vuint64m8_t;
184#if defined(__riscv_zvfh)
185326typedef __rvv_float16mf4_t vfloat16mf4_t;
327typedef __rvv_float16mf4x2_t vfloat16mf4x2_t;
328typedef __rvv_float16mf4x3_t vfloat16mf4x3_t;
329typedef __rvv_float16mf4x4_t vfloat16mf4x4_t;
330typedef __rvv_float16mf4x5_t vfloat16mf4x5_t;
331typedef __rvv_float16mf4x6_t vfloat16mf4x6_t;
332typedef __rvv_float16mf4x7_t vfloat16mf4x7_t;
333typedef __rvv_float16mf4x8_t vfloat16mf4x8_t;
186334typedef __rvv_float16mf2_t vfloat16mf2_t;
335typedef __rvv_float16mf2x2_t vfloat16mf2x2_t;
336typedef __rvv_float16mf2x3_t vfloat16mf2x3_t;
337typedef __rvv_float16mf2x4_t vfloat16mf2x4_t;
338typedef __rvv_float16mf2x5_t vfloat16mf2x5_t;
339typedef __rvv_float16mf2x6_t vfloat16mf2x6_t;
340typedef __rvv_float16mf2x7_t vfloat16mf2x7_t;
341typedef __rvv_float16mf2x8_t vfloat16mf2x8_t;
187342typedef __rvv_float16m1_t vfloat16m1_t;
343typedef __rvv_float16m1x2_t vfloat16m1x2_t;
344typedef __rvv_float16m1x3_t vfloat16m1x3_t;
345typedef __rvv_float16m1x4_t vfloat16m1x4_t;
346typedef __rvv_float16m1x5_t vfloat16m1x5_t;
347typedef __rvv_float16m1x6_t vfloat16m1x6_t;
348typedef __rvv_float16m1x7_t vfloat16m1x7_t;
349typedef __rvv_float16m1x8_t vfloat16m1x8_t;
188350typedef __rvv_float16m2_t vfloat16m2_t;
351typedef __rvv_float16m2x2_t vfloat16m2x2_t;
352typedef __rvv_float16m2x3_t vfloat16m2x3_t;
353typedef __rvv_float16m2x4_t vfloat16m2x4_t;
189354typedef __rvv_float16m4_t vfloat16m4_t;
355typedef __rvv_float16m4x2_t vfloat16m4x2_t;
190356typedef __rvv_float16m8_t vfloat16m8_t;
191#endif
192#if (__riscv_v_elen_fp >= 32)
193357typedef __rvv_float32mf2_t vfloat32mf2_t;
358typedef __rvv_float32mf2x2_t vfloat32mf2x2_t;
359typedef __rvv_float32mf2x3_t vfloat32mf2x3_t;
360typedef __rvv_float32mf2x4_t vfloat32mf2x4_t;
361typedef __rvv_float32mf2x5_t vfloat32mf2x5_t;
362typedef __rvv_float32mf2x6_t vfloat32mf2x6_t;
363typedef __rvv_float32mf2x7_t vfloat32mf2x7_t;
364typedef __rvv_float32mf2x8_t vfloat32mf2x8_t;
194365typedef __rvv_float32m1_t vfloat32m1_t;
366typedef __rvv_float32m1x2_t vfloat32m1x2_t;
367typedef __rvv_float32m1x3_t vfloat32m1x3_t;
368typedef __rvv_float32m1x4_t vfloat32m1x4_t;
369typedef __rvv_float32m1x5_t vfloat32m1x5_t;
370typedef __rvv_float32m1x6_t vfloat32m1x6_t;
371typedef __rvv_float32m1x7_t vfloat32m1x7_t;
372typedef __rvv_float32m1x8_t vfloat32m1x8_t;
195373typedef __rvv_float32m2_t vfloat32m2_t;
374typedef __rvv_float32m2x2_t vfloat32m2x2_t;
375typedef __rvv_float32m2x3_t vfloat32m2x3_t;
376typedef __rvv_float32m2x4_t vfloat32m2x4_t;
196377typedef __rvv_float32m4_t vfloat32m4_t;
378typedef __rvv_float32m4x2_t vfloat32m4x2_t;
197379typedef __rvv_float32m8_t vfloat32m8_t;
198#endif
199#if (__riscv_v_elen_fp >= 64)
200380typedef __rvv_float64m1_t vfloat64m1_t;
381typedef __rvv_float64m1x2_t vfloat64m1x2_t;
382typedef __rvv_float64m1x3_t vfloat64m1x3_t;
383typedef __rvv_float64m1x4_t vfloat64m1x4_t;
384typedef __rvv_float64m1x5_t vfloat64m1x5_t;
385typedef __rvv_float64m1x6_t vfloat64m1x6_t;
386typedef __rvv_float64m1x7_t vfloat64m1x7_t;
387typedef __rvv_float64m1x8_t vfloat64m1x8_t;
201388typedef __rvv_float64m2_t vfloat64m2_t;
389typedef __rvv_float64m2x2_t vfloat64m2x2_t;
390typedef __rvv_float64m2x3_t vfloat64m2x3_t;
391typedef __rvv_float64m2x4_t vfloat64m2x4_t;
202392typedef __rvv_float64m4_t vfloat64m4_t;
393typedef __rvv_float64m4x2_t vfloat64m4x2_t;
203394typedef __rvv_float64m8_t vfloat64m8_t;
204#endif
205
206395#define __riscv_v_intrinsic_overloading 1
207396
208397#ifdef __cplusplus
lib/include/sha512intrin.h created+200
......@@ -0,0 +1,200 @@
1/*===--------------- sha512intrin.h - SHA512 intrinsics -----------------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __IMMINTRIN_H
11#error "Never use <sha512intrin.h> directly; include <immintrin.h> instead."
12#endif // __IMMINTRIN_H
13
14#ifndef __SHA512INTRIN_H
15#define __SHA512INTRIN_H
16
17#define __DEFAULT_FN_ATTRS256 \
18 __attribute__((__always_inline__, __nodebug__, __target__("sha512"), \
19 __min_vector_width__(256)))
20
21/// This intrinisc is one of the two SHA512 message scheduling instructions.
22/// The intrinsic performs an intermediate calculation for the next four
23/// SHA512 message qwords. The calculated results are stored in \a dst.
24///
25/// \headerfile <immintrin.h>
26///
27/// \code
28/// __m256i _mm256_sha512msg1_epi64(__m256i __A, __m128i __B)
29/// \endcode
30///
31/// This intrinsic corresponds to the \c VSHA512MSG1 instruction.
32///
33/// \param __A
34/// A 256-bit vector of [4 x long long].
35/// \param __B
36/// A 128-bit vector of [2 x long long].
37/// \returns
38/// A 256-bit vector of [4 x long long].
39///
40/// \code{.operation}
41/// DEFINE ROR64(qword, n) {
42/// count := n % 64
43/// dest := (qword >> count) | (qword << (64 - count))
44/// RETURN dest
45/// }
46/// DEFINE SHR64(qword, n) {
47/// RETURN qword >> n
48/// }
49/// DEFINE s0(qword):
50/// RETURN ROR64(qword,1) ^ ROR64(qword, 8) ^ SHR64(qword, 7)
51/// }
52/// W[4] := __B.qword[0]
53/// W[3] := __A.qword[3]
54/// W[2] := __A.qword[2]
55/// W[1] := __A.qword[1]
56/// W[0] := __A.qword[0]
57/// dst.qword[3] := W[3] + s0(W[4])
58/// dst.qword[2] := W[2] + s0(W[3])
59/// dst.qword[1] := W[1] + s0(W[2])
60/// dst.qword[0] := W[0] + s0(W[1])
61/// dst[MAX:256] := 0
62/// \endcode
63static __inline__ __m256i __DEFAULT_FN_ATTRS256
64_mm256_sha512msg1_epi64(__m256i __A, __m128i __B) {
65 return (__m256i)__builtin_ia32_vsha512msg1((__v4du)__A, (__v2du)__B);
66}
67
68/// This intrinisc is one of the two SHA512 message scheduling instructions.
69/// The intrinsic performs the final calculation for the next four SHA512
70/// message qwords. The calculated results are stored in \a dst.
71///
72/// \headerfile <immintrin.h>
73///
74/// \code
75/// __m256i _mm256_sha512msg2_epi64(__m256i __A, __m256i __B)
76/// \endcode
77///
78/// This intrinsic corresponds to the \c VSHA512MSG2 instruction.
79///
80/// \param __A
81/// A 256-bit vector of [4 x long long].
82/// \param __B
83/// A 256-bit vector of [4 x long long].
84/// \returns
85/// A 256-bit vector of [4 x long long].
86///
87/// \code{.operation}
88/// DEFINE ROR64(qword, n) {
89/// count := n % 64
90/// dest := (qword >> count) | (qword << (64 - count))
91/// RETURN dest
92/// }
93/// DEFINE SHR64(qword, n) {
94/// RETURN qword >> n
95/// }
96/// DEFINE s1(qword) {
97/// RETURN ROR64(qword,19) ^ ROR64(qword, 61) ^ SHR64(qword, 6)
98/// }
99/// W[14] := __B.qword[2]
100/// W[15] := __B.qword[3]
101/// W[16] := __A.qword[0] + s1(W[14])
102/// W[17] := __A.qword[1] + s1(W[15])
103/// W[18] := __A.qword[2] + s1(W[16])
104/// W[19] := __A.qword[3] + s1(W[17])
105/// dst.qword[3] := W[19]
106/// dst.qword[2] := W[18]
107/// dst.qword[1] := W[17]
108/// dst.qword[0] := W[16]
109/// dst[MAX:256] := 0
110/// \endcode
111static __inline__ __m256i __DEFAULT_FN_ATTRS256
112_mm256_sha512msg2_epi64(__m256i __A, __m256i __B) {
113 return (__m256i)__builtin_ia32_vsha512msg2((__v4du)__A, (__v4du)__B);
114}
115
116/// This intrinisc performs two rounds of SHA512 operation using initial SHA512
117/// state (C,D,G,H) from \a __A, an initial SHA512 state (A,B,E,F) from
118/// \a __A, and a pre-computed sum of the next two round message qwords and
119/// the corresponding round constants from \a __C (only the two lower qwords
120/// of the third operand). The updated SHA512 state (A,B,E,F) is written to
121/// \a __A, and \a __A can be used as the updated state (C,D,G,H) in later
122/// rounds.
123///
124/// \headerfile <immintrin.h>
125///
126/// \code
127/// __m256i _mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C)
128/// \endcode
129///
130/// This intrinsic corresponds to the \c VSHA512RNDS2 instruction.
131///
132/// \param __A
133/// A 256-bit vector of [4 x long long].
134/// \param __B
135/// A 256-bit vector of [4 x long long].
136/// \param __C
137/// A 128-bit vector of [2 x long long].
138/// \returns
139/// A 256-bit vector of [4 x long long].
140///
141/// \code{.operation}
142/// DEFINE ROR64(qword, n) {
143/// count := n % 64
144/// dest := (qword >> count) | (qword << (64 - count))
145/// RETURN dest
146/// }
147/// DEFINE SHR64(qword, n) {
148/// RETURN qword >> n
149/// }
150/// DEFINE cap_sigma0(qword) {
151/// RETURN ROR64(qword,28) ^ ROR64(qword, 34) ^ ROR64(qword, 39)
152/// }
153/// DEFINE cap_sigma1(qword) {
154/// RETURN ROR64(qword,14) ^ ROR64(qword, 18) ^ ROR64(qword, 41)
155/// }
156/// DEFINE MAJ(a,b,c) {
157/// RETURN (a & b) ^ (a & c) ^ (b & c)
158/// }
159/// DEFINE CH(e,f,g) {
160/// RETURN (e & f) ^ (g & ~e)
161/// }
162/// A[0] := __B.qword[3]
163/// B[0] := __B.qword[2]
164/// C[0] := __C.qword[3]
165/// D[0] := __C.qword[2]
166/// E[0] := __B.qword[1]
167/// F[0] := __B.qword[0]
168/// G[0] := __C.qword[1]
169/// H[0] := __C.qword[0]
170/// WK[0]:= __A.qword[0]
171/// WK[1]:= __A.qword[1]
172/// FOR i := 0 to 1:
173/// A[i+1] := CH(E[i], F[i], G[i]) +
174/// cap_sigma1(E[i]) + WK[i] + H[i] +
175/// MAJ(A[i], B[i], C[i]) +
176/// cap_sigma0(A[i])
177/// B[i+1] := A[i]
178/// C[i+1] := B[i]
179/// D[i+1] := C[i]
180/// E[i+1] := CH(E[i], F[i], G[i]) +
181/// cap_sigma1(E[i]) + WK[i] + H[i] + D[i]
182/// F[i+1] := E[i]
183/// G[i+1] := F[i]
184/// H[i+1] := G[i]
185/// ENDFOR
186/// dst.qword[3] := A[2]
187/// dst.qword[2] := B[2]
188/// dst.qword[1] := E[2]
189/// dst.qword[0] := F[2]
190/// dst[MAX:256] := 0
191/// \endcode
192static __inline__ __m256i __DEFAULT_FN_ATTRS256
193_mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C) {
194 return (__m256i)__builtin_ia32_vsha512rnds2((__v4du)__A, (__v4du)__B,
195 (__v2du)__C);
196}
197
198#undef __DEFAULT_FN_ATTRS256
199
200#endif // __SHA512INTRIN_H
lib/include/shaintrin.h+128
......@@ -17,39 +17,167 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sha"), __min_vector_width__(128)))
1919
20/// Performs four iterations of the inner loop of the SHA-1 message digest
21/// algorithm using the starting SHA-1 state (A, B, C, D) from the 128-bit
22/// vector of [4 x i32] in \a V1 and the next four 32-bit elements of the
23/// message from the 128-bit vector of [4 x i32] in \a V2. Note that the
24/// SHA-1 state variable E must have already been added to \a V2
25/// (\c _mm_sha1nexte_epu32() can perform this step). Returns the updated
26/// SHA-1 state (A, B, C, D) as a 128-bit vector of [4 x i32].
27///
28/// The SHA-1 algorithm has an inner loop of 80 iterations, twenty each
29/// with a different combining function and rounding constant. This
30/// intrinsic performs four iterations using a combining function and
31/// rounding constant selected by \a M[1:0].
32///
33/// \headerfile <immintrin.h>
34///
35/// \code
36/// __m128i _mm_sha1rnds4_epu32(__m128i V1, __m128i V2, const int M);
37/// \endcode
38///
39/// This intrinsic corresponds to the \c SHA1RNDS4 instruction.
40///
41/// \param V1
42/// A 128-bit vector of [4 x i32] containing the initial SHA-1 state.
43/// \param V2
44/// A 128-bit vector of [4 x i32] containing the next four elements of
45/// the message, plus SHA-1 state variable E.
46/// \param M
47/// An immediate value where bits [1:0] select among four possible
48/// combining functions and rounding constants (not specified here).
49/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state.
2050#define _mm_sha1rnds4_epu32(V1, V2, M) \
2151 __builtin_ia32_sha1rnds4((__v4si)(__m128i)(V1), (__v4si)(__m128i)(V2), (M))
2252
53/// Calculates the SHA-1 state variable E from the SHA-1 state variables in
54/// the 128-bit vector of [4 x i32] in \a __X, adds that to the next set of
55/// four message elements in the 128-bit vector of [4 x i32] in \a __Y, and
56/// returns the result.
57///
58/// \headerfile <immintrin.h>
59///
60/// This intrinsic corresponds to the \c SHA1NEXTE instruction.
61///
62/// \param __X
63/// A 128-bit vector of [4 x i32] containing the current SHA-1 state.
64/// \param __Y
65/// A 128-bit vector of [4 x i32] containing the next four elements of the
66/// message.
67/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1
68/// values.
2369static __inline__ __m128i __DEFAULT_FN_ATTRS
2470_mm_sha1nexte_epu32(__m128i __X, __m128i __Y)
2571{
2672 return (__m128i)__builtin_ia32_sha1nexte((__v4si)__X, (__v4si)__Y);
2773}
2874
75/// Performs an intermediate calculation for deriving the next four SHA-1
76/// message elements using previous message elements from the 128-bit
77/// vectors of [4 x i32] in \a __X and \a __Y, and returns the result.
78///
79/// \headerfile <immintrin.h>
80///
81/// This intrinsic corresponds to the \c SHA1MSG1 instruction.
82///
83/// \param __X
84/// A 128-bit vector of [4 x i32] containing previous message elements.
85/// \param __Y
86/// A 128-bit vector of [4 x i32] containing previous message elements.
87/// \returns A 128-bit vector of [4 x i32] containing the derived SHA-1
88/// elements.
2989static __inline__ __m128i __DEFAULT_FN_ATTRS
3090_mm_sha1msg1_epu32(__m128i __X, __m128i __Y)
3191{
3292 return (__m128i)__builtin_ia32_sha1msg1((__v4si)__X, (__v4si)__Y);
3393}
3494
95/// Performs the final calculation for deriving the next four SHA-1 message
96/// elements using previous message elements from the 128-bit vectors of
97/// [4 x i32] in \a __X and \a __Y, and returns the result.
98///
99/// \headerfile <immintrin.h>
100///
101/// This intrinsic corresponds to the \c SHA1MSG2 instruction.
102///
103/// \param __X
104/// A 128-bit vector of [4 x i32] containing an intermediate result.
105/// \param __Y
106/// A 128-bit vector of [4 x i32] containing previous message values.
107/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1
108/// values.
35109static __inline__ __m128i __DEFAULT_FN_ATTRS
36110_mm_sha1msg2_epu32(__m128i __X, __m128i __Y)
37111{
38112 return (__m128i)__builtin_ia32_sha1msg2((__v4si)__X, (__v4si)__Y);
39113}
40114
115/// Performs two rounds of SHA-256 operation using the following inputs: a
116/// starting SHA-256 state (C, D, G, H) from the 128-bit vector of
117/// [4 x i32] in \a __X; a starting SHA-256 state (A, B, E, F) from the
118/// 128-bit vector of [4 x i32] in \a __Y; and a pre-computed sum of the
119/// next two message elements (unsigned 32-bit integers) and corresponding
120/// rounding constants from the 128-bit vector of [4 x i32] in \a __Z.
121/// Returns the updated SHA-256 state (A, B, E, F) as a 128-bit vector of
122/// [4 x i32].
123///
124/// The SHA-256 algorithm has a core loop of 64 iterations. This intrinsic
125/// performs two of those iterations.
126///
127/// \headerfile <immintrin.h>
128///
129/// This intrinsic corresponds to the \c SHA256RNDS2 instruction.
130///
131/// \param __X
132/// A 128-bit vector of [4 x i32] containing part of the initial SHA-256
133/// state.
134/// \param __Y
135/// A 128-bit vector of [4 x i32] containing part of the initial SHA-256
136/// state.
137/// \param __Z
138/// A 128-bit vector of [4 x i32] containing additional input to the
139/// SHA-256 operation.
140/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state.
41141static __inline__ __m128i __DEFAULT_FN_ATTRS
42142_mm_sha256rnds2_epu32(__m128i __X, __m128i __Y, __m128i __Z)
43143{
44144 return (__m128i)__builtin_ia32_sha256rnds2((__v4si)__X, (__v4si)__Y, (__v4si)__Z);
45145}
46146
147/// Performs an intermediate calculation for deriving the next four SHA-256
148/// message elements using previous message elements from the 128-bit
149/// vectors of [4 x i32] in \a __X and \a __Y, and returns the result.
150///
151/// \headerfile <immintrin.h>
152///
153/// This intrinsic corresponds to the \c SHA256MSG1 instruction.
154///
155/// \param __X
156/// A 128-bit vector of [4 x i32] containing previous message elements.
157/// \param __Y
158/// A 128-bit vector of [4 x i32] containing previous message elements.
159/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-256
160/// values.
47161static __inline__ __m128i __DEFAULT_FN_ATTRS
48162_mm_sha256msg1_epu32(__m128i __X, __m128i __Y)
49163{
50164 return (__m128i)__builtin_ia32_sha256msg1((__v4si)__X, (__v4si)__Y);
51165}
52166
167/// Performs the final calculation for deriving the next four SHA-256 message
168/// elements using previous message elements from the 128-bit vectors of
169/// [4 x i32] in \a __X and \a __Y, and returns the result.
170///
171/// \headerfile <immintrin.h>
172///
173/// This intrinsic corresponds to the \c SHA256MSG2 instruction.
174///
175/// \param __X
176/// A 128-bit vector of [4 x i32] containing an intermediate result.
177/// \param __Y
178/// A 128-bit vector of [4 x i32] containing previous message values.
179/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-256
180/// values.
53181static __inline__ __m128i __DEFAULT_FN_ATTRS
54182_mm_sha256msg2_epu32(__m128i __X, __m128i __Y)
55183{
lib/include/sifive_vector.h created+16
......@@ -0,0 +1,16 @@
1//===----- sifive_vector.h - SiFive Vector definitions --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _SIFIVE_VECTOR_H_
10#define _SIFIVE_VECTOR_H_
11
12#include "riscv_vector.h"
13
14#pragma clang riscv intrinsic sifive_vector
15
16#endif //_SIFIVE_VECTOR_H_
lib/include/sm3intrin.h created+238
......@@ -0,0 +1,238 @@
1/*===-------------------- sm3intrin.h - SM3 intrinsics ---------------------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __IMMINTRIN_H
11#error "Never use <sm3intrin.h> directly; include <immintrin.h> instead."
12#endif // __IMMINTRIN_H
13
14#ifndef __SM3INTRIN_H
15#define __SM3INTRIN_H
16
17#define __DEFAULT_FN_ATTRS128 \
18 __attribute__((__always_inline__, __nodebug__, __target__("sm3"), \
19 __min_vector_width__(128)))
20
21/// This intrinisc is one of the two SM3 message scheduling intrinsics. The
22/// intrinsic performs an initial calculation for the next four SM3 message
23/// words. The calculated results are stored in \a dst.
24///
25/// \headerfile <immintrin.h>
26///
27/// \code
28/// __m128i _mm_sm3msg1_epi32(__m128i __A, __m128i __B, __m128i __C)
29/// \endcode
30///
31/// This intrinsic corresponds to the \c VSM3MSG1 instruction.
32///
33/// \param __A
34/// A 128-bit vector of [4 x int].
35/// \param __B
36/// A 128-bit vector of [4 x int].
37/// \param __C
38/// A 128-bit vector of [4 x int].
39/// \returns
40/// A 128-bit vector of [4 x int].
41///
42/// \code{.operation}
43/// DEFINE ROL32(dword, n) {
44/// count := n % 32
45/// dest := (dword << count) | (dword >> (32 - count))
46/// RETURN dest
47/// }
48/// DEFINE P1(x) {
49/// RETURN x ^ ROL32(x, 15) ^ ROL32(x, 23)
50/// }
51/// W[0] := __C.dword[0]
52/// W[1] := __C.dword[1]
53/// W[2] := __C.dword[2]
54/// W[3] := __C.dword[3]
55/// W[7] := __A.dword[0]
56/// W[8] := __A.dword[1]
57/// W[9] := __A.dword[2]
58/// W[10] := __A.dword[3]
59/// W[13] := __B.dword[0]
60/// W[14] := __B.dword[1]
61/// W[15] := __B.dword[2]
62/// TMP0 := W[7] ^ W[0] ^ ROL32(W[13], 15)
63/// TMP1 := W[8] ^ W[1] ^ ROL32(W[14], 15)
64/// TMP2 := W[9] ^ W[2] ^ ROL32(W[15], 15)
65/// TMP3 := W[10] ^ W[3]
66/// dst.dword[0] := P1(TMP0)
67/// dst.dword[1] := P1(TMP1)
68/// dst.dword[2] := P1(TMP2)
69/// dst.dword[3] := P1(TMP3)
70/// dst[MAX:128] := 0
71/// \endcode
72static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_sm3msg1_epi32(__m128i __A,
73 __m128i __B,
74 __m128i __C) {
75 return (__m128i)__builtin_ia32_vsm3msg1((__v4su)__A, (__v4su)__B,
76 (__v4su)__C);
77}
78
79/// This intrinisc is one of the two SM3 message scheduling intrinsics. The
80/// intrinsic performs the final calculation for the next four SM3 message
81/// words. The calculated results are stored in \a dst.
82///
83/// \headerfile <immintrin.h>
84///
85/// \code
86/// __m128i _mm_sm3msg2_epi32(__m128i __A, __m128i __B, __m128i __C)
87/// \endcode
88///
89/// This intrinsic corresponds to the \c VSM3MSG2 instruction.
90///
91/// \param __A
92/// A 128-bit vector of [4 x int].
93/// \param __B
94/// A 128-bit vector of [4 x int].
95/// \param __C
96/// A 128-bit vector of [4 x int].
97/// \returns
98/// A 128-bit vector of [4 x int].
99///
100/// \code{.operation}
101/// DEFINE ROL32(dword, n) {
102/// count := n % 32
103/// dest := (dword << count) | (dword >> (32-count))
104/// RETURN dest
105/// }
106/// WTMP[0] := __A.dword[0]
107/// WTMP[1] := __A.dword[1]
108/// WTMP[2] := __A.dword[2]
109/// WTMP[3] := __A.dword[3]
110/// W[3] := __B.dword[0]
111/// W[4] := __B.dword[1]
112/// W[5] := __B.dword[2]
113/// W[6] := __B.dword[3]
114/// W[10] := __C.dword[0]
115/// W[11] := __C.dword[1]
116/// W[12] := __C.dword[2]
117/// W[13] := __C.dword[3]
118/// W[16] := ROL32(W[3], 7) ^ W[10] ^ WTMP[0]
119/// W[17] := ROL32(W[4], 7) ^ W[11] ^ WTMP[1]
120/// W[18] := ROL32(W[5], 7) ^ W[12] ^ WTMP[2]
121/// W[19] := ROL32(W[6], 7) ^ W[13] ^ WTMP[3]
122/// W[19] := W[19] ^ ROL32(W[16], 6) ^ ROL32(W[16], 15) ^ ROL32(W[16], 30)
123/// dst.dword[0] := W[16]
124/// dst.dword[1] := W[17]
125/// dst.dword[2] := W[18]
126/// dst.dword[3] := W[19]
127/// dst[MAX:128] := 0
128/// \endcode
129static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_sm3msg2_epi32(__m128i __A,
130 __m128i __B,
131 __m128i __C) {
132 return (__m128i)__builtin_ia32_vsm3msg2((__v4su)__A, (__v4su)__B,
133 (__v4su)__C);
134}
135
136/// This intrinsic performs two rounds of SM3 operation using initial SM3 state
137/// (C, D, G, H) from \a __A, an initial SM3 states (A, B, E, F)
138/// from \a __B and a pre-computed words from the \a __C. \a __A with
139/// initial SM3 state of (C, D, G, H) assumes input of non-rotated left
140/// variables from previous state. The updated SM3 state (A, B, E, F) is
141/// written to \a __A. The \a imm8 should contain the even round number
142/// for the first of the two rounds computed by this instruction. The
143/// computation masks the \a imm8 value by AND’ing it with 0x3E so that only
144/// even round numbers from 0 through 62 are used for this operation. The
145/// calculated results are stored in \a dst.
146///
147/// \headerfile <immintrin.h>
148///
149/// \code
150/// __m128i _mm_sm3rnds2_epi32(__m128i __A, __m128i __B, __m128i __C, const int
151/// imm8) \endcode
152///
153/// This intrinsic corresponds to the \c VSM3RNDS2 instruction.
154///
155/// \param __A
156/// A 128-bit vector of [4 x int].
157/// \param __B
158/// A 128-bit vector of [4 x int].
159/// \param __C
160/// A 128-bit vector of [4 x int].
161/// \param imm8
162/// A 8-bit constant integer.
163/// \returns
164/// A 128-bit vector of [4 x int].
165///
166/// \code{.operation}
167/// DEFINE ROL32(dword, n) {
168/// count := n % 32
169/// dest := (dword << count) | (dword >> (32-count))
170/// RETURN dest
171/// }
172/// DEFINE P0(dword) {
173/// RETURN dword ^ ROL32(dword, 9) ^ ROL32(dword, 17)
174/// }
175/// DEFINE FF(x,y,z, round){
176/// IF round < 16
177/// RETURN (x ^ y ^ z)
178/// ELSE
179/// RETURN (x & y) | (x & z) | (y & z)
180/// FI
181/// }
182/// DEFINE GG(x, y, z, round){
183/// IF round < 16
184/// RETURN (x ^ y ^ z)
185/// ELSE
186/// RETURN (x & y) | (~x & z)
187/// FI
188/// }
189/// A[0] := __B.dword[3]
190/// B[0] := __B.dword[2]
191/// C[0] := __A.dword[3]
192/// D[0] := __A.dword[2]
193/// E[0] := __B.dword[1]
194/// F[0] := __B.dword[0]
195/// G[0] := __A.dword[1]
196/// H[0] := __A.dword[0]
197/// W[0] := __C.dword[0]
198/// W[1] := __C.dword[1]
199/// W[4] := __C.dword[2]
200/// W[5] := __C.dword[3]
201/// C[0] := ROL32(C[0], 9)
202/// D[0] := ROL32(D[0], 9)
203/// G[0] := ROL32(G[0], 19)
204/// H[0] := ROL32(H[0], 19)
205/// ROUND := __D & 0x3E
206/// IF ROUND < 16
207/// CONST := 0x79CC4519
208/// ELSE
209/// CONST := 0x7A879D8A
210/// FI
211/// CONST := ROL32(CONST,ROUND)
212/// FOR i:= 0 to 1
213/// S1 := ROL32((ROL32(A[i], 12) + E[i] + CONST), 7)
214/// S2 := S1 ^ ROL32(A[i], 12)
215/// T1 := FF(A[i], B[i], C[i], ROUND) + D[i] + S2 + (W[i] ^ W[i+4])
216/// T2 := GG(E[i], F[i], G[i], ROUND) + H[i] + S1 + W[i]
217/// D[i+1] := C[i]
218/// C[i+1] := ROL32(B[i],9)
219/// B[i+1] := A[i]
220/// A[i+1] := T1
221/// H[i+1] := G[i]
222/// G[i+1] := ROL32(F[i], 19)
223/// F[i+1] := E[i]
224/// E[i+1] := P0(T2)
225/// CONST := ROL32(CONST, 1)
226/// ENDFOR
227/// dst.dword[3] := A[2]
228/// dst.dword[2] := B[2]
229/// dst.dword[1] := E[2]
230/// dst.dword[0] := F[2]
231/// dst[MAX:128] := 0
232/// \endcode
233#define _mm_sm3rnds2_epi32(A, B, C, D) \
234 (__m128i) __builtin_ia32_vsm3rnds2((__v4su)A, (__v4su)B, (__v4su)C, (int)D)
235
236#undef __DEFAULT_FN_ATTRS128
237
238#endif // __SM3INTRIN_H
lib/include/sm4intrin.h created+269
......@@ -0,0 +1,269 @@
1/*===--------------- sm4intrin.h - SM4 intrinsics -----------------===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __IMMINTRIN_H
11#error "Never use <sm4intrin.h> directly; include <immintrin.h> instead."
12#endif // __IMMINTRIN_H
13
14#ifndef __SM4INTRIN_H
15#define __SM4INTRIN_H
16
17/// This intrinsic performs four rounds of SM4 key expansion. The intrinsic
18/// operates on independent 128-bit lanes. The calculated results are
19/// stored in \a dst.
20/// \headerfile <immintrin.h>
21///
22/// \code
23/// __m128i _mm_sm4key4_epi32(__m128i __A, __m128i __B)
24/// \endcode
25///
26/// This intrinsic corresponds to the \c VSM4KEY4 instruction.
27///
28/// \param __A
29/// A 128-bit vector of [4 x int].
30/// \param __B
31/// A 128-bit vector of [4 x int].
32/// \returns
33/// A 128-bit vector of [4 x int].
34///
35/// \code{.operation}
36/// DEFINE ROL32(dword, n) {
37/// count := n % 32
38/// dest := (dword << count) | (dword >> (32-count))
39/// RETURN dest
40/// }
41/// DEFINE SBOX_BYTE(dword, i) {
42/// RETURN sbox[dword.byte[i]]
43/// }
44/// DEFINE lower_t(dword) {
45/// tmp.byte[0] := SBOX_BYTE(dword, 0)
46/// tmp.byte[1] := SBOX_BYTE(dword, 1)
47/// tmp.byte[2] := SBOX_BYTE(dword, 2)
48/// tmp.byte[3] := SBOX_BYTE(dword, 3)
49/// RETURN tmp
50/// }
51/// DEFINE L_KEY(dword) {
52/// RETURN dword ^ ROL32(dword, 13) ^ ROL32(dword, 23)
53/// }
54/// DEFINE T_KEY(dword) {
55/// RETURN L_KEY(lower_t(dword))
56/// }
57/// DEFINE F_KEY(X0, X1, X2, X3, round_key) {
58/// RETURN X0 ^ T_KEY(X1 ^ X2 ^ X3 ^ round_key)
59/// }
60/// FOR i:= 0 to 0
61/// P[0] := __B.xmm[i].dword[0]
62/// P[1] := __B.xmm[i].dword[1]
63/// P[2] := __B.xmm[i].dword[2]
64/// P[3] := __B.xmm[i].dword[3]
65/// C[0] := F_KEY(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0])
66/// C[1] := F_KEY(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1])
67/// C[2] := F_KEY(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2])
68/// C[3] := F_KEY(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3])
69/// DEST.xmm[i].dword[0] := C[0]
70/// DEST.xmm[i].dword[1] := C[1]
71/// DEST.xmm[i].dword[2] := C[2]
72/// DEST.xmm[i].dword[3] := C[3]
73/// ENDFOR
74/// DEST[MAX:128] := 0
75/// \endcode
76#define _mm_sm4key4_epi32(A, B) \
77 (__m128i) __builtin_ia32_vsm4key4128((__v4su)A, (__v4su)B)
78
79/// This intrinsic performs four rounds of SM4 key expansion. The intrinsic
80/// operates on independent 128-bit lanes. The calculated results are
81/// stored in \a dst.
82/// \headerfile <immintrin.h>
83///
84/// \code
85/// __m256i _mm256_sm4key4_epi32(__m256i __A, __m256i __B)
86/// \endcode
87///
88/// This intrinsic corresponds to the \c VSM4KEY4 instruction.
89///
90/// \param __A
91/// A 256-bit vector of [8 x int].
92/// \param __B
93/// A 256-bit vector of [8 x int].
94/// \returns
95/// A 256-bit vector of [8 x int].
96///
97/// \code{.operation}
98/// DEFINE ROL32(dword, n) {
99/// count := n % 32
100/// dest := (dword << count) | (dword >> (32-count))
101/// RETURN dest
102/// }
103/// DEFINE SBOX_BYTE(dword, i) {
104/// RETURN sbox[dword.byte[i]]
105/// }
106/// DEFINE lower_t(dword) {
107/// tmp.byte[0] := SBOX_BYTE(dword, 0)
108/// tmp.byte[1] := SBOX_BYTE(dword, 1)
109/// tmp.byte[2] := SBOX_BYTE(dword, 2)
110/// tmp.byte[3] := SBOX_BYTE(dword, 3)
111/// RETURN tmp
112/// }
113/// DEFINE L_KEY(dword) {
114/// RETURN dword ^ ROL32(dword, 13) ^ ROL32(dword, 23)
115/// }
116/// DEFINE T_KEY(dword) {
117/// RETURN L_KEY(lower_t(dword))
118/// }
119/// DEFINE F_KEY(X0, X1, X2, X3, round_key) {
120/// RETURN X0 ^ T_KEY(X1 ^ X2 ^ X3 ^ round_key)
121/// }
122/// FOR i:= 0 to 1
123/// P[0] := __B.xmm[i].dword[0]
124/// P[1] := __B.xmm[i].dword[1]
125/// P[2] := __B.xmm[i].dword[2]
126/// P[3] := __B.xmm[i].dword[3]
127/// C[0] := F_KEY(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0])
128/// C[1] := F_KEY(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1])
129/// C[2] := F_KEY(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2])
130/// C[3] := F_KEY(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3])
131/// DEST.xmm[i].dword[0] := C[0]
132/// DEST.xmm[i].dword[1] := C[1]
133/// DEST.xmm[i].dword[2] := C[2]
134/// DEST.xmm[i].dword[3] := C[3]
135/// ENDFOR
136/// DEST[MAX:256] := 0
137/// \endcode
138#define _mm256_sm4key4_epi32(A, B) \
139 (__m256i) __builtin_ia32_vsm4key4256((__v8su)A, (__v8su)B)
140
141/// This intrinisc performs four rounds of SM4 encryption. The intrinisc
142/// operates on independent 128-bit lanes. The calculated results are
143/// stored in \a dst.
144/// \headerfile <immintrin.h>
145///
146/// \code
147/// __m128i _mm_sm4rnds4_epi32(__m128i __A, __m128i __B)
148/// \endcode
149///
150/// This intrinsic corresponds to the \c VSM4RNDS4 instruction.
151///
152/// \param __A
153/// A 128-bit vector of [4 x int].
154/// \param __B
155/// A 128-bit vector of [4 x int].
156/// \returns
157/// A 128-bit vector of [4 x int].
158///
159/// \code{.operation}
160/// DEFINE ROL32(dword, n) {
161/// count := n % 32
162/// dest := (dword << count) | (dword >> (32-count))
163/// RETURN dest
164/// }
165/// DEFINE lower_t(dword) {
166/// tmp.byte[0] := SBOX_BYTE(dword, 0)
167/// tmp.byte[1] := SBOX_BYTE(dword, 1)
168/// tmp.byte[2] := SBOX_BYTE(dword, 2)
169/// tmp.byte[3] := SBOX_BYTE(dword, 3)
170/// RETURN tmp
171/// }
172/// DEFINE L_RND(dword) {
173/// tmp := dword
174/// tmp := tmp ^ ROL32(dword, 2)
175/// tmp := tmp ^ ROL32(dword, 10)
176/// tmp := tmp ^ ROL32(dword, 18)
177/// tmp := tmp ^ ROL32(dword, 24)
178/// RETURN tmp
179/// }
180/// DEFINE T_RND(dword) {
181/// RETURN L_RND(lower_t(dword))
182/// }
183/// DEFINE F_RND(X0, X1, X2, X3, round_key) {
184/// RETURN X0 ^ T_RND(X1 ^ X2 ^ X3 ^ round_key)
185/// }
186/// FOR i:= 0 to 0
187/// P[0] := __B.xmm[i].dword[0]
188/// P[1] := __B.xmm[i].dword[1]
189/// P[2] := __B.xmm[i].dword[2]
190/// P[3] := __B.xmm[i].dword[3]
191/// C[0] := F_RND(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0])
192/// C[1] := F_RND(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1])
193/// C[2] := F_RND(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2])
194/// C[3] := F_RND(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3])
195/// DEST.xmm[i].dword[0] := C[0]
196/// DEST.xmm[i].dword[1] := C[1]
197/// DEST.xmm[i].dword[2] := C[2]
198/// DEST.xmm[i].dword[3] := C[3]
199/// ENDFOR
200/// DEST[MAX:128] := 0
201/// \endcode
202#define _mm_sm4rnds4_epi32(A, B) \
203 (__m128i) __builtin_ia32_vsm4rnds4128((__v4su)A, (__v4su)B)
204
205/// This intrinisc performs four rounds of SM4 encryption. The intrinisc
206/// operates on independent 128-bit lanes. The calculated results are
207/// stored in \a dst.
208/// \headerfile <immintrin.h>
209///
210/// \code
211/// __m256i _mm256_sm4rnds4_epi32(__m256i __A, __m256i __B)
212/// \endcode
213///
214/// This intrinsic corresponds to the \c VSM4RNDS4 instruction.
215///
216/// \param __A
217/// A 256-bit vector of [8 x int].
218/// \param __B
219/// A 256-bit vector of [8 x int].
220/// \returns
221/// A 256-bit vector of [8 x int].
222///
223/// \code{.operation}
224/// DEFINE ROL32(dword, n) {
225/// count := n % 32
226/// dest := (dword << count) | (dword >> (32-count))
227/// RETURN dest
228/// }
229/// DEFINE lower_t(dword) {
230/// tmp.byte[0] := SBOX_BYTE(dword, 0)
231/// tmp.byte[1] := SBOX_BYTE(dword, 1)
232/// tmp.byte[2] := SBOX_BYTE(dword, 2)
233/// tmp.byte[3] := SBOX_BYTE(dword, 3)
234/// RETURN tmp
235/// }
236/// DEFINE L_RND(dword) {
237/// tmp := dword
238/// tmp := tmp ^ ROL32(dword, 2)
239/// tmp := tmp ^ ROL32(dword, 10)
240/// tmp := tmp ^ ROL32(dword, 18)
241/// tmp := tmp ^ ROL32(dword, 24)
242/// RETURN tmp
243/// }
244/// DEFINE T_RND(dword) {
245/// RETURN L_RND(lower_t(dword))
246/// }
247/// DEFINE F_RND(X0, X1, X2, X3, round_key) {
248/// RETURN X0 ^ T_RND(X1 ^ X2 ^ X3 ^ round_key)
249/// }
250/// FOR i:= 0 to 0
251/// P[0] := __B.xmm[i].dword[0]
252/// P[1] := __B.xmm[i].dword[1]
253/// P[2] := __B.xmm[i].dword[2]
254/// P[3] := __B.xmm[i].dword[3]
255/// C[0] := F_RND(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0])
256/// C[1] := F_RND(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1])
257/// C[2] := F_RND(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2])
258/// C[3] := F_RND(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3])
259/// DEST.xmm[i].dword[0] := C[0]
260/// DEST.xmm[i].dword[1] := C[1]
261/// DEST.xmm[i].dword[2] := C[2]
262/// DEST.xmm[i].dword[3] := C[3]
263/// ENDFOR
264/// DEST[MAX:256] := 0
265/// \endcode
266#define _mm256_sm4rnds4_epi32(A, B) \
267 (__m256i) __builtin_ia32_vsm4rnds4256((__v8su)A, (__v8su)B)
268
269#endif // __SM4INTRIN_H
lib/include/stdalign.h+5
......@@ -10,6 +10,10 @@
1010#ifndef __STDALIGN_H
1111#define __STDALIGN_H
1212
13/* FIXME: This is using the placeholder dates Clang produces for these macros
14 in C2x mode; switch to the correct values once they've been published. */
15#if defined(__cplusplus) || \
16 (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L)
1317#ifndef __cplusplus
1418#define alignas _Alignas
1519#define alignof _Alignof
......@@ -17,5 +21,6 @@
1721
1822#define __alignas_is_defined 1
1923#define __alignof_is_defined 1
24#endif /* __STDC_VERSION__ */
2025
2126#endif /* __STDALIGN_H */
lib/include/stdatomic.h+9-2
......@@ -45,9 +45,16 @@ extern "C" {
4545#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
4646
4747/* 7.17.2 Initialization */
48
48/* FIXME: This is using the placeholder dates Clang produces for these macros
49 in C2x mode; switch to the correct values once they've been published. */
50#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L) || \
51 defined(__cplusplus)
52/* ATOMIC_VAR_INIT was removed in C2x, but still remains in C++23. */
4953#define ATOMIC_VAR_INIT(value) (value)
50#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L) || \
54#endif
55
56#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L && \
57 __STDC_VERSION__ < 202000L) || \
5158 (defined(__cplusplus) && __cplusplus >= 202002L)) && \
5259 !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
5360/* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
lib/include/stddef.h+5
......@@ -103,6 +103,11 @@ using ::std::nullptr_t;
103103typedef typeof(nullptr) nullptr_t;
104104#endif /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L */
105105
106#if defined(__need_STDDEF_H_misc) && defined(__STDC_VERSION__) && \
107 __STDC_VERSION__ >= 202000L
108#define unreachable() __builtin_unreachable()
109#endif /* defined(__need_STDDEF_H_misc) && >= C23 */
110
106111#if defined(__need_STDDEF_H_misc)
107112#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
108113 (defined(__cplusplus) && __cplusplus >= 201103L)
lib/include/wasm_simd128.h+132-12
......@@ -961,17 +961,17 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_popcnt(v128_t __a) {
961961
962962static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shl(v128_t __a,
963963 uint32_t __b) {
964 return (v128_t)((__i8x16)__a << __b);
964 return (v128_t)((__i8x16)__a << (__b & 0x7));
965965}
966966
967967static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shr(v128_t __a,
968968 uint32_t __b) {
969 return (v128_t)((__i8x16)__a >> __b);
969 return (v128_t)((__i8x16)__a >> (__b & 0x7));
970970}
971971
972972static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_shr(v128_t __a,
973973 uint32_t __b) {
974 return (v128_t)((__u8x16)__a >> __b);
974 return (v128_t)((__u8x16)__a >> (__b & 0x7));
975975}
976976
977977static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add(v128_t __a,
......@@ -1047,17 +1047,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i16x8_bitmask(v128_t __a) {
10471047
10481048static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shl(v128_t __a,
10491049 uint32_t __b) {
1050 return (v128_t)((__i16x8)__a << __b);
1050 return (v128_t)((__i16x8)__a << (__b & 0xF));
10511051}
10521052
10531053static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shr(v128_t __a,
10541054 uint32_t __b) {
1055 return (v128_t)((__i16x8)__a >> __b);
1055 return (v128_t)((__i16x8)__a >> (__b & 0xF));
10561056}
10571057
10581058static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_shr(v128_t __a,
10591059 uint32_t __b) {
1060 return (v128_t)((__u16x8)__a >> __b);
1060 return (v128_t)((__u16x8)__a >> (__b & 0xF));
10611061}
10621062
10631063static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add(v128_t __a,
......@@ -1138,17 +1138,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i32x4_bitmask(v128_t __a) {
11381138
11391139static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shl(v128_t __a,
11401140 uint32_t __b) {
1141 return (v128_t)((__i32x4)__a << __b);
1141 return (v128_t)((__i32x4)__a << (__b & 0x1F));
11421142}
11431143
11441144static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shr(v128_t __a,
11451145 uint32_t __b) {
1146 return (v128_t)((__i32x4)__a >> __b);
1146 return (v128_t)((__i32x4)__a >> (__b & 0x1F));
11471147}
11481148
11491149static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_shr(v128_t __a,
11501150 uint32_t __b) {
1151 return (v128_t)((__u32x4)__a >> __b);
1151 return (v128_t)((__u32x4)__a >> (__b & 0x1F));
11521152}
11531153
11541154static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_add(v128_t __a,
......@@ -1209,17 +1209,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i64x2_bitmask(v128_t __a) {
12091209
12101210static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t __a,
12111211 uint32_t __b) {
1212 return (v128_t)((__i64x2)__a << (int64_t)__b);
1212 return (v128_t)((__i64x2)__a << ((int64_t)__b & 0x3F));
12131213}
12141214
12151215static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shr(v128_t __a,
12161216 uint32_t __b) {
1217 return (v128_t)((__i64x2)__a >> (int64_t)__b);
1217 return (v128_t)((__i64x2)__a >> ((int64_t)__b & 0x3F));
12181218}
12191219
12201220static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_shr(v128_t __a,
12211221 uint32_t __b) {
1222 return (v128_t)((__u64x2)__a >> (int64_t)__b);
1222 return (v128_t)((__u64x2)__a >> ((int64_t)__b & 0x3F));
12231223}
12241224
12251225static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_add(v128_t __a,
......@@ -1760,6 +1760,126 @@ wasm_u64x2_load_32x2(const void *__mem) {
17601760 __DEPRECATED_WASM_MACRO("wasm_v64x2_shuffle", "wasm_i64x2_shuffle") \
17611761 wasm_i64x2_shuffle(__a, __b, __c0, __c1)
17621762
1763// Relaxed SIMD intrinsics
1764
1765#define __RELAXED_FN_ATTRS \
1766 __attribute__((__always_inline__, __nodebug__, __target__("relaxed-simd"), \
1767 __min_vector_width__(128)))
1768
1769static __inline__ v128_t __RELAXED_FN_ATTRS
1770wasm_f32x4_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) {
1771 return (v128_t)__builtin_wasm_relaxed_madd_f32x4((__f32x4)__a, (__f32x4)__b,
1772 (__f32x4)__c);
1773}
1774
1775static __inline__ v128_t __RELAXED_FN_ATTRS
1776wasm_f32x4_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) {
1777 return (v128_t)__builtin_wasm_relaxed_nmadd_f32x4((__f32x4)__a, (__f32x4)__b,
1778 (__f32x4)__c);
1779}
1780
1781static __inline__ v128_t __RELAXED_FN_ATTRS
1782wasm_f64x2_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) {
1783 return (v128_t)__builtin_wasm_relaxed_madd_f64x2((__f64x2)__a, (__f64x2)__b,
1784 (__f64x2)__c);
1785}
1786
1787static __inline__ v128_t __RELAXED_FN_ATTRS
1788wasm_f64x2_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) {
1789 return (v128_t)__builtin_wasm_relaxed_nmadd_f64x2((__f64x2)__a, (__f64x2)__b,
1790 (__f64x2)__c);
1791}
1792
1793static __inline__ v128_t __RELAXED_FN_ATTRS
1794wasm_i8x16_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) {
1795 return (v128_t)__builtin_wasm_relaxed_laneselect_i8x16(
1796 (__i8x16)__a, (__i8x16)__b, (__i8x16)__m);
1797}
1798
1799static __inline__ v128_t __RELAXED_FN_ATTRS
1800wasm_i16x8_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) {
1801 return (v128_t)__builtin_wasm_relaxed_laneselect_i16x8(
1802 (__i16x8)__a, (__i16x8)__b, (__i16x8)__m);
1803}
1804
1805static __inline__ v128_t __RELAXED_FN_ATTRS
1806wasm_i32x4_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) {
1807 return (v128_t)__builtin_wasm_relaxed_laneselect_i32x4(
1808 (__i32x4)__a, (__i32x4)__b, (__i32x4)__m);
1809}
1810
1811static __inline__ v128_t __RELAXED_FN_ATTRS
1812wasm_i64x2_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) {
1813 return (v128_t)__builtin_wasm_relaxed_laneselect_i64x2(
1814 (__i64x2)__a, (__i64x2)__b, (__i64x2)__m);
1815}
1816
1817static __inline__ v128_t __RELAXED_FN_ATTRS
1818wasm_i8x16_relaxed_swizzle(v128_t __a, v128_t __s) {
1819 return (v128_t)__builtin_wasm_relaxed_swizzle_i8x16((__i8x16)__a,
1820 (__i8x16)__s);
1821}
1822
1823static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_min(v128_t __a,
1824 v128_t __b) {
1825 return (v128_t)__builtin_wasm_relaxed_min_f32x4((__f32x4)__a, (__f32x4)__b);
1826}
1827
1828static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_max(v128_t __a,
1829 v128_t __b) {
1830 return (v128_t)__builtin_wasm_relaxed_max_f32x4((__f32x4)__a, (__f32x4)__b);
1831}
1832
1833static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_min(v128_t __a,
1834 v128_t __b) {
1835 return (v128_t)__builtin_wasm_relaxed_min_f64x2((__f64x2)__a, (__f64x2)__b);
1836}
1837
1838static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_max(v128_t __a,
1839 v128_t __b) {
1840 return (v128_t)__builtin_wasm_relaxed_max_f64x2((__f64x2)__a, (__f64x2)__b);
1841}
1842
1843static __inline__ v128_t __RELAXED_FN_ATTRS
1844wasm_i32x4_relaxed_trunc_f32x4(v128_t __a) {
1845 return (v128_t)__builtin_wasm_relaxed_trunc_s_i32x4_f32x4((__f32x4)__a);
1846}
1847
1848static __inline__ v128_t __RELAXED_FN_ATTRS
1849wasm_u32x4_relaxed_trunc_f32x4(v128_t __a) {
1850 return (v128_t)__builtin_wasm_relaxed_trunc_u_i32x4_f32x4((__f32x4)__a);
1851}
1852
1853static __inline__ v128_t __RELAXED_FN_ATTRS
1854wasm_i32x4_relaxed_trunc_f64x2_zero(v128_t __a) {
1855 return (v128_t)__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2((__f64x2)__a);
1856}
1857
1858static __inline__ v128_t __RELAXED_FN_ATTRS
1859wasm_u32x4_relaxed_trunc_f64x2_zero(v128_t __a) {
1860 return (v128_t)__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2((__f64x2)__a);
1861}
1862
1863static __inline__ v128_t __RELAXED_FN_ATTRS
1864wasm_i16x8_relaxed_q15mulr(v128_t __a, v128_t __b) {
1865 return (v128_t)__builtin_wasm_relaxed_q15mulr_s_i16x8((__i16x8)__a,
1866 (__i16x8)__b);
1867}
1868
1869static __inline__ v128_t __RELAXED_FN_ATTRS
1870wasm_i16x8_relaxed_dot_i8x16_i7x16(v128_t __a, v128_t __b) {
1871 return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_s_i16x8((__i8x16)__a,
1872 (__i8x16)__b);
1873}
1874
1875static __inline__ v128_t __RELAXED_FN_ATTRS
1876wasm_i32x4_relaxed_dot_i8x16_i7x16_add(v128_t __a, v128_t __b, v128_t __c) {
1877 return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_add_s_i32x4(
1878 (__i8x16)__a, (__i8x16)__b, (__i32x4)__c);
1879}
1880
1881// Deprecated intrinsics
1882
17631883static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_swizzle")
17641884wasm_v8x16_swizzle(v128_t __a, v128_t __b) {
17651885 return wasm_i8x16_swizzle(__a, __b);
lib/include/xsavecintrin.h+50
......@@ -17,12 +17,62 @@
1717/* Define the default attributes for the functions in this file. */
1818#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsavec")))
1919
20/// Performs a full or partial save of processor state to the memory at
21/// \a __p. The exact state saved depends on the 64-bit mask \a __m and
22/// processor control register \c XCR0.
23///
24/// \code{.operation}
25/// mask[62:0] := __m[62:0] AND XCR0[62:0]
26/// FOR i := 0 TO 62
27/// IF mask[i] == 1
28/// CASE (i) OF
29/// 0: save X87 FPU state
30/// 1: save SSE state
31/// DEFAULT: __p.Ext_Save_Area[i] := ProcessorState[i]
32/// FI
33/// ENDFOR
34/// __p.Header.XSTATE_BV[62:0] := INIT_FUNCTION(mask[62:0])
35/// \endcode
36///
37/// \headerfile <immintrin.h>
38///
39/// This intrinsic corresponds to the \c XSAVEC instruction.
40///
41/// \param __p
42/// Pointer to the save area; must be 64-byte aligned.
43/// \param __m
44/// A 64-bit mask indicating what state should be saved.
2045static __inline__ void __DEFAULT_FN_ATTRS
2146_xsavec(void *__p, unsigned long long __m) {
2247 __builtin_ia32_xsavec(__p, __m);
2348}
2449
2550#ifdef __x86_64__
51/// Performs a full or partial save of processor state to the memory at
52/// \a __p. The exact state saved depends on the 64-bit mask \a __m and
53/// processor control register \c XCR0.
54///
55/// \code{.operation}
56/// mask[62:0] := __m[62:0] AND XCR0[62:0]
57/// FOR i := 0 TO 62
58/// IF mask[i] == 1
59/// CASE (i) OF
60/// 0: save X87 FPU state
61/// 1: save SSE state
62/// DEFAULT: __p.Ext_Save_Area[i] := ProcessorState[i]
63/// FI
64/// ENDFOR
65/// __p.Header.XSTATE_BV[62:0] := INIT_FUNCTION(mask[62:0])
66/// \endcode
67///
68/// \headerfile <immintrin.h>
69///
70/// This intrinsic corresponds to the \c XSAVEC64 instruction.
71///
72/// \param __p
73/// Pointer to the save area; must be 64-byte aligned.
74/// \param __m
75/// A 64-bit mask indicating what state should be saved.
2676static __inline__ void __DEFAULT_FN_ATTRS
2777_xsavec64(void *__p, unsigned long long __m) {
2878 __builtin_ia32_xsavec64(__p, __m);