1 /*===----------------- gfniintrin.h - GFNI intrinsics ----------------------===
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
8 *===-----------------------------------------------------------------------===
11 #error "Never use <gfniintrin.h> directly; include <immintrin.h> instead."
14 #ifndef __GFNIINTRIN_H
15 #define __GFNIINTRIN_H
17 /* Default attributes for simple form (no masking). */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("gfni"), __min_vector_width__(128)))
20 /* Default attributes for YMM unmasked form. */
21 #define __DEFAULT_FN_ATTRS_Y __attribute__((__always_inline__, __nodebug__, __target__("avx,gfni"), __min_vector_width__(256)))
23 /* Default attributes for ZMM forms. */
24 #define __DEFAULT_FN_ATTRS_Z __attribute__((__always_inline__, __nodebug__, __target__("avx512bw,gfni"), __min_vector_width__(512)))
26 /* Default attributes for VLX forms. */
27 #define __DEFAULT_FN_ATTRS_VL128 __attribute__((__always_inline__, __nodebug__, __target__("avx512bw,avx512vl,gfni"), __min_vector_width__(128)))
28 #define __DEFAULT_FN_ATTRS_VL256 __attribute__((__always_inline__, __nodebug__, __target__("avx512bw,avx512vl,gfni"), __min_vector_width__(256)))
30 #define _mm_gf2p8affineinv_epi64_epi8(A, B, I) \
31 ((__m128i)__builtin_ia32_vgf2p8affineinvqb_v16qi((__v16qi)(__m128i)(A), \
32 (__v16qi)(__m128i)(B), \
35 #define _mm_gf2p8affine_epi64_epi8(A, B, I) \
36 ((__m128i)__builtin_ia32_vgf2p8affineqb_v16qi((__v16qi)(__m128i)(A), \
37 (__v16qi)(__m128i)(B), \
40 static __inline__ __m128i __DEFAULT_FN_ATTRS
41 _mm_gf2p8mul_epi8(__m128i __A
, __m128i __B
)
43 return (__m128i
) __builtin_ia32_vgf2p8mulb_v16qi((__v16qi
) __A
,
48 #define _mm256_gf2p8affineinv_epi64_epi8(A, B, I) \
49 ((__m256i)__builtin_ia32_vgf2p8affineinvqb_v32qi((__v32qi)(__m256i)(A), \
50 (__v32qi)(__m256i)(B), \
53 #define _mm256_gf2p8affine_epi64_epi8(A, B, I) \
54 ((__m256i)__builtin_ia32_vgf2p8affineqb_v32qi((__v32qi)(__m256i)(A), \
55 (__v32qi)(__m256i)(B), \
58 static __inline__ __m256i __DEFAULT_FN_ATTRS_Y
59 _mm256_gf2p8mul_epi8(__m256i __A
, __m256i __B
)
61 return (__m256i
) __builtin_ia32_vgf2p8mulb_v32qi((__v32qi
) __A
,
64 #endif /* __AVXINTRIN_H */
66 #ifdef __AVX512BWINTRIN_H
67 #define _mm512_gf2p8affineinv_epi64_epi8(A, B, I) \
68 ((__m512i)__builtin_ia32_vgf2p8affineinvqb_v64qi((__v64qi)(__m512i)(A), \
69 (__v64qi)(__m512i)(B), \
72 #define _mm512_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \
73 ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \
74 (__v64qi)_mm512_gf2p8affineinv_epi64_epi8(A, B, I), \
75 (__v64qi)(__m512i)(S)))
77 #define _mm512_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \
78 _mm512_mask_gf2p8affineinv_epi64_epi8((__m512i)_mm512_setzero_si512(), \
81 #define _mm512_gf2p8affine_epi64_epi8(A, B, I) \
82 ((__m512i)__builtin_ia32_vgf2p8affineqb_v64qi((__v64qi)(__m512i)(A), \
83 (__v64qi)(__m512i)(B), \
86 #define _mm512_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \
87 ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \
88 (__v64qi)_mm512_gf2p8affine_epi64_epi8((A), (B), (I)), \
89 (__v64qi)(__m512i)(S)))
91 #define _mm512_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \
92 _mm512_mask_gf2p8affine_epi64_epi8((__m512i)_mm512_setzero_si512(), \
95 static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
96 _mm512_gf2p8mul_epi8(__m512i __A
, __m512i __B
)
98 return (__m512i
) __builtin_ia32_vgf2p8mulb_v64qi((__v64qi
) __A
,
102 static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
103 _mm512_mask_gf2p8mul_epi8(__m512i __S
, __mmask64 __U
, __m512i __A
, __m512i __B
)
105 return (__m512i
) __builtin_ia32_selectb_512(__U
,
106 (__v64qi
) _mm512_gf2p8mul_epi8(__A
, __B
),
110 static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
111 _mm512_maskz_gf2p8mul_epi8(__mmask64 __U
, __m512i __A
, __m512i __B
)
113 return _mm512_mask_gf2p8mul_epi8((__m512i
)_mm512_setzero_si512(),
116 #endif /* __AVX512BWINTRIN_H */
118 #ifdef __AVX512VLBWINTRIN_H
119 #define _mm_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \
120 ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \
121 (__v16qi)_mm_gf2p8affineinv_epi64_epi8(A, B, I), \
122 (__v16qi)(__m128i)(S)))
124 #define _mm_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \
125 _mm_mask_gf2p8affineinv_epi64_epi8((__m128i)_mm_setzero_si128(), \
128 #define _mm256_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \
129 ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \
130 (__v32qi)_mm256_gf2p8affineinv_epi64_epi8(A, B, I), \
131 (__v32qi)(__m256i)(S)))
133 #define _mm256_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \
134 _mm256_mask_gf2p8affineinv_epi64_epi8((__m256i)_mm256_setzero_si256(), \
137 #define _mm_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \
138 ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \
139 (__v16qi)_mm_gf2p8affine_epi64_epi8(A, B, I), \
140 (__v16qi)(__m128i)(S)))
142 #define _mm_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \
143 _mm_mask_gf2p8affine_epi64_epi8((__m128i)_mm_setzero_si128(), U, A, B, I)
145 #define _mm256_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \
146 ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \
147 (__v32qi)_mm256_gf2p8affine_epi64_epi8(A, B, I), \
148 (__v32qi)(__m256i)(S)))
150 #define _mm256_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \
151 _mm256_mask_gf2p8affine_epi64_epi8((__m256i)_mm256_setzero_si256(), \
154 static __inline__ __m128i __DEFAULT_FN_ATTRS_VL128
155 _mm_mask_gf2p8mul_epi8(__m128i __S
, __mmask16 __U
, __m128i __A
, __m128i __B
)
157 return (__m128i
) __builtin_ia32_selectb_128(__U
,
158 (__v16qi
) _mm_gf2p8mul_epi8(__A
, __B
),
162 static __inline__ __m128i __DEFAULT_FN_ATTRS_VL128
163 _mm_maskz_gf2p8mul_epi8(__mmask16 __U
, __m128i __A
, __m128i __B
)
165 return _mm_mask_gf2p8mul_epi8((__m128i
)_mm_setzero_si128(),
169 static __inline__ __m256i __DEFAULT_FN_ATTRS_VL256
170 _mm256_mask_gf2p8mul_epi8(__m256i __S
, __mmask32 __U
, __m256i __A
, __m256i __B
)
172 return (__m256i
) __builtin_ia32_selectb_256(__U
,
173 (__v32qi
) _mm256_gf2p8mul_epi8(__A
, __B
),
177 static __inline__ __m256i __DEFAULT_FN_ATTRS_VL256
178 _mm256_maskz_gf2p8mul_epi8(__mmask32 __U
, __m256i __A
, __m256i __B
)
180 return _mm256_mask_gf2p8mul_epi8((__m256i
)_mm256_setzero_si256(),
183 #endif /* __AVX512VLBWINTRIN_H */
185 #undef __DEFAULT_FN_ATTRS
186 #undef __DEFAULT_FN_ATTRS_Y
187 #undef __DEFAULT_FN_ATTRS_Z
188 #undef __DEFAULT_FN_ATTRS_VL128
189 #undef __DEFAULT_FN_ATTRS_VL256
191 #endif /* __GFNIINTRIN_H */