Debian Codegraph @

clang/lib/Headers/avxvnniintrin.h

raw
1 /*===--------------- avxvnniintrin.h - VNNI intrinsics --------------------===
2 *
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 *
22 *===-----------------------------------------------------------------------===
23 */
24 #ifndef __IMMINTRIN_H
25 #error "Never use <avxvnniintrin.h> directly; include <immintrin.h> instead."
26 #endif
27
28 #ifndef __AVXVNNIINTRIN_H
29 #define __AVXVNNIINTRIN_H
30
31 /* Below intrinsics defined in avx512vlvnniintrin.h can be used for AVXVNNI */
32 /// \fn __m256i _mm256_dpbusd_epi32(__m256i __S, __m256i __A, __m256i __B)
33 /// \fn __m256i _mm256_dpbusds_epi32(__m256i __S, __m256i __A, __m256i __B)
34 /// \fn __m256i _mm256_dpwssd_epi32(__m256i __S, __m256i __A, __m256i __B)
35 /// \fn __m256i _mm256_dpwssds_epi32(__m256i __S, __m256i __A, __m256i __B)
36 /// \fn __m128i _mm_dpbusd_epi32(__m128i __S, __m128i __A, __m128i __B)
37 /// \fn __m128i _mm_dpbusds_epi32(__m128i __S, __m128i __A, __m128i __B)
38 /// \fn __m128i _mm_dpwssd_epi32(__m128i __S, __m128i __A, __m128i __B)
39 /// \fn __m128i _mm_dpwssds_epi32(__m128i __S, __m128i __A, __m128i __B)
40
41 /* Intrinsics with _avx_ prefix are for compatibility with msvc. */
42 /* Define the default attributes for the functions in this file. */
43 #define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("avxvnni"), __min_vector_width__(256)))
44 #define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("avxvnni"), __min_vector_width__(128)))
45
46 /// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with
47 /// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed
48 /// 16-bit results. Sum these 4 results with the corresponding 32-bit integer
49 /// in \a __S, and store the packed 32-bit results in DST.
50 ///
51 /// This intrinsic corresponds to the <c> VPDPBUSD </c> instructions.
52 ///
53 /// \code{.operation}
54 /// FOR j := 0 to 7
55 /// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]))
56 /// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]))
57 /// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]))
58 /// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]))
59 /// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4
60 /// ENDFOR
61 /// DST[MAX:256] := 0
62 /// \endcode
63 static __inline__ __m256i __DEFAULT_FN_ATTRS256
64 _mm256_dpbusd_avx_epi32(__m256i __S, __m256i __A, __m256i __B)
65 {
66 return (__m256i)__builtin_ia32_vpdpbusd256((__v8si)__S, (__v32qu)__A,
67 (__v32qi)__B);
68 }
69
70 /// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with
71 /// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed
72 /// 16-bit results. Sum these 4 results with the corresponding 32-bit integer
73 /// in \a __S using signed saturation, and store the packed 32-bit results in DST.
74 ///
75 /// This intrinsic corresponds to the <c> VPDPBUSDS </c> instructions.
76 ///
77 /// \code{.operation}
78 /// FOR j := 0 to 7
79 /// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]))
80 /// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]))
81 /// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]))
82 /// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]))
83 /// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4)
84 /// ENDFOR
85 /// DST[MAX:256] := 0
86 /// \endcode
87 static __inline__ __m256i __DEFAULT_FN_ATTRS256
88 _mm256_dpbusds_avx_epi32(__m256i __S, __m256i __A, __m256i __B)
89 {
90 return (__m256i)__builtin_ia32_vpdpbusds256((__v8si)__S, (__v32qu)__A,
91 (__v32qi)__B);
92 }
93
94 /// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
95 /// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit
96 /// results. Sum these 2 results with the corresponding 32-bit integer in \a __S,
97 /// and store the packed 32-bit results in DST.
98 ///
99 /// This intrinsic corresponds to the <c> VPDPWSSD </c> instructions.
100 ///
101 /// \code{.operation}
102 /// FOR j := 0 to 7
103 /// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
104 /// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
105 /// DST.dword[j] := __S.dword[j] + tmp1 + tmp2
106 /// ENDFOR
107 /// DST[MAX:256] := 0
108 /// \endcode
109 static __inline__ __m256i __DEFAULT_FN_ATTRS256
110 _mm256_dpwssd_avx_epi32(__m256i __S, __m256i __A, __m256i __B)
111 {
112 return (__m256i)__builtin_ia32_vpdpwssd256((__v8si)__S, (__v16hi)__A,
113 (__v16hi)__B);
114 }
115
116 /// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
117 /// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit
118 /// results. Sum these 2 results with the corresponding 32-bit integer in \a __S
119 /// using signed saturation, and store the packed 32-bit results in DST.
120 ///
121 /// This intrinsic corresponds to the <c> VPDPWSSDS </c> instructions.
122 ///
123 /// \code{.operation}
124 /// FOR j := 0 to 7
125 /// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
126 /// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
127 /// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2)
128 /// ENDFOR
129 /// DST[MAX:256] := 0
130 /// \endcode
131 static __inline__ __m256i __DEFAULT_FN_ATTRS256
132 _mm256_dpwssds_avx_epi32(__m256i __S, __m256i __A, __m256i __B)
133 {
134 return (__m256i)__builtin_ia32_vpdpwssds256((__v8si)__S, (__v16hi)__A,
135 (__v16hi)__B);
136 }
137
138 /// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with
139 /// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed
140 /// 16-bit results. Sum these 4 results with the corresponding 32-bit integer
141 /// in \a __S, and store the packed 32-bit results in DST.
142 ///
143 /// This intrinsic corresponds to the <c> VPDPBUSD </c> instructions.
144 ///
145 /// \code{.operation}
146 /// FOR j := 0 to 3
147 /// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]))
148 /// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]))
149 /// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]))
150 /// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]))
151 /// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4
152 /// ENDFOR
153 /// DST[MAX:128] := 0
154 /// \endcode
155 static __inline__ __m128i __DEFAULT_FN_ATTRS128
156 _mm_dpbusd_avx_epi32(__m128i __S, __m128i __A, __m128i __B)
157 {
158 return (__m128i)__builtin_ia32_vpdpbusd128((__v4si)__S, (__v16qu)__A,
159 (__v16qi)__B);
160 }
161
162 /// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with
163 /// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed
164 /// 16-bit results. Sum these 4 results with the corresponding 32-bit integer
165 /// in \a __S using signed saturation, and store the packed 32-bit results in DST.
166 ///
167 /// This intrinsic corresponds to the <c> VPDPBUSDS </c> instructions.
168 ///
169 /// \code{.operation}
170 /// FOR j := 0 to 3
171 /// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]))
172 /// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]))
173 /// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]))
174 /// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]))
175 /// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4)
176 /// ENDFOR
177 /// DST[MAX:128] := 0
178 /// \endcode
179 static __inline__ __m128i __DEFAULT_FN_ATTRS128
180 _mm_dpbusds_avx_epi32(__m128i __S, __m128i __A, __m128i __B)
181 {
182 return (__m128i)__builtin_ia32_vpdpbusds128((__v4si)__S, (__v16qu)__A,
183 (__v16qi)__B);
184 }
185
186 /// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
187 /// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit
188 /// results. Sum these 2 results with the corresponding 32-bit integer in \a __S,
189 /// and store the packed 32-bit results in DST.
190 ///
191 /// This intrinsic corresponds to the <c> VPDPWSSD </c> instructions.
192 ///
193 /// \code{.operation}
194 /// FOR j := 0 to 3
195 /// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
196 /// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
197 /// DST.dword[j] := __S.dword[j] + tmp1 + tmp2
198 /// ENDFOR
199 /// DST[MAX:128] := 0
200 /// \endcode
201 static __inline__ __m128i __DEFAULT_FN_ATTRS128
202 _mm_dpwssd_avx_epi32(__m128i __S, __m128i __A, __m128i __B)
203 {
204 return (__m128i)__builtin_ia32_vpdpwssd128((__v4si)__S, (__v8hi)__A,
205 (__v8hi)__B);
206 }
207
208 /// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with
209 /// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit
210 /// results. Sum these 2 results with the corresponding 32-bit integer in \a __S
211 /// using signed saturation, and store the packed 32-bit results in DST.
212 ///
213 /// This intrinsic corresponds to the <c> VPDPWSSDS </c> instructions.
214 ///
215 /// \code{.operation}
216 /// FOR j := 0 to 3
217 /// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j])
218 /// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1])
219 /// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2)
220 /// ENDFOR
221 /// DST[MAX:128] := 0
222 /// \endcode
223 static __inline__ __m128i __DEFAULT_FN_ATTRS128
224 _mm_dpwssds_avx_epi32(__m128i __S, __m128i __A, __m128i __B)
225 {
226 return (__m128i)__builtin_ia32_vpdpwssds128((__v4si)__S, (__v8hi)__A,
227 (__v8hi)__B);
228 }
229
230 #undef __DEFAULT_FN_ATTRS128
231 #undef __DEFAULT_FN_ATTRS256
232
233 #endif // __AVXVNNIINTRIN_H