]>
Commit | Line | Data |
---|---|---|
38388f7e RH |
1 | /* |
2 | * AArch64 SVE translation | |
3 | * | |
4 | * Copyright (c) 2018 Linaro, Ltd | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
50f57e09 | 9 | * version 2.1 of the License, or (at your option) any later version. |
38388f7e RH |
10 | * |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #include "qemu/osdep.h" | |
21 | #include "cpu.h" | |
22 | #include "exec/exec-all.h" | |
dcb32f1d PMD |
23 | #include "tcg/tcg-op.h" |
24 | #include "tcg/tcg-op-gvec.h" | |
25 | #include "tcg/tcg-gvec-desc.h" | |
38388f7e RH |
26 | #include "qemu/log.h" |
27 | #include "arm_ldst.h" | |
28 | #include "translate.h" | |
29 | #include "internals.h" | |
30 | #include "exec/helper-proto.h" | |
31 | #include "exec/helper-gen.h" | |
32 | #include "exec/log.h" | |
38388f7e | 33 | #include "translate-a64.h" |
cc48affe | 34 | #include "fpu/softfloat.h" |
38388f7e | 35 | |
757f9cff | 36 | |
9ee3a611 RH |
37 | typedef void GVecGen2sFn(unsigned, uint32_t, uint32_t, |
38 | TCGv_i64, uint32_t, uint32_t); | |
39 | ||
38cadeba RH |
40 | typedef void gen_helper_gvec_flags_3(TCGv_i32, TCGv_ptr, TCGv_ptr, |
41 | TCGv_ptr, TCGv_i32); | |
757f9cff RH |
42 | typedef void gen_helper_gvec_flags_4(TCGv_i32, TCGv_ptr, TCGv_ptr, |
43 | TCGv_ptr, TCGv_ptr, TCGv_i32); | |
44 | ||
c4e7c493 | 45 | typedef void gen_helper_gvec_mem(TCGv_env, TCGv_ptr, TCGv_i64, TCGv_i32); |
f6dbf62a RH |
46 | typedef void gen_helper_gvec_mem_scatter(TCGv_env, TCGv_ptr, TCGv_ptr, |
47 | TCGv_ptr, TCGv_i64, TCGv_i32); | |
c4e7c493 | 48 | |
ccd841c3 RH |
49 | /* |
50 | * Helpers for extracting complex instruction fields. | |
51 | */ | |
52 | ||
53 | /* See e.g. ASR (immediate, predicated). | |
54 | * Returns -1 for unallocated encoding; diagnose later. | |
55 | */ | |
451e4ffd | 56 | static int tszimm_esz(DisasContext *s, int x) |
ccd841c3 RH |
57 | { |
58 | x >>= 3; /* discard imm3 */ | |
59 | return 31 - clz32(x); | |
60 | } | |
61 | ||
451e4ffd | 62 | static int tszimm_shr(DisasContext *s, int x) |
ccd841c3 | 63 | { |
451e4ffd | 64 | return (16 << tszimm_esz(s, x)) - x; |
ccd841c3 RH |
65 | } |
66 | ||
67 | /* See e.g. LSL (immediate, predicated). */ | |
451e4ffd | 68 | static int tszimm_shl(DisasContext *s, int x) |
ccd841c3 | 69 | { |
451e4ffd | 70 | return x - (8 << tszimm_esz(s, x)); |
ccd841c3 RH |
71 | } |
72 | ||
f25a2361 | 73 | /* The SH bit is in bit 8. Extract the low 8 and shift. */ |
451e4ffd | 74 | static inline int expand_imm_sh8s(DisasContext *s, int x) |
f25a2361 RH |
75 | { |
76 | return (int8_t)x << (x & 0x100 ? 8 : 0); | |
77 | } | |
78 | ||
451e4ffd | 79 | static inline int expand_imm_sh8u(DisasContext *s, int x) |
6e6a157d RH |
80 | { |
81 | return (uint8_t)x << (x & 0x100 ? 8 : 0); | |
82 | } | |
83 | ||
c4e7c493 RH |
84 | /* Convert a 2-bit memory size (msz) to a 4-bit data type (dtype) |
85 | * with unsigned data. C.f. SVE Memory Contiguous Load Group. | |
86 | */ | |
451e4ffd | 87 | static inline int msz_dtype(DisasContext *s, int msz) |
c4e7c493 RH |
88 | { |
89 | static const uint8_t dtype[4] = { 0, 5, 10, 15 }; | |
90 | return dtype[msz]; | |
91 | } | |
92 | ||
38388f7e RH |
93 | /* |
94 | * Include the generated decoder. | |
95 | */ | |
96 | ||
139c1837 | 97 | #include "decode-sve.c.inc" |
38388f7e RH |
98 | |
99 | /* | |
100 | * Implement all of the translator functions referenced by the decoder. | |
101 | */ | |
102 | ||
d1822297 RH |
103 | /* Return the offset info CPUARMState of the predicate vector register Pn. |
104 | * Note for this purpose, FFR is P16. | |
105 | */ | |
106 | static inline int pred_full_reg_offset(DisasContext *s, int regno) | |
107 | { | |
108 | return offsetof(CPUARMState, vfp.pregs[regno]); | |
109 | } | |
110 | ||
111 | /* Return the byte size of the whole predicate register, VL / 64. */ | |
112 | static inline int pred_full_reg_size(DisasContext *s) | |
113 | { | |
114 | return s->sve_len >> 3; | |
115 | } | |
116 | ||
516e246a RH |
117 | /* Round up the size of a register to a size allowed by |
118 | * the tcg vector infrastructure. Any operation which uses this | |
119 | * size may assume that the bits above pred_full_reg_size are zero, | |
120 | * and must leave them the same way. | |
121 | * | |
122 | * Note that this is not needed for the vector registers as they | |
123 | * are always properly sized for tcg vectors. | |
124 | */ | |
125 | static int size_for_gvec(int size) | |
126 | { | |
127 | if (size <= 8) { | |
128 | return 8; | |
129 | } else { | |
130 | return QEMU_ALIGN_UP(size, 16); | |
131 | } | |
132 | } | |
133 | ||
134 | static int pred_gvec_reg_size(DisasContext *s) | |
135 | { | |
136 | return size_for_gvec(pred_full_reg_size(s)); | |
137 | } | |
138 | ||
40e32e5a RH |
139 | /* Invoke an out-of-line helper on 2 Zregs. */ |
140 | static void gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn, | |
141 | int rd, int rn, int data) | |
142 | { | |
143 | unsigned vsz = vec_full_reg_size(s); | |
144 | tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | |
145 | vec_full_reg_offset(s, rn), | |
146 | vsz, vsz, data, fn); | |
147 | } | |
148 | ||
e645d1a1 RH |
149 | /* Invoke an out-of-line helper on 3 Zregs. */ |
150 | static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn, | |
151 | int rd, int rn, int rm, int data) | |
152 | { | |
153 | unsigned vsz = vec_full_reg_size(s); | |
154 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | |
155 | vec_full_reg_offset(s, rn), | |
156 | vec_full_reg_offset(s, rm), | |
157 | vsz, vsz, data, fn); | |
158 | } | |
159 | ||
38650638 RH |
160 | /* Invoke an out-of-line helper on 4 Zregs. */ |
161 | static void gen_gvec_ool_zzzz(DisasContext *s, gen_helper_gvec_4 *fn, | |
162 | int rd, int rn, int rm, int ra, int data) | |
163 | { | |
164 | unsigned vsz = vec_full_reg_size(s); | |
165 | tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | |
166 | vec_full_reg_offset(s, rn), | |
167 | vec_full_reg_offset(s, rm), | |
168 | vec_full_reg_offset(s, ra), | |
169 | vsz, vsz, data, fn); | |
170 | } | |
171 | ||
96a461f7 RH |
172 | /* Invoke an out-of-line helper on 2 Zregs and a predicate. */ |
173 | static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn, | |
174 | int rd, int rn, int pg, int data) | |
175 | { | |
176 | unsigned vsz = vec_full_reg_size(s); | |
177 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | |
178 | vec_full_reg_offset(s, rn), | |
179 | pred_full_reg_offset(s, pg), | |
180 | vsz, vsz, data, fn); | |
181 | } | |
182 | ||
36cbb7a8 RH |
183 | /* Invoke an out-of-line helper on 3 Zregs and a predicate. */ |
184 | static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn, | |
185 | int rd, int rn, int rm, int pg, int data) | |
186 | { | |
187 | unsigned vsz = vec_full_reg_size(s); | |
188 | tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | |
189 | vec_full_reg_offset(s, rn), | |
190 | vec_full_reg_offset(s, rm), | |
191 | pred_full_reg_offset(s, pg), | |
192 | vsz, vsz, data, fn); | |
193 | } | |
f7d79c41 | 194 | |
36cbb7a8 | 195 | /* Invoke a vector expander on two Zregs. */ |
f7d79c41 RH |
196 | static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn, |
197 | int esz, int rd, int rn) | |
38388f7e | 198 | { |
f7d79c41 RH |
199 | unsigned vsz = vec_full_reg_size(s); |
200 | gvec_fn(esz, vec_full_reg_offset(s, rd), | |
201 | vec_full_reg_offset(s, rn), vsz, vsz); | |
38388f7e RH |
202 | } |
203 | ||
39eea561 | 204 | /* Invoke a vector expander on three Zregs. */ |
28c4da31 RH |
205 | static void gen_gvec_fn_zzz(DisasContext *s, GVecGen3Fn *gvec_fn, |
206 | int esz, int rd, int rn, int rm) | |
38388f7e | 207 | { |
28c4da31 RH |
208 | unsigned vsz = vec_full_reg_size(s); |
209 | gvec_fn(esz, vec_full_reg_offset(s, rd), | |
210 | vec_full_reg_offset(s, rn), | |
211 | vec_full_reg_offset(s, rm), vsz, vsz); | |
38388f7e RH |
212 | } |
213 | ||
911cdc6d RH |
214 | /* Invoke a vector expander on four Zregs. */ |
215 | static void gen_gvec_fn_zzzz(DisasContext *s, GVecGen4Fn *gvec_fn, | |
216 | int esz, int rd, int rn, int rm, int ra) | |
217 | { | |
218 | unsigned vsz = vec_full_reg_size(s); | |
219 | gvec_fn(esz, vec_full_reg_offset(s, rd), | |
220 | vec_full_reg_offset(s, rn), | |
221 | vec_full_reg_offset(s, rm), | |
222 | vec_full_reg_offset(s, ra), vsz, vsz); | |
223 | } | |
224 | ||
39eea561 RH |
225 | /* Invoke a vector move on two Zregs. */ |
226 | static bool do_mov_z(DisasContext *s, int rd, int rn) | |
38388f7e | 227 | { |
f7d79c41 RH |
228 | if (sve_access_check(s)) { |
229 | gen_gvec_fn_zz(s, tcg_gen_gvec_mov, MO_8, rd, rn); | |
230 | } | |
231 | return true; | |
38388f7e RH |
232 | } |
233 | ||
d9d78dcc RH |
234 | /* Initialize a Zreg with replications of a 64-bit immediate. */ |
235 | static void do_dupi_z(DisasContext *s, int rd, uint64_t word) | |
236 | { | |
237 | unsigned vsz = vec_full_reg_size(s); | |
8711e71f | 238 | tcg_gen_gvec_dup_imm(MO_64, vec_full_reg_offset(s, rd), vsz, vsz, word); |
d9d78dcc RH |
239 | } |
240 | ||
516e246a | 241 | /* Invoke a vector expander on three Pregs. */ |
dd81a8d7 RH |
242 | static void gen_gvec_fn_ppp(DisasContext *s, GVecGen3Fn *gvec_fn, |
243 | int rd, int rn, int rm) | |
516e246a | 244 | { |
dd81a8d7 RH |
245 | unsigned psz = pred_gvec_reg_size(s); |
246 | gvec_fn(MO_64, pred_full_reg_offset(s, rd), | |
247 | pred_full_reg_offset(s, rn), | |
248 | pred_full_reg_offset(s, rm), psz, psz); | |
516e246a RH |
249 | } |
250 | ||
251 | /* Invoke a vector move on two Pregs. */ | |
252 | static bool do_mov_p(DisasContext *s, int rd, int rn) | |
253 | { | |
d0b2df5a RH |
254 | if (sve_access_check(s)) { |
255 | unsigned psz = pred_gvec_reg_size(s); | |
256 | tcg_gen_gvec_mov(MO_8, pred_full_reg_offset(s, rd), | |
257 | pred_full_reg_offset(s, rn), psz, psz); | |
258 | } | |
259 | return true; | |
516e246a RH |
260 | } |
261 | ||
9e18d7a6 RH |
262 | /* Set the cpu flags as per a return from an SVE helper. */ |
263 | static void do_pred_flags(TCGv_i32 t) | |
264 | { | |
265 | tcg_gen_mov_i32(cpu_NF, t); | |
266 | tcg_gen_andi_i32(cpu_ZF, t, 2); | |
267 | tcg_gen_andi_i32(cpu_CF, t, 1); | |
268 | tcg_gen_movi_i32(cpu_VF, 0); | |
269 | } | |
270 | ||
271 | /* Subroutines computing the ARM PredTest psuedofunction. */ | |
272 | static void do_predtest1(TCGv_i64 d, TCGv_i64 g) | |
273 | { | |
274 | TCGv_i32 t = tcg_temp_new_i32(); | |
275 | ||
276 | gen_helper_sve_predtest1(t, d, g); | |
277 | do_pred_flags(t); | |
278 | tcg_temp_free_i32(t); | |
279 | } | |
280 | ||
281 | static void do_predtest(DisasContext *s, int dofs, int gofs, int words) | |
282 | { | |
283 | TCGv_ptr dptr = tcg_temp_new_ptr(); | |
284 | TCGv_ptr gptr = tcg_temp_new_ptr(); | |
285 | TCGv_i32 t; | |
286 | ||
287 | tcg_gen_addi_ptr(dptr, cpu_env, dofs); | |
288 | tcg_gen_addi_ptr(gptr, cpu_env, gofs); | |
289 | t = tcg_const_i32(words); | |
290 | ||
291 | gen_helper_sve_predtest(t, dptr, gptr, t); | |
292 | tcg_temp_free_ptr(dptr); | |
293 | tcg_temp_free_ptr(gptr); | |
294 | ||
295 | do_pred_flags(t); | |
296 | tcg_temp_free_i32(t); | |
297 | } | |
298 | ||
028e2a7b RH |
299 | /* For each element size, the bits within a predicate word that are active. */ |
300 | const uint64_t pred_esz_masks[4] = { | |
301 | 0xffffffffffffffffull, 0x5555555555555555ull, | |
302 | 0x1111111111111111ull, 0x0101010101010101ull | |
303 | }; | |
304 | ||
39eea561 RH |
305 | /* |
306 | *** SVE Logical - Unpredicated Group | |
307 | */ | |
308 | ||
28c4da31 RH |
309 | static bool do_zzz_fn(DisasContext *s, arg_rrr_esz *a, GVecGen3Fn *gvec_fn) |
310 | { | |
311 | if (sve_access_check(s)) { | |
312 | gen_gvec_fn_zzz(s, gvec_fn, a->esz, a->rd, a->rn, a->rm); | |
313 | } | |
314 | return true; | |
315 | } | |
316 | ||
3a7be554 | 317 | static bool trans_AND_zzz(DisasContext *s, arg_rrr_esz *a) |
39eea561 | 318 | { |
28c4da31 | 319 | return do_zzz_fn(s, a, tcg_gen_gvec_and); |
39eea561 RH |
320 | } |
321 | ||
3a7be554 | 322 | static bool trans_ORR_zzz(DisasContext *s, arg_rrr_esz *a) |
39eea561 | 323 | { |
28c4da31 | 324 | return do_zzz_fn(s, a, tcg_gen_gvec_or); |
39eea561 RH |
325 | } |
326 | ||
3a7be554 | 327 | static bool trans_EOR_zzz(DisasContext *s, arg_rrr_esz *a) |
39eea561 | 328 | { |
28c4da31 | 329 | return do_zzz_fn(s, a, tcg_gen_gvec_xor); |
39eea561 RH |
330 | } |
331 | ||
3a7be554 | 332 | static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a) |
38388f7e | 333 | { |
28c4da31 | 334 | return do_zzz_fn(s, a, tcg_gen_gvec_andc); |
38388f7e | 335 | } |
d1822297 | 336 | |
e6eba6e5 RH |
337 | static void gen_xar8_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, int64_t sh) |
338 | { | |
339 | TCGv_i64 t = tcg_temp_new_i64(); | |
340 | uint64_t mask = dup_const(MO_8, 0xff >> sh); | |
341 | ||
342 | tcg_gen_xor_i64(t, n, m); | |
343 | tcg_gen_shri_i64(d, t, sh); | |
344 | tcg_gen_shli_i64(t, t, 8 - sh); | |
345 | tcg_gen_andi_i64(d, d, mask); | |
346 | tcg_gen_andi_i64(t, t, ~mask); | |
347 | tcg_gen_or_i64(d, d, t); | |
348 | tcg_temp_free_i64(t); | |
349 | } | |
350 | ||
351 | static void gen_xar16_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, int64_t sh) | |
352 | { | |
353 | TCGv_i64 t = tcg_temp_new_i64(); | |
354 | uint64_t mask = dup_const(MO_16, 0xffff >> sh); | |
355 | ||
356 | tcg_gen_xor_i64(t, n, m); | |
357 | tcg_gen_shri_i64(d, t, sh); | |
358 | tcg_gen_shli_i64(t, t, 16 - sh); | |
359 | tcg_gen_andi_i64(d, d, mask); | |
360 | tcg_gen_andi_i64(t, t, ~mask); | |
361 | tcg_gen_or_i64(d, d, t); | |
362 | tcg_temp_free_i64(t); | |
363 | } | |
364 | ||
365 | static void gen_xar_i32(TCGv_i32 d, TCGv_i32 n, TCGv_i32 m, int32_t sh) | |
366 | { | |
367 | tcg_gen_xor_i32(d, n, m); | |
368 | tcg_gen_rotri_i32(d, d, sh); | |
369 | } | |
370 | ||
371 | static void gen_xar_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, int64_t sh) | |
372 | { | |
373 | tcg_gen_xor_i64(d, n, m); | |
374 | tcg_gen_rotri_i64(d, d, sh); | |
375 | } | |
376 | ||
377 | static void gen_xar_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
378 | TCGv_vec m, int64_t sh) | |
379 | { | |
380 | tcg_gen_xor_vec(vece, d, n, m); | |
381 | tcg_gen_rotri_vec(vece, d, d, sh); | |
382 | } | |
383 | ||
384 | void gen_gvec_xar(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | |
385 | uint32_t rm_ofs, int64_t shift, | |
386 | uint32_t opr_sz, uint32_t max_sz) | |
387 | { | |
388 | static const TCGOpcode vecop[] = { INDEX_op_rotli_vec, 0 }; | |
389 | static const GVecGen3i ops[4] = { | |
390 | { .fni8 = gen_xar8_i64, | |
391 | .fniv = gen_xar_vec, | |
392 | .fno = gen_helper_sve2_xar_b, | |
393 | .opt_opc = vecop, | |
394 | .vece = MO_8 }, | |
395 | { .fni8 = gen_xar16_i64, | |
396 | .fniv = gen_xar_vec, | |
397 | .fno = gen_helper_sve2_xar_h, | |
398 | .opt_opc = vecop, | |
399 | .vece = MO_16 }, | |
400 | { .fni4 = gen_xar_i32, | |
401 | .fniv = gen_xar_vec, | |
402 | .fno = gen_helper_sve2_xar_s, | |
403 | .opt_opc = vecop, | |
404 | .vece = MO_32 }, | |
405 | { .fni8 = gen_xar_i64, | |
406 | .fniv = gen_xar_vec, | |
407 | .fno = gen_helper_gvec_xar_d, | |
408 | .opt_opc = vecop, | |
409 | .vece = MO_64 } | |
410 | }; | |
411 | int esize = 8 << vece; | |
412 | ||
413 | /* The SVE2 range is 1 .. esize; the AdvSIMD range is 0 .. esize-1. */ | |
414 | tcg_debug_assert(shift >= 0); | |
415 | tcg_debug_assert(shift <= esize); | |
416 | shift &= esize - 1; | |
417 | ||
418 | if (shift == 0) { | |
419 | /* xar with no rotate devolves to xor. */ | |
420 | tcg_gen_gvec_xor(vece, rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz); | |
421 | } else { | |
422 | tcg_gen_gvec_3i(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, | |
423 | shift, &ops[vece]); | |
424 | } | |
425 | } | |
426 | ||
427 | static bool trans_XAR(DisasContext *s, arg_rrri_esz *a) | |
428 | { | |
429 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
430 | return false; | |
431 | } | |
432 | if (sve_access_check(s)) { | |
433 | unsigned vsz = vec_full_reg_size(s); | |
434 | gen_gvec_xar(a->esz, vec_full_reg_offset(s, a->rd), | |
435 | vec_full_reg_offset(s, a->rn), | |
436 | vec_full_reg_offset(s, a->rm), a->imm, vsz, vsz); | |
437 | } | |
438 | return true; | |
439 | } | |
440 | ||
911cdc6d RH |
441 | static bool do_sve2_zzzz_fn(DisasContext *s, arg_rrrr_esz *a, GVecGen4Fn *fn) |
442 | { | |
443 | if (!dc_isar_feature(aa64_sve2, s)) { | |
444 | return false; | |
445 | } | |
446 | if (sve_access_check(s)) { | |
447 | gen_gvec_fn_zzzz(s, fn, a->esz, a->rd, a->rn, a->rm, a->ra); | |
448 | } | |
449 | return true; | |
450 | } | |
451 | ||
452 | static void gen_eor3_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 k) | |
453 | { | |
454 | tcg_gen_xor_i64(d, n, m); | |
455 | tcg_gen_xor_i64(d, d, k); | |
456 | } | |
457 | ||
458 | static void gen_eor3_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
459 | TCGv_vec m, TCGv_vec k) | |
460 | { | |
461 | tcg_gen_xor_vec(vece, d, n, m); | |
462 | tcg_gen_xor_vec(vece, d, d, k); | |
463 | } | |
464 | ||
465 | static void gen_eor3(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
466 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
467 | { | |
468 | static const GVecGen4 op = { | |
469 | .fni8 = gen_eor3_i64, | |
470 | .fniv = gen_eor3_vec, | |
471 | .fno = gen_helper_sve2_eor3, | |
472 | .vece = MO_64, | |
473 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
474 | }; | |
475 | tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op); | |
476 | } | |
477 | ||
478 | static bool trans_EOR3(DisasContext *s, arg_rrrr_esz *a) | |
479 | { | |
480 | return do_sve2_zzzz_fn(s, a, gen_eor3); | |
481 | } | |
482 | ||
483 | static void gen_bcax_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 k) | |
484 | { | |
485 | tcg_gen_andc_i64(d, m, k); | |
486 | tcg_gen_xor_i64(d, d, n); | |
487 | } | |
488 | ||
489 | static void gen_bcax_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
490 | TCGv_vec m, TCGv_vec k) | |
491 | { | |
492 | tcg_gen_andc_vec(vece, d, m, k); | |
493 | tcg_gen_xor_vec(vece, d, d, n); | |
494 | } | |
495 | ||
496 | static void gen_bcax(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
497 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
498 | { | |
499 | static const GVecGen4 op = { | |
500 | .fni8 = gen_bcax_i64, | |
501 | .fniv = gen_bcax_vec, | |
502 | .fno = gen_helper_sve2_bcax, | |
503 | .vece = MO_64, | |
504 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
505 | }; | |
506 | tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op); | |
507 | } | |
508 | ||
509 | static bool trans_BCAX(DisasContext *s, arg_rrrr_esz *a) | |
510 | { | |
511 | return do_sve2_zzzz_fn(s, a, gen_bcax); | |
512 | } | |
513 | ||
514 | static void gen_bsl(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
515 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
516 | { | |
517 | /* BSL differs from the generic bitsel in argument ordering. */ | |
518 | tcg_gen_gvec_bitsel(vece, d, a, n, m, oprsz, maxsz); | |
519 | } | |
520 | ||
521 | static bool trans_BSL(DisasContext *s, arg_rrrr_esz *a) | |
522 | { | |
523 | return do_sve2_zzzz_fn(s, a, gen_bsl); | |
524 | } | |
525 | ||
526 | static void gen_bsl1n_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 k) | |
527 | { | |
528 | tcg_gen_andc_i64(n, k, n); | |
529 | tcg_gen_andc_i64(m, m, k); | |
530 | tcg_gen_or_i64(d, n, m); | |
531 | } | |
532 | ||
533 | static void gen_bsl1n_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
534 | TCGv_vec m, TCGv_vec k) | |
535 | { | |
536 | if (TCG_TARGET_HAS_bitsel_vec) { | |
537 | tcg_gen_not_vec(vece, n, n); | |
538 | tcg_gen_bitsel_vec(vece, d, k, n, m); | |
539 | } else { | |
540 | tcg_gen_andc_vec(vece, n, k, n); | |
541 | tcg_gen_andc_vec(vece, m, m, k); | |
542 | tcg_gen_or_vec(vece, d, n, m); | |
543 | } | |
544 | } | |
545 | ||
546 | static void gen_bsl1n(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
547 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
548 | { | |
549 | static const GVecGen4 op = { | |
550 | .fni8 = gen_bsl1n_i64, | |
551 | .fniv = gen_bsl1n_vec, | |
552 | .fno = gen_helper_sve2_bsl1n, | |
553 | .vece = MO_64, | |
554 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
555 | }; | |
556 | tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op); | |
557 | } | |
558 | ||
559 | static bool trans_BSL1N(DisasContext *s, arg_rrrr_esz *a) | |
560 | { | |
561 | return do_sve2_zzzz_fn(s, a, gen_bsl1n); | |
562 | } | |
563 | ||
564 | static void gen_bsl2n_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 k) | |
565 | { | |
566 | /* | |
567 | * Z[dn] = (n & k) | (~m & ~k) | |
568 | * = | ~(m | k) | |
569 | */ | |
570 | tcg_gen_and_i64(n, n, k); | |
571 | if (TCG_TARGET_HAS_orc_i64) { | |
572 | tcg_gen_or_i64(m, m, k); | |
573 | tcg_gen_orc_i64(d, n, m); | |
574 | } else { | |
575 | tcg_gen_nor_i64(m, m, k); | |
576 | tcg_gen_or_i64(d, n, m); | |
577 | } | |
578 | } | |
579 | ||
580 | static void gen_bsl2n_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
581 | TCGv_vec m, TCGv_vec k) | |
582 | { | |
583 | if (TCG_TARGET_HAS_bitsel_vec) { | |
584 | tcg_gen_not_vec(vece, m, m); | |
585 | tcg_gen_bitsel_vec(vece, d, k, n, m); | |
586 | } else { | |
587 | tcg_gen_and_vec(vece, n, n, k); | |
588 | tcg_gen_or_vec(vece, m, m, k); | |
589 | tcg_gen_orc_vec(vece, d, n, m); | |
590 | } | |
591 | } | |
592 | ||
593 | static void gen_bsl2n(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
594 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
595 | { | |
596 | static const GVecGen4 op = { | |
597 | .fni8 = gen_bsl2n_i64, | |
598 | .fniv = gen_bsl2n_vec, | |
599 | .fno = gen_helper_sve2_bsl2n, | |
600 | .vece = MO_64, | |
601 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
602 | }; | |
603 | tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op); | |
604 | } | |
605 | ||
606 | static bool trans_BSL2N(DisasContext *s, arg_rrrr_esz *a) | |
607 | { | |
608 | return do_sve2_zzzz_fn(s, a, gen_bsl2n); | |
609 | } | |
610 | ||
611 | static void gen_nbsl_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 k) | |
612 | { | |
613 | tcg_gen_and_i64(n, n, k); | |
614 | tcg_gen_andc_i64(m, m, k); | |
615 | tcg_gen_nor_i64(d, n, m); | |
616 | } | |
617 | ||
618 | static void gen_nbsl_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | |
619 | TCGv_vec m, TCGv_vec k) | |
620 | { | |
621 | tcg_gen_bitsel_vec(vece, d, k, n, m); | |
622 | tcg_gen_not_vec(vece, d, d); | |
623 | } | |
624 | ||
625 | static void gen_nbsl(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | |
626 | uint32_t a, uint32_t oprsz, uint32_t maxsz) | |
627 | { | |
628 | static const GVecGen4 op = { | |
629 | .fni8 = gen_nbsl_i64, | |
630 | .fniv = gen_nbsl_vec, | |
631 | .fno = gen_helper_sve2_nbsl, | |
632 | .vece = MO_64, | |
633 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
634 | }; | |
635 | tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &op); | |
636 | } | |
637 | ||
638 | static bool trans_NBSL(DisasContext *s, arg_rrrr_esz *a) | |
639 | { | |
640 | return do_sve2_zzzz_fn(s, a, gen_nbsl); | |
641 | } | |
642 | ||
fea98f9c RH |
643 | /* |
644 | *** SVE Integer Arithmetic - Unpredicated Group | |
645 | */ | |
646 | ||
3a7be554 | 647 | static bool trans_ADD_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 648 | { |
28c4da31 | 649 | return do_zzz_fn(s, a, tcg_gen_gvec_add); |
fea98f9c RH |
650 | } |
651 | ||
3a7be554 | 652 | static bool trans_SUB_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 653 | { |
28c4da31 | 654 | return do_zzz_fn(s, a, tcg_gen_gvec_sub); |
fea98f9c RH |
655 | } |
656 | ||
3a7be554 | 657 | static bool trans_SQADD_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 658 | { |
28c4da31 | 659 | return do_zzz_fn(s, a, tcg_gen_gvec_ssadd); |
fea98f9c RH |
660 | } |
661 | ||
3a7be554 | 662 | static bool trans_SQSUB_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 663 | { |
28c4da31 | 664 | return do_zzz_fn(s, a, tcg_gen_gvec_sssub); |
fea98f9c RH |
665 | } |
666 | ||
3a7be554 | 667 | static bool trans_UQADD_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 668 | { |
28c4da31 | 669 | return do_zzz_fn(s, a, tcg_gen_gvec_usadd); |
fea98f9c RH |
670 | } |
671 | ||
3a7be554 | 672 | static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a) |
fea98f9c | 673 | { |
28c4da31 | 674 | return do_zzz_fn(s, a, tcg_gen_gvec_ussub); |
fea98f9c RH |
675 | } |
676 | ||
f97cfd59 RH |
677 | /* |
678 | *** SVE Integer Arithmetic - Binary Predicated Group | |
679 | */ | |
680 | ||
681 | static bool do_zpzz_ool(DisasContext *s, arg_rprr_esz *a, gen_helper_gvec_4 *fn) | |
682 | { | |
f97cfd59 RH |
683 | if (fn == NULL) { |
684 | return false; | |
685 | } | |
686 | if (sve_access_check(s)) { | |
36cbb7a8 | 687 | gen_gvec_ool_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0); |
f97cfd59 RH |
688 | } |
689 | return true; | |
690 | } | |
691 | ||
a2103582 RH |
692 | /* Select active elememnts from Zn and inactive elements from Zm, |
693 | * storing the result in Zd. | |
694 | */ | |
695 | static void do_sel_z(DisasContext *s, int rd, int rn, int rm, int pg, int esz) | |
696 | { | |
697 | static gen_helper_gvec_4 * const fns[4] = { | |
698 | gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h, | |
699 | gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d | |
700 | }; | |
36cbb7a8 | 701 | gen_gvec_ool_zzzp(s, fns[esz], rd, rn, rm, pg, 0); |
a2103582 RH |
702 | } |
703 | ||
f97cfd59 | 704 | #define DO_ZPZZ(NAME, name) \ |
3a7be554 | 705 | static bool trans_##NAME##_zpzz(DisasContext *s, arg_rprr_esz *a) \ |
f97cfd59 RH |
706 | { \ |
707 | static gen_helper_gvec_4 * const fns[4] = { \ | |
708 | gen_helper_sve_##name##_zpzz_b, gen_helper_sve_##name##_zpzz_h, \ | |
709 | gen_helper_sve_##name##_zpzz_s, gen_helper_sve_##name##_zpzz_d, \ | |
710 | }; \ | |
711 | return do_zpzz_ool(s, a, fns[a->esz]); \ | |
712 | } | |
713 | ||
714 | DO_ZPZZ(AND, and) | |
715 | DO_ZPZZ(EOR, eor) | |
716 | DO_ZPZZ(ORR, orr) | |
717 | DO_ZPZZ(BIC, bic) | |
718 | ||
719 | DO_ZPZZ(ADD, add) | |
720 | DO_ZPZZ(SUB, sub) | |
721 | ||
722 | DO_ZPZZ(SMAX, smax) | |
723 | DO_ZPZZ(UMAX, umax) | |
724 | DO_ZPZZ(SMIN, smin) | |
725 | DO_ZPZZ(UMIN, umin) | |
726 | DO_ZPZZ(SABD, sabd) | |
727 | DO_ZPZZ(UABD, uabd) | |
728 | ||
729 | DO_ZPZZ(MUL, mul) | |
730 | DO_ZPZZ(SMULH, smulh) | |
731 | DO_ZPZZ(UMULH, umulh) | |
732 | ||
27721dbb RH |
733 | DO_ZPZZ(ASR, asr) |
734 | DO_ZPZZ(LSR, lsr) | |
735 | DO_ZPZZ(LSL, lsl) | |
736 | ||
3a7be554 | 737 | static bool trans_SDIV_zpzz(DisasContext *s, arg_rprr_esz *a) |
f97cfd59 RH |
738 | { |
739 | static gen_helper_gvec_4 * const fns[4] = { | |
740 | NULL, NULL, gen_helper_sve_sdiv_zpzz_s, gen_helper_sve_sdiv_zpzz_d | |
741 | }; | |
742 | return do_zpzz_ool(s, a, fns[a->esz]); | |
743 | } | |
744 | ||
3a7be554 | 745 | static bool trans_UDIV_zpzz(DisasContext *s, arg_rprr_esz *a) |
f97cfd59 RH |
746 | { |
747 | static gen_helper_gvec_4 * const fns[4] = { | |
748 | NULL, NULL, gen_helper_sve_udiv_zpzz_s, gen_helper_sve_udiv_zpzz_d | |
749 | }; | |
750 | return do_zpzz_ool(s, a, fns[a->esz]); | |
751 | } | |
752 | ||
3a7be554 | 753 | static bool trans_SEL_zpzz(DisasContext *s, arg_rprr_esz *a) |
a2103582 RH |
754 | { |
755 | if (sve_access_check(s)) { | |
756 | do_sel_z(s, a->rd, a->rn, a->rm, a->pg, a->esz); | |
757 | } | |
758 | return true; | |
759 | } | |
d3fe4a29 | 760 | |
f97cfd59 RH |
761 | #undef DO_ZPZZ |
762 | ||
afac6d04 RH |
763 | /* |
764 | *** SVE Integer Arithmetic - Unary Predicated Group | |
765 | */ | |
766 | ||
767 | static bool do_zpz_ool(DisasContext *s, arg_rpr_esz *a, gen_helper_gvec_3 *fn) | |
768 | { | |
769 | if (fn == NULL) { | |
770 | return false; | |
771 | } | |
772 | if (sve_access_check(s)) { | |
96a461f7 | 773 | gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, 0); |
afac6d04 RH |
774 | } |
775 | return true; | |
776 | } | |
777 | ||
778 | #define DO_ZPZ(NAME, name) \ | |
3a7be554 | 779 | static bool trans_##NAME(DisasContext *s, arg_rpr_esz *a) \ |
afac6d04 RH |
780 | { \ |
781 | static gen_helper_gvec_3 * const fns[4] = { \ | |
782 | gen_helper_sve_##name##_b, gen_helper_sve_##name##_h, \ | |
783 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d, \ | |
784 | }; \ | |
785 | return do_zpz_ool(s, a, fns[a->esz]); \ | |
786 | } | |
787 | ||
788 | DO_ZPZ(CLS, cls) | |
789 | DO_ZPZ(CLZ, clz) | |
790 | DO_ZPZ(CNT_zpz, cnt_zpz) | |
791 | DO_ZPZ(CNOT, cnot) | |
792 | DO_ZPZ(NOT_zpz, not_zpz) | |
793 | DO_ZPZ(ABS, abs) | |
794 | DO_ZPZ(NEG, neg) | |
795 | ||
3a7be554 | 796 | static bool trans_FABS(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
797 | { |
798 | static gen_helper_gvec_3 * const fns[4] = { | |
799 | NULL, | |
800 | gen_helper_sve_fabs_h, | |
801 | gen_helper_sve_fabs_s, | |
802 | gen_helper_sve_fabs_d | |
803 | }; | |
804 | return do_zpz_ool(s, a, fns[a->esz]); | |
805 | } | |
806 | ||
3a7be554 | 807 | static bool trans_FNEG(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
808 | { |
809 | static gen_helper_gvec_3 * const fns[4] = { | |
810 | NULL, | |
811 | gen_helper_sve_fneg_h, | |
812 | gen_helper_sve_fneg_s, | |
813 | gen_helper_sve_fneg_d | |
814 | }; | |
815 | return do_zpz_ool(s, a, fns[a->esz]); | |
816 | } | |
817 | ||
3a7be554 | 818 | static bool trans_SXTB(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
819 | { |
820 | static gen_helper_gvec_3 * const fns[4] = { | |
821 | NULL, | |
822 | gen_helper_sve_sxtb_h, | |
823 | gen_helper_sve_sxtb_s, | |
824 | gen_helper_sve_sxtb_d | |
825 | }; | |
826 | return do_zpz_ool(s, a, fns[a->esz]); | |
827 | } | |
828 | ||
3a7be554 | 829 | static bool trans_UXTB(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
830 | { |
831 | static gen_helper_gvec_3 * const fns[4] = { | |
832 | NULL, | |
833 | gen_helper_sve_uxtb_h, | |
834 | gen_helper_sve_uxtb_s, | |
835 | gen_helper_sve_uxtb_d | |
836 | }; | |
837 | return do_zpz_ool(s, a, fns[a->esz]); | |
838 | } | |
839 | ||
3a7be554 | 840 | static bool trans_SXTH(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
841 | { |
842 | static gen_helper_gvec_3 * const fns[4] = { | |
843 | NULL, NULL, | |
844 | gen_helper_sve_sxth_s, | |
845 | gen_helper_sve_sxth_d | |
846 | }; | |
847 | return do_zpz_ool(s, a, fns[a->esz]); | |
848 | } | |
849 | ||
3a7be554 | 850 | static bool trans_UXTH(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
851 | { |
852 | static gen_helper_gvec_3 * const fns[4] = { | |
853 | NULL, NULL, | |
854 | gen_helper_sve_uxth_s, | |
855 | gen_helper_sve_uxth_d | |
856 | }; | |
857 | return do_zpz_ool(s, a, fns[a->esz]); | |
858 | } | |
859 | ||
3a7be554 | 860 | static bool trans_SXTW(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
861 | { |
862 | return do_zpz_ool(s, a, a->esz == 3 ? gen_helper_sve_sxtw_d : NULL); | |
863 | } | |
864 | ||
3a7be554 | 865 | static bool trans_UXTW(DisasContext *s, arg_rpr_esz *a) |
afac6d04 RH |
866 | { |
867 | return do_zpz_ool(s, a, a->esz == 3 ? gen_helper_sve_uxtw_d : NULL); | |
868 | } | |
869 | ||
870 | #undef DO_ZPZ | |
871 | ||
047cec97 RH |
872 | /* |
873 | *** SVE Integer Reduction Group | |
874 | */ | |
875 | ||
876 | typedef void gen_helper_gvec_reduc(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_i32); | |
877 | static bool do_vpz_ool(DisasContext *s, arg_rpr_esz *a, | |
878 | gen_helper_gvec_reduc *fn) | |
879 | { | |
880 | unsigned vsz = vec_full_reg_size(s); | |
881 | TCGv_ptr t_zn, t_pg; | |
882 | TCGv_i32 desc; | |
883 | TCGv_i64 temp; | |
884 | ||
885 | if (fn == NULL) { | |
886 | return false; | |
887 | } | |
888 | if (!sve_access_check(s)) { | |
889 | return true; | |
890 | } | |
891 | ||
892 | desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
893 | temp = tcg_temp_new_i64(); | |
894 | t_zn = tcg_temp_new_ptr(); | |
895 | t_pg = tcg_temp_new_ptr(); | |
896 | ||
897 | tcg_gen_addi_ptr(t_zn, cpu_env, vec_full_reg_offset(s, a->rn)); | |
898 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->pg)); | |
899 | fn(temp, t_zn, t_pg, desc); | |
900 | tcg_temp_free_ptr(t_zn); | |
901 | tcg_temp_free_ptr(t_pg); | |
902 | tcg_temp_free_i32(desc); | |
903 | ||
904 | write_fp_dreg(s, a->rd, temp); | |
905 | tcg_temp_free_i64(temp); | |
906 | return true; | |
907 | } | |
908 | ||
909 | #define DO_VPZ(NAME, name) \ | |
3a7be554 | 910 | static bool trans_##NAME(DisasContext *s, arg_rpr_esz *a) \ |
047cec97 RH |
911 | { \ |
912 | static gen_helper_gvec_reduc * const fns[4] = { \ | |
913 | gen_helper_sve_##name##_b, gen_helper_sve_##name##_h, \ | |
914 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d, \ | |
915 | }; \ | |
916 | return do_vpz_ool(s, a, fns[a->esz]); \ | |
917 | } | |
918 | ||
919 | DO_VPZ(ORV, orv) | |
920 | DO_VPZ(ANDV, andv) | |
921 | DO_VPZ(EORV, eorv) | |
922 | ||
923 | DO_VPZ(UADDV, uaddv) | |
924 | DO_VPZ(SMAXV, smaxv) | |
925 | DO_VPZ(UMAXV, umaxv) | |
926 | DO_VPZ(SMINV, sminv) | |
927 | DO_VPZ(UMINV, uminv) | |
928 | ||
3a7be554 | 929 | static bool trans_SADDV(DisasContext *s, arg_rpr_esz *a) |
047cec97 RH |
930 | { |
931 | static gen_helper_gvec_reduc * const fns[4] = { | |
932 | gen_helper_sve_saddv_b, gen_helper_sve_saddv_h, | |
933 | gen_helper_sve_saddv_s, NULL | |
934 | }; | |
935 | return do_vpz_ool(s, a, fns[a->esz]); | |
936 | } | |
937 | ||
938 | #undef DO_VPZ | |
939 | ||
ccd841c3 RH |
940 | /* |
941 | *** SVE Shift by Immediate - Predicated Group | |
942 | */ | |
943 | ||
60245996 RH |
944 | /* |
945 | * Copy Zn into Zd, storing zeros into inactive elements. | |
946 | * If invert, store zeros into the active elements. | |
ccd841c3 | 947 | */ |
60245996 RH |
948 | static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg, |
949 | int esz, bool invert) | |
ccd841c3 | 950 | { |
60245996 RH |
951 | static gen_helper_gvec_3 * const fns[4] = { |
952 | gen_helper_sve_movz_b, gen_helper_sve_movz_h, | |
953 | gen_helper_sve_movz_s, gen_helper_sve_movz_d, | |
ccd841c3 | 954 | }; |
60245996 | 955 | |
ccd841c3 | 956 | if (sve_access_check(s)) { |
96a461f7 | 957 | gen_gvec_ool_zzp(s, fns[esz], rd, rn, pg, invert); |
ccd841c3 RH |
958 | } |
959 | return true; | |
960 | } | |
961 | ||
962 | static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a, | |
963 | gen_helper_gvec_3 *fn) | |
964 | { | |
965 | if (sve_access_check(s)) { | |
96a461f7 | 966 | gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, a->imm); |
ccd841c3 RH |
967 | } |
968 | return true; | |
969 | } | |
970 | ||
3a7be554 | 971 | static bool trans_ASR_zpzi(DisasContext *s, arg_rpri_esz *a) |
ccd841c3 RH |
972 | { |
973 | static gen_helper_gvec_3 * const fns[4] = { | |
974 | gen_helper_sve_asr_zpzi_b, gen_helper_sve_asr_zpzi_h, | |
975 | gen_helper_sve_asr_zpzi_s, gen_helper_sve_asr_zpzi_d, | |
976 | }; | |
977 | if (a->esz < 0) { | |
978 | /* Invalid tsz encoding -- see tszimm_esz. */ | |
979 | return false; | |
980 | } | |
981 | /* Shift by element size is architecturally valid. For | |
982 | arithmetic right-shift, it's the same as by one less. */ | |
983 | a->imm = MIN(a->imm, (8 << a->esz) - 1); | |
984 | return do_zpzi_ool(s, a, fns[a->esz]); | |
985 | } | |
986 | ||
3a7be554 | 987 | static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a) |
ccd841c3 RH |
988 | { |
989 | static gen_helper_gvec_3 * const fns[4] = { | |
990 | gen_helper_sve_lsr_zpzi_b, gen_helper_sve_lsr_zpzi_h, | |
991 | gen_helper_sve_lsr_zpzi_s, gen_helper_sve_lsr_zpzi_d, | |
992 | }; | |
993 | if (a->esz < 0) { | |
994 | return false; | |
995 | } | |
996 | /* Shift by element size is architecturally valid. | |
997 | For logical shifts, it is a zeroing operation. */ | |
998 | if (a->imm >= (8 << a->esz)) { | |
60245996 | 999 | return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); |
ccd841c3 RH |
1000 | } else { |
1001 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1002 | } | |
1003 | } | |
1004 | ||
3a7be554 | 1005 | static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a) |
ccd841c3 RH |
1006 | { |
1007 | static gen_helper_gvec_3 * const fns[4] = { | |
1008 | gen_helper_sve_lsl_zpzi_b, gen_helper_sve_lsl_zpzi_h, | |
1009 | gen_helper_sve_lsl_zpzi_s, gen_helper_sve_lsl_zpzi_d, | |
1010 | }; | |
1011 | if (a->esz < 0) { | |
1012 | return false; | |
1013 | } | |
1014 | /* Shift by element size is architecturally valid. | |
1015 | For logical shifts, it is a zeroing operation. */ | |
1016 | if (a->imm >= (8 << a->esz)) { | |
60245996 | 1017 | return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); |
ccd841c3 RH |
1018 | } else { |
1019 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1020 | } | |
1021 | } | |
1022 | ||
3a7be554 | 1023 | static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a) |
ccd841c3 RH |
1024 | { |
1025 | static gen_helper_gvec_3 * const fns[4] = { | |
1026 | gen_helper_sve_asrd_b, gen_helper_sve_asrd_h, | |
1027 | gen_helper_sve_asrd_s, gen_helper_sve_asrd_d, | |
1028 | }; | |
1029 | if (a->esz < 0) { | |
1030 | return false; | |
1031 | } | |
1032 | /* Shift by element size is architecturally valid. For arithmetic | |
1033 | right shift for division, it is a zeroing operation. */ | |
1034 | if (a->imm >= (8 << a->esz)) { | |
60245996 | 1035 | return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); |
ccd841c3 RH |
1036 | } else { |
1037 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1038 | } | |
1039 | } | |
1040 | ||
a5421b54 SL |
1041 | static bool trans_SQSHL_zpzi(DisasContext *s, arg_rpri_esz *a) |
1042 | { | |
1043 | static gen_helper_gvec_3 * const fns[4] = { | |
1044 | gen_helper_sve2_sqshl_zpzi_b, gen_helper_sve2_sqshl_zpzi_h, | |
1045 | gen_helper_sve2_sqshl_zpzi_s, gen_helper_sve2_sqshl_zpzi_d, | |
1046 | }; | |
1047 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
1048 | return false; | |
1049 | } | |
1050 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1051 | } | |
1052 | ||
1053 | static bool trans_UQSHL_zpzi(DisasContext *s, arg_rpri_esz *a) | |
1054 | { | |
1055 | static gen_helper_gvec_3 * const fns[4] = { | |
1056 | gen_helper_sve2_uqshl_zpzi_b, gen_helper_sve2_uqshl_zpzi_h, | |
1057 | gen_helper_sve2_uqshl_zpzi_s, gen_helper_sve2_uqshl_zpzi_d, | |
1058 | }; | |
1059 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
1060 | return false; | |
1061 | } | |
1062 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1063 | } | |
1064 | ||
1065 | static bool trans_SRSHR(DisasContext *s, arg_rpri_esz *a) | |
1066 | { | |
1067 | static gen_helper_gvec_3 * const fns[4] = { | |
1068 | gen_helper_sve2_srshr_b, gen_helper_sve2_srshr_h, | |
1069 | gen_helper_sve2_srshr_s, gen_helper_sve2_srshr_d, | |
1070 | }; | |
1071 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
1072 | return false; | |
1073 | } | |
1074 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1075 | } | |
1076 | ||
1077 | static bool trans_URSHR(DisasContext *s, arg_rpri_esz *a) | |
1078 | { | |
1079 | static gen_helper_gvec_3 * const fns[4] = { | |
1080 | gen_helper_sve2_urshr_b, gen_helper_sve2_urshr_h, | |
1081 | gen_helper_sve2_urshr_s, gen_helper_sve2_urshr_d, | |
1082 | }; | |
1083 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
1084 | return false; | |
1085 | } | |
1086 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1087 | } | |
1088 | ||
1089 | static bool trans_SQSHLU(DisasContext *s, arg_rpri_esz *a) | |
1090 | { | |
1091 | static gen_helper_gvec_3 * const fns[4] = { | |
1092 | gen_helper_sve2_sqshlu_b, gen_helper_sve2_sqshlu_h, | |
1093 | gen_helper_sve2_sqshlu_s, gen_helper_sve2_sqshlu_d, | |
1094 | }; | |
1095 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
1096 | return false; | |
1097 | } | |
1098 | return do_zpzi_ool(s, a, fns[a->esz]); | |
1099 | } | |
1100 | ||
fe7f8dfb RH |
1101 | /* |
1102 | *** SVE Bitwise Shift - Predicated Group | |
1103 | */ | |
1104 | ||
1105 | #define DO_ZPZW(NAME, name) \ | |
3a7be554 | 1106 | static bool trans_##NAME##_zpzw(DisasContext *s, arg_rprr_esz *a) \ |
fe7f8dfb RH |
1107 | { \ |
1108 | static gen_helper_gvec_4 * const fns[3] = { \ | |
1109 | gen_helper_sve_##name##_zpzw_b, gen_helper_sve_##name##_zpzw_h, \ | |
1110 | gen_helper_sve_##name##_zpzw_s, \ | |
1111 | }; \ | |
1112 | if (a->esz < 0 || a->esz >= 3) { \ | |
1113 | return false; \ | |
1114 | } \ | |
1115 | return do_zpzz_ool(s, a, fns[a->esz]); \ | |
1116 | } | |
1117 | ||
1118 | DO_ZPZW(ASR, asr) | |
1119 | DO_ZPZW(LSR, lsr) | |
1120 | DO_ZPZW(LSL, lsl) | |
1121 | ||
1122 | #undef DO_ZPZW | |
1123 | ||
d9d78dcc RH |
1124 | /* |
1125 | *** SVE Bitwise Shift - Unpredicated Group | |
1126 | */ | |
1127 | ||
1128 | static bool do_shift_imm(DisasContext *s, arg_rri_esz *a, bool asr, | |
1129 | void (*gvec_fn)(unsigned, uint32_t, uint32_t, | |
1130 | int64_t, uint32_t, uint32_t)) | |
1131 | { | |
1132 | if (a->esz < 0) { | |
1133 | /* Invalid tsz encoding -- see tszimm_esz. */ | |
1134 | return false; | |
1135 | } | |
1136 | if (sve_access_check(s)) { | |
1137 | unsigned vsz = vec_full_reg_size(s); | |
1138 | /* Shift by element size is architecturally valid. For | |
1139 | arithmetic right-shift, it's the same as by one less. | |
1140 | Otherwise it is a zeroing operation. */ | |
1141 | if (a->imm >= 8 << a->esz) { | |
1142 | if (asr) { | |
1143 | a->imm = (8 << a->esz) - 1; | |
1144 | } else { | |
1145 | do_dupi_z(s, a->rd, 0); | |
1146 | return true; | |
1147 | } | |
1148 | } | |
1149 | gvec_fn(a->esz, vec_full_reg_offset(s, a->rd), | |
1150 | vec_full_reg_offset(s, a->rn), a->imm, vsz, vsz); | |
1151 | } | |
1152 | return true; | |
1153 | } | |
1154 | ||
3a7be554 | 1155 | static bool trans_ASR_zzi(DisasContext *s, arg_rri_esz *a) |
d9d78dcc RH |
1156 | { |
1157 | return do_shift_imm(s, a, true, tcg_gen_gvec_sari); | |
1158 | } | |
1159 | ||
3a7be554 | 1160 | static bool trans_LSR_zzi(DisasContext *s, arg_rri_esz *a) |
d9d78dcc RH |
1161 | { |
1162 | return do_shift_imm(s, a, false, tcg_gen_gvec_shri); | |
1163 | } | |
1164 | ||
3a7be554 | 1165 | static bool trans_LSL_zzi(DisasContext *s, arg_rri_esz *a) |
d9d78dcc RH |
1166 | { |
1167 | return do_shift_imm(s, a, false, tcg_gen_gvec_shli); | |
1168 | } | |
1169 | ||
1170 | static bool do_zzw_ool(DisasContext *s, arg_rrr_esz *a, gen_helper_gvec_3 *fn) | |
1171 | { | |
1172 | if (fn == NULL) { | |
1173 | return false; | |
1174 | } | |
1175 | if (sve_access_check(s)) { | |
e645d1a1 | 1176 | gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0); |
d9d78dcc RH |
1177 | } |
1178 | return true; | |
1179 | } | |
1180 | ||
1181 | #define DO_ZZW(NAME, name) \ | |
3a7be554 | 1182 | static bool trans_##NAME##_zzw(DisasContext *s, arg_rrr_esz *a) \ |
d9d78dcc RH |
1183 | { \ |
1184 | static gen_helper_gvec_3 * const fns[4] = { \ | |
1185 | gen_helper_sve_##name##_zzw_b, gen_helper_sve_##name##_zzw_h, \ | |
1186 | gen_helper_sve_##name##_zzw_s, NULL \ | |
1187 | }; \ | |
1188 | return do_zzw_ool(s, a, fns[a->esz]); \ | |
1189 | } | |
1190 | ||
1191 | DO_ZZW(ASR, asr) | |
1192 | DO_ZZW(LSR, lsr) | |
1193 | DO_ZZW(LSL, lsl) | |
1194 | ||
1195 | #undef DO_ZZW | |
1196 | ||
96a36e4a RH |
1197 | /* |
1198 | *** SVE Integer Multiply-Add Group | |
1199 | */ | |
1200 | ||
1201 | static bool do_zpzzz_ool(DisasContext *s, arg_rprrr_esz *a, | |
1202 | gen_helper_gvec_5 *fn) | |
1203 | { | |
1204 | if (sve_access_check(s)) { | |
1205 | unsigned vsz = vec_full_reg_size(s); | |
1206 | tcg_gen_gvec_5_ool(vec_full_reg_offset(s, a->rd), | |
1207 | vec_full_reg_offset(s, a->ra), | |
1208 | vec_full_reg_offset(s, a->rn), | |
1209 | vec_full_reg_offset(s, a->rm), | |
1210 | pred_full_reg_offset(s, a->pg), | |
1211 | vsz, vsz, 0, fn); | |
1212 | } | |
1213 | return true; | |
1214 | } | |
1215 | ||
1216 | #define DO_ZPZZZ(NAME, name) \ | |
3a7be554 | 1217 | static bool trans_##NAME(DisasContext *s, arg_rprrr_esz *a) \ |
96a36e4a RH |
1218 | { \ |
1219 | static gen_helper_gvec_5 * const fns[4] = { \ | |
1220 | gen_helper_sve_##name##_b, gen_helper_sve_##name##_h, \ | |
1221 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d, \ | |
1222 | }; \ | |
1223 | return do_zpzzz_ool(s, a, fns[a->esz]); \ | |
1224 | } | |
1225 | ||
1226 | DO_ZPZZZ(MLA, mla) | |
1227 | DO_ZPZZZ(MLS, mls) | |
1228 | ||
1229 | #undef DO_ZPZZZ | |
1230 | ||
9a56c9c3 RH |
1231 | /* |
1232 | *** SVE Index Generation Group | |
1233 | */ | |
1234 | ||
1235 | static void do_index(DisasContext *s, int esz, int rd, | |
1236 | TCGv_i64 start, TCGv_i64 incr) | |
1237 | { | |
1238 | unsigned vsz = vec_full_reg_size(s); | |
1239 | TCGv_i32 desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
1240 | TCGv_ptr t_zd = tcg_temp_new_ptr(); | |
1241 | ||
1242 | tcg_gen_addi_ptr(t_zd, cpu_env, vec_full_reg_offset(s, rd)); | |
1243 | if (esz == 3) { | |
1244 | gen_helper_sve_index_d(t_zd, start, incr, desc); | |
1245 | } else { | |
1246 | typedef void index_fn(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | |
1247 | static index_fn * const fns[3] = { | |
1248 | gen_helper_sve_index_b, | |
1249 | gen_helper_sve_index_h, | |
1250 | gen_helper_sve_index_s, | |
1251 | }; | |
1252 | TCGv_i32 s32 = tcg_temp_new_i32(); | |
1253 | TCGv_i32 i32 = tcg_temp_new_i32(); | |
1254 | ||
1255 | tcg_gen_extrl_i64_i32(s32, start); | |
1256 | tcg_gen_extrl_i64_i32(i32, incr); | |
1257 | fns[esz](t_zd, s32, i32, desc); | |
1258 | ||
1259 | tcg_temp_free_i32(s32); | |
1260 | tcg_temp_free_i32(i32); | |
1261 | } | |
1262 | tcg_temp_free_ptr(t_zd); | |
1263 | tcg_temp_free_i32(desc); | |
1264 | } | |
1265 | ||
3a7be554 | 1266 | static bool trans_INDEX_ii(DisasContext *s, arg_INDEX_ii *a) |
9a56c9c3 RH |
1267 | { |
1268 | if (sve_access_check(s)) { | |
b0c3aece RH |
1269 | TCGv_i64 start = tcg_constant_i64(a->imm1); |
1270 | TCGv_i64 incr = tcg_constant_i64(a->imm2); | |
9a56c9c3 | 1271 | do_index(s, a->esz, a->rd, start, incr); |
9a56c9c3 RH |
1272 | } |
1273 | return true; | |
1274 | } | |
1275 | ||
3a7be554 | 1276 | static bool trans_INDEX_ir(DisasContext *s, arg_INDEX_ir *a) |
9a56c9c3 RH |
1277 | { |
1278 | if (sve_access_check(s)) { | |
b0c3aece | 1279 | TCGv_i64 start = tcg_constant_i64(a->imm); |
9a56c9c3 RH |
1280 | TCGv_i64 incr = cpu_reg(s, a->rm); |
1281 | do_index(s, a->esz, a->rd, start, incr); | |
9a56c9c3 RH |
1282 | } |
1283 | return true; | |
1284 | } | |
1285 | ||
3a7be554 | 1286 | static bool trans_INDEX_ri(DisasContext *s, arg_INDEX_ri *a) |
9a56c9c3 RH |
1287 | { |
1288 | if (sve_access_check(s)) { | |
1289 | TCGv_i64 start = cpu_reg(s, a->rn); | |
b0c3aece | 1290 | TCGv_i64 incr = tcg_constant_i64(a->imm); |
9a56c9c3 | 1291 | do_index(s, a->esz, a->rd, start, incr); |
9a56c9c3 RH |
1292 | } |
1293 | return true; | |
1294 | } | |
1295 | ||
3a7be554 | 1296 | static bool trans_INDEX_rr(DisasContext *s, arg_INDEX_rr *a) |
9a56c9c3 RH |
1297 | { |
1298 | if (sve_access_check(s)) { | |
1299 | TCGv_i64 start = cpu_reg(s, a->rn); | |
1300 | TCGv_i64 incr = cpu_reg(s, a->rm); | |
1301 | do_index(s, a->esz, a->rd, start, incr); | |
1302 | } | |
1303 | return true; | |
1304 | } | |
1305 | ||
96f922cc RH |
1306 | /* |
1307 | *** SVE Stack Allocation Group | |
1308 | */ | |
1309 | ||
3a7be554 | 1310 | static bool trans_ADDVL(DisasContext *s, arg_ADDVL *a) |
96f922cc | 1311 | { |
5de56742 AC |
1312 | if (sve_access_check(s)) { |
1313 | TCGv_i64 rd = cpu_reg_sp(s, a->rd); | |
1314 | TCGv_i64 rn = cpu_reg_sp(s, a->rn); | |
1315 | tcg_gen_addi_i64(rd, rn, a->imm * vec_full_reg_size(s)); | |
1316 | } | |
96f922cc RH |
1317 | return true; |
1318 | } | |
1319 | ||
3a7be554 | 1320 | static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a) |
96f922cc | 1321 | { |
5de56742 AC |
1322 | if (sve_access_check(s)) { |
1323 | TCGv_i64 rd = cpu_reg_sp(s, a->rd); | |
1324 | TCGv_i64 rn = cpu_reg_sp(s, a->rn); | |
1325 | tcg_gen_addi_i64(rd, rn, a->imm * pred_full_reg_size(s)); | |
1326 | } | |
96f922cc RH |
1327 | return true; |
1328 | } | |
1329 | ||
3a7be554 | 1330 | static bool trans_RDVL(DisasContext *s, arg_RDVL *a) |
96f922cc | 1331 | { |
5de56742 AC |
1332 | if (sve_access_check(s)) { |
1333 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
1334 | tcg_gen_movi_i64(reg, a->imm * vec_full_reg_size(s)); | |
1335 | } | |
96f922cc RH |
1336 | return true; |
1337 | } | |
1338 | ||
4b242d9c RH |
1339 | /* |
1340 | *** SVE Compute Vector Address Group | |
1341 | */ | |
1342 | ||
1343 | static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn) | |
1344 | { | |
1345 | if (sve_access_check(s)) { | |
e645d1a1 | 1346 | gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm); |
4b242d9c RH |
1347 | } |
1348 | return true; | |
1349 | } | |
1350 | ||
3a7be554 | 1351 | static bool trans_ADR_p32(DisasContext *s, arg_rrri *a) |
4b242d9c RH |
1352 | { |
1353 | return do_adr(s, a, gen_helper_sve_adr_p32); | |
1354 | } | |
1355 | ||
3a7be554 | 1356 | static bool trans_ADR_p64(DisasContext *s, arg_rrri *a) |
4b242d9c RH |
1357 | { |
1358 | return do_adr(s, a, gen_helper_sve_adr_p64); | |
1359 | } | |
1360 | ||
3a7be554 | 1361 | static bool trans_ADR_s32(DisasContext *s, arg_rrri *a) |
4b242d9c RH |
1362 | { |
1363 | return do_adr(s, a, gen_helper_sve_adr_s32); | |
1364 | } | |
1365 | ||
3a7be554 | 1366 | static bool trans_ADR_u32(DisasContext *s, arg_rrri *a) |
4b242d9c RH |
1367 | { |
1368 | return do_adr(s, a, gen_helper_sve_adr_u32); | |
1369 | } | |
1370 | ||
0762cd42 RH |
1371 | /* |
1372 | *** SVE Integer Misc - Unpredicated Group | |
1373 | */ | |
1374 | ||
3a7be554 | 1375 | static bool trans_FEXPA(DisasContext *s, arg_rr_esz *a) |
0762cd42 RH |
1376 | { |
1377 | static gen_helper_gvec_2 * const fns[4] = { | |
1378 | NULL, | |
1379 | gen_helper_sve_fexpa_h, | |
1380 | gen_helper_sve_fexpa_s, | |
1381 | gen_helper_sve_fexpa_d, | |
1382 | }; | |
1383 | if (a->esz == 0) { | |
1384 | return false; | |
1385 | } | |
1386 | if (sve_access_check(s)) { | |
40e32e5a | 1387 | gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0); |
0762cd42 RH |
1388 | } |
1389 | return true; | |
1390 | } | |
1391 | ||
3a7be554 | 1392 | static bool trans_FTSSEL(DisasContext *s, arg_rrr_esz *a) |
a1f233f2 RH |
1393 | { |
1394 | static gen_helper_gvec_3 * const fns[4] = { | |
1395 | NULL, | |
1396 | gen_helper_sve_ftssel_h, | |
1397 | gen_helper_sve_ftssel_s, | |
1398 | gen_helper_sve_ftssel_d, | |
1399 | }; | |
1400 | if (a->esz == 0) { | |
1401 | return false; | |
1402 | } | |
1403 | if (sve_access_check(s)) { | |
e645d1a1 | 1404 | gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0); |
a1f233f2 RH |
1405 | } |
1406 | return true; | |
1407 | } | |
1408 | ||
516e246a RH |
1409 | /* |
1410 | *** SVE Predicate Logical Operations Group | |
1411 | */ | |
1412 | ||
1413 | static bool do_pppp_flags(DisasContext *s, arg_rprr_s *a, | |
1414 | const GVecGen4 *gvec_op) | |
1415 | { | |
1416 | if (!sve_access_check(s)) { | |
1417 | return true; | |
1418 | } | |
1419 | ||
1420 | unsigned psz = pred_gvec_reg_size(s); | |
1421 | int dofs = pred_full_reg_offset(s, a->rd); | |
1422 | int nofs = pred_full_reg_offset(s, a->rn); | |
1423 | int mofs = pred_full_reg_offset(s, a->rm); | |
1424 | int gofs = pred_full_reg_offset(s, a->pg); | |
1425 | ||
dd81a8d7 RH |
1426 | if (!a->s) { |
1427 | tcg_gen_gvec_4(dofs, nofs, mofs, gofs, psz, psz, gvec_op); | |
1428 | return true; | |
1429 | } | |
1430 | ||
516e246a RH |
1431 | if (psz == 8) { |
1432 | /* Do the operation and the flags generation in temps. */ | |
1433 | TCGv_i64 pd = tcg_temp_new_i64(); | |
1434 | TCGv_i64 pn = tcg_temp_new_i64(); | |
1435 | TCGv_i64 pm = tcg_temp_new_i64(); | |
1436 | TCGv_i64 pg = tcg_temp_new_i64(); | |
1437 | ||
1438 | tcg_gen_ld_i64(pn, cpu_env, nofs); | |
1439 | tcg_gen_ld_i64(pm, cpu_env, mofs); | |
1440 | tcg_gen_ld_i64(pg, cpu_env, gofs); | |
1441 | ||
1442 | gvec_op->fni8(pd, pn, pm, pg); | |
1443 | tcg_gen_st_i64(pd, cpu_env, dofs); | |
1444 | ||
1445 | do_predtest1(pd, pg); | |
1446 | ||
1447 | tcg_temp_free_i64(pd); | |
1448 | tcg_temp_free_i64(pn); | |
1449 | tcg_temp_free_i64(pm); | |
1450 | tcg_temp_free_i64(pg); | |
1451 | } else { | |
1452 | /* The operation and flags generation is large. The computation | |
1453 | * of the flags depends on the original contents of the guarding | |
1454 | * predicate. If the destination overwrites the guarding predicate, | |
1455 | * then the easiest way to get this right is to save a copy. | |
1456 | */ | |
1457 | int tofs = gofs; | |
1458 | if (a->rd == a->pg) { | |
1459 | tofs = offsetof(CPUARMState, vfp.preg_tmp); | |
1460 | tcg_gen_gvec_mov(0, tofs, gofs, psz, psz); | |
1461 | } | |
1462 | ||
1463 | tcg_gen_gvec_4(dofs, nofs, mofs, gofs, psz, psz, gvec_op); | |
1464 | do_predtest(s, dofs, tofs, psz / 8); | |
1465 | } | |
1466 | return true; | |
1467 | } | |
1468 | ||
1469 | static void gen_and_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1470 | { | |
1471 | tcg_gen_and_i64(pd, pn, pm); | |
1472 | tcg_gen_and_i64(pd, pd, pg); | |
1473 | } | |
1474 | ||
1475 | static void gen_and_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1476 | TCGv_vec pm, TCGv_vec pg) | |
1477 | { | |
1478 | tcg_gen_and_vec(vece, pd, pn, pm); | |
1479 | tcg_gen_and_vec(vece, pd, pd, pg); | |
1480 | } | |
1481 | ||
3a7be554 | 1482 | static bool trans_AND_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1483 | { |
1484 | static const GVecGen4 op = { | |
1485 | .fni8 = gen_and_pg_i64, | |
1486 | .fniv = gen_and_pg_vec, | |
1487 | .fno = gen_helper_sve_and_pppp, | |
1488 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1489 | }; | |
dd81a8d7 RH |
1490 | |
1491 | if (!a->s) { | |
1492 | if (!sve_access_check(s)) { | |
1493 | return true; | |
1494 | } | |
1495 | if (a->rn == a->rm) { | |
1496 | if (a->pg == a->rn) { | |
1497 | do_mov_p(s, a->rd, a->rn); | |
1498 | } else { | |
1499 | gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->pg); | |
1500 | } | |
1501 | return true; | |
1502 | } else if (a->pg == a->rn || a->pg == a->rm) { | |
1503 | gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->rm); | |
1504 | return true; | |
516e246a | 1505 | } |
516e246a | 1506 | } |
dd81a8d7 | 1507 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1508 | } |
1509 | ||
1510 | static void gen_bic_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1511 | { | |
1512 | tcg_gen_andc_i64(pd, pn, pm); | |
1513 | tcg_gen_and_i64(pd, pd, pg); | |
1514 | } | |
1515 | ||
1516 | static void gen_bic_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1517 | TCGv_vec pm, TCGv_vec pg) | |
1518 | { | |
1519 | tcg_gen_andc_vec(vece, pd, pn, pm); | |
1520 | tcg_gen_and_vec(vece, pd, pd, pg); | |
1521 | } | |
1522 | ||
3a7be554 | 1523 | static bool trans_BIC_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1524 | { |
1525 | static const GVecGen4 op = { | |
1526 | .fni8 = gen_bic_pg_i64, | |
1527 | .fniv = gen_bic_pg_vec, | |
1528 | .fno = gen_helper_sve_bic_pppp, | |
1529 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1530 | }; | |
dd81a8d7 RH |
1531 | |
1532 | if (!a->s && a->pg == a->rn) { | |
1533 | if (sve_access_check(s)) { | |
1534 | gen_gvec_fn_ppp(s, tcg_gen_gvec_andc, a->rd, a->rn, a->rm); | |
1535 | } | |
1536 | return true; | |
516e246a | 1537 | } |
dd81a8d7 | 1538 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1539 | } |
1540 | ||
1541 | static void gen_eor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1542 | { | |
1543 | tcg_gen_xor_i64(pd, pn, pm); | |
1544 | tcg_gen_and_i64(pd, pd, pg); | |
1545 | } | |
1546 | ||
1547 | static void gen_eor_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1548 | TCGv_vec pm, TCGv_vec pg) | |
1549 | { | |
1550 | tcg_gen_xor_vec(vece, pd, pn, pm); | |
1551 | tcg_gen_and_vec(vece, pd, pd, pg); | |
1552 | } | |
1553 | ||
3a7be554 | 1554 | static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1555 | { |
1556 | static const GVecGen4 op = { | |
1557 | .fni8 = gen_eor_pg_i64, | |
1558 | .fniv = gen_eor_pg_vec, | |
1559 | .fno = gen_helper_sve_eor_pppp, | |
1560 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1561 | }; | |
dd81a8d7 | 1562 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1563 | } |
1564 | ||
3a7be554 | 1565 | static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a | 1566 | { |
516e246a RH |
1567 | if (a->s) { |
1568 | return false; | |
516e246a | 1569 | } |
d4bc6232 RH |
1570 | if (sve_access_check(s)) { |
1571 | unsigned psz = pred_gvec_reg_size(s); | |
1572 | tcg_gen_gvec_bitsel(MO_8, pred_full_reg_offset(s, a->rd), | |
1573 | pred_full_reg_offset(s, a->pg), | |
1574 | pred_full_reg_offset(s, a->rn), | |
1575 | pred_full_reg_offset(s, a->rm), psz, psz); | |
1576 | } | |
1577 | return true; | |
516e246a RH |
1578 | } |
1579 | ||
1580 | static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1581 | { | |
1582 | tcg_gen_or_i64(pd, pn, pm); | |
1583 | tcg_gen_and_i64(pd, pd, pg); | |
1584 | } | |
1585 | ||
1586 | static void gen_orr_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1587 | TCGv_vec pm, TCGv_vec pg) | |
1588 | { | |
1589 | tcg_gen_or_vec(vece, pd, pn, pm); | |
1590 | tcg_gen_and_vec(vece, pd, pd, pg); | |
1591 | } | |
1592 | ||
3a7be554 | 1593 | static bool trans_ORR_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1594 | { |
1595 | static const GVecGen4 op = { | |
1596 | .fni8 = gen_orr_pg_i64, | |
1597 | .fniv = gen_orr_pg_vec, | |
1598 | .fno = gen_helper_sve_orr_pppp, | |
1599 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1600 | }; | |
dd81a8d7 RH |
1601 | |
1602 | if (!a->s && a->pg == a->rn && a->rn == a->rm) { | |
516e246a | 1603 | return do_mov_p(s, a->rd, a->rn); |
516e246a | 1604 | } |
dd81a8d7 | 1605 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1606 | } |
1607 | ||
1608 | static void gen_orn_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1609 | { | |
1610 | tcg_gen_orc_i64(pd, pn, pm); | |
1611 | tcg_gen_and_i64(pd, pd, pg); | |
1612 | } | |
1613 | ||
1614 | static void gen_orn_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1615 | TCGv_vec pm, TCGv_vec pg) | |
1616 | { | |
1617 | tcg_gen_orc_vec(vece, pd, pn, pm); | |
1618 | tcg_gen_and_vec(vece, pd, pd, pg); | |
1619 | } | |
1620 | ||
3a7be554 | 1621 | static bool trans_ORN_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1622 | { |
1623 | static const GVecGen4 op = { | |
1624 | .fni8 = gen_orn_pg_i64, | |
1625 | .fniv = gen_orn_pg_vec, | |
1626 | .fno = gen_helper_sve_orn_pppp, | |
1627 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1628 | }; | |
dd81a8d7 | 1629 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1630 | } |
1631 | ||
1632 | static void gen_nor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1633 | { | |
1634 | tcg_gen_or_i64(pd, pn, pm); | |
1635 | tcg_gen_andc_i64(pd, pg, pd); | |
1636 | } | |
1637 | ||
1638 | static void gen_nor_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1639 | TCGv_vec pm, TCGv_vec pg) | |
1640 | { | |
1641 | tcg_gen_or_vec(vece, pd, pn, pm); | |
1642 | tcg_gen_andc_vec(vece, pd, pg, pd); | |
1643 | } | |
1644 | ||
3a7be554 | 1645 | static bool trans_NOR_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1646 | { |
1647 | static const GVecGen4 op = { | |
1648 | .fni8 = gen_nor_pg_i64, | |
1649 | .fniv = gen_nor_pg_vec, | |
1650 | .fno = gen_helper_sve_nor_pppp, | |
1651 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1652 | }; | |
dd81a8d7 | 1653 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1654 | } |
1655 | ||
1656 | static void gen_nand_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | |
1657 | { | |
1658 | tcg_gen_and_i64(pd, pn, pm); | |
1659 | tcg_gen_andc_i64(pd, pg, pd); | |
1660 | } | |
1661 | ||
1662 | static void gen_nand_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, | |
1663 | TCGv_vec pm, TCGv_vec pg) | |
1664 | { | |
1665 | tcg_gen_and_vec(vece, pd, pn, pm); | |
1666 | tcg_gen_andc_vec(vece, pd, pg, pd); | |
1667 | } | |
1668 | ||
3a7be554 | 1669 | static bool trans_NAND_pppp(DisasContext *s, arg_rprr_s *a) |
516e246a RH |
1670 | { |
1671 | static const GVecGen4 op = { | |
1672 | .fni8 = gen_nand_pg_i64, | |
1673 | .fniv = gen_nand_pg_vec, | |
1674 | .fno = gen_helper_sve_nand_pppp, | |
1675 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | |
1676 | }; | |
dd81a8d7 | 1677 | return do_pppp_flags(s, a, &op); |
516e246a RH |
1678 | } |
1679 | ||
9e18d7a6 RH |
1680 | /* |
1681 | *** SVE Predicate Misc Group | |
1682 | */ | |
1683 | ||
3a7be554 | 1684 | static bool trans_PTEST(DisasContext *s, arg_PTEST *a) |
9e18d7a6 RH |
1685 | { |
1686 | if (sve_access_check(s)) { | |
1687 | int nofs = pred_full_reg_offset(s, a->rn); | |
1688 | int gofs = pred_full_reg_offset(s, a->pg); | |
1689 | int words = DIV_ROUND_UP(pred_full_reg_size(s), 8); | |
1690 | ||
1691 | if (words == 1) { | |
1692 | TCGv_i64 pn = tcg_temp_new_i64(); | |
1693 | TCGv_i64 pg = tcg_temp_new_i64(); | |
1694 | ||
1695 | tcg_gen_ld_i64(pn, cpu_env, nofs); | |
1696 | tcg_gen_ld_i64(pg, cpu_env, gofs); | |
1697 | do_predtest1(pn, pg); | |
1698 | ||
1699 | tcg_temp_free_i64(pn); | |
1700 | tcg_temp_free_i64(pg); | |
1701 | } else { | |
1702 | do_predtest(s, nofs, gofs, words); | |
1703 | } | |
1704 | } | |
1705 | return true; | |
1706 | } | |
1707 | ||
028e2a7b RH |
1708 | /* See the ARM pseudocode DecodePredCount. */ |
1709 | static unsigned decode_pred_count(unsigned fullsz, int pattern, int esz) | |
1710 | { | |
1711 | unsigned elements = fullsz >> esz; | |
1712 | unsigned bound; | |
1713 | ||
1714 | switch (pattern) { | |
1715 | case 0x0: /* POW2 */ | |
1716 | return pow2floor(elements); | |
1717 | case 0x1: /* VL1 */ | |
1718 | case 0x2: /* VL2 */ | |
1719 | case 0x3: /* VL3 */ | |
1720 | case 0x4: /* VL4 */ | |
1721 | case 0x5: /* VL5 */ | |
1722 | case 0x6: /* VL6 */ | |
1723 | case 0x7: /* VL7 */ | |
1724 | case 0x8: /* VL8 */ | |
1725 | bound = pattern; | |
1726 | break; | |
1727 | case 0x9: /* VL16 */ | |
1728 | case 0xa: /* VL32 */ | |
1729 | case 0xb: /* VL64 */ | |
1730 | case 0xc: /* VL128 */ | |
1731 | case 0xd: /* VL256 */ | |
1732 | bound = 16 << (pattern - 9); | |
1733 | break; | |
1734 | case 0x1d: /* MUL4 */ | |
1735 | return elements - elements % 4; | |
1736 | case 0x1e: /* MUL3 */ | |
1737 | return elements - elements % 3; | |
1738 | case 0x1f: /* ALL */ | |
1739 | return elements; | |
1740 | default: /* #uimm5 */ | |
1741 | return 0; | |
1742 | } | |
1743 | return elements >= bound ? bound : 0; | |
1744 | } | |
1745 | ||
1746 | /* This handles all of the predicate initialization instructions, | |
1747 | * PTRUE, PFALSE, SETFFR. For PFALSE, we will have set PAT == 32 | |
1748 | * so that decode_pred_count returns 0. For SETFFR, we will have | |
1749 | * set RD == 16 == FFR. | |
1750 | */ | |
1751 | static bool do_predset(DisasContext *s, int esz, int rd, int pat, bool setflag) | |
1752 | { | |
1753 | if (!sve_access_check(s)) { | |
1754 | return true; | |
1755 | } | |
1756 | ||
1757 | unsigned fullsz = vec_full_reg_size(s); | |
1758 | unsigned ofs = pred_full_reg_offset(s, rd); | |
1759 | unsigned numelem, setsz, i; | |
1760 | uint64_t word, lastword; | |
1761 | TCGv_i64 t; | |
1762 | ||
1763 | numelem = decode_pred_count(fullsz, pat, esz); | |
1764 | ||
1765 | /* Determine what we must store into each bit, and how many. */ | |
1766 | if (numelem == 0) { | |
1767 | lastword = word = 0; | |
1768 | setsz = fullsz; | |
1769 | } else { | |
1770 | setsz = numelem << esz; | |
1771 | lastword = word = pred_esz_masks[esz]; | |
1772 | if (setsz % 64) { | |
973558a3 | 1773 | lastword &= MAKE_64BIT_MASK(0, setsz % 64); |
028e2a7b RH |
1774 | } |
1775 | } | |
1776 | ||
1777 | t = tcg_temp_new_i64(); | |
1778 | if (fullsz <= 64) { | |
1779 | tcg_gen_movi_i64(t, lastword); | |
1780 | tcg_gen_st_i64(t, cpu_env, ofs); | |
1781 | goto done; | |
1782 | } | |
1783 | ||
1784 | if (word == lastword) { | |
1785 | unsigned maxsz = size_for_gvec(fullsz / 8); | |
1786 | unsigned oprsz = size_for_gvec(setsz / 8); | |
1787 | ||
1788 | if (oprsz * 8 == setsz) { | |
8711e71f | 1789 | tcg_gen_gvec_dup_imm(MO_64, ofs, oprsz, maxsz, word); |
028e2a7b RH |
1790 | goto done; |
1791 | } | |
028e2a7b RH |
1792 | } |
1793 | ||
1794 | setsz /= 8; | |
1795 | fullsz /= 8; | |
1796 | ||
1797 | tcg_gen_movi_i64(t, word); | |
973558a3 | 1798 | for (i = 0; i < QEMU_ALIGN_DOWN(setsz, 8); i += 8) { |
028e2a7b RH |
1799 | tcg_gen_st_i64(t, cpu_env, ofs + i); |
1800 | } | |
1801 | if (lastword != word) { | |
1802 | tcg_gen_movi_i64(t, lastword); | |
1803 | tcg_gen_st_i64(t, cpu_env, ofs + i); | |
1804 | i += 8; | |
1805 | } | |
1806 | if (i < fullsz) { | |
1807 | tcg_gen_movi_i64(t, 0); | |
1808 | for (; i < fullsz; i += 8) { | |
1809 | tcg_gen_st_i64(t, cpu_env, ofs + i); | |
1810 | } | |
1811 | } | |
1812 | ||
1813 | done: | |
1814 | tcg_temp_free_i64(t); | |
1815 | ||
1816 | /* PTRUES */ | |
1817 | if (setflag) { | |
1818 | tcg_gen_movi_i32(cpu_NF, -(word != 0)); | |
1819 | tcg_gen_movi_i32(cpu_CF, word == 0); | |
1820 | tcg_gen_movi_i32(cpu_VF, 0); | |
1821 | tcg_gen_mov_i32(cpu_ZF, cpu_NF); | |
1822 | } | |
1823 | return true; | |
1824 | } | |
1825 | ||
3a7be554 | 1826 | static bool trans_PTRUE(DisasContext *s, arg_PTRUE *a) |
028e2a7b RH |
1827 | { |
1828 | return do_predset(s, a->esz, a->rd, a->pat, a->s); | |
1829 | } | |
1830 | ||
3a7be554 | 1831 | static bool trans_SETFFR(DisasContext *s, arg_SETFFR *a) |
028e2a7b RH |
1832 | { |
1833 | /* Note pat == 31 is #all, to set all elements. */ | |
1834 | return do_predset(s, 0, FFR_PRED_NUM, 31, false); | |
1835 | } | |
1836 | ||
3a7be554 | 1837 | static bool trans_PFALSE(DisasContext *s, arg_PFALSE *a) |
028e2a7b RH |
1838 | { |
1839 | /* Note pat == 32 is #unimp, to set no elements. */ | |
1840 | return do_predset(s, 0, a->rd, 32, false); | |
1841 | } | |
1842 | ||
3a7be554 | 1843 | static bool trans_RDFFR_p(DisasContext *s, arg_RDFFR_p *a) |
028e2a7b RH |
1844 | { |
1845 | /* The path through do_pppp_flags is complicated enough to want to avoid | |
1846 | * duplication. Frob the arguments into the form of a predicated AND. | |
1847 | */ | |
1848 | arg_rprr_s alt_a = { | |
1849 | .rd = a->rd, .pg = a->pg, .s = a->s, | |
1850 | .rn = FFR_PRED_NUM, .rm = FFR_PRED_NUM, | |
1851 | }; | |
3a7be554 | 1852 | return trans_AND_pppp(s, &alt_a); |
028e2a7b RH |
1853 | } |
1854 | ||
3a7be554 | 1855 | static bool trans_RDFFR(DisasContext *s, arg_RDFFR *a) |
028e2a7b RH |
1856 | { |
1857 | return do_mov_p(s, a->rd, FFR_PRED_NUM); | |
1858 | } | |
1859 | ||
3a7be554 | 1860 | static bool trans_WRFFR(DisasContext *s, arg_WRFFR *a) |
028e2a7b RH |
1861 | { |
1862 | return do_mov_p(s, FFR_PRED_NUM, a->rn); | |
1863 | } | |
1864 | ||
1865 | static bool do_pfirst_pnext(DisasContext *s, arg_rr_esz *a, | |
1866 | void (*gen_fn)(TCGv_i32, TCGv_ptr, | |
1867 | TCGv_ptr, TCGv_i32)) | |
1868 | { | |
1869 | if (!sve_access_check(s)) { | |
1870 | return true; | |
1871 | } | |
1872 | ||
1873 | TCGv_ptr t_pd = tcg_temp_new_ptr(); | |
1874 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | |
1875 | TCGv_i32 t; | |
86300b5d | 1876 | unsigned desc = 0; |
028e2a7b | 1877 | |
86300b5d RH |
1878 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s)); |
1879 | desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | |
028e2a7b RH |
1880 | |
1881 | tcg_gen_addi_ptr(t_pd, cpu_env, pred_full_reg_offset(s, a->rd)); | |
1882 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->rn)); | |
1883 | t = tcg_const_i32(desc); | |
1884 | ||
1885 | gen_fn(t, t_pd, t_pg, t); | |
1886 | tcg_temp_free_ptr(t_pd); | |
1887 | tcg_temp_free_ptr(t_pg); | |
1888 | ||
1889 | do_pred_flags(t); | |
1890 | tcg_temp_free_i32(t); | |
1891 | return true; | |
1892 | } | |
1893 | ||
3a7be554 | 1894 | static bool trans_PFIRST(DisasContext *s, arg_rr_esz *a) |
028e2a7b RH |
1895 | { |
1896 | return do_pfirst_pnext(s, a, gen_helper_sve_pfirst); | |
1897 | } | |
1898 | ||
3a7be554 | 1899 | static bool trans_PNEXT(DisasContext *s, arg_rr_esz *a) |
028e2a7b RH |
1900 | { |
1901 | return do_pfirst_pnext(s, a, gen_helper_sve_pnext); | |
1902 | } | |
1903 | ||
24e82e68 RH |
1904 | /* |
1905 | *** SVE Element Count Group | |
1906 | */ | |
1907 | ||
1908 | /* Perform an inline saturating addition of a 32-bit value within | |
1909 | * a 64-bit register. The second operand is known to be positive, | |
1910 | * which halves the comparisions we must perform to bound the result. | |
1911 | */ | |
1912 | static void do_sat_addsub_32(TCGv_i64 reg, TCGv_i64 val, bool u, bool d) | |
1913 | { | |
1914 | int64_t ibound; | |
24e82e68 RH |
1915 | |
1916 | /* Use normal 64-bit arithmetic to detect 32-bit overflow. */ | |
1917 | if (u) { | |
1918 | tcg_gen_ext32u_i64(reg, reg); | |
1919 | } else { | |
1920 | tcg_gen_ext32s_i64(reg, reg); | |
1921 | } | |
1922 | if (d) { | |
1923 | tcg_gen_sub_i64(reg, reg, val); | |
1924 | ibound = (u ? 0 : INT32_MIN); | |
aa5b0b29 | 1925 | tcg_gen_smax_i64(reg, reg, tcg_constant_i64(ibound)); |
24e82e68 RH |
1926 | } else { |
1927 | tcg_gen_add_i64(reg, reg, val); | |
1928 | ibound = (u ? UINT32_MAX : INT32_MAX); | |
aa5b0b29 | 1929 | tcg_gen_smin_i64(reg, reg, tcg_constant_i64(ibound)); |
24e82e68 | 1930 | } |
24e82e68 RH |
1931 | } |
1932 | ||
1933 | /* Similarly with 64-bit values. */ | |
1934 | static void do_sat_addsub_64(TCGv_i64 reg, TCGv_i64 val, bool u, bool d) | |
1935 | { | |
1936 | TCGv_i64 t0 = tcg_temp_new_i64(); | |
24e82e68 RH |
1937 | TCGv_i64 t2; |
1938 | ||
1939 | if (u) { | |
1940 | if (d) { | |
1941 | tcg_gen_sub_i64(t0, reg, val); | |
35a1ec8e PMD |
1942 | t2 = tcg_constant_i64(0); |
1943 | tcg_gen_movcond_i64(TCG_COND_LTU, reg, reg, val, t2, t0); | |
24e82e68 RH |
1944 | } else { |
1945 | tcg_gen_add_i64(t0, reg, val); | |
35a1ec8e PMD |
1946 | t2 = tcg_constant_i64(-1); |
1947 | tcg_gen_movcond_i64(TCG_COND_LTU, reg, t0, reg, t2, t0); | |
24e82e68 RH |
1948 | } |
1949 | } else { | |
35a1ec8e | 1950 | TCGv_i64 t1 = tcg_temp_new_i64(); |
24e82e68 RH |
1951 | if (d) { |
1952 | /* Detect signed overflow for subtraction. */ | |
1953 | tcg_gen_xor_i64(t0, reg, val); | |
1954 | tcg_gen_sub_i64(t1, reg, val); | |
7a31e0c6 | 1955 | tcg_gen_xor_i64(reg, reg, t1); |
24e82e68 RH |
1956 | tcg_gen_and_i64(t0, t0, reg); |
1957 | ||
1958 | /* Bound the result. */ | |
1959 | tcg_gen_movi_i64(reg, INT64_MIN); | |
35a1ec8e | 1960 | t2 = tcg_constant_i64(0); |
24e82e68 RH |
1961 | tcg_gen_movcond_i64(TCG_COND_LT, reg, t0, t2, reg, t1); |
1962 | } else { | |
1963 | /* Detect signed overflow for addition. */ | |
1964 | tcg_gen_xor_i64(t0, reg, val); | |
1965 | tcg_gen_add_i64(reg, reg, val); | |
1966 | tcg_gen_xor_i64(t1, reg, val); | |
1967 | tcg_gen_andc_i64(t0, t1, t0); | |
1968 | ||
1969 | /* Bound the result. */ | |
1970 | tcg_gen_movi_i64(t1, INT64_MAX); | |
35a1ec8e | 1971 | t2 = tcg_constant_i64(0); |
24e82e68 RH |
1972 | tcg_gen_movcond_i64(TCG_COND_LT, reg, t0, t2, t1, reg); |
1973 | } | |
35a1ec8e | 1974 | tcg_temp_free_i64(t1); |
24e82e68 RH |
1975 | } |
1976 | tcg_temp_free_i64(t0); | |
24e82e68 RH |
1977 | } |
1978 | ||
1979 | /* Similarly with a vector and a scalar operand. */ | |
1980 | static void do_sat_addsub_vec(DisasContext *s, int esz, int rd, int rn, | |
1981 | TCGv_i64 val, bool u, bool d) | |
1982 | { | |
1983 | unsigned vsz = vec_full_reg_size(s); | |
1984 | TCGv_ptr dptr, nptr; | |
1985 | TCGv_i32 t32, desc; | |
1986 | TCGv_i64 t64; | |
1987 | ||
1988 | dptr = tcg_temp_new_ptr(); | |
1989 | nptr = tcg_temp_new_ptr(); | |
1990 | tcg_gen_addi_ptr(dptr, cpu_env, vec_full_reg_offset(s, rd)); | |
1991 | tcg_gen_addi_ptr(nptr, cpu_env, vec_full_reg_offset(s, rn)); | |
1992 | desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
1993 | ||
1994 | switch (esz) { | |
1995 | case MO_8: | |
1996 | t32 = tcg_temp_new_i32(); | |
1997 | tcg_gen_extrl_i64_i32(t32, val); | |
1998 | if (d) { | |
1999 | tcg_gen_neg_i32(t32, t32); | |
2000 | } | |
2001 | if (u) { | |
2002 | gen_helper_sve_uqaddi_b(dptr, nptr, t32, desc); | |
2003 | } else { | |
2004 | gen_helper_sve_sqaddi_b(dptr, nptr, t32, desc); | |
2005 | } | |
2006 | tcg_temp_free_i32(t32); | |
2007 | break; | |
2008 | ||
2009 | case MO_16: | |
2010 | t32 = tcg_temp_new_i32(); | |
2011 | tcg_gen_extrl_i64_i32(t32, val); | |
2012 | if (d) { | |
2013 | tcg_gen_neg_i32(t32, t32); | |
2014 | } | |
2015 | if (u) { | |
2016 | gen_helper_sve_uqaddi_h(dptr, nptr, t32, desc); | |
2017 | } else { | |
2018 | gen_helper_sve_sqaddi_h(dptr, nptr, t32, desc); | |
2019 | } | |
2020 | tcg_temp_free_i32(t32); | |
2021 | break; | |
2022 | ||
2023 | case MO_32: | |
2024 | t64 = tcg_temp_new_i64(); | |
2025 | if (d) { | |
2026 | tcg_gen_neg_i64(t64, val); | |
2027 | } else { | |
2028 | tcg_gen_mov_i64(t64, val); | |
2029 | } | |
2030 | if (u) { | |
2031 | gen_helper_sve_uqaddi_s(dptr, nptr, t64, desc); | |
2032 | } else { | |
2033 | gen_helper_sve_sqaddi_s(dptr, nptr, t64, desc); | |
2034 | } | |
2035 | tcg_temp_free_i64(t64); | |
2036 | break; | |
2037 | ||
2038 | case MO_64: | |
2039 | if (u) { | |
2040 | if (d) { | |
2041 | gen_helper_sve_uqsubi_d(dptr, nptr, val, desc); | |
2042 | } else { | |
2043 | gen_helper_sve_uqaddi_d(dptr, nptr, val, desc); | |
2044 | } | |
2045 | } else if (d) { | |
2046 | t64 = tcg_temp_new_i64(); | |
2047 | tcg_gen_neg_i64(t64, val); | |
2048 | gen_helper_sve_sqaddi_d(dptr, nptr, t64, desc); | |
2049 | tcg_temp_free_i64(t64); | |
2050 | } else { | |
2051 | gen_helper_sve_sqaddi_d(dptr, nptr, val, desc); | |
2052 | } | |
2053 | break; | |
2054 | ||
2055 | default: | |
2056 | g_assert_not_reached(); | |
2057 | } | |
2058 | ||
2059 | tcg_temp_free_ptr(dptr); | |
2060 | tcg_temp_free_ptr(nptr); | |
2061 | tcg_temp_free_i32(desc); | |
2062 | } | |
2063 | ||
3a7be554 | 2064 | static bool trans_CNT_r(DisasContext *s, arg_CNT_r *a) |
24e82e68 RH |
2065 | { |
2066 | if (sve_access_check(s)) { | |
2067 | unsigned fullsz = vec_full_reg_size(s); | |
2068 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2069 | tcg_gen_movi_i64(cpu_reg(s, a->rd), numelem * a->imm); | |
2070 | } | |
2071 | return true; | |
2072 | } | |
2073 | ||
3a7be554 | 2074 | static bool trans_INCDEC_r(DisasContext *s, arg_incdec_cnt *a) |
24e82e68 RH |
2075 | { |
2076 | if (sve_access_check(s)) { | |
2077 | unsigned fullsz = vec_full_reg_size(s); | |
2078 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2079 | int inc = numelem * a->imm * (a->d ? -1 : 1); | |
2080 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
2081 | ||
2082 | tcg_gen_addi_i64(reg, reg, inc); | |
2083 | } | |
2084 | return true; | |
2085 | } | |
2086 | ||
3a7be554 | 2087 | static bool trans_SINCDEC_r_32(DisasContext *s, arg_incdec_cnt *a) |
24e82e68 RH |
2088 | { |
2089 | if (!sve_access_check(s)) { | |
2090 | return true; | |
2091 | } | |
2092 | ||
2093 | unsigned fullsz = vec_full_reg_size(s); | |
2094 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2095 | int inc = numelem * a->imm; | |
2096 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
2097 | ||
2098 | /* Use normal 64-bit arithmetic to detect 32-bit overflow. */ | |
2099 | if (inc == 0) { | |
2100 | if (a->u) { | |
2101 | tcg_gen_ext32u_i64(reg, reg); | |
2102 | } else { | |
2103 | tcg_gen_ext32s_i64(reg, reg); | |
2104 | } | |
2105 | } else { | |
d681f125 | 2106 | do_sat_addsub_32(reg, tcg_constant_i64(inc), a->u, a->d); |
24e82e68 RH |
2107 | } |
2108 | return true; | |
2109 | } | |
2110 | ||
3a7be554 | 2111 | static bool trans_SINCDEC_r_64(DisasContext *s, arg_incdec_cnt *a) |
24e82e68 RH |
2112 | { |
2113 | if (!sve_access_check(s)) { | |
2114 | return true; | |
2115 | } | |
2116 | ||
2117 | unsigned fullsz = vec_full_reg_size(s); | |
2118 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2119 | int inc = numelem * a->imm; | |
2120 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
2121 | ||
2122 | if (inc != 0) { | |
d681f125 | 2123 | do_sat_addsub_64(reg, tcg_constant_i64(inc), a->u, a->d); |
24e82e68 RH |
2124 | } |
2125 | return true; | |
2126 | } | |
2127 | ||
3a7be554 | 2128 | static bool trans_INCDEC_v(DisasContext *s, arg_incdec2_cnt *a) |
24e82e68 RH |
2129 | { |
2130 | if (a->esz == 0) { | |
2131 | return false; | |
2132 | } | |
2133 | ||
2134 | unsigned fullsz = vec_full_reg_size(s); | |
2135 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2136 | int inc = numelem * a->imm; | |
2137 | ||
2138 | if (inc != 0) { | |
2139 | if (sve_access_check(s)) { | |
24e82e68 RH |
2140 | tcg_gen_gvec_adds(a->esz, vec_full_reg_offset(s, a->rd), |
2141 | vec_full_reg_offset(s, a->rn), | |
d681f125 RH |
2142 | tcg_constant_i64(a->d ? -inc : inc), |
2143 | fullsz, fullsz); | |
24e82e68 RH |
2144 | } |
2145 | } else { | |
2146 | do_mov_z(s, a->rd, a->rn); | |
2147 | } | |
2148 | return true; | |
2149 | } | |
2150 | ||
3a7be554 | 2151 | static bool trans_SINCDEC_v(DisasContext *s, arg_incdec2_cnt *a) |
24e82e68 RH |
2152 | { |
2153 | if (a->esz == 0) { | |
2154 | return false; | |
2155 | } | |
2156 | ||
2157 | unsigned fullsz = vec_full_reg_size(s); | |
2158 | unsigned numelem = decode_pred_count(fullsz, a->pat, a->esz); | |
2159 | int inc = numelem * a->imm; | |
2160 | ||
2161 | if (inc != 0) { | |
2162 | if (sve_access_check(s)) { | |
d681f125 RH |
2163 | do_sat_addsub_vec(s, a->esz, a->rd, a->rn, |
2164 | tcg_constant_i64(inc), a->u, a->d); | |
24e82e68 RH |
2165 | } |
2166 | } else { | |
2167 | do_mov_z(s, a->rd, a->rn); | |
2168 | } | |
2169 | return true; | |
2170 | } | |
2171 | ||
e1fa1164 RH |
2172 | /* |
2173 | *** SVE Bitwise Immediate Group | |
2174 | */ | |
2175 | ||
2176 | static bool do_zz_dbm(DisasContext *s, arg_rr_dbm *a, GVecGen2iFn *gvec_fn) | |
2177 | { | |
2178 | uint64_t imm; | |
2179 | if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), | |
2180 | extract32(a->dbm, 0, 6), | |
2181 | extract32(a->dbm, 6, 6))) { | |
2182 | return false; | |
2183 | } | |
2184 | if (sve_access_check(s)) { | |
2185 | unsigned vsz = vec_full_reg_size(s); | |
2186 | gvec_fn(MO_64, vec_full_reg_offset(s, a->rd), | |
2187 | vec_full_reg_offset(s, a->rn), imm, vsz, vsz); | |
2188 | } | |
2189 | return true; | |
2190 | } | |
2191 | ||
3a7be554 | 2192 | static bool trans_AND_zzi(DisasContext *s, arg_rr_dbm *a) |
e1fa1164 RH |
2193 | { |
2194 | return do_zz_dbm(s, a, tcg_gen_gvec_andi); | |
2195 | } | |
2196 | ||
3a7be554 | 2197 | static bool trans_ORR_zzi(DisasContext *s, arg_rr_dbm *a) |
e1fa1164 RH |
2198 | { |
2199 | return do_zz_dbm(s, a, tcg_gen_gvec_ori); | |
2200 | } | |
2201 | ||
3a7be554 | 2202 | static bool trans_EOR_zzi(DisasContext *s, arg_rr_dbm *a) |
e1fa1164 RH |
2203 | { |
2204 | return do_zz_dbm(s, a, tcg_gen_gvec_xori); | |
2205 | } | |
2206 | ||
3a7be554 | 2207 | static bool trans_DUPM(DisasContext *s, arg_DUPM *a) |
e1fa1164 RH |
2208 | { |
2209 | uint64_t imm; | |
2210 | if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), | |
2211 | extract32(a->dbm, 0, 6), | |
2212 | extract32(a->dbm, 6, 6))) { | |
2213 | return false; | |
2214 | } | |
2215 | if (sve_access_check(s)) { | |
2216 | do_dupi_z(s, a->rd, imm); | |
2217 | } | |
2218 | return true; | |
2219 | } | |
2220 | ||
f25a2361 RH |
2221 | /* |
2222 | *** SVE Integer Wide Immediate - Predicated Group | |
2223 | */ | |
2224 | ||
2225 | /* Implement all merging copies. This is used for CPY (immediate), | |
2226 | * FCPY, CPY (scalar), CPY (SIMD&FP scalar). | |
2227 | */ | |
2228 | static void do_cpy_m(DisasContext *s, int esz, int rd, int rn, int pg, | |
2229 | TCGv_i64 val) | |
2230 | { | |
2231 | typedef void gen_cpy(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_i32); | |
2232 | static gen_cpy * const fns[4] = { | |
2233 | gen_helper_sve_cpy_m_b, gen_helper_sve_cpy_m_h, | |
2234 | gen_helper_sve_cpy_m_s, gen_helper_sve_cpy_m_d, | |
2235 | }; | |
2236 | unsigned vsz = vec_full_reg_size(s); | |
2237 | TCGv_i32 desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
2238 | TCGv_ptr t_zd = tcg_temp_new_ptr(); | |
2239 | TCGv_ptr t_zn = tcg_temp_new_ptr(); | |
2240 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | |
2241 | ||
2242 | tcg_gen_addi_ptr(t_zd, cpu_env, vec_full_reg_offset(s, rd)); | |
2243 | tcg_gen_addi_ptr(t_zn, cpu_env, vec_full_reg_offset(s, rn)); | |
2244 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | |
2245 | ||
2246 | fns[esz](t_zd, t_zn, t_pg, val, desc); | |
2247 | ||
2248 | tcg_temp_free_ptr(t_zd); | |
2249 | tcg_temp_free_ptr(t_zn); | |
2250 | tcg_temp_free_ptr(t_pg); | |
2251 | tcg_temp_free_i32(desc); | |
2252 | } | |
2253 | ||
3a7be554 | 2254 | static bool trans_FCPY(DisasContext *s, arg_FCPY *a) |
f25a2361 RH |
2255 | { |
2256 | if (a->esz == 0) { | |
2257 | return false; | |
2258 | } | |
2259 | if (sve_access_check(s)) { | |
2260 | /* Decode the VFP immediate. */ | |
2261 | uint64_t imm = vfp_expand_imm(a->esz, a->imm); | |
e152b48b | 2262 | do_cpy_m(s, a->esz, a->rd, a->rn, a->pg, tcg_constant_i64(imm)); |
f25a2361 RH |
2263 | } |
2264 | return true; | |
2265 | } | |
2266 | ||
3a7be554 | 2267 | static bool trans_CPY_m_i(DisasContext *s, arg_rpri_esz *a) |
f25a2361 | 2268 | { |
3a7be554 | 2269 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
f25a2361 RH |
2270 | return false; |
2271 | } | |
2272 | if (sve_access_check(s)) { | |
e152b48b | 2273 | do_cpy_m(s, a->esz, a->rd, a->rn, a->pg, tcg_constant_i64(a->imm)); |
f25a2361 RH |
2274 | } |
2275 | return true; | |
2276 | } | |
2277 | ||
3a7be554 | 2278 | static bool trans_CPY_z_i(DisasContext *s, arg_CPY_z_i *a) |
f25a2361 RH |
2279 | { |
2280 | static gen_helper_gvec_2i * const fns[4] = { | |
2281 | gen_helper_sve_cpy_z_b, gen_helper_sve_cpy_z_h, | |
2282 | gen_helper_sve_cpy_z_s, gen_helper_sve_cpy_z_d, | |
2283 | }; | |
2284 | ||
3a7be554 | 2285 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
f25a2361 RH |
2286 | return false; |
2287 | } | |
2288 | if (sve_access_check(s)) { | |
2289 | unsigned vsz = vec_full_reg_size(s); | |
f25a2361 RH |
2290 | tcg_gen_gvec_2i_ool(vec_full_reg_offset(s, a->rd), |
2291 | pred_full_reg_offset(s, a->pg), | |
e152b48b RH |
2292 | tcg_constant_i64(a->imm), |
2293 | vsz, vsz, 0, fns[a->esz]); | |
f25a2361 RH |
2294 | } |
2295 | return true; | |
2296 | } | |
2297 | ||
b94f8f60 RH |
2298 | /* |
2299 | *** SVE Permute Extract Group | |
2300 | */ | |
2301 | ||
75114792 | 2302 | static bool do_EXT(DisasContext *s, int rd, int rn, int rm, int imm) |
b94f8f60 RH |
2303 | { |
2304 | if (!sve_access_check(s)) { | |
2305 | return true; | |
2306 | } | |
2307 | ||
2308 | unsigned vsz = vec_full_reg_size(s); | |
75114792 | 2309 | unsigned n_ofs = imm >= vsz ? 0 : imm; |
b94f8f60 | 2310 | unsigned n_siz = vsz - n_ofs; |
75114792 SL |
2311 | unsigned d = vec_full_reg_offset(s, rd); |
2312 | unsigned n = vec_full_reg_offset(s, rn); | |
2313 | unsigned m = vec_full_reg_offset(s, rm); | |
b94f8f60 RH |
2314 | |
2315 | /* Use host vector move insns if we have appropriate sizes | |
2316 | * and no unfortunate overlap. | |
2317 | */ | |
2318 | if (m != d | |
2319 | && n_ofs == size_for_gvec(n_ofs) | |
2320 | && n_siz == size_for_gvec(n_siz) | |
2321 | && (d != n || n_siz <= n_ofs)) { | |
2322 | tcg_gen_gvec_mov(0, d, n + n_ofs, n_siz, n_siz); | |
2323 | if (n_ofs != 0) { | |
2324 | tcg_gen_gvec_mov(0, d + n_siz, m, n_ofs, n_ofs); | |
2325 | } | |
2326 | } else { | |
2327 | tcg_gen_gvec_3_ool(d, n, m, vsz, vsz, n_ofs, gen_helper_sve_ext); | |
2328 | } | |
2329 | return true; | |
2330 | } | |
2331 | ||
75114792 SL |
2332 | static bool trans_EXT(DisasContext *s, arg_EXT *a) |
2333 | { | |
2334 | return do_EXT(s, a->rd, a->rn, a->rm, a->imm); | |
2335 | } | |
2336 | ||
2337 | static bool trans_EXT_sve2(DisasContext *s, arg_rri *a) | |
2338 | { | |
2339 | if (!dc_isar_feature(aa64_sve2, s)) { | |
2340 | return false; | |
2341 | } | |
2342 | return do_EXT(s, a->rd, a->rn, (a->rn + 1) % 32, a->imm); | |
2343 | } | |
2344 | ||
30562ab7 RH |
2345 | /* |
2346 | *** SVE Permute - Unpredicated Group | |
2347 | */ | |
2348 | ||
3a7be554 | 2349 | static bool trans_DUP_s(DisasContext *s, arg_DUP_s *a) |
30562ab7 RH |
2350 | { |
2351 | if (sve_access_check(s)) { | |
2352 | unsigned vsz = vec_full_reg_size(s); | |
2353 | tcg_gen_gvec_dup_i64(a->esz, vec_full_reg_offset(s, a->rd), | |
2354 | vsz, vsz, cpu_reg_sp(s, a->rn)); | |
2355 | } | |
2356 | return true; | |
2357 | } | |
2358 | ||
3a7be554 | 2359 | static bool trans_DUP_x(DisasContext *s, arg_DUP_x *a) |
30562ab7 RH |
2360 | { |
2361 | if ((a->imm & 0x1f) == 0) { | |
2362 | return false; | |
2363 | } | |
2364 | if (sve_access_check(s)) { | |
2365 | unsigned vsz = vec_full_reg_size(s); | |
2366 | unsigned dofs = vec_full_reg_offset(s, a->rd); | |
2367 | unsigned esz, index; | |
2368 | ||
2369 | esz = ctz32(a->imm); | |
2370 | index = a->imm >> (esz + 1); | |
2371 | ||
2372 | if ((index << esz) < vsz) { | |
2373 | unsigned nofs = vec_reg_offset(s, a->rn, index, esz); | |
2374 | tcg_gen_gvec_dup_mem(esz, dofs, nofs, vsz, vsz); | |
2375 | } else { | |
7e17d50e RH |
2376 | /* |
2377 | * While dup_mem handles 128-bit elements, dup_imm does not. | |
2378 | * Thankfully element size doesn't matter for splatting zero. | |
2379 | */ | |
2380 | tcg_gen_gvec_dup_imm(MO_64, dofs, vsz, vsz, 0); | |
30562ab7 RH |
2381 | } |
2382 | } | |
2383 | return true; | |
2384 | } | |
2385 | ||
2386 | static void do_insr_i64(DisasContext *s, arg_rrr_esz *a, TCGv_i64 val) | |
2387 | { | |
2388 | typedef void gen_insr(TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_i32); | |
2389 | static gen_insr * const fns[4] = { | |
2390 | gen_helper_sve_insr_b, gen_helper_sve_insr_h, | |
2391 | gen_helper_sve_insr_s, gen_helper_sve_insr_d, | |
2392 | }; | |
2393 | unsigned vsz = vec_full_reg_size(s); | |
2394 | TCGv_i32 desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
2395 | TCGv_ptr t_zd = tcg_temp_new_ptr(); | |
2396 | TCGv_ptr t_zn = tcg_temp_new_ptr(); | |
2397 | ||
2398 | tcg_gen_addi_ptr(t_zd, cpu_env, vec_full_reg_offset(s, a->rd)); | |
2399 | tcg_gen_addi_ptr(t_zn, cpu_env, vec_full_reg_offset(s, a->rn)); | |
2400 | ||
2401 | fns[a->esz](t_zd, t_zn, val, desc); | |
2402 | ||
2403 | tcg_temp_free_ptr(t_zd); | |
2404 | tcg_temp_free_ptr(t_zn); | |
2405 | tcg_temp_free_i32(desc); | |
2406 | } | |
2407 | ||
3a7be554 | 2408 | static bool trans_INSR_f(DisasContext *s, arg_rrr_esz *a) |
30562ab7 RH |
2409 | { |
2410 | if (sve_access_check(s)) { | |
2411 | TCGv_i64 t = tcg_temp_new_i64(); | |
2412 | tcg_gen_ld_i64(t, cpu_env, vec_reg_offset(s, a->rm, 0, MO_64)); | |
2413 | do_insr_i64(s, a, t); | |
2414 | tcg_temp_free_i64(t); | |
2415 | } | |
2416 | return true; | |
2417 | } | |
2418 | ||
3a7be554 | 2419 | static bool trans_INSR_r(DisasContext *s, arg_rrr_esz *a) |
30562ab7 RH |
2420 | { |
2421 | if (sve_access_check(s)) { | |
2422 | do_insr_i64(s, a, cpu_reg(s, a->rm)); | |
2423 | } | |
2424 | return true; | |
2425 | } | |
2426 | ||
3a7be554 | 2427 | static bool trans_REV_v(DisasContext *s, arg_rr_esz *a) |
30562ab7 RH |
2428 | { |
2429 | static gen_helper_gvec_2 * const fns[4] = { | |
2430 | gen_helper_sve_rev_b, gen_helper_sve_rev_h, | |
2431 | gen_helper_sve_rev_s, gen_helper_sve_rev_d | |
2432 | }; | |
2433 | ||
2434 | if (sve_access_check(s)) { | |
40e32e5a | 2435 | gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0); |
30562ab7 RH |
2436 | } |
2437 | return true; | |
2438 | } | |
2439 | ||
3a7be554 | 2440 | static bool trans_TBL(DisasContext *s, arg_rrr_esz *a) |
30562ab7 RH |
2441 | { |
2442 | static gen_helper_gvec_3 * const fns[4] = { | |
2443 | gen_helper_sve_tbl_b, gen_helper_sve_tbl_h, | |
2444 | gen_helper_sve_tbl_s, gen_helper_sve_tbl_d | |
2445 | }; | |
2446 | ||
2447 | if (sve_access_check(s)) { | |
e645d1a1 | 2448 | gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0); |
30562ab7 RH |
2449 | } |
2450 | return true; | |
2451 | } | |
2452 | ||
80a712a2 SL |
2453 | static bool trans_TBL_sve2(DisasContext *s, arg_rrr_esz *a) |
2454 | { | |
2455 | static gen_helper_gvec_4 * const fns[4] = { | |
2456 | gen_helper_sve2_tbl_b, gen_helper_sve2_tbl_h, | |
2457 | gen_helper_sve2_tbl_s, gen_helper_sve2_tbl_d | |
2458 | }; | |
2459 | ||
2460 | if (!dc_isar_feature(aa64_sve2, s)) { | |
2461 | return false; | |
2462 | } | |
2463 | if (sve_access_check(s)) { | |
2464 | gen_gvec_ool_zzzz(s, fns[a->esz], a->rd, a->rn, | |
2465 | (a->rn + 1) % 32, a->rm, 0); | |
2466 | } | |
2467 | return true; | |
2468 | } | |
2469 | ||
2470 | static bool trans_TBX(DisasContext *s, arg_rrr_esz *a) | |
2471 | { | |
2472 | static gen_helper_gvec_3 * const fns[4] = { | |
2473 | gen_helper_sve2_tbx_b, gen_helper_sve2_tbx_h, | |
2474 | gen_helper_sve2_tbx_s, gen_helper_sve2_tbx_d | |
2475 | }; | |
2476 | ||
2477 | if (!dc_isar_feature(aa64_sve2, s)) { | |
2478 | return false; | |
2479 | } | |
2480 | if (sve_access_check(s)) { | |
2481 | gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0); | |
2482 | } | |
2483 | return true; | |
2484 | } | |
2485 | ||
3a7be554 | 2486 | static bool trans_UNPK(DisasContext *s, arg_UNPK *a) |
30562ab7 RH |
2487 | { |
2488 | static gen_helper_gvec_2 * const fns[4][2] = { | |
2489 | { NULL, NULL }, | |
2490 | { gen_helper_sve_sunpk_h, gen_helper_sve_uunpk_h }, | |
2491 | { gen_helper_sve_sunpk_s, gen_helper_sve_uunpk_s }, | |
2492 | { gen_helper_sve_sunpk_d, gen_helper_sve_uunpk_d }, | |
2493 | }; | |
2494 | ||
2495 | if (a->esz == 0) { | |
2496 | return false; | |
2497 | } | |
2498 | if (sve_access_check(s)) { | |
2499 | unsigned vsz = vec_full_reg_size(s); | |
2500 | tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd), | |
2501 | vec_full_reg_offset(s, a->rn) | |
2502 | + (a->h ? vsz / 2 : 0), | |
2503 | vsz, vsz, 0, fns[a->esz][a->u]); | |
2504 | } | |
2505 | return true; | |
2506 | } | |
2507 | ||
d731d8cb RH |
2508 | /* |
2509 | *** SVE Permute - Predicates Group | |
2510 | */ | |
2511 | ||
2512 | static bool do_perm_pred3(DisasContext *s, arg_rrr_esz *a, bool high_odd, | |
2513 | gen_helper_gvec_3 *fn) | |
2514 | { | |
2515 | if (!sve_access_check(s)) { | |
2516 | return true; | |
2517 | } | |
2518 | ||
2519 | unsigned vsz = pred_full_reg_size(s); | |
2520 | ||
d731d8cb RH |
2521 | TCGv_ptr t_d = tcg_temp_new_ptr(); |
2522 | TCGv_ptr t_n = tcg_temp_new_ptr(); | |
2523 | TCGv_ptr t_m = tcg_temp_new_ptr(); | |
2524 | TCGv_i32 t_desc; | |
f9b0fcce | 2525 | uint32_t desc = 0; |
d731d8cb | 2526 | |
f9b0fcce RH |
2527 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz); |
2528 | desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | |
2529 | desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd); | |
d731d8cb RH |
2530 | |
2531 | tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd)); | |
2532 | tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn)); | |
2533 | tcg_gen_addi_ptr(t_m, cpu_env, pred_full_reg_offset(s, a->rm)); | |
2534 | t_desc = tcg_const_i32(desc); | |
2535 | ||
2536 | fn(t_d, t_n, t_m, t_desc); | |
2537 | ||
2538 | tcg_temp_free_ptr(t_d); | |
2539 | tcg_temp_free_ptr(t_n); | |
2540 | tcg_temp_free_ptr(t_m); | |
2541 | tcg_temp_free_i32(t_desc); | |
2542 | return true; | |
2543 | } | |
2544 | ||
2545 | static bool do_perm_pred2(DisasContext *s, arg_rr_esz *a, bool high_odd, | |
2546 | gen_helper_gvec_2 *fn) | |
2547 | { | |
2548 | if (!sve_access_check(s)) { | |
2549 | return true; | |
2550 | } | |
2551 | ||
2552 | unsigned vsz = pred_full_reg_size(s); | |
2553 | TCGv_ptr t_d = tcg_temp_new_ptr(); | |
2554 | TCGv_ptr t_n = tcg_temp_new_ptr(); | |
2555 | TCGv_i32 t_desc; | |
70acaafe | 2556 | uint32_t desc = 0; |
d731d8cb RH |
2557 | |
2558 | tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd)); | |
2559 | tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn)); | |
2560 | ||
70acaafe RH |
2561 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz); |
2562 | desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | |
2563 | desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd); | |
d731d8cb RH |
2564 | t_desc = tcg_const_i32(desc); |
2565 | ||
2566 | fn(t_d, t_n, t_desc); | |
2567 | ||
2568 | tcg_temp_free_i32(t_desc); | |
2569 | tcg_temp_free_ptr(t_d); | |
2570 | tcg_temp_free_ptr(t_n); | |
2571 | return true; | |
2572 | } | |
2573 | ||
3a7be554 | 2574 | static bool trans_ZIP1_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2575 | { |
2576 | return do_perm_pred3(s, a, 0, gen_helper_sve_zip_p); | |
2577 | } | |
2578 | ||
3a7be554 | 2579 | static bool trans_ZIP2_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2580 | { |
2581 | return do_perm_pred3(s, a, 1, gen_helper_sve_zip_p); | |
2582 | } | |
2583 | ||
3a7be554 | 2584 | static bool trans_UZP1_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2585 | { |
2586 | return do_perm_pred3(s, a, 0, gen_helper_sve_uzp_p); | |
2587 | } | |
2588 | ||
3a7be554 | 2589 | static bool trans_UZP2_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2590 | { |
2591 | return do_perm_pred3(s, a, 1, gen_helper_sve_uzp_p); | |
2592 | } | |
2593 | ||
3a7be554 | 2594 | static bool trans_TRN1_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2595 | { |
2596 | return do_perm_pred3(s, a, 0, gen_helper_sve_trn_p); | |
2597 | } | |
2598 | ||
3a7be554 | 2599 | static bool trans_TRN2_p(DisasContext *s, arg_rrr_esz *a) |
d731d8cb RH |
2600 | { |
2601 | return do_perm_pred3(s, a, 1, gen_helper_sve_trn_p); | |
2602 | } | |
2603 | ||
3a7be554 | 2604 | static bool trans_REV_p(DisasContext *s, arg_rr_esz *a) |
d731d8cb RH |
2605 | { |
2606 | return do_perm_pred2(s, a, 0, gen_helper_sve_rev_p); | |
2607 | } | |
2608 | ||
3a7be554 | 2609 | static bool trans_PUNPKLO(DisasContext *s, arg_PUNPKLO *a) |
d731d8cb RH |
2610 | { |
2611 | return do_perm_pred2(s, a, 0, gen_helper_sve_punpk_p); | |
2612 | } | |
2613 | ||
3a7be554 | 2614 | static bool trans_PUNPKHI(DisasContext *s, arg_PUNPKHI *a) |
d731d8cb RH |
2615 | { |
2616 | return do_perm_pred2(s, a, 1, gen_helper_sve_punpk_p); | |
2617 | } | |
2618 | ||
234b48e9 RH |
2619 | /* |
2620 | *** SVE Permute - Interleaving Group | |
2621 | */ | |
2622 | ||
2623 | static bool do_zip(DisasContext *s, arg_rrr_esz *a, bool high) | |
2624 | { | |
2625 | static gen_helper_gvec_3 * const fns[4] = { | |
2626 | gen_helper_sve_zip_b, gen_helper_sve_zip_h, | |
2627 | gen_helper_sve_zip_s, gen_helper_sve_zip_d, | |
2628 | }; | |
2629 | ||
2630 | if (sve_access_check(s)) { | |
2631 | unsigned vsz = vec_full_reg_size(s); | |
2632 | unsigned high_ofs = high ? vsz / 2 : 0; | |
2633 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), | |
2634 | vec_full_reg_offset(s, a->rn) + high_ofs, | |
2635 | vec_full_reg_offset(s, a->rm) + high_ofs, | |
2636 | vsz, vsz, 0, fns[a->esz]); | |
2637 | } | |
2638 | return true; | |
2639 | } | |
2640 | ||
2641 | static bool do_zzz_data_ool(DisasContext *s, arg_rrr_esz *a, int data, | |
2642 | gen_helper_gvec_3 *fn) | |
2643 | { | |
2644 | if (sve_access_check(s)) { | |
e645d1a1 | 2645 | gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, data); |
234b48e9 RH |
2646 | } |
2647 | return true; | |
2648 | } | |
2649 | ||
3a7be554 | 2650 | static bool trans_ZIP1_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2651 | { |
2652 | return do_zip(s, a, false); | |
2653 | } | |
2654 | ||
3a7be554 | 2655 | static bool trans_ZIP2_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2656 | { |
2657 | return do_zip(s, a, true); | |
2658 | } | |
2659 | ||
74b64b25 RH |
2660 | static bool do_zip_q(DisasContext *s, arg_rrr_esz *a, bool high) |
2661 | { | |
2662 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
2663 | return false; | |
2664 | } | |
2665 | if (sve_access_check(s)) { | |
2666 | unsigned vsz = vec_full_reg_size(s); | |
2667 | unsigned high_ofs = high ? QEMU_ALIGN_DOWN(vsz, 32) / 2 : 0; | |
2668 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), | |
2669 | vec_full_reg_offset(s, a->rn) + high_ofs, | |
2670 | vec_full_reg_offset(s, a->rm) + high_ofs, | |
2671 | vsz, vsz, 0, gen_helper_sve2_zip_q); | |
2672 | } | |
2673 | return true; | |
2674 | } | |
2675 | ||
2676 | static bool trans_ZIP1_q(DisasContext *s, arg_rrr_esz *a) | |
2677 | { | |
2678 | return do_zip_q(s, a, false); | |
2679 | } | |
2680 | ||
2681 | static bool trans_ZIP2_q(DisasContext *s, arg_rrr_esz *a) | |
2682 | { | |
2683 | return do_zip_q(s, a, true); | |
2684 | } | |
2685 | ||
234b48e9 RH |
2686 | static gen_helper_gvec_3 * const uzp_fns[4] = { |
2687 | gen_helper_sve_uzp_b, gen_helper_sve_uzp_h, | |
2688 | gen_helper_sve_uzp_s, gen_helper_sve_uzp_d, | |
2689 | }; | |
2690 | ||
3a7be554 | 2691 | static bool trans_UZP1_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2692 | { |
2693 | return do_zzz_data_ool(s, a, 0, uzp_fns[a->esz]); | |
2694 | } | |
2695 | ||
3a7be554 | 2696 | static bool trans_UZP2_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2697 | { |
2698 | return do_zzz_data_ool(s, a, 1 << a->esz, uzp_fns[a->esz]); | |
2699 | } | |
2700 | ||
74b64b25 RH |
2701 | static bool trans_UZP1_q(DisasContext *s, arg_rrr_esz *a) |
2702 | { | |
2703 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
2704 | return false; | |
2705 | } | |
2706 | return do_zzz_data_ool(s, a, 0, gen_helper_sve2_uzp_q); | |
2707 | } | |
2708 | ||
2709 | static bool trans_UZP2_q(DisasContext *s, arg_rrr_esz *a) | |
2710 | { | |
2711 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
2712 | return false; | |
2713 | } | |
2714 | return do_zzz_data_ool(s, a, 16, gen_helper_sve2_uzp_q); | |
2715 | } | |
2716 | ||
234b48e9 RH |
2717 | static gen_helper_gvec_3 * const trn_fns[4] = { |
2718 | gen_helper_sve_trn_b, gen_helper_sve_trn_h, | |
2719 | gen_helper_sve_trn_s, gen_helper_sve_trn_d, | |
2720 | }; | |
2721 | ||
3a7be554 | 2722 | static bool trans_TRN1_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2723 | { |
2724 | return do_zzz_data_ool(s, a, 0, trn_fns[a->esz]); | |
2725 | } | |
2726 | ||
3a7be554 | 2727 | static bool trans_TRN2_z(DisasContext *s, arg_rrr_esz *a) |
234b48e9 RH |
2728 | { |
2729 | return do_zzz_data_ool(s, a, 1 << a->esz, trn_fns[a->esz]); | |
2730 | } | |
2731 | ||
74b64b25 RH |
2732 | static bool trans_TRN1_q(DisasContext *s, arg_rrr_esz *a) |
2733 | { | |
2734 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
2735 | return false; | |
2736 | } | |
2737 | return do_zzz_data_ool(s, a, 0, gen_helper_sve2_trn_q); | |
2738 | } | |
2739 | ||
2740 | static bool trans_TRN2_q(DisasContext *s, arg_rrr_esz *a) | |
2741 | { | |
2742 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
2743 | return false; | |
2744 | } | |
2745 | return do_zzz_data_ool(s, a, 16, gen_helper_sve2_trn_q); | |
2746 | } | |
2747 | ||
3ca879ae RH |
2748 | /* |
2749 | *** SVE Permute Vector - Predicated Group | |
2750 | */ | |
2751 | ||
3a7be554 | 2752 | static bool trans_COMPACT(DisasContext *s, arg_rpr_esz *a) |
3ca879ae RH |
2753 | { |
2754 | static gen_helper_gvec_3 * const fns[4] = { | |
2755 | NULL, NULL, gen_helper_sve_compact_s, gen_helper_sve_compact_d | |
2756 | }; | |
2757 | return do_zpz_ool(s, a, fns[a->esz]); | |
2758 | } | |
2759 | ||
ef23cb72 RH |
2760 | /* Call the helper that computes the ARM LastActiveElement pseudocode |
2761 | * function, scaled by the element size. This includes the not found | |
2762 | * indication; e.g. not found for esz=3 is -8. | |
2763 | */ | |
2764 | static void find_last_active(DisasContext *s, TCGv_i32 ret, int esz, int pg) | |
2765 | { | |
2766 | /* Predicate sizes may be smaller and cannot use simd_desc. We cannot | |
2767 | * round up, as we do elsewhere, because we need the exact size. | |
2768 | */ | |
2769 | TCGv_ptr t_p = tcg_temp_new_ptr(); | |
2770 | TCGv_i32 t_desc; | |
2acbfbe4 | 2771 | unsigned desc = 0; |
ef23cb72 | 2772 | |
2acbfbe4 RH |
2773 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s)); |
2774 | desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | |
ef23cb72 RH |
2775 | |
2776 | tcg_gen_addi_ptr(t_p, cpu_env, pred_full_reg_offset(s, pg)); | |
2777 | t_desc = tcg_const_i32(desc); | |
2778 | ||
2779 | gen_helper_sve_last_active_element(ret, t_p, t_desc); | |
2780 | ||
2781 | tcg_temp_free_i32(t_desc); | |
2782 | tcg_temp_free_ptr(t_p); | |
2783 | } | |
2784 | ||
2785 | /* Increment LAST to the offset of the next element in the vector, | |
2786 | * wrapping around to 0. | |
2787 | */ | |
2788 | static void incr_last_active(DisasContext *s, TCGv_i32 last, int esz) | |
2789 | { | |
2790 | unsigned vsz = vec_full_reg_size(s); | |
2791 | ||
2792 | tcg_gen_addi_i32(last, last, 1 << esz); | |
2793 | if (is_power_of_2(vsz)) { | |
2794 | tcg_gen_andi_i32(last, last, vsz - 1); | |
2795 | } else { | |
4b308bd5 RH |
2796 | TCGv_i32 max = tcg_constant_i32(vsz); |
2797 | TCGv_i32 zero = tcg_constant_i32(0); | |
ef23cb72 | 2798 | tcg_gen_movcond_i32(TCG_COND_GEU, last, last, max, zero, last); |
ef23cb72 RH |
2799 | } |
2800 | } | |
2801 | ||
2802 | /* If LAST < 0, set LAST to the offset of the last element in the vector. */ | |
2803 | static void wrap_last_active(DisasContext *s, TCGv_i32 last, int esz) | |
2804 | { | |
2805 | unsigned vsz = vec_full_reg_size(s); | |
2806 | ||
2807 | if (is_power_of_2(vsz)) { | |
2808 | tcg_gen_andi_i32(last, last, vsz - 1); | |
2809 | } else { | |
4b308bd5 RH |
2810 | TCGv_i32 max = tcg_constant_i32(vsz - (1 << esz)); |
2811 | TCGv_i32 zero = tcg_constant_i32(0); | |
ef23cb72 | 2812 | tcg_gen_movcond_i32(TCG_COND_LT, last, last, zero, max, last); |
ef23cb72 RH |
2813 | } |
2814 | } | |
2815 | ||
2816 | /* Load an unsigned element of ESZ from BASE+OFS. */ | |
2817 | static TCGv_i64 load_esz(TCGv_ptr base, int ofs, int esz) | |
2818 | { | |
2819 | TCGv_i64 r = tcg_temp_new_i64(); | |
2820 | ||
2821 | switch (esz) { | |
2822 | case 0: | |
2823 | tcg_gen_ld8u_i64(r, base, ofs); | |
2824 | break; | |
2825 | case 1: | |
2826 | tcg_gen_ld16u_i64(r, base, ofs); | |
2827 | break; | |
2828 | case 2: | |
2829 | tcg_gen_ld32u_i64(r, base, ofs); | |
2830 | break; | |
2831 | case 3: | |
2832 | tcg_gen_ld_i64(r, base, ofs); | |
2833 | break; | |
2834 | default: | |
2835 | g_assert_not_reached(); | |
2836 | } | |
2837 | return r; | |
2838 | } | |
2839 | ||
2840 | /* Load an unsigned element of ESZ from RM[LAST]. */ | |
2841 | static TCGv_i64 load_last_active(DisasContext *s, TCGv_i32 last, | |
2842 | int rm, int esz) | |
2843 | { | |
2844 | TCGv_ptr p = tcg_temp_new_ptr(); | |
2845 | TCGv_i64 r; | |
2846 | ||
2847 | /* Convert offset into vector into offset into ENV. | |
2848 | * The final adjustment for the vector register base | |
2849 | * is added via constant offset to the load. | |
2850 | */ | |
e03b5686 | 2851 | #if HOST_BIG_ENDIAN |
ef23cb72 RH |
2852 | /* Adjust for element ordering. See vec_reg_offset. */ |
2853 | if (esz < 3) { | |
2854 | tcg_gen_xori_i32(last, last, 8 - (1 << esz)); | |
2855 | } | |
2856 | #endif | |
2857 | tcg_gen_ext_i32_ptr(p, last); | |
2858 | tcg_gen_add_ptr(p, p, cpu_env); | |
2859 | ||
2860 | r = load_esz(p, vec_full_reg_offset(s, rm), esz); | |
2861 | tcg_temp_free_ptr(p); | |
2862 | ||
2863 | return r; | |
2864 | } | |
2865 | ||
2866 | /* Compute CLAST for a Zreg. */ | |
2867 | static bool do_clast_vector(DisasContext *s, arg_rprr_esz *a, bool before) | |
2868 | { | |
2869 | TCGv_i32 last; | |
2870 | TCGLabel *over; | |
2871 | TCGv_i64 ele; | |
2872 | unsigned vsz, esz = a->esz; | |
2873 | ||
2874 | if (!sve_access_check(s)) { | |
2875 | return true; | |
2876 | } | |
2877 | ||
2878 | last = tcg_temp_local_new_i32(); | |
2879 | over = gen_new_label(); | |
2880 | ||
2881 | find_last_active(s, last, esz, a->pg); | |
2882 | ||
2883 | /* There is of course no movcond for a 2048-bit vector, | |
2884 | * so we must branch over the actual store. | |
2885 | */ | |
2886 | tcg_gen_brcondi_i32(TCG_COND_LT, last, 0, over); | |
2887 | ||
2888 | if (!before) { | |
2889 | incr_last_active(s, last, esz); | |
2890 | } | |
2891 | ||
2892 | ele = load_last_active(s, last, a->rm, esz); | |
2893 | tcg_temp_free_i32(last); | |
2894 | ||
2895 | vsz = vec_full_reg_size(s); | |
2896 | tcg_gen_gvec_dup_i64(esz, vec_full_reg_offset(s, a->rd), vsz, vsz, ele); | |
2897 | tcg_temp_free_i64(ele); | |
2898 | ||
2899 | /* If this insn used MOVPRFX, we may need a second move. */ | |
2900 | if (a->rd != a->rn) { | |
2901 | TCGLabel *done = gen_new_label(); | |
2902 | tcg_gen_br(done); | |
2903 | ||
2904 | gen_set_label(over); | |
2905 | do_mov_z(s, a->rd, a->rn); | |
2906 | ||
2907 | gen_set_label(done); | |
2908 | } else { | |
2909 | gen_set_label(over); | |
2910 | } | |
2911 | return true; | |
2912 | } | |
2913 | ||
3a7be554 | 2914 | static bool trans_CLASTA_z(DisasContext *s, arg_rprr_esz *a) |
ef23cb72 RH |
2915 | { |
2916 | return do_clast_vector(s, a, false); | |
2917 | } | |
2918 | ||
3a7be554 | 2919 | static bool trans_CLASTB_z(DisasContext *s, arg_rprr_esz *a) |
ef23cb72 RH |
2920 | { |
2921 | return do_clast_vector(s, a, true); | |
2922 | } | |
2923 | ||
2924 | /* Compute CLAST for a scalar. */ | |
2925 | static void do_clast_scalar(DisasContext *s, int esz, int pg, int rm, | |
2926 | bool before, TCGv_i64 reg_val) | |
2927 | { | |
2928 | TCGv_i32 last = tcg_temp_new_i32(); | |
053552d3 | 2929 | TCGv_i64 ele, cmp; |
ef23cb72 RH |
2930 | |
2931 | find_last_active(s, last, esz, pg); | |
2932 | ||
2933 | /* Extend the original value of last prior to incrementing. */ | |
2934 | cmp = tcg_temp_new_i64(); | |
2935 | tcg_gen_ext_i32_i64(cmp, last); | |
2936 | ||
2937 | if (!before) { | |
2938 | incr_last_active(s, last, esz); | |
2939 | } | |
2940 | ||
2941 | /* The conceit here is that while last < 0 indicates not found, after | |
2942 | * adjusting for cpu_env->vfp.zregs[rm], it is still a valid address | |
2943 | * from which we can load garbage. We then discard the garbage with | |
2944 | * a conditional move. | |
2945 | */ | |
2946 | ele = load_last_active(s, last, rm, esz); | |
2947 | tcg_temp_free_i32(last); | |
2948 | ||
053552d3 RH |
2949 | tcg_gen_movcond_i64(TCG_COND_GE, reg_val, cmp, tcg_constant_i64(0), |
2950 | ele, reg_val); | |
ef23cb72 | 2951 | |
ef23cb72 RH |
2952 | tcg_temp_free_i64(cmp); |
2953 | tcg_temp_free_i64(ele); | |
2954 | } | |
2955 | ||
2956 | /* Compute CLAST for a Vreg. */ | |
2957 | static bool do_clast_fp(DisasContext *s, arg_rpr_esz *a, bool before) | |
2958 | { | |
2959 | if (sve_access_check(s)) { | |
2960 | int esz = a->esz; | |
2961 | int ofs = vec_reg_offset(s, a->rd, 0, esz); | |
2962 | TCGv_i64 reg = load_esz(cpu_env, ofs, esz); | |
2963 | ||
2964 | do_clast_scalar(s, esz, a->pg, a->rn, before, reg); | |
2965 | write_fp_dreg(s, a->rd, reg); | |
2966 | tcg_temp_free_i64(reg); | |
2967 | } | |
2968 | return true; | |
2969 | } | |
2970 | ||
3a7be554 | 2971 | static bool trans_CLASTA_v(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
2972 | { |
2973 | return do_clast_fp(s, a, false); | |
2974 | } | |
2975 | ||
3a7be554 | 2976 | static bool trans_CLASTB_v(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
2977 | { |
2978 | return do_clast_fp(s, a, true); | |
2979 | } | |
2980 | ||
2981 | /* Compute CLAST for a Xreg. */ | |
2982 | static bool do_clast_general(DisasContext *s, arg_rpr_esz *a, bool before) | |
2983 | { | |
2984 | TCGv_i64 reg; | |
2985 | ||
2986 | if (!sve_access_check(s)) { | |
2987 | return true; | |
2988 | } | |
2989 | ||
2990 | reg = cpu_reg(s, a->rd); | |
2991 | switch (a->esz) { | |
2992 | case 0: | |
2993 | tcg_gen_ext8u_i64(reg, reg); | |
2994 | break; | |
2995 | case 1: | |
2996 | tcg_gen_ext16u_i64(reg, reg); | |
2997 | break; | |
2998 | case 2: | |
2999 | tcg_gen_ext32u_i64(reg, reg); | |
3000 | break; | |
3001 | case 3: | |
3002 | break; | |
3003 | default: | |
3004 | g_assert_not_reached(); | |
3005 | } | |
3006 | ||
3007 | do_clast_scalar(s, a->esz, a->pg, a->rn, before, reg); | |
3008 | return true; | |
3009 | } | |
3010 | ||
3a7be554 | 3011 | static bool trans_CLASTA_r(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3012 | { |
3013 | return do_clast_general(s, a, false); | |
3014 | } | |
3015 | ||
3a7be554 | 3016 | static bool trans_CLASTB_r(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3017 | { |
3018 | return do_clast_general(s, a, true); | |
3019 | } | |
3020 | ||
3021 | /* Compute LAST for a scalar. */ | |
3022 | static TCGv_i64 do_last_scalar(DisasContext *s, int esz, | |
3023 | int pg, int rm, bool before) | |
3024 | { | |
3025 | TCGv_i32 last = tcg_temp_new_i32(); | |
3026 | TCGv_i64 ret; | |
3027 | ||
3028 | find_last_active(s, last, esz, pg); | |
3029 | if (before) { | |
3030 | wrap_last_active(s, last, esz); | |
3031 | } else { | |
3032 | incr_last_active(s, last, esz); | |
3033 | } | |
3034 | ||
3035 | ret = load_last_active(s, last, rm, esz); | |
3036 | tcg_temp_free_i32(last); | |
3037 | return ret; | |
3038 | } | |
3039 | ||
3040 | /* Compute LAST for a Vreg. */ | |
3041 | static bool do_last_fp(DisasContext *s, arg_rpr_esz *a, bool before) | |
3042 | { | |
3043 | if (sve_access_check(s)) { | |
3044 | TCGv_i64 val = do_last_scalar(s, a->esz, a->pg, a->rn, before); | |
3045 | write_fp_dreg(s, a->rd, val); | |
3046 | tcg_temp_free_i64(val); | |
3047 | } | |
3048 | return true; | |
3049 | } | |
3050 | ||
3a7be554 | 3051 | static bool trans_LASTA_v(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3052 | { |
3053 | return do_last_fp(s, a, false); | |
3054 | } | |
3055 | ||
3a7be554 | 3056 | static bool trans_LASTB_v(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3057 | { |
3058 | return do_last_fp(s, a, true); | |
3059 | } | |
3060 | ||
3061 | /* Compute LAST for a Xreg. */ | |
3062 | static bool do_last_general(DisasContext *s, arg_rpr_esz *a, bool before) | |
3063 | { | |
3064 | if (sve_access_check(s)) { | |
3065 | TCGv_i64 val = do_last_scalar(s, a->esz, a->pg, a->rn, before); | |
3066 | tcg_gen_mov_i64(cpu_reg(s, a->rd), val); | |
3067 | tcg_temp_free_i64(val); | |
3068 | } | |
3069 | return true; | |
3070 | } | |
3071 | ||
3a7be554 | 3072 | static bool trans_LASTA_r(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3073 | { |
3074 | return do_last_general(s, a, false); | |
3075 | } | |
3076 | ||
3a7be554 | 3077 | static bool trans_LASTB_r(DisasContext *s, arg_rpr_esz *a) |
ef23cb72 RH |
3078 | { |
3079 | return do_last_general(s, a, true); | |
3080 | } | |
3081 | ||
3a7be554 | 3082 | static bool trans_CPY_m_r(DisasContext *s, arg_rpr_esz *a) |
792a5578 RH |
3083 | { |
3084 | if (sve_access_check(s)) { | |
3085 | do_cpy_m(s, a->esz, a->rd, a->rd, a->pg, cpu_reg_sp(s, a->rn)); | |
3086 | } | |
3087 | return true; | |
3088 | } | |
3089 | ||
3a7be554 | 3090 | static bool trans_CPY_m_v(DisasContext *s, arg_rpr_esz *a) |
792a5578 RH |
3091 | { |
3092 | if (sve_access_check(s)) { | |
3093 | int ofs = vec_reg_offset(s, a->rn, 0, a->esz); | |
3094 | TCGv_i64 t = load_esz(cpu_env, ofs, a->esz); | |
3095 | do_cpy_m(s, a->esz, a->rd, a->rd, a->pg, t); | |
3096 | tcg_temp_free_i64(t); | |
3097 | } | |
3098 | return true; | |
3099 | } | |
3100 | ||
3a7be554 | 3101 | static bool trans_REVB(DisasContext *s, arg_rpr_esz *a) |
dae8fb90 RH |
3102 | { |
3103 | static gen_helper_gvec_3 * const fns[4] = { | |
3104 | NULL, | |
3105 | gen_helper_sve_revb_h, | |
3106 | gen_helper_sve_revb_s, | |
3107 | gen_helper_sve_revb_d, | |
3108 | }; | |
3109 | return do_zpz_ool(s, a, fns[a->esz]); | |
3110 | } | |
3111 | ||
3a7be554 | 3112 | static bool trans_REVH(DisasContext *s, arg_rpr_esz *a) |
dae8fb90 RH |
3113 | { |
3114 | static gen_helper_gvec_3 * const fns[4] = { | |
3115 | NULL, | |
3116 | NULL, | |
3117 | gen_helper_sve_revh_s, | |
3118 | gen_helper_sve_revh_d, | |
3119 | }; | |
3120 | return do_zpz_ool(s, a, fns[a->esz]); | |
3121 | } | |
3122 | ||
3a7be554 | 3123 | static bool trans_REVW(DisasContext *s, arg_rpr_esz *a) |
dae8fb90 RH |
3124 | { |
3125 | return do_zpz_ool(s, a, a->esz == 3 ? gen_helper_sve_revw_d : NULL); | |
3126 | } | |
3127 | ||
3a7be554 | 3128 | static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a) |
dae8fb90 RH |
3129 | { |
3130 | static gen_helper_gvec_3 * const fns[4] = { | |
3131 | gen_helper_sve_rbit_b, | |
3132 | gen_helper_sve_rbit_h, | |
3133 | gen_helper_sve_rbit_s, | |
3134 | gen_helper_sve_rbit_d, | |
3135 | }; | |
3136 | return do_zpz_ool(s, a, fns[a->esz]); | |
3137 | } | |
3138 | ||
3a7be554 | 3139 | static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a) |
b48ff240 RH |
3140 | { |
3141 | if (sve_access_check(s)) { | |
36cbb7a8 | 3142 | gen_gvec_ool_zzzp(s, gen_helper_sve_splice, |
dd701faf | 3143 | a->rd, a->rn, a->rm, a->pg, a->esz); |
b48ff240 RH |
3144 | } |
3145 | return true; | |
3146 | } | |
3147 | ||
75114792 SL |
3148 | static bool trans_SPLICE_sve2(DisasContext *s, arg_rpr_esz *a) |
3149 | { | |
3150 | if (!dc_isar_feature(aa64_sve2, s)) { | |
3151 | return false; | |
3152 | } | |
3153 | if (sve_access_check(s)) { | |
3154 | gen_gvec_ool_zzzp(s, gen_helper_sve_splice, | |
3155 | a->rd, a->rn, (a->rn + 1) % 32, a->pg, a->esz); | |
3156 | } | |
3157 | return true; | |
3158 | } | |
3159 | ||
757f9cff RH |
3160 | /* |
3161 | *** SVE Integer Compare - Vectors Group | |
3162 | */ | |
3163 | ||
3164 | static bool do_ppzz_flags(DisasContext *s, arg_rprr_esz *a, | |
3165 | gen_helper_gvec_flags_4 *gen_fn) | |
3166 | { | |
3167 | TCGv_ptr pd, zn, zm, pg; | |
3168 | unsigned vsz; | |
3169 | TCGv_i32 t; | |
3170 | ||
3171 | if (gen_fn == NULL) { | |
3172 | return false; | |
3173 | } | |
3174 | if (!sve_access_check(s)) { | |
3175 | return true; | |
3176 | } | |
3177 | ||
3178 | vsz = vec_full_reg_size(s); | |
3179 | t = tcg_const_i32(simd_desc(vsz, vsz, 0)); | |
3180 | pd = tcg_temp_new_ptr(); | |
3181 | zn = tcg_temp_new_ptr(); | |
3182 | zm = tcg_temp_new_ptr(); | |
3183 | pg = tcg_temp_new_ptr(); | |
3184 | ||
3185 | tcg_gen_addi_ptr(pd, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3186 | tcg_gen_addi_ptr(zn, cpu_env, vec_full_reg_offset(s, a->rn)); | |
3187 | tcg_gen_addi_ptr(zm, cpu_env, vec_full_reg_offset(s, a->rm)); | |
3188 | tcg_gen_addi_ptr(pg, cpu_env, pred_full_reg_offset(s, a->pg)); | |
3189 | ||
3190 | gen_fn(t, pd, zn, zm, pg, t); | |
3191 | ||
3192 | tcg_temp_free_ptr(pd); | |
3193 | tcg_temp_free_ptr(zn); | |
3194 | tcg_temp_free_ptr(zm); | |
3195 | tcg_temp_free_ptr(pg); | |
3196 | ||
3197 | do_pred_flags(t); | |
3198 | ||
3199 | tcg_temp_free_i32(t); | |
3200 | return true; | |
3201 | } | |
3202 | ||
3203 | #define DO_PPZZ(NAME, name) \ | |
3a7be554 | 3204 | static bool trans_##NAME##_ppzz(DisasContext *s, arg_rprr_esz *a) \ |
757f9cff RH |
3205 | { \ |
3206 | static gen_helper_gvec_flags_4 * const fns[4] = { \ | |
3207 | gen_helper_sve_##name##_ppzz_b, gen_helper_sve_##name##_ppzz_h, \ | |
3208 | gen_helper_sve_##name##_ppzz_s, gen_helper_sve_##name##_ppzz_d, \ | |
3209 | }; \ | |
3210 | return do_ppzz_flags(s, a, fns[a->esz]); \ | |
3211 | } | |
3212 | ||
3213 | DO_PPZZ(CMPEQ, cmpeq) | |
3214 | DO_PPZZ(CMPNE, cmpne) | |
3215 | DO_PPZZ(CMPGT, cmpgt) | |
3216 | DO_PPZZ(CMPGE, cmpge) | |
3217 | DO_PPZZ(CMPHI, cmphi) | |
3218 | DO_PPZZ(CMPHS, cmphs) | |
3219 | ||
3220 | #undef DO_PPZZ | |
3221 | ||
3222 | #define DO_PPZW(NAME, name) \ | |
3a7be554 | 3223 | static bool trans_##NAME##_ppzw(DisasContext *s, arg_rprr_esz *a) \ |
757f9cff RH |
3224 | { \ |
3225 | static gen_helper_gvec_flags_4 * const fns[4] = { \ | |
3226 | gen_helper_sve_##name##_ppzw_b, gen_helper_sve_##name##_ppzw_h, \ | |
3227 | gen_helper_sve_##name##_ppzw_s, NULL \ | |
3228 | }; \ | |
3229 | return do_ppzz_flags(s, a, fns[a->esz]); \ | |
3230 | } | |
3231 | ||
3232 | DO_PPZW(CMPEQ, cmpeq) | |
3233 | DO_PPZW(CMPNE, cmpne) | |
3234 | DO_PPZW(CMPGT, cmpgt) | |
3235 | DO_PPZW(CMPGE, cmpge) | |
3236 | DO_PPZW(CMPHI, cmphi) | |
3237 | DO_PPZW(CMPHS, cmphs) | |
3238 | DO_PPZW(CMPLT, cmplt) | |
3239 | DO_PPZW(CMPLE, cmple) | |
3240 | DO_PPZW(CMPLO, cmplo) | |
3241 | DO_PPZW(CMPLS, cmpls) | |
3242 | ||
3243 | #undef DO_PPZW | |
3244 | ||
38cadeba RH |
3245 | /* |
3246 | *** SVE Integer Compare - Immediate Groups | |
3247 | */ | |
3248 | ||
3249 | static bool do_ppzi_flags(DisasContext *s, arg_rpri_esz *a, | |
3250 | gen_helper_gvec_flags_3 *gen_fn) | |
3251 | { | |
3252 | TCGv_ptr pd, zn, pg; | |
3253 | unsigned vsz; | |
3254 | TCGv_i32 t; | |
3255 | ||
3256 | if (gen_fn == NULL) { | |
3257 | return false; | |
3258 | } | |
3259 | if (!sve_access_check(s)) { | |
3260 | return true; | |
3261 | } | |
3262 | ||
3263 | vsz = vec_full_reg_size(s); | |
3264 | t = tcg_const_i32(simd_desc(vsz, vsz, a->imm)); | |
3265 | pd = tcg_temp_new_ptr(); | |
3266 | zn = tcg_temp_new_ptr(); | |
3267 | pg = tcg_temp_new_ptr(); | |
3268 | ||
3269 | tcg_gen_addi_ptr(pd, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3270 | tcg_gen_addi_ptr(zn, cpu_env, vec_full_reg_offset(s, a->rn)); | |
3271 | tcg_gen_addi_ptr(pg, cpu_env, pred_full_reg_offset(s, a->pg)); | |
3272 | ||
3273 | gen_fn(t, pd, zn, pg, t); | |
3274 | ||
3275 | tcg_temp_free_ptr(pd); | |
3276 | tcg_temp_free_ptr(zn); | |
3277 | tcg_temp_free_ptr(pg); | |
3278 | ||
3279 | do_pred_flags(t); | |
3280 | ||
3281 | tcg_temp_free_i32(t); | |
3282 | return true; | |
3283 | } | |
3284 | ||
3285 | #define DO_PPZI(NAME, name) \ | |
3a7be554 | 3286 | static bool trans_##NAME##_ppzi(DisasContext *s, arg_rpri_esz *a) \ |
38cadeba RH |
3287 | { \ |
3288 | static gen_helper_gvec_flags_3 * const fns[4] = { \ | |
3289 | gen_helper_sve_##name##_ppzi_b, gen_helper_sve_##name##_ppzi_h, \ | |
3290 | gen_helper_sve_##name##_ppzi_s, gen_helper_sve_##name##_ppzi_d, \ | |
3291 | }; \ | |
3292 | return do_ppzi_flags(s, a, fns[a->esz]); \ | |
3293 | } | |
3294 | ||
3295 | DO_PPZI(CMPEQ, cmpeq) | |
3296 | DO_PPZI(CMPNE, cmpne) | |
3297 | DO_PPZI(CMPGT, cmpgt) | |
3298 | DO_PPZI(CMPGE, cmpge) | |
3299 | DO_PPZI(CMPHI, cmphi) | |
3300 | DO_PPZI(CMPHS, cmphs) | |
3301 | DO_PPZI(CMPLT, cmplt) | |
3302 | DO_PPZI(CMPLE, cmple) | |
3303 | DO_PPZI(CMPLO, cmplo) | |
3304 | DO_PPZI(CMPLS, cmpls) | |
3305 | ||
3306 | #undef DO_PPZI | |
3307 | ||
35da316f RH |
3308 | /* |
3309 | *** SVE Partition Break Group | |
3310 | */ | |
3311 | ||
3312 | static bool do_brk3(DisasContext *s, arg_rprr_s *a, | |
3313 | gen_helper_gvec_4 *fn, gen_helper_gvec_flags_4 *fn_s) | |
3314 | { | |
3315 | if (!sve_access_check(s)) { | |
3316 | return true; | |
3317 | } | |
3318 | ||
3319 | unsigned vsz = pred_full_reg_size(s); | |
3320 | ||
3321 | /* Predicate sizes may be smaller and cannot use simd_desc. */ | |
3322 | TCGv_ptr d = tcg_temp_new_ptr(); | |
3323 | TCGv_ptr n = tcg_temp_new_ptr(); | |
3324 | TCGv_ptr m = tcg_temp_new_ptr(); | |
3325 | TCGv_ptr g = tcg_temp_new_ptr(); | |
04c774a2 | 3326 | TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); |
35da316f RH |
3327 | |
3328 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3329 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | |
3330 | tcg_gen_addi_ptr(m, cpu_env, pred_full_reg_offset(s, a->rm)); | |
3331 | tcg_gen_addi_ptr(g, cpu_env, pred_full_reg_offset(s, a->pg)); | |
3332 | ||
3333 | if (a->s) { | |
3334 | fn_s(t, d, n, m, g, t); | |
3335 | do_pred_flags(t); | |
3336 | } else { | |
3337 | fn(d, n, m, g, t); | |
3338 | } | |
3339 | tcg_temp_free_ptr(d); | |
3340 | tcg_temp_free_ptr(n); | |
3341 | tcg_temp_free_ptr(m); | |
3342 | tcg_temp_free_ptr(g); | |
3343 | tcg_temp_free_i32(t); | |
3344 | return true; | |
3345 | } | |
3346 | ||
3347 | static bool do_brk2(DisasContext *s, arg_rpr_s *a, | |
3348 | gen_helper_gvec_3 *fn, gen_helper_gvec_flags_3 *fn_s) | |
3349 | { | |
3350 | if (!sve_access_check(s)) { | |
3351 | return true; | |
3352 | } | |
3353 | ||
3354 | unsigned vsz = pred_full_reg_size(s); | |
3355 | ||
3356 | /* Predicate sizes may be smaller and cannot use simd_desc. */ | |
3357 | TCGv_ptr d = tcg_temp_new_ptr(); | |
3358 | TCGv_ptr n = tcg_temp_new_ptr(); | |
3359 | TCGv_ptr g = tcg_temp_new_ptr(); | |
04c774a2 | 3360 | TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); |
35da316f RH |
3361 | |
3362 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3363 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | |
3364 | tcg_gen_addi_ptr(g, cpu_env, pred_full_reg_offset(s, a->pg)); | |
3365 | ||
3366 | if (a->s) { | |
3367 | fn_s(t, d, n, g, t); | |
3368 | do_pred_flags(t); | |
3369 | } else { | |
3370 | fn(d, n, g, t); | |
3371 | } | |
3372 | tcg_temp_free_ptr(d); | |
3373 | tcg_temp_free_ptr(n); | |
3374 | tcg_temp_free_ptr(g); | |
3375 | tcg_temp_free_i32(t); | |
3376 | return true; | |
3377 | } | |
3378 | ||
3a7be554 | 3379 | static bool trans_BRKPA(DisasContext *s, arg_rprr_s *a) |
35da316f RH |
3380 | { |
3381 | return do_brk3(s, a, gen_helper_sve_brkpa, gen_helper_sve_brkpas); | |
3382 | } | |
3383 | ||
3a7be554 | 3384 | static bool trans_BRKPB(DisasContext *s, arg_rprr_s *a) |
35da316f RH |
3385 | { |
3386 | return do_brk3(s, a, gen_helper_sve_brkpb, gen_helper_sve_brkpbs); | |
3387 | } | |
3388 | ||
3a7be554 | 3389 | static bool trans_BRKA_m(DisasContext *s, arg_rpr_s *a) |
35da316f RH |
3390 | { |
3391 | return do_brk2(s, a, gen_helper_sve_brka_m, gen_helper_sve_brkas_m); | |
3392 | } | |
3393 | ||
3a7be554 | 3394 | static bool trans_BRKB_m(DisasContext *s, arg_rpr_s *a) |
35da316f RH |
3395 | { |
3396 | return do_brk2(s, a, gen_helper_sve_brkb_m, gen_helper_sve_brkbs_m); | |
3397 | } | |
3398 | ||
3a7be554 | 3399 | static bool trans_BRKA_z(DisasContext *s, arg_rpr_s *a) |
35da316f RH |
3400 | { |
3401 | return do_brk2(s, a, gen_helper_sve_brka_z, gen_helper_sve_brkas_z); | |
3402 | } | |
3403 | ||
3a7be554 | 3404 | static bool trans_BRKB_z(DisasContext *s, arg_rpr_s *a) |
35da316f RH |
3405 | { |
3406 | return do_brk2(s, a, gen_helper_sve_brkb_z, gen_helper_sve_brkbs_z); | |
3407 | } | |
3408 | ||
3a7be554 | 3409 | static bool trans_BRKN(DisasContext *s, arg_rpr_s *a) |
35da316f RH |
3410 | { |
3411 | return do_brk2(s, a, gen_helper_sve_brkn, gen_helper_sve_brkns); | |
3412 | } | |
3413 | ||
9ee3a611 RH |
3414 | /* |
3415 | *** SVE Predicate Count Group | |
3416 | */ | |
3417 | ||
3418 | static void do_cntp(DisasContext *s, TCGv_i64 val, int esz, int pn, int pg) | |
3419 | { | |
3420 | unsigned psz = pred_full_reg_size(s); | |
3421 | ||
3422 | if (psz <= 8) { | |
3423 | uint64_t psz_mask; | |
3424 | ||
3425 | tcg_gen_ld_i64(val, cpu_env, pred_full_reg_offset(s, pn)); | |
3426 | if (pn != pg) { | |
3427 | TCGv_i64 g = tcg_temp_new_i64(); | |
3428 | tcg_gen_ld_i64(g, cpu_env, pred_full_reg_offset(s, pg)); | |
3429 | tcg_gen_and_i64(val, val, g); | |
3430 | tcg_temp_free_i64(g); | |
3431 | } | |
3432 | ||
3433 | /* Reduce the pred_esz_masks value simply to reduce the | |
3434 | * size of the code generated here. | |
3435 | */ | |
3436 | psz_mask = MAKE_64BIT_MASK(0, psz * 8); | |
3437 | tcg_gen_andi_i64(val, val, pred_esz_masks[esz] & psz_mask); | |
3438 | ||
3439 | tcg_gen_ctpop_i64(val, val); | |
3440 | } else { | |
3441 | TCGv_ptr t_pn = tcg_temp_new_ptr(); | |
3442 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | |
f556a201 | 3443 | unsigned desc = 0; |
9ee3a611 RH |
3444 | TCGv_i32 t_desc; |
3445 | ||
f556a201 RH |
3446 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, psz); |
3447 | desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | |
9ee3a611 RH |
3448 | |
3449 | tcg_gen_addi_ptr(t_pn, cpu_env, pred_full_reg_offset(s, pn)); | |
3450 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | |
3451 | t_desc = tcg_const_i32(desc); | |
3452 | ||
3453 | gen_helper_sve_cntp(val, t_pn, t_pg, t_desc); | |
3454 | tcg_temp_free_ptr(t_pn); | |
3455 | tcg_temp_free_ptr(t_pg); | |
3456 | tcg_temp_free_i32(t_desc); | |
3457 | } | |
3458 | } | |
3459 | ||
3a7be554 | 3460 | static bool trans_CNTP(DisasContext *s, arg_CNTP *a) |
9ee3a611 RH |
3461 | { |
3462 | if (sve_access_check(s)) { | |
3463 | do_cntp(s, cpu_reg(s, a->rd), a->esz, a->rn, a->pg); | |
3464 | } | |
3465 | return true; | |
3466 | } | |
3467 | ||
3a7be554 | 3468 | static bool trans_INCDECP_r(DisasContext *s, arg_incdec_pred *a) |
9ee3a611 RH |
3469 | { |
3470 | if (sve_access_check(s)) { | |
3471 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
3472 | TCGv_i64 val = tcg_temp_new_i64(); | |
3473 | ||
3474 | do_cntp(s, val, a->esz, a->pg, a->pg); | |
3475 | if (a->d) { | |
3476 | tcg_gen_sub_i64(reg, reg, val); | |
3477 | } else { | |
3478 | tcg_gen_add_i64(reg, reg, val); | |
3479 | } | |
3480 | tcg_temp_free_i64(val); | |
3481 | } | |
3482 | return true; | |
3483 | } | |
3484 | ||
3a7be554 | 3485 | static bool trans_INCDECP_z(DisasContext *s, arg_incdec2_pred *a) |
9ee3a611 RH |
3486 | { |
3487 | if (a->esz == 0) { | |
3488 | return false; | |
3489 | } | |
3490 | if (sve_access_check(s)) { | |
3491 | unsigned vsz = vec_full_reg_size(s); | |
3492 | TCGv_i64 val = tcg_temp_new_i64(); | |
3493 | GVecGen2sFn *gvec_fn = a->d ? tcg_gen_gvec_subs : tcg_gen_gvec_adds; | |
3494 | ||
3495 | do_cntp(s, val, a->esz, a->pg, a->pg); | |
3496 | gvec_fn(a->esz, vec_full_reg_offset(s, a->rd), | |
3497 | vec_full_reg_offset(s, a->rn), val, vsz, vsz); | |
3498 | } | |
3499 | return true; | |
3500 | } | |
3501 | ||
3a7be554 | 3502 | static bool trans_SINCDECP_r_32(DisasContext *s, arg_incdec_pred *a) |
9ee3a611 RH |
3503 | { |
3504 | if (sve_access_check(s)) { | |
3505 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
3506 | TCGv_i64 val = tcg_temp_new_i64(); | |
3507 | ||
3508 | do_cntp(s, val, a->esz, a->pg, a->pg); | |
3509 | do_sat_addsub_32(reg, val, a->u, a->d); | |
3510 | } | |
3511 | return true; | |
3512 | } | |
3513 | ||
3a7be554 | 3514 | static bool trans_SINCDECP_r_64(DisasContext *s, arg_incdec_pred *a) |
9ee3a611 RH |
3515 | { |
3516 | if (sve_access_check(s)) { | |
3517 | TCGv_i64 reg = cpu_reg(s, a->rd); | |
3518 | TCGv_i64 val = tcg_temp_new_i64(); | |
3519 | ||
3520 | do_cntp(s, val, a->esz, a->pg, a->pg); | |
3521 | do_sat_addsub_64(reg, val, a->u, a->d); | |
3522 | } | |
3523 | return true; | |
3524 | } | |
3525 | ||
3a7be554 | 3526 | static bool trans_SINCDECP_z(DisasContext *s, arg_incdec2_pred *a) |
9ee3a611 RH |
3527 | { |
3528 | if (a->esz == 0) { | |
3529 | return false; | |
3530 | } | |
3531 | if (sve_access_check(s)) { | |
3532 | TCGv_i64 val = tcg_temp_new_i64(); | |
3533 | do_cntp(s, val, a->esz, a->pg, a->pg); | |
3534 | do_sat_addsub_vec(s, a->esz, a->rd, a->rn, val, a->u, a->d); | |
3535 | } | |
3536 | return true; | |
3537 | } | |
3538 | ||
caf1cefc RH |
3539 | /* |
3540 | *** SVE Integer Compare Scalars Group | |
3541 | */ | |
3542 | ||
3a7be554 | 3543 | static bool trans_CTERM(DisasContext *s, arg_CTERM *a) |
caf1cefc RH |
3544 | { |
3545 | if (!sve_access_check(s)) { | |
3546 | return true; | |
3547 | } | |
3548 | ||
3549 | TCGCond cond = (a->ne ? TCG_COND_NE : TCG_COND_EQ); | |
3550 | TCGv_i64 rn = read_cpu_reg(s, a->rn, a->sf); | |
3551 | TCGv_i64 rm = read_cpu_reg(s, a->rm, a->sf); | |
3552 | TCGv_i64 cmp = tcg_temp_new_i64(); | |
3553 | ||
3554 | tcg_gen_setcond_i64(cond, cmp, rn, rm); | |
3555 | tcg_gen_extrl_i64_i32(cpu_NF, cmp); | |
3556 | tcg_temp_free_i64(cmp); | |
3557 | ||
3558 | /* VF = !NF & !CF. */ | |
3559 | tcg_gen_xori_i32(cpu_VF, cpu_NF, 1); | |
3560 | tcg_gen_andc_i32(cpu_VF, cpu_VF, cpu_CF); | |
3561 | ||
3562 | /* Both NF and VF actually look at bit 31. */ | |
3563 | tcg_gen_neg_i32(cpu_NF, cpu_NF); | |
3564 | tcg_gen_neg_i32(cpu_VF, cpu_VF); | |
3565 | return true; | |
3566 | } | |
3567 | ||
3a7be554 | 3568 | static bool trans_WHILE(DisasContext *s, arg_WHILE *a) |
caf1cefc | 3569 | { |
bbd0968c | 3570 | TCGv_i64 op0, op1, t0, t1, tmax; |
4481bbf2 | 3571 | TCGv_i32 t2; |
caf1cefc | 3572 | TCGv_ptr ptr; |
e610906c RH |
3573 | unsigned vsz = vec_full_reg_size(s); |
3574 | unsigned desc = 0; | |
caf1cefc | 3575 | TCGCond cond; |
34688dbc RH |
3576 | uint64_t maxval; |
3577 | /* Note that GE/HS has a->eq == 0 and GT/HI has a->eq == 1. */ | |
3578 | bool eq = a->eq == a->lt; | |
caf1cefc | 3579 | |
34688dbc RH |
3580 | /* The greater-than conditions are all SVE2. */ |
3581 | if (!a->lt && !dc_isar_feature(aa64_sve2, s)) { | |
3582 | return false; | |
3583 | } | |
bbd0968c RH |
3584 | if (!sve_access_check(s)) { |
3585 | return true; | |
3586 | } | |
3587 | ||
3588 | op0 = read_cpu_reg(s, a->rn, 1); | |
3589 | op1 = read_cpu_reg(s, a->rm, 1); | |
3590 | ||
caf1cefc RH |
3591 | if (!a->sf) { |
3592 | if (a->u) { | |
3593 | tcg_gen_ext32u_i64(op0, op0); | |
3594 | tcg_gen_ext32u_i64(op1, op1); | |
3595 | } else { | |
3596 | tcg_gen_ext32s_i64(op0, op0); | |
3597 | tcg_gen_ext32s_i64(op1, op1); | |
3598 | } | |
3599 | } | |
3600 | ||
3601 | /* For the helper, compress the different conditions into a computation | |
3602 | * of how many iterations for which the condition is true. | |
caf1cefc | 3603 | */ |
bbd0968c RH |
3604 | t0 = tcg_temp_new_i64(); |
3605 | t1 = tcg_temp_new_i64(); | |
34688dbc RH |
3606 | |
3607 | if (a->lt) { | |
3608 | tcg_gen_sub_i64(t0, op1, op0); | |
3609 | if (a->u) { | |
3610 | maxval = a->sf ? UINT64_MAX : UINT32_MAX; | |
3611 | cond = eq ? TCG_COND_LEU : TCG_COND_LTU; | |
3612 | } else { | |
3613 | maxval = a->sf ? INT64_MAX : INT32_MAX; | |
3614 | cond = eq ? TCG_COND_LE : TCG_COND_LT; | |
3615 | } | |
3616 | } else { | |
3617 | tcg_gen_sub_i64(t0, op0, op1); | |
3618 | if (a->u) { | |
3619 | maxval = 0; | |
3620 | cond = eq ? TCG_COND_GEU : TCG_COND_GTU; | |
3621 | } else { | |
3622 | maxval = a->sf ? INT64_MIN : INT32_MIN; | |
3623 | cond = eq ? TCG_COND_GE : TCG_COND_GT; | |
3624 | } | |
3625 | } | |
caf1cefc | 3626 | |
4481bbf2 | 3627 | tmax = tcg_constant_i64(vsz >> a->esz); |
34688dbc | 3628 | if (eq) { |
caf1cefc RH |
3629 | /* Equality means one more iteration. */ |
3630 | tcg_gen_addi_i64(t0, t0, 1); | |
bbd0968c | 3631 | |
34688dbc RH |
3632 | /* |
3633 | * For the less-than while, if op1 is maxval (and the only time | |
3634 | * the addition above could overflow), then we produce an all-true | |
3635 | * predicate by setting the count to the vector length. This is | |
3636 | * because the pseudocode is described as an increment + compare | |
3637 | * loop, and the maximum integer would always compare true. | |
3638 | * Similarly, the greater-than while has the same issue with the | |
3639 | * minimum integer due to the decrement + compare loop. | |
bbd0968c | 3640 | */ |
34688dbc | 3641 | tcg_gen_movi_i64(t1, maxval); |
bbd0968c | 3642 | tcg_gen_movcond_i64(TCG_COND_EQ, t0, op1, t1, tmax, t0); |
caf1cefc RH |
3643 | } |
3644 | ||
bbd0968c RH |
3645 | /* Bound to the maximum. */ |
3646 | tcg_gen_umin_i64(t0, t0, tmax); | |
bbd0968c RH |
3647 | |
3648 | /* Set the count to zero if the condition is false. */ | |
caf1cefc RH |
3649 | tcg_gen_movi_i64(t1, 0); |
3650 | tcg_gen_movcond_i64(cond, t0, op0, op1, t0, t1); | |
bbd0968c | 3651 | tcg_temp_free_i64(t1); |
caf1cefc | 3652 | |
bbd0968c | 3653 | /* Since we're bounded, pass as a 32-bit type. */ |
caf1cefc RH |
3654 | t2 = tcg_temp_new_i32(); |
3655 | tcg_gen_extrl_i64_i32(t2, t0); | |
3656 | tcg_temp_free_i64(t0); | |
bbd0968c RH |
3657 | |
3658 | /* Scale elements to bits. */ | |
3659 | tcg_gen_shli_i32(t2, t2, a->esz); | |
caf1cefc | 3660 | |
e610906c RH |
3661 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz / 8); |
3662 | desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | |
caf1cefc RH |
3663 | |
3664 | ptr = tcg_temp_new_ptr(); | |
3665 | tcg_gen_addi_ptr(ptr, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3666 | ||
34688dbc | 3667 | if (a->lt) { |
4481bbf2 | 3668 | gen_helper_sve_whilel(t2, ptr, t2, tcg_constant_i32(desc)); |
34688dbc | 3669 | } else { |
4481bbf2 | 3670 | gen_helper_sve_whileg(t2, ptr, t2, tcg_constant_i32(desc)); |
34688dbc | 3671 | } |
caf1cefc RH |
3672 | do_pred_flags(t2); |
3673 | ||
3674 | tcg_temp_free_ptr(ptr); | |
3675 | tcg_temp_free_i32(t2); | |
caf1cefc RH |
3676 | return true; |
3677 | } | |
3678 | ||
14f6dad1 RH |
3679 | static bool trans_WHILE_ptr(DisasContext *s, arg_WHILE_ptr *a) |
3680 | { | |
3681 | TCGv_i64 op0, op1, diff, t1, tmax; | |
4481bbf2 | 3682 | TCGv_i32 t2; |
14f6dad1 RH |
3683 | TCGv_ptr ptr; |
3684 | unsigned vsz = vec_full_reg_size(s); | |
3685 | unsigned desc = 0; | |
3686 | ||
3687 | if (!dc_isar_feature(aa64_sve2, s)) { | |
3688 | return false; | |
3689 | } | |
3690 | if (!sve_access_check(s)) { | |
3691 | return true; | |
3692 | } | |
3693 | ||
3694 | op0 = read_cpu_reg(s, a->rn, 1); | |
3695 | op1 = read_cpu_reg(s, a->rm, 1); | |
3696 | ||
4481bbf2 | 3697 | tmax = tcg_constant_i64(vsz); |
14f6dad1 RH |
3698 | diff = tcg_temp_new_i64(); |
3699 | ||
3700 | if (a->rw) { | |
3701 | /* WHILERW */ | |
3702 | /* diff = abs(op1 - op0), noting that op0/1 are unsigned. */ | |
3703 | t1 = tcg_temp_new_i64(); | |
3704 | tcg_gen_sub_i64(diff, op0, op1); | |
3705 | tcg_gen_sub_i64(t1, op1, op0); | |
3706 | tcg_gen_movcond_i64(TCG_COND_GEU, diff, op0, op1, diff, t1); | |
3707 | tcg_temp_free_i64(t1); | |
3708 | /* Round down to a multiple of ESIZE. */ | |
3709 | tcg_gen_andi_i64(diff, diff, -1 << a->esz); | |
3710 | /* If op1 == op0, diff == 0, and the condition is always true. */ | |
3711 | tcg_gen_movcond_i64(TCG_COND_EQ, diff, op0, op1, tmax, diff); | |
3712 | } else { | |
3713 | /* WHILEWR */ | |
3714 | tcg_gen_sub_i64(diff, op1, op0); | |
3715 | /* Round down to a multiple of ESIZE. */ | |
3716 | tcg_gen_andi_i64(diff, diff, -1 << a->esz); | |
3717 | /* If op0 >= op1, diff <= 0, the condition is always true. */ | |
3718 | tcg_gen_movcond_i64(TCG_COND_GEU, diff, op0, op1, tmax, diff); | |
3719 | } | |
3720 | ||
3721 | /* Bound to the maximum. */ | |
3722 | tcg_gen_umin_i64(diff, diff, tmax); | |
14f6dad1 RH |
3723 | |
3724 | /* Since we're bounded, pass as a 32-bit type. */ | |
3725 | t2 = tcg_temp_new_i32(); | |
3726 | tcg_gen_extrl_i64_i32(t2, diff); | |
3727 | tcg_temp_free_i64(diff); | |
3728 | ||
3729 | desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz / 8); | |
3730 | desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | |
14f6dad1 RH |
3731 | |
3732 | ptr = tcg_temp_new_ptr(); | |
3733 | tcg_gen_addi_ptr(ptr, cpu_env, pred_full_reg_offset(s, a->rd)); | |
3734 | ||
4481bbf2 | 3735 | gen_helper_sve_whilel(t2, ptr, t2, tcg_constant_i32(desc)); |
14f6dad1 RH |
3736 | do_pred_flags(t2); |
3737 | ||
3738 | tcg_temp_free_ptr(ptr); | |
3739 | tcg_temp_free_i32(t2); | |
14f6dad1 RH |
3740 | return true; |
3741 | } | |
3742 | ||
ed491961 RH |
3743 | /* |
3744 | *** SVE Integer Wide Immediate - Unpredicated Group | |
3745 | */ | |
3746 | ||
3a7be554 | 3747 | static bool trans_FDUP(DisasContext *s, arg_FDUP *a) |
ed491961 RH |
3748 | { |
3749 | if (a->esz == 0) { | |
3750 | return false; | |
3751 | } | |
3752 | if (sve_access_check(s)) { | |
3753 | unsigned vsz = vec_full_reg_size(s); | |
3754 | int dofs = vec_full_reg_offset(s, a->rd); | |
3755 | uint64_t imm; | |
3756 | ||
3757 | /* Decode the VFP immediate. */ | |
3758 | imm = vfp_expand_imm(a->esz, a->imm); | |
8711e71f | 3759 | tcg_gen_gvec_dup_imm(a->esz, dofs, vsz, vsz, imm); |
ed491961 RH |
3760 | } |
3761 | return true; | |
3762 | } | |
3763 | ||
3a7be554 | 3764 | static bool trans_DUP_i(DisasContext *s, arg_DUP_i *a) |
ed491961 | 3765 | { |
3a7be554 | 3766 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
ed491961 RH |
3767 | return false; |
3768 | } | |
3769 | if (sve_access_check(s)) { | |
3770 | unsigned vsz = vec_full_reg_size(s); | |
3771 | int dofs = vec_full_reg_offset(s, a->rd); | |
3772 | ||
8711e71f | 3773 | tcg_gen_gvec_dup_imm(a->esz, dofs, vsz, vsz, a->imm); |
ed491961 RH |
3774 | } |
3775 | return true; | |
3776 | } | |
3777 | ||
3a7be554 | 3778 | static bool trans_ADD_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3779 | { |
3a7be554 | 3780 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
6e6a157d RH |
3781 | return false; |
3782 | } | |
3783 | if (sve_access_check(s)) { | |
3784 | unsigned vsz = vec_full_reg_size(s); | |
3785 | tcg_gen_gvec_addi(a->esz, vec_full_reg_offset(s, a->rd), | |
3786 | vec_full_reg_offset(s, a->rn), a->imm, vsz, vsz); | |
3787 | } | |
3788 | return true; | |
3789 | } | |
3790 | ||
3a7be554 | 3791 | static bool trans_SUB_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d RH |
3792 | { |
3793 | a->imm = -a->imm; | |
3a7be554 | 3794 | return trans_ADD_zzi(s, a); |
6e6a157d RH |
3795 | } |
3796 | ||
3a7be554 | 3797 | static bool trans_SUBR_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3798 | { |
53229a77 | 3799 | static const TCGOpcode vecop_list[] = { INDEX_op_sub_vec, 0 }; |
6e6a157d RH |
3800 | static const GVecGen2s op[4] = { |
3801 | { .fni8 = tcg_gen_vec_sub8_i64, | |
3802 | .fniv = tcg_gen_sub_vec, | |
3803 | .fno = gen_helper_sve_subri_b, | |
53229a77 | 3804 | .opt_opc = vecop_list, |
6e6a157d RH |
3805 | .vece = MO_8, |
3806 | .scalar_first = true }, | |
3807 | { .fni8 = tcg_gen_vec_sub16_i64, | |
3808 | .fniv = tcg_gen_sub_vec, | |
3809 | .fno = gen_helper_sve_subri_h, | |
53229a77 | 3810 | .opt_opc = vecop_list, |
6e6a157d RH |
3811 | .vece = MO_16, |
3812 | .scalar_first = true }, | |
3813 | { .fni4 = tcg_gen_sub_i32, | |
3814 | .fniv = tcg_gen_sub_vec, | |
3815 | .fno = gen_helper_sve_subri_s, | |
53229a77 | 3816 | .opt_opc = vecop_list, |
6e6a157d RH |
3817 | .vece = MO_32, |
3818 | .scalar_first = true }, | |
3819 | { .fni8 = tcg_gen_sub_i64, | |
3820 | .fniv = tcg_gen_sub_vec, | |
3821 | .fno = gen_helper_sve_subri_d, | |
53229a77 | 3822 | .opt_opc = vecop_list, |
6e6a157d RH |
3823 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, |
3824 | .vece = MO_64, | |
3825 | .scalar_first = true } | |
3826 | }; | |
3827 | ||
3a7be554 | 3828 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
6e6a157d RH |
3829 | return false; |
3830 | } | |
3831 | if (sve_access_check(s)) { | |
3832 | unsigned vsz = vec_full_reg_size(s); | |
3833 | TCGv_i64 c = tcg_const_i64(a->imm); | |
3834 | tcg_gen_gvec_2s(vec_full_reg_offset(s, a->rd), | |
3835 | vec_full_reg_offset(s, a->rn), | |
3836 | vsz, vsz, c, &op[a->esz]); | |
3837 | tcg_temp_free_i64(c); | |
3838 | } | |
3839 | return true; | |
3840 | } | |
3841 | ||
3a7be554 | 3842 | static bool trans_MUL_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d RH |
3843 | { |
3844 | if (sve_access_check(s)) { | |
3845 | unsigned vsz = vec_full_reg_size(s); | |
3846 | tcg_gen_gvec_muli(a->esz, vec_full_reg_offset(s, a->rd), | |
3847 | vec_full_reg_offset(s, a->rn), a->imm, vsz, vsz); | |
3848 | } | |
3849 | return true; | |
3850 | } | |
3851 | ||
3a7be554 | 3852 | static bool do_zzi_sat(DisasContext *s, arg_rri_esz *a, bool u, bool d) |
6e6a157d | 3853 | { |
3a7be554 | 3854 | if (a->esz == 0 && extract32(s->insn, 13, 1)) { |
6e6a157d RH |
3855 | return false; |
3856 | } | |
3857 | if (sve_access_check(s)) { | |
3858 | TCGv_i64 val = tcg_const_i64(a->imm); | |
3859 | do_sat_addsub_vec(s, a->esz, a->rd, a->rn, val, u, d); | |
3860 | tcg_temp_free_i64(val); | |
3861 | } | |
3862 | return true; | |
3863 | } | |
3864 | ||
3a7be554 | 3865 | static bool trans_SQADD_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3866 | { |
3a7be554 | 3867 | return do_zzi_sat(s, a, false, false); |
6e6a157d RH |
3868 | } |
3869 | ||
3a7be554 | 3870 | static bool trans_UQADD_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3871 | { |
3a7be554 | 3872 | return do_zzi_sat(s, a, true, false); |
6e6a157d RH |
3873 | } |
3874 | ||
3a7be554 | 3875 | static bool trans_SQSUB_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3876 | { |
3a7be554 | 3877 | return do_zzi_sat(s, a, false, true); |
6e6a157d RH |
3878 | } |
3879 | ||
3a7be554 | 3880 | static bool trans_UQSUB_zzi(DisasContext *s, arg_rri_esz *a) |
6e6a157d | 3881 | { |
3a7be554 | 3882 | return do_zzi_sat(s, a, true, true); |
6e6a157d RH |
3883 | } |
3884 | ||
3885 | static bool do_zzi_ool(DisasContext *s, arg_rri_esz *a, gen_helper_gvec_2i *fn) | |
3886 | { | |
3887 | if (sve_access_check(s)) { | |
3888 | unsigned vsz = vec_full_reg_size(s); | |
3889 | TCGv_i64 c = tcg_const_i64(a->imm); | |
3890 | ||
3891 | tcg_gen_gvec_2i_ool(vec_full_reg_offset(s, a->rd), | |
3892 | vec_full_reg_offset(s, a->rn), | |
3893 | c, vsz, vsz, 0, fn); | |
3894 | tcg_temp_free_i64(c); | |
3895 | } | |
3896 | return true; | |
3897 | } | |
3898 | ||
3899 | #define DO_ZZI(NAME, name) \ | |
3a7be554 | 3900 | static bool trans_##NAME##_zzi(DisasContext *s, arg_rri_esz *a) \ |
6e6a157d RH |
3901 | { \ |
3902 | static gen_helper_gvec_2i * const fns[4] = { \ | |
3903 | gen_helper_sve_##name##i_b, gen_helper_sve_##name##i_h, \ | |
3904 | gen_helper_sve_##name##i_s, gen_helper_sve_##name##i_d, \ | |
3905 | }; \ | |
3906 | return do_zzi_ool(s, a, fns[a->esz]); \ | |
3907 | } | |
3908 | ||
3909 | DO_ZZI(SMAX, smax) | |
3910 | DO_ZZI(UMAX, umax) | |
3911 | DO_ZZI(SMIN, smin) | |
3912 | DO_ZZI(UMIN, umin) | |
3913 | ||
3914 | #undef DO_ZZI | |
3915 | ||
bc2bd697 | 3916 | static bool trans_DOT_zzzz(DisasContext *s, arg_DOT_zzzz *a) |
d730ecaa | 3917 | { |
bc2bd697 | 3918 | static gen_helper_gvec_4 * const fns[2][2] = { |
d730ecaa RH |
3919 | { gen_helper_gvec_sdot_b, gen_helper_gvec_sdot_h }, |
3920 | { gen_helper_gvec_udot_b, gen_helper_gvec_udot_h } | |
3921 | }; | |
3922 | ||
3923 | if (sve_access_check(s)) { | |
bc2bd697 | 3924 | gen_gvec_ool_zzzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, a->ra, 0); |
d730ecaa RH |
3925 | } |
3926 | return true; | |
3927 | } | |
3928 | ||
814d4c52 RH |
3929 | /* |
3930 | * SVE Multiply - Indexed | |
3931 | */ | |
3932 | ||
0a82d963 RH |
3933 | static bool do_zzxz_ool(DisasContext *s, arg_rrxr_esz *a, |
3934 | gen_helper_gvec_4 *fn) | |
16fcfdc7 | 3935 | { |
0a82d963 RH |
3936 | if (fn == NULL) { |
3937 | return false; | |
3938 | } | |
16fcfdc7 | 3939 | if (sve_access_check(s)) { |
0a82d963 | 3940 | gen_gvec_ool_zzzz(s, fn, a->rd, a->rn, a->rm, a->ra, a->index); |
16fcfdc7 RH |
3941 | } |
3942 | return true; | |
3943 | } | |
3944 | ||
0a82d963 RH |
3945 | #define DO_RRXR(NAME, FUNC) \ |
3946 | static bool NAME(DisasContext *s, arg_rrxr_esz *a) \ | |
3947 | { return do_zzxz_ool(s, a, FUNC); } | |
3948 | ||
3949 | DO_RRXR(trans_SDOT_zzxw_s, gen_helper_gvec_sdot_idx_b) | |
3950 | DO_RRXR(trans_SDOT_zzxw_d, gen_helper_gvec_sdot_idx_h) | |
3951 | DO_RRXR(trans_UDOT_zzxw_s, gen_helper_gvec_udot_idx_b) | |
3952 | DO_RRXR(trans_UDOT_zzxw_d, gen_helper_gvec_udot_idx_h) | |
3953 | ||
2867039a RH |
3954 | static bool trans_SUDOT_zzxw_s(DisasContext *s, arg_rrxr_esz *a) |
3955 | { | |
3956 | if (!dc_isar_feature(aa64_sve_i8mm, s)) { | |
3957 | return false; | |
3958 | } | |
3959 | return do_zzxz_ool(s, a, gen_helper_gvec_sudot_idx_b); | |
3960 | } | |
3961 | ||
3962 | static bool trans_USDOT_zzxw_s(DisasContext *s, arg_rrxr_esz *a) | |
3963 | { | |
3964 | if (!dc_isar_feature(aa64_sve_i8mm, s)) { | |
3965 | return false; | |
3966 | } | |
3967 | return do_zzxz_ool(s, a, gen_helper_gvec_usdot_idx_b); | |
3968 | } | |
3969 | ||
0a82d963 | 3970 | #undef DO_RRXR |
16fcfdc7 | 3971 | |
814d4c52 RH |
3972 | static bool do_sve2_zzz_data(DisasContext *s, int rd, int rn, int rm, int data, |
3973 | gen_helper_gvec_3 *fn) | |
3974 | { | |
3975 | if (fn == NULL || !dc_isar_feature(aa64_sve2, s)) { | |
3976 | return false; | |
3977 | } | |
3978 | if (sve_access_check(s)) { | |
3979 | unsigned vsz = vec_full_reg_size(s); | |
3980 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | |
3981 | vec_full_reg_offset(s, rn), | |
3982 | vec_full_reg_offset(s, rm), | |
3983 | vsz, vsz, data, fn); | |
3984 | } | |
3985 | return true; | |
3986 | } | |
3987 | ||
3988 | #define DO_SVE2_RRX(NAME, FUNC) \ | |
3989 | static bool NAME(DisasContext *s, arg_rrx_esz *a) \ | |
3990 | { return do_sve2_zzz_data(s, a->rd, a->rn, a->rm, a->index, FUNC); } | |
3991 | ||
3992 | DO_SVE2_RRX(trans_MUL_zzx_h, gen_helper_gvec_mul_idx_h) | |
3993 | DO_SVE2_RRX(trans_MUL_zzx_s, gen_helper_gvec_mul_idx_s) | |
3994 | DO_SVE2_RRX(trans_MUL_zzx_d, gen_helper_gvec_mul_idx_d) | |
3995 | ||
1aee2d70 RH |
3996 | DO_SVE2_RRX(trans_SQDMULH_zzx_h, gen_helper_sve2_sqdmulh_idx_h) |
3997 | DO_SVE2_RRX(trans_SQDMULH_zzx_s, gen_helper_sve2_sqdmulh_idx_s) | |
3998 | DO_SVE2_RRX(trans_SQDMULH_zzx_d, gen_helper_sve2_sqdmulh_idx_d) | |
3999 | ||
4000 | DO_SVE2_RRX(trans_SQRDMULH_zzx_h, gen_helper_sve2_sqrdmulh_idx_h) | |
4001 | DO_SVE2_RRX(trans_SQRDMULH_zzx_s, gen_helper_sve2_sqrdmulh_idx_s) | |
4002 | DO_SVE2_RRX(trans_SQRDMULH_zzx_d, gen_helper_sve2_sqrdmulh_idx_d) | |
4003 | ||
814d4c52 RH |
4004 | #undef DO_SVE2_RRX |
4005 | ||
b95f5eeb RH |
4006 | #define DO_SVE2_RRX_TB(NAME, FUNC, TOP) \ |
4007 | static bool NAME(DisasContext *s, arg_rrx_esz *a) \ | |
4008 | { \ | |
4009 | return do_sve2_zzz_data(s, a->rd, a->rn, a->rm, \ | |
4010 | (a->index << 1) | TOP, FUNC); \ | |
4011 | } | |
4012 | ||
4013 | DO_SVE2_RRX_TB(trans_SQDMULLB_zzx_s, gen_helper_sve2_sqdmull_idx_s, false) | |
4014 | DO_SVE2_RRX_TB(trans_SQDMULLB_zzx_d, gen_helper_sve2_sqdmull_idx_d, false) | |
4015 | DO_SVE2_RRX_TB(trans_SQDMULLT_zzx_s, gen_helper_sve2_sqdmull_idx_s, true) | |
4016 | DO_SVE2_RRX_TB(trans_SQDMULLT_zzx_d, gen_helper_sve2_sqdmull_idx_d, true) | |
4017 | ||
d3949c4c RH |
4018 | DO_SVE2_RRX_TB(trans_SMULLB_zzx_s, gen_helper_sve2_smull_idx_s, false) |
4019 | DO_SVE2_RRX_TB(trans_SMULLB_zzx_d, gen_helper_sve2_smull_idx_d, false) | |
4020 | DO_SVE2_RRX_TB(trans_SMULLT_zzx_s, gen_helper_sve2_smull_idx_s, true) | |
4021 | DO_SVE2_RRX_TB(trans_SMULLT_zzx_d, gen_helper_sve2_smull_idx_d, true) | |
4022 | ||
4023 | DO_SVE2_RRX_TB(trans_UMULLB_zzx_s, gen_helper_sve2_umull_idx_s, false) | |
4024 | DO_SVE2_RRX_TB(trans_UMULLB_zzx_d, gen_helper_sve2_umull_idx_d, false) | |
4025 | DO_SVE2_RRX_TB(trans_UMULLT_zzx_s, gen_helper_sve2_umull_idx_s, true) | |
4026 | DO_SVE2_RRX_TB(trans_UMULLT_zzx_d, gen_helper_sve2_umull_idx_d, true) | |
4027 | ||
b95f5eeb RH |
4028 | #undef DO_SVE2_RRX_TB |
4029 | ||
8a02aac7 RH |
4030 | static bool do_sve2_zzzz_data(DisasContext *s, int rd, int rn, int rm, int ra, |
4031 | int data, gen_helper_gvec_4 *fn) | |
4032 | { | |
4033 | if (fn == NULL || !dc_isar_feature(aa64_sve2, s)) { | |
4034 | return false; | |
4035 | } | |
4036 | if (sve_access_check(s)) { | |
4037 | unsigned vsz = vec_full_reg_size(s); | |
4038 | tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | |
4039 | vec_full_reg_offset(s, rn), | |
4040 | vec_full_reg_offset(s, rm), | |
4041 | vec_full_reg_offset(s, ra), | |
4042 | vsz, vsz, data, fn); | |
4043 | } | |
4044 | return true; | |
4045 | } | |
4046 | ||
4047 | #define DO_SVE2_RRXR(NAME, FUNC) \ | |
4048 | static bool NAME(DisasContext *s, arg_rrxr_esz *a) \ | |
4049 | { return do_sve2_zzzz_data(s, a->rd, a->rn, a->rm, a->ra, a->index, FUNC); } | |
4050 | ||
4051 | DO_SVE2_RRXR(trans_MLA_zzxz_h, gen_helper_gvec_mla_idx_h) | |
4052 | DO_SVE2_RRXR(trans_MLA_zzxz_s, gen_helper_gvec_mla_idx_s) | |
4053 | DO_SVE2_RRXR(trans_MLA_zzxz_d, gen_helper_gvec_mla_idx_d) | |
4054 | ||
4055 | DO_SVE2_RRXR(trans_MLS_zzxz_h, gen_helper_gvec_mls_idx_h) | |
4056 | DO_SVE2_RRXR(trans_MLS_zzxz_s, gen_helper_gvec_mls_idx_s) | |
4057 | DO_SVE2_RRXR(trans_MLS_zzxz_d, gen_helper_gvec_mls_idx_d) | |
4058 | ||
75d6d5fc RH |
4059 | DO_SVE2_RRXR(trans_SQRDMLAH_zzxz_h, gen_helper_sve2_sqrdmlah_idx_h) |
4060 | DO_SVE2_RRXR(trans_SQRDMLAH_zzxz_s, gen_helper_sve2_sqrdmlah_idx_s) | |
4061 | DO_SVE2_RRXR(trans_SQRDMLAH_zzxz_d, gen_helper_sve2_sqrdmlah_idx_d) | |
4062 | ||
4063 | DO_SVE2_RRXR(trans_SQRDMLSH_zzxz_h, gen_helper_sve2_sqrdmlsh_idx_h) | |
4064 | DO_SVE2_RRXR(trans_SQRDMLSH_zzxz_s, gen_helper_sve2_sqrdmlsh_idx_s) | |
4065 | DO_SVE2_RRXR(trans_SQRDMLSH_zzxz_d, gen_helper_sve2_sqrdmlsh_idx_d) | |
4066 | ||
8a02aac7 RH |
4067 | #undef DO_SVE2_RRXR |
4068 | ||
c5c455d7 RH |
4069 | #define DO_SVE2_RRXR_TB(NAME, FUNC, TOP) \ |
4070 | static bool NAME(DisasContext *s, arg_rrxr_esz *a) \ | |
4071 | { \ | |
4072 | return do_sve2_zzzz_data(s, a->rd, a->rn, a->rm, a->rd, \ | |
4073 | (a->index << 1) | TOP, FUNC); \ | |
4074 | } | |
4075 | ||
4076 | DO_SVE2_RRXR_TB(trans_SQDMLALB_zzxw_s, gen_helper_sve2_sqdmlal_idx_s, false) | |
4077 | DO_SVE2_RRXR_TB(trans_SQDMLALB_zzxw_d, gen_helper_sve2_sqdmlal_idx_d, false) | |
4078 | DO_SVE2_RRXR_TB(trans_SQDMLALT_zzxw_s, gen_helper_sve2_sqdmlal_idx_s, true) | |
4079 | DO_SVE2_RRXR_TB(trans_SQDMLALT_zzxw_d, gen_helper_sve2_sqdmlal_idx_d, true) | |
4080 | ||
4081 | DO_SVE2_RRXR_TB(trans_SQDMLSLB_zzxw_s, gen_helper_sve2_sqdmlsl_idx_s, false) | |
4082 | DO_SVE2_RRXR_TB(trans_SQDMLSLB_zzxw_d, gen_helper_sve2_sqdmlsl_idx_d, false) | |
4083 | DO_SVE2_RRXR_TB(trans_SQDMLSLT_zzxw_s, gen_helper_sve2_sqdmlsl_idx_s, true) | |
4084 | DO_SVE2_RRXR_TB(trans_SQDMLSLT_zzxw_d, gen_helper_sve2_sqdmlsl_idx_d, true) | |
d462469f RH |
4085 | |
4086 | DO_SVE2_RRXR_TB(trans_SMLALB_zzxw_s, gen_helper_sve2_smlal_idx_s, false) | |
4087 | DO_SVE2_RRXR_TB(trans_SMLALB_zzxw_d, gen_helper_sve2_smlal_idx_d, false) | |
4088 | DO_SVE2_RRXR_TB(trans_SMLALT_zzxw_s, gen_helper_sve2_smlal_idx_s, true) | |
4089 | DO_SVE2_RRXR_TB(trans_SMLALT_zzxw_d, gen_helper_sve2_smlal_idx_d, true) | |
4090 | ||
4091 | DO_SVE2_RRXR_TB(trans_UMLALB_zzxw_s, gen_helper_sve2_umlal_idx_s, false) | |
4092 | DO_SVE2_RRXR_TB(trans_UMLALB_zzxw_d, gen_helper_sve2_umlal_idx_d, false) | |
4093 | DO_SVE2_RRXR_TB(trans_UMLALT_zzxw_s, gen_helper_sve2_umlal_idx_s, true) | |
4094 | DO_SVE2_RRXR_TB(trans_UMLALT_zzxw_d, gen_helper_sve2_umlal_idx_d, true) | |
4095 | ||
4096 | DO_SVE2_RRXR_TB(trans_SMLSLB_zzxw_s, gen_helper_sve2_smlsl_idx_s, false) | |
4097 | DO_SVE2_RRXR_TB(trans_SMLSLB_zzxw_d, gen_helper_sve2_smlsl_idx_d, false) | |
4098 | DO_SVE2_RRXR_TB(trans_SMLSLT_zzxw_s, gen_helper_sve2_smlsl_idx_s, true) | |
4099 | DO_SVE2_RRXR_TB(trans_SMLSLT_zzxw_d, gen_helper_sve2_smlsl_idx_d, true) | |
4100 | ||
4101 | DO_SVE2_RRXR_TB(trans_UMLSLB_zzxw_s, gen_helper_sve2_umlsl_idx_s, false) | |
4102 | DO_SVE2_RRXR_TB(trans_UMLSLB_zzxw_d, gen_helper_sve2_umlsl_idx_d, false) | |
4103 | DO_SVE2_RRXR_TB(trans_UMLSLT_zzxw_s, gen_helper_sve2_umlsl_idx_s, true) | |
4104 | DO_SVE2_RRXR_TB(trans_UMLSLT_zzxw_d, gen_helper_sve2_umlsl_idx_d, true) | |
c5c455d7 RH |
4105 | |
4106 | #undef DO_SVE2_RRXR_TB | |
4107 | ||
3b787ed8 RH |
4108 | #define DO_SVE2_RRXR_ROT(NAME, FUNC) \ |
4109 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ | |
4110 | { \ | |
4111 | return do_sve2_zzzz_data(s, a->rd, a->rn, a->rm, a->ra, \ | |
4112 | (a->index << 2) | a->rot, FUNC); \ | |
4113 | } | |
4114 | ||
4115 | DO_SVE2_RRXR_ROT(CMLA_zzxz_h, gen_helper_sve2_cmla_idx_h) | |
4116 | DO_SVE2_RRXR_ROT(CMLA_zzxz_s, gen_helper_sve2_cmla_idx_s) | |
4117 | ||
4118 | DO_SVE2_RRXR_ROT(SQRDCMLAH_zzxz_h, gen_helper_sve2_sqrdcmlah_idx_h) | |
4119 | DO_SVE2_RRXR_ROT(SQRDCMLAH_zzxz_s, gen_helper_sve2_sqrdcmlah_idx_s) | |
4120 | ||
21068f39 RH |
4121 | DO_SVE2_RRXR_ROT(CDOT_zzxw_s, gen_helper_sve2_cdot_idx_s) |
4122 | DO_SVE2_RRXR_ROT(CDOT_zzxw_d, gen_helper_sve2_cdot_idx_d) | |
4123 | ||
3b787ed8 RH |
4124 | #undef DO_SVE2_RRXR_ROT |
4125 | ||
ca40a6e6 RH |
4126 | /* |
4127 | *** SVE Floating Point Multiply-Add Indexed Group | |
4128 | */ | |
4129 | ||
0a82d963 | 4130 | static bool do_FMLA_zzxz(DisasContext *s, arg_rrxr_esz *a, bool sub) |
ca40a6e6 RH |
4131 | { |
4132 | static gen_helper_gvec_4_ptr * const fns[3] = { | |
4133 | gen_helper_gvec_fmla_idx_h, | |
4134 | gen_helper_gvec_fmla_idx_s, | |
4135 | gen_helper_gvec_fmla_idx_d, | |
4136 | }; | |
4137 | ||
4138 | if (sve_access_check(s)) { | |
4139 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4140 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
ca40a6e6 RH |
4141 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), |
4142 | vec_full_reg_offset(s, a->rn), | |
4143 | vec_full_reg_offset(s, a->rm), | |
4144 | vec_full_reg_offset(s, a->ra), | |
0a82d963 | 4145 | status, vsz, vsz, (a->index << 1) | sub, |
ca40a6e6 RH |
4146 | fns[a->esz - 1]); |
4147 | tcg_temp_free_ptr(status); | |
4148 | } | |
4149 | return true; | |
4150 | } | |
4151 | ||
0a82d963 RH |
4152 | static bool trans_FMLA_zzxz(DisasContext *s, arg_FMLA_zzxz *a) |
4153 | { | |
4154 | return do_FMLA_zzxz(s, a, false); | |
4155 | } | |
4156 | ||
4157 | static bool trans_FMLS_zzxz(DisasContext *s, arg_FMLA_zzxz *a) | |
4158 | { | |
4159 | return do_FMLA_zzxz(s, a, true); | |
4160 | } | |
4161 | ||
ca40a6e6 RH |
4162 | /* |
4163 | *** SVE Floating Point Multiply Indexed Group | |
4164 | */ | |
4165 | ||
3a7be554 | 4166 | static bool trans_FMUL_zzx(DisasContext *s, arg_FMUL_zzx *a) |
ca40a6e6 RH |
4167 | { |
4168 | static gen_helper_gvec_3_ptr * const fns[3] = { | |
4169 | gen_helper_gvec_fmul_idx_h, | |
4170 | gen_helper_gvec_fmul_idx_s, | |
4171 | gen_helper_gvec_fmul_idx_d, | |
4172 | }; | |
4173 | ||
4174 | if (sve_access_check(s)) { | |
4175 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4176 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
ca40a6e6 RH |
4177 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), |
4178 | vec_full_reg_offset(s, a->rn), | |
4179 | vec_full_reg_offset(s, a->rm), | |
4180 | status, vsz, vsz, a->index, fns[a->esz - 1]); | |
4181 | tcg_temp_free_ptr(status); | |
4182 | } | |
4183 | return true; | |
4184 | } | |
4185 | ||
23fbe79f RH |
4186 | /* |
4187 | *** SVE Floating Point Fast Reduction Group | |
4188 | */ | |
4189 | ||
4190 | typedef void gen_helper_fp_reduce(TCGv_i64, TCGv_ptr, TCGv_ptr, | |
4191 | TCGv_ptr, TCGv_i32); | |
4192 | ||
4193 | static void do_reduce(DisasContext *s, arg_rpr_esz *a, | |
4194 | gen_helper_fp_reduce *fn) | |
4195 | { | |
4196 | unsigned vsz = vec_full_reg_size(s); | |
4197 | unsigned p2vsz = pow2ceil(vsz); | |
c648c9b7 | 4198 | TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, vsz, p2vsz)); |
23fbe79f RH |
4199 | TCGv_ptr t_zn, t_pg, status; |
4200 | TCGv_i64 temp; | |
4201 | ||
4202 | temp = tcg_temp_new_i64(); | |
4203 | t_zn = tcg_temp_new_ptr(); | |
4204 | t_pg = tcg_temp_new_ptr(); | |
4205 | ||
4206 | tcg_gen_addi_ptr(t_zn, cpu_env, vec_full_reg_offset(s, a->rn)); | |
4207 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->pg)); | |
cdfb22bb | 4208 | status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
23fbe79f RH |
4209 | |
4210 | fn(temp, t_zn, t_pg, status, t_desc); | |
4211 | tcg_temp_free_ptr(t_zn); | |
4212 | tcg_temp_free_ptr(t_pg); | |
4213 | tcg_temp_free_ptr(status); | |
4214 | tcg_temp_free_i32(t_desc); | |
4215 | ||
4216 | write_fp_dreg(s, a->rd, temp); | |
4217 | tcg_temp_free_i64(temp); | |
4218 | } | |
4219 | ||
4220 | #define DO_VPZ(NAME, name) \ | |
3a7be554 | 4221 | static bool trans_##NAME(DisasContext *s, arg_rpr_esz *a) \ |
23fbe79f RH |
4222 | { \ |
4223 | static gen_helper_fp_reduce * const fns[3] = { \ | |
4224 | gen_helper_sve_##name##_h, \ | |
4225 | gen_helper_sve_##name##_s, \ | |
4226 | gen_helper_sve_##name##_d, \ | |
4227 | }; \ | |
4228 | if (a->esz == 0) { \ | |
4229 | return false; \ | |
4230 | } \ | |
4231 | if (sve_access_check(s)) { \ | |
4232 | do_reduce(s, a, fns[a->esz - 1]); \ | |
4233 | } \ | |
4234 | return true; \ | |
4235 | } | |
4236 | ||
4237 | DO_VPZ(FADDV, faddv) | |
4238 | DO_VPZ(FMINNMV, fminnmv) | |
4239 | DO_VPZ(FMAXNMV, fmaxnmv) | |
4240 | DO_VPZ(FMINV, fminv) | |
4241 | DO_VPZ(FMAXV, fmaxv) | |
4242 | ||
3887c038 RH |
4243 | /* |
4244 | *** SVE Floating Point Unary Operations - Unpredicated Group | |
4245 | */ | |
4246 | ||
4247 | static void do_zz_fp(DisasContext *s, arg_rr_esz *a, gen_helper_gvec_2_ptr *fn) | |
4248 | { | |
4249 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4250 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
3887c038 RH |
4251 | |
4252 | tcg_gen_gvec_2_ptr(vec_full_reg_offset(s, a->rd), | |
4253 | vec_full_reg_offset(s, a->rn), | |
4254 | status, vsz, vsz, 0, fn); | |
4255 | tcg_temp_free_ptr(status); | |
4256 | } | |
4257 | ||
3a7be554 | 4258 | static bool trans_FRECPE(DisasContext *s, arg_rr_esz *a) |
3887c038 RH |
4259 | { |
4260 | static gen_helper_gvec_2_ptr * const fns[3] = { | |
4261 | gen_helper_gvec_frecpe_h, | |
4262 | gen_helper_gvec_frecpe_s, | |
4263 | gen_helper_gvec_frecpe_d, | |
4264 | }; | |
4265 | if (a->esz == 0) { | |
4266 | return false; | |
4267 | } | |
4268 | if (sve_access_check(s)) { | |
4269 | do_zz_fp(s, a, fns[a->esz - 1]); | |
4270 | } | |
4271 | return true; | |
4272 | } | |
4273 | ||
3a7be554 | 4274 | static bool trans_FRSQRTE(DisasContext *s, arg_rr_esz *a) |
3887c038 RH |
4275 | { |
4276 | static gen_helper_gvec_2_ptr * const fns[3] = { | |
4277 | gen_helper_gvec_frsqrte_h, | |
4278 | gen_helper_gvec_frsqrte_s, | |
4279 | gen_helper_gvec_frsqrte_d, | |
4280 | }; | |
4281 | if (a->esz == 0) { | |
4282 | return false; | |
4283 | } | |
4284 | if (sve_access_check(s)) { | |
4285 | do_zz_fp(s, a, fns[a->esz - 1]); | |
4286 | } | |
4287 | return true; | |
4288 | } | |
4289 | ||
4d2e2a03 RH |
4290 | /* |
4291 | *** SVE Floating Point Compare with Zero Group | |
4292 | */ | |
4293 | ||
4294 | static void do_ppz_fp(DisasContext *s, arg_rpr_esz *a, | |
4295 | gen_helper_gvec_3_ptr *fn) | |
4296 | { | |
4297 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4298 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
4d2e2a03 RH |
4299 | |
4300 | tcg_gen_gvec_3_ptr(pred_full_reg_offset(s, a->rd), | |
4301 | vec_full_reg_offset(s, a->rn), | |
4302 | pred_full_reg_offset(s, a->pg), | |
4303 | status, vsz, vsz, 0, fn); | |
4304 | tcg_temp_free_ptr(status); | |
4305 | } | |
4306 | ||
4307 | #define DO_PPZ(NAME, name) \ | |
3a7be554 | 4308 | static bool trans_##NAME(DisasContext *s, arg_rpr_esz *a) \ |
4d2e2a03 RH |
4309 | { \ |
4310 | static gen_helper_gvec_3_ptr * const fns[3] = { \ | |
4311 | gen_helper_sve_##name##_h, \ | |
4312 | gen_helper_sve_##name##_s, \ | |
4313 | gen_helper_sve_##name##_d, \ | |
4314 | }; \ | |
4315 | if (a->esz == 0) { \ | |
4316 | return false; \ | |
4317 | } \ | |
4318 | if (sve_access_check(s)) { \ | |
4319 | do_ppz_fp(s, a, fns[a->esz - 1]); \ | |
4320 | } \ | |
4321 | return true; \ | |
4322 | } | |
4323 | ||
4324 | DO_PPZ(FCMGE_ppz0, fcmge0) | |
4325 | DO_PPZ(FCMGT_ppz0, fcmgt0) | |
4326 | DO_PPZ(FCMLE_ppz0, fcmle0) | |
4327 | DO_PPZ(FCMLT_ppz0, fcmlt0) | |
4328 | DO_PPZ(FCMEQ_ppz0, fcmeq0) | |
4329 | DO_PPZ(FCMNE_ppz0, fcmne0) | |
4330 | ||
4331 | #undef DO_PPZ | |
4332 | ||
67fcd9ad RH |
4333 | /* |
4334 | *** SVE floating-point trig multiply-add coefficient | |
4335 | */ | |
4336 | ||
3a7be554 | 4337 | static bool trans_FTMAD(DisasContext *s, arg_FTMAD *a) |
67fcd9ad RH |
4338 | { |
4339 | static gen_helper_gvec_3_ptr * const fns[3] = { | |
4340 | gen_helper_sve_ftmad_h, | |
4341 | gen_helper_sve_ftmad_s, | |
4342 | gen_helper_sve_ftmad_d, | |
4343 | }; | |
4344 | ||
4345 | if (a->esz == 0) { | |
4346 | return false; | |
4347 | } | |
4348 | if (sve_access_check(s)) { | |
4349 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4350 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
67fcd9ad RH |
4351 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), |
4352 | vec_full_reg_offset(s, a->rn), | |
4353 | vec_full_reg_offset(s, a->rm), | |
4354 | status, vsz, vsz, a->imm, fns[a->esz - 1]); | |
4355 | tcg_temp_free_ptr(status); | |
4356 | } | |
4357 | return true; | |
4358 | } | |
4359 | ||
7f9ddf64 RH |
4360 | /* |
4361 | *** SVE Floating Point Accumulating Reduction Group | |
4362 | */ | |
4363 | ||
3a7be554 | 4364 | static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a) |
7f9ddf64 RH |
4365 | { |
4366 | typedef void fadda_fn(TCGv_i64, TCGv_i64, TCGv_ptr, | |
4367 | TCGv_ptr, TCGv_ptr, TCGv_i32); | |
4368 | static fadda_fn * const fns[3] = { | |
4369 | gen_helper_sve_fadda_h, | |
4370 | gen_helper_sve_fadda_s, | |
4371 | gen_helper_sve_fadda_d, | |
4372 | }; | |
4373 | unsigned vsz = vec_full_reg_size(s); | |
4374 | TCGv_ptr t_rm, t_pg, t_fpst; | |
4375 | TCGv_i64 t_val; | |
4376 | TCGv_i32 t_desc; | |
4377 | ||
4378 | if (a->esz == 0) { | |
4379 | return false; | |
4380 | } | |
4381 | if (!sve_access_check(s)) { | |
4382 | return true; | |
4383 | } | |
4384 | ||
4385 | t_val = load_esz(cpu_env, vec_reg_offset(s, a->rn, 0, a->esz), a->esz); | |
4386 | t_rm = tcg_temp_new_ptr(); | |
4387 | t_pg = tcg_temp_new_ptr(); | |
4388 | tcg_gen_addi_ptr(t_rm, cpu_env, vec_full_reg_offset(s, a->rm)); | |
4389 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->pg)); | |
cdfb22bb | 4390 | t_fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
7f9ddf64 RH |
4391 | t_desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); |
4392 | ||
4393 | fns[a->esz - 1](t_val, t_val, t_rm, t_pg, t_fpst, t_desc); | |
4394 | ||
4395 | tcg_temp_free_i32(t_desc); | |
4396 | tcg_temp_free_ptr(t_fpst); | |
4397 | tcg_temp_free_ptr(t_pg); | |
4398 | tcg_temp_free_ptr(t_rm); | |
4399 | ||
4400 | write_fp_dreg(s, a->rd, t_val); | |
4401 | tcg_temp_free_i64(t_val); | |
4402 | return true; | |
4403 | } | |
4404 | ||
29b80469 RH |
4405 | /* |
4406 | *** SVE Floating Point Arithmetic - Unpredicated Group | |
4407 | */ | |
4408 | ||
4409 | static bool do_zzz_fp(DisasContext *s, arg_rrr_esz *a, | |
4410 | gen_helper_gvec_3_ptr *fn) | |
4411 | { | |
4412 | if (fn == NULL) { | |
4413 | return false; | |
4414 | } | |
4415 | if (sve_access_check(s)) { | |
4416 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4417 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
29b80469 RH |
4418 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), |
4419 | vec_full_reg_offset(s, a->rn), | |
4420 | vec_full_reg_offset(s, a->rm), | |
4421 | status, vsz, vsz, 0, fn); | |
4422 | tcg_temp_free_ptr(status); | |
4423 | } | |
4424 | return true; | |
4425 | } | |
4426 | ||
4427 | ||
4428 | #define DO_FP3(NAME, name) \ | |
3a7be554 | 4429 | static bool trans_##NAME(DisasContext *s, arg_rrr_esz *a) \ |
29b80469 RH |
4430 | { \ |
4431 | static gen_helper_gvec_3_ptr * const fns[4] = { \ | |
4432 | NULL, gen_helper_gvec_##name##_h, \ | |
4433 | gen_helper_gvec_##name##_s, gen_helper_gvec_##name##_d \ | |
4434 | }; \ | |
4435 | return do_zzz_fp(s, a, fns[a->esz]); \ | |
4436 | } | |
4437 | ||
4438 | DO_FP3(FADD_zzz, fadd) | |
4439 | DO_FP3(FSUB_zzz, fsub) | |
4440 | DO_FP3(FMUL_zzz, fmul) | |
4441 | DO_FP3(FTSMUL, ftsmul) | |
4442 | DO_FP3(FRECPS, recps) | |
4443 | DO_FP3(FRSQRTS, rsqrts) | |
4444 | ||
4445 | #undef DO_FP3 | |
4446 | ||
ec3b87c2 RH |
4447 | /* |
4448 | *** SVE Floating Point Arithmetic - Predicated Group | |
4449 | */ | |
4450 | ||
4451 | static bool do_zpzz_fp(DisasContext *s, arg_rprr_esz *a, | |
4452 | gen_helper_gvec_4_ptr *fn) | |
4453 | { | |
4454 | if (fn == NULL) { | |
4455 | return false; | |
4456 | } | |
4457 | if (sve_access_check(s)) { | |
4458 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4459 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
ec3b87c2 RH |
4460 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), |
4461 | vec_full_reg_offset(s, a->rn), | |
4462 | vec_full_reg_offset(s, a->rm), | |
4463 | pred_full_reg_offset(s, a->pg), | |
4464 | status, vsz, vsz, 0, fn); | |
4465 | tcg_temp_free_ptr(status); | |
4466 | } | |
4467 | return true; | |
4468 | } | |
4469 | ||
4470 | #define DO_FP3(NAME, name) \ | |
3a7be554 | 4471 | static bool trans_##NAME(DisasContext *s, arg_rprr_esz *a) \ |
ec3b87c2 RH |
4472 | { \ |
4473 | static gen_helper_gvec_4_ptr * const fns[4] = { \ | |
4474 | NULL, gen_helper_sve_##name##_h, \ | |
4475 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d \ | |
4476 | }; \ | |
4477 | return do_zpzz_fp(s, a, fns[a->esz]); \ | |
4478 | } | |
4479 | ||
4480 | DO_FP3(FADD_zpzz, fadd) | |
4481 | DO_FP3(FSUB_zpzz, fsub) | |
4482 | DO_FP3(FMUL_zpzz, fmul) | |
4483 | DO_FP3(FMIN_zpzz, fmin) | |
4484 | DO_FP3(FMAX_zpzz, fmax) | |
4485 | DO_FP3(FMINNM_zpzz, fminnum) | |
4486 | DO_FP3(FMAXNM_zpzz, fmaxnum) | |
4487 | DO_FP3(FABD, fabd) | |
4488 | DO_FP3(FSCALE, fscalbn) | |
4489 | DO_FP3(FDIV, fdiv) | |
4490 | DO_FP3(FMULX, fmulx) | |
4491 | ||
4492 | #undef DO_FP3 | |
8092c6a3 | 4493 | |
cc48affe RH |
4494 | typedef void gen_helper_sve_fp2scalar(TCGv_ptr, TCGv_ptr, TCGv_ptr, |
4495 | TCGv_i64, TCGv_ptr, TCGv_i32); | |
4496 | ||
4497 | static void do_fp_scalar(DisasContext *s, int zd, int zn, int pg, bool is_fp16, | |
4498 | TCGv_i64 scalar, gen_helper_sve_fp2scalar *fn) | |
4499 | { | |
4500 | unsigned vsz = vec_full_reg_size(s); | |
4501 | TCGv_ptr t_zd, t_zn, t_pg, status; | |
4502 | TCGv_i32 desc; | |
4503 | ||
4504 | t_zd = tcg_temp_new_ptr(); | |
4505 | t_zn = tcg_temp_new_ptr(); | |
4506 | t_pg = tcg_temp_new_ptr(); | |
4507 | tcg_gen_addi_ptr(t_zd, cpu_env, vec_full_reg_offset(s, zd)); | |
4508 | tcg_gen_addi_ptr(t_zn, cpu_env, vec_full_reg_offset(s, zn)); | |
4509 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | |
4510 | ||
cdfb22bb | 4511 | status = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_FPCR); |
cc48affe RH |
4512 | desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); |
4513 | fn(t_zd, t_zn, t_pg, scalar, status, desc); | |
4514 | ||
4515 | tcg_temp_free_i32(desc); | |
4516 | tcg_temp_free_ptr(status); | |
4517 | tcg_temp_free_ptr(t_pg); | |
4518 | tcg_temp_free_ptr(t_zn); | |
4519 | tcg_temp_free_ptr(t_zd); | |
4520 | } | |
4521 | ||
4522 | static void do_fp_imm(DisasContext *s, arg_rpri_esz *a, uint64_t imm, | |
4523 | gen_helper_sve_fp2scalar *fn) | |
4524 | { | |
4525 | TCGv_i64 temp = tcg_const_i64(imm); | |
4526 | do_fp_scalar(s, a->rd, a->rn, a->pg, a->esz == MO_16, temp, fn); | |
4527 | tcg_temp_free_i64(temp); | |
4528 | } | |
4529 | ||
4530 | #define DO_FP_IMM(NAME, name, const0, const1) \ | |
3a7be554 | 4531 | static bool trans_##NAME##_zpzi(DisasContext *s, arg_rpri_esz *a) \ |
cc48affe RH |
4532 | { \ |
4533 | static gen_helper_sve_fp2scalar * const fns[3] = { \ | |
4534 | gen_helper_sve_##name##_h, \ | |
4535 | gen_helper_sve_##name##_s, \ | |
4536 | gen_helper_sve_##name##_d \ | |
4537 | }; \ | |
4538 | static uint64_t const val[3][2] = { \ | |
4539 | { float16_##const0, float16_##const1 }, \ | |
4540 | { float32_##const0, float32_##const1 }, \ | |
4541 | { float64_##const0, float64_##const1 }, \ | |
4542 | }; \ | |
4543 | if (a->esz == 0) { \ | |
4544 | return false; \ | |
4545 | } \ | |
4546 | if (sve_access_check(s)) { \ | |
4547 | do_fp_imm(s, a, val[a->esz - 1][a->imm], fns[a->esz - 1]); \ | |
4548 | } \ | |
4549 | return true; \ | |
4550 | } | |
4551 | ||
cc48affe RH |
4552 | DO_FP_IMM(FADD, fadds, half, one) |
4553 | DO_FP_IMM(FSUB, fsubs, half, one) | |
4554 | DO_FP_IMM(FMUL, fmuls, half, two) | |
4555 | DO_FP_IMM(FSUBR, fsubrs, half, one) | |
4556 | DO_FP_IMM(FMAXNM, fmaxnms, zero, one) | |
4557 | DO_FP_IMM(FMINNM, fminnms, zero, one) | |
4558 | DO_FP_IMM(FMAX, fmaxs, zero, one) | |
4559 | DO_FP_IMM(FMIN, fmins, zero, one) | |
4560 | ||
4561 | #undef DO_FP_IMM | |
4562 | ||
abfdefd5 RH |
4563 | static bool do_fp_cmp(DisasContext *s, arg_rprr_esz *a, |
4564 | gen_helper_gvec_4_ptr *fn) | |
4565 | { | |
4566 | if (fn == NULL) { | |
4567 | return false; | |
4568 | } | |
4569 | if (sve_access_check(s)) { | |
4570 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4571 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
abfdefd5 RH |
4572 | tcg_gen_gvec_4_ptr(pred_full_reg_offset(s, a->rd), |
4573 | vec_full_reg_offset(s, a->rn), | |
4574 | vec_full_reg_offset(s, a->rm), | |
4575 | pred_full_reg_offset(s, a->pg), | |
4576 | status, vsz, vsz, 0, fn); | |
4577 | tcg_temp_free_ptr(status); | |
4578 | } | |
4579 | return true; | |
4580 | } | |
4581 | ||
4582 | #define DO_FPCMP(NAME, name) \ | |
3a7be554 | 4583 | static bool trans_##NAME##_ppzz(DisasContext *s, arg_rprr_esz *a) \ |
abfdefd5 RH |
4584 | { \ |
4585 | static gen_helper_gvec_4_ptr * const fns[4] = { \ | |
4586 | NULL, gen_helper_sve_##name##_h, \ | |
4587 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d \ | |
4588 | }; \ | |
4589 | return do_fp_cmp(s, a, fns[a->esz]); \ | |
4590 | } | |
4591 | ||
4592 | DO_FPCMP(FCMGE, fcmge) | |
4593 | DO_FPCMP(FCMGT, fcmgt) | |
4594 | DO_FPCMP(FCMEQ, fcmeq) | |
4595 | DO_FPCMP(FCMNE, fcmne) | |
4596 | DO_FPCMP(FCMUO, fcmuo) | |
4597 | DO_FPCMP(FACGE, facge) | |
4598 | DO_FPCMP(FACGT, facgt) | |
4599 | ||
4600 | #undef DO_FPCMP | |
4601 | ||
3a7be554 | 4602 | static bool trans_FCADD(DisasContext *s, arg_FCADD *a) |
76a9d9cd RH |
4603 | { |
4604 | static gen_helper_gvec_4_ptr * const fns[3] = { | |
4605 | gen_helper_sve_fcadd_h, | |
4606 | gen_helper_sve_fcadd_s, | |
4607 | gen_helper_sve_fcadd_d | |
4608 | }; | |
4609 | ||
4610 | if (a->esz == 0) { | |
4611 | return false; | |
4612 | } | |
4613 | if (sve_access_check(s)) { | |
4614 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4615 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
76a9d9cd RH |
4616 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), |
4617 | vec_full_reg_offset(s, a->rn), | |
4618 | vec_full_reg_offset(s, a->rm), | |
4619 | pred_full_reg_offset(s, a->pg), | |
4620 | status, vsz, vsz, a->rot, fns[a->esz - 1]); | |
4621 | tcg_temp_free_ptr(status); | |
4622 | } | |
4623 | return true; | |
4624 | } | |
4625 | ||
08975da9 RH |
4626 | static bool do_fmla(DisasContext *s, arg_rprrr_esz *a, |
4627 | gen_helper_gvec_5_ptr *fn) | |
6ceabaad | 4628 | { |
08975da9 | 4629 | if (a->esz == 0) { |
6ceabaad RH |
4630 | return false; |
4631 | } | |
08975da9 RH |
4632 | if (sve_access_check(s)) { |
4633 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4634 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
08975da9 RH |
4635 | tcg_gen_gvec_5_ptr(vec_full_reg_offset(s, a->rd), |
4636 | vec_full_reg_offset(s, a->rn), | |
4637 | vec_full_reg_offset(s, a->rm), | |
4638 | vec_full_reg_offset(s, a->ra), | |
4639 | pred_full_reg_offset(s, a->pg), | |
4640 | status, vsz, vsz, 0, fn); | |
4641 | tcg_temp_free_ptr(status); | |
6ceabaad | 4642 | } |
6ceabaad RH |
4643 | return true; |
4644 | } | |
4645 | ||
4646 | #define DO_FMLA(NAME, name) \ | |
3a7be554 | 4647 | static bool trans_##NAME(DisasContext *s, arg_rprrr_esz *a) \ |
6ceabaad | 4648 | { \ |
08975da9 | 4649 | static gen_helper_gvec_5_ptr * const fns[4] = { \ |
6ceabaad RH |
4650 | NULL, gen_helper_sve_##name##_h, \ |
4651 | gen_helper_sve_##name##_s, gen_helper_sve_##name##_d \ | |
4652 | }; \ | |
4653 | return do_fmla(s, a, fns[a->esz]); \ | |
4654 | } | |
4655 | ||
4656 | DO_FMLA(FMLA_zpzzz, fmla_zpzzz) | |
4657 | DO_FMLA(FMLS_zpzzz, fmls_zpzzz) | |
4658 | DO_FMLA(FNMLA_zpzzz, fnmla_zpzzz) | |
4659 | DO_FMLA(FNMLS_zpzzz, fnmls_zpzzz) | |
4660 | ||
4661 | #undef DO_FMLA | |
4662 | ||
3a7be554 | 4663 | static bool trans_FCMLA_zpzzz(DisasContext *s, arg_FCMLA_zpzzz *a) |
05f48bab | 4664 | { |
08975da9 RH |
4665 | static gen_helper_gvec_5_ptr * const fns[4] = { |
4666 | NULL, | |
05f48bab RH |
4667 | gen_helper_sve_fcmla_zpzzz_h, |
4668 | gen_helper_sve_fcmla_zpzzz_s, | |
4669 | gen_helper_sve_fcmla_zpzzz_d, | |
4670 | }; | |
4671 | ||
4672 | if (a->esz == 0) { | |
4673 | return false; | |
4674 | } | |
4675 | if (sve_access_check(s)) { | |
4676 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4677 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
08975da9 RH |
4678 | tcg_gen_gvec_5_ptr(vec_full_reg_offset(s, a->rd), |
4679 | vec_full_reg_offset(s, a->rn), | |
4680 | vec_full_reg_offset(s, a->rm), | |
4681 | vec_full_reg_offset(s, a->ra), | |
4682 | pred_full_reg_offset(s, a->pg), | |
4683 | status, vsz, vsz, a->rot, fns[a->esz]); | |
4684 | tcg_temp_free_ptr(status); | |
05f48bab RH |
4685 | } |
4686 | return true; | |
4687 | } | |
4688 | ||
3a7be554 | 4689 | static bool trans_FCMLA_zzxz(DisasContext *s, arg_FCMLA_zzxz *a) |
18fc2405 | 4690 | { |
636ddeb1 | 4691 | static gen_helper_gvec_4_ptr * const fns[2] = { |
18fc2405 RH |
4692 | gen_helper_gvec_fcmlah_idx, |
4693 | gen_helper_gvec_fcmlas_idx, | |
4694 | }; | |
4695 | ||
4696 | tcg_debug_assert(a->esz == 1 || a->esz == 2); | |
4697 | tcg_debug_assert(a->rd == a->ra); | |
4698 | if (sve_access_check(s)) { | |
4699 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4700 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
636ddeb1 | 4701 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), |
18fc2405 RH |
4702 | vec_full_reg_offset(s, a->rn), |
4703 | vec_full_reg_offset(s, a->rm), | |
636ddeb1 | 4704 | vec_full_reg_offset(s, a->ra), |
18fc2405 RH |
4705 | status, vsz, vsz, |
4706 | a->index * 4 + a->rot, | |
4707 | fns[a->esz - 1]); | |
4708 | tcg_temp_free_ptr(status); | |
4709 | } | |
4710 | return true; | |
4711 | } | |
4712 | ||
8092c6a3 RH |
4713 | /* |
4714 | *** SVE Floating Point Unary Operations Predicated Group | |
4715 | */ | |
4716 | ||
4717 | static bool do_zpz_ptr(DisasContext *s, int rd, int rn, int pg, | |
4718 | bool is_fp16, gen_helper_gvec_3_ptr *fn) | |
4719 | { | |
4720 | if (sve_access_check(s)) { | |
4721 | unsigned vsz = vec_full_reg_size(s); | |
cdfb22bb | 4722 | TCGv_ptr status = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_FPCR); |
8092c6a3 RH |
4723 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), |
4724 | vec_full_reg_offset(s, rn), | |
4725 | pred_full_reg_offset(s, pg), | |
4726 | status, vsz, vsz, 0, fn); | |
4727 | tcg_temp_free_ptr(status); | |
4728 | } | |
4729 | return true; | |
4730 | } | |
4731 | ||
3a7be554 | 4732 | static bool trans_FCVT_sh(DisasContext *s, arg_rpr_esz *a) |
46d33d1e | 4733 | { |
e4ab5124 | 4734 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_sh); |
46d33d1e RH |
4735 | } |
4736 | ||
3a7be554 | 4737 | static bool trans_FCVT_hs(DisasContext *s, arg_rpr_esz *a) |
46d33d1e RH |
4738 | { |
4739 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_hs); | |
4740 | } | |
4741 | ||
d29b17ca RH |
4742 | static bool trans_BFCVT(DisasContext *s, arg_rpr_esz *a) |
4743 | { | |
4744 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
4745 | return false; | |
4746 | } | |
4747 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_bfcvt); | |
4748 | } | |
4749 | ||
3a7be554 | 4750 | static bool trans_FCVT_dh(DisasContext *s, arg_rpr_esz *a) |
46d33d1e | 4751 | { |
e4ab5124 | 4752 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_dh); |
46d33d1e RH |
4753 | } |
4754 | ||
3a7be554 | 4755 | static bool trans_FCVT_hd(DisasContext *s, arg_rpr_esz *a) |
46d33d1e RH |
4756 | { |
4757 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_hd); | |
4758 | } | |
4759 | ||
3a7be554 | 4760 | static bool trans_FCVT_ds(DisasContext *s, arg_rpr_esz *a) |
46d33d1e RH |
4761 | { |
4762 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_ds); | |
4763 | } | |
4764 | ||
3a7be554 | 4765 | static bool trans_FCVT_sd(DisasContext *s, arg_rpr_esz *a) |
46d33d1e RH |
4766 | { |
4767 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_sd); | |
4768 | } | |
4769 | ||
3a7be554 | 4770 | static bool trans_FCVTZS_hh(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4771 | { |
4772 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzs_hh); | |
4773 | } | |
4774 | ||
3a7be554 | 4775 | static bool trans_FCVTZU_hh(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4776 | { |
4777 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzu_hh); | |
4778 | } | |
4779 | ||
3a7be554 | 4780 | static bool trans_FCVTZS_hs(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4781 | { |
4782 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzs_hs); | |
4783 | } | |
4784 | ||
3a7be554 | 4785 | static bool trans_FCVTZU_hs(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4786 | { |
4787 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzu_hs); | |
4788 | } | |
4789 | ||
3a7be554 | 4790 | static bool trans_FCVTZS_hd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4791 | { |
4792 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzs_hd); | |
4793 | } | |
4794 | ||
3a7be554 | 4795 | static bool trans_FCVTZU_hd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4796 | { |
4797 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvtzu_hd); | |
4798 | } | |
4799 | ||
3a7be554 | 4800 | static bool trans_FCVTZS_ss(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4801 | { |
4802 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzs_ss); | |
4803 | } | |
4804 | ||
3a7be554 | 4805 | static bool trans_FCVTZU_ss(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4806 | { |
4807 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_ss); | |
4808 | } | |
4809 | ||
3a7be554 | 4810 | static bool trans_FCVTZS_sd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4811 | { |
4812 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzs_sd); | |
4813 | } | |
4814 | ||
3a7be554 | 4815 | static bool trans_FCVTZU_sd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4816 | { |
4817 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_sd); | |
4818 | } | |
4819 | ||
3a7be554 | 4820 | static bool trans_FCVTZS_ds(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4821 | { |
4822 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzs_ds); | |
4823 | } | |
4824 | ||
3a7be554 | 4825 | static bool trans_FCVTZU_ds(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4826 | { |
4827 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_ds); | |
4828 | } | |
4829 | ||
3a7be554 | 4830 | static bool trans_FCVTZS_dd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4831 | { |
4832 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzs_dd); | |
4833 | } | |
4834 | ||
3a7be554 | 4835 | static bool trans_FCVTZU_dd(DisasContext *s, arg_rpr_esz *a) |
df4de1af RH |
4836 | { |
4837 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_dd); | |
4838 | } | |
4839 | ||
cda3c753 RH |
4840 | static gen_helper_gvec_3_ptr * const frint_fns[3] = { |
4841 | gen_helper_sve_frint_h, | |
4842 | gen_helper_sve_frint_s, | |
4843 | gen_helper_sve_frint_d | |
4844 | }; | |
4845 | ||
3a7be554 | 4846 | static bool trans_FRINTI(DisasContext *s, arg_rpr_esz *a) |
cda3c753 RH |
4847 | { |
4848 | if (a->esz == 0) { | |
4849 | return false; | |
4850 | } | |
4851 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, | |
4852 | frint_fns[a->esz - 1]); | |
4853 | } | |
4854 | ||
3a7be554 | 4855 | static bool trans_FRINTX(DisasContext *s, arg_rpr_esz *a) |
cda3c753 RH |
4856 | { |
4857 | static gen_helper_gvec_3_ptr * const fns[3] = { | |
4858 | gen_helper_sve_frintx_h, | |
4859 | gen_helper_sve_frintx_s, | |
4860 | gen_helper_sve_frintx_d | |
4861 | }; | |
4862 | if (a->esz == 0) { | |
4863 | return false; | |
4864 | } | |
4865 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]); | |
4866 | } | |
4867 | ||
95365277 SL |
4868 | static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, |
4869 | int mode, gen_helper_gvec_3_ptr *fn) | |
cda3c753 | 4870 | { |
cda3c753 RH |
4871 | if (sve_access_check(s)) { |
4872 | unsigned vsz = vec_full_reg_size(s); | |
4873 | TCGv_i32 tmode = tcg_const_i32(mode); | |
cdfb22bb | 4874 | TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); |
cda3c753 RH |
4875 | |
4876 | gen_helper_set_rmode(tmode, tmode, status); | |
4877 | ||
4878 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), | |
4879 | vec_full_reg_offset(s, a->rn), | |
4880 | pred_full_reg_offset(s, a->pg), | |
95365277 | 4881 | status, vsz, vsz, 0, fn); |
cda3c753 RH |
4882 | |
4883 | gen_helper_set_rmode(tmode, tmode, status); | |
4884 | tcg_temp_free_i32(tmode); | |
4885 | tcg_temp_free_ptr(status); | |
4886 | } | |
4887 | return true; | |
4888 | } | |
4889 | ||
3a7be554 | 4890 | static bool trans_FRINTN(DisasContext *s, arg_rpr_esz *a) |
cda3c753 | 4891 | { |
95365277 SL |
4892 | if (a->esz == 0) { |
4893 | return false; | |
4894 | } | |
4895 | return do_frint_mode(s, a, float_round_nearest_even, frint_fns[a->esz - 1]); | |
cda3c753 RH |
4896 | } |
4897 | ||
3a7be554 | 4898 | static bool trans_FRINTP(DisasContext *s, arg_rpr_esz *a) |
cda3c753 | 4899 | { |
95365277 SL |
4900 | if (a->esz == 0) { |
4901 | return false; | |
4902 | } | |
4903 | return do_frint_mode(s, a, float_round_up, frint_fns[a->esz - 1]); | |
cda3c753 RH |
4904 | } |
4905 | ||
3a7be554 | 4906 | static bool trans_FRINTM(DisasContext *s, arg_rpr_esz *a) |
cda3c753 | 4907 | { |
95365277 SL |
4908 | if (a->esz == 0) { |
4909 | return false; | |
4910 | } | |
4911 | return do_frint_mode(s, a, float_round_down, frint_fns[a->esz - 1]); | |
cda3c753 RH |
4912 | } |
4913 | ||
3a7be554 | 4914 | static bool trans_FRINTZ(DisasContext *s, arg_rpr_esz *a) |
cda3c753 | 4915 | { |
95365277 SL |
4916 | if (a->esz == 0) { |
4917 | return false; | |
4918 | } | |
4919 | return do_frint_mode(s, a, float_round_to_zero, frint_fns[a->esz - 1]); | |
cda3c753 RH |
4920 | } |
4921 | ||
3a7be554 | 4922 | static bool trans_FRINTA(DisasContext *s, arg_rpr_esz *a) |
cda3c753 | 4923 | { |
95365277 SL |
4924 | if (a->esz == 0) { |
4925 | return false; | |
4926 | } | |
4927 | return do_frint_mode(s, a, float_round_ties_away, frint_fns[a->esz - 1]); | |
cda3c753 RH |
4928 | } |
4929 | ||
3a7be554 | 4930 | static bool trans_FRECPX(DisasContext *s, arg_rpr_esz *a) |
ec5b375b RH |
4931 | { |
4932 | static gen_helper_gvec_3_ptr * const fns[3] = { | |
4933 | gen_helper_sve_frecpx_h, | |
4934 | gen_helper_sve_frecpx_s, | |
4935 | gen_helper_sve_frecpx_d | |
4936 | }; | |
4937 | if (a->esz == 0) { | |
4938 | return false; | |
4939 | } | |
4940 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]); | |
4941 | } | |
4942 | ||
3a7be554 | 4943 | static bool trans_FSQRT(DisasContext *s, arg_rpr_esz *a) |
ec5b375b RH |
4944 | { |
4945 | static gen_helper_gvec_3_ptr * const fns[3] = { | |
4946 | gen_helper_sve_fsqrt_h, | |
4947 | gen_helper_sve_fsqrt_s, | |
4948 | gen_helper_sve_fsqrt_d | |
4949 | }; | |
4950 | if (a->esz == 0) { | |
4951 | return false; | |
4952 | } | |
4953 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]); | |
4954 | } | |
4955 | ||
3a7be554 | 4956 | static bool trans_SCVTF_hh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4957 | { |
4958 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_scvt_hh); | |
4959 | } | |
4960 | ||
3a7be554 | 4961 | static bool trans_SCVTF_sh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4962 | { |
4963 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_scvt_sh); | |
4964 | } | |
4965 | ||
3a7be554 | 4966 | static bool trans_SCVTF_dh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4967 | { |
4968 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_scvt_dh); | |
4969 | } | |
4970 | ||
3a7be554 | 4971 | static bool trans_SCVTF_ss(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4972 | { |
4973 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_scvt_ss); | |
4974 | } | |
4975 | ||
3a7be554 | 4976 | static bool trans_SCVTF_ds(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4977 | { |
4978 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_scvt_ds); | |
4979 | } | |
4980 | ||
3a7be554 | 4981 | static bool trans_SCVTF_sd(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4982 | { |
4983 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_scvt_sd); | |
4984 | } | |
4985 | ||
3a7be554 | 4986 | static bool trans_SCVTF_dd(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4987 | { |
4988 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_scvt_dd); | |
4989 | } | |
4990 | ||
3a7be554 | 4991 | static bool trans_UCVTF_hh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4992 | { |
4993 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_ucvt_hh); | |
4994 | } | |
4995 | ||
3a7be554 | 4996 | static bool trans_UCVTF_sh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
4997 | { |
4998 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_ucvt_sh); | |
4999 | } | |
5000 | ||
3a7be554 | 5001 | static bool trans_UCVTF_dh(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
5002 | { |
5003 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_ucvt_dh); | |
5004 | } | |
5005 | ||
3a7be554 | 5006 | static bool trans_UCVTF_ss(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
5007 | { |
5008 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_ucvt_ss); | |
5009 | } | |
5010 | ||
3a7be554 | 5011 | static bool trans_UCVTF_ds(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
5012 | { |
5013 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_ucvt_ds); | |
5014 | } | |
5015 | ||
3a7be554 | 5016 | static bool trans_UCVTF_sd(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
5017 | { |
5018 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_ucvt_sd); | |
5019 | } | |
5020 | ||
3a7be554 | 5021 | static bool trans_UCVTF_dd(DisasContext *s, arg_rpr_esz *a) |
8092c6a3 RH |
5022 | { |
5023 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_ucvt_dd); | |
5024 | } | |
5025 | ||
d1822297 RH |
5026 | /* |
5027 | *** SVE Memory - 32-bit Gather and Unsized Contiguous Group | |
5028 | */ | |
5029 | ||
5030 | /* Subroutine loading a vector register at VOFS of LEN bytes. | |
5031 | * The load should begin at the address Rn + IMM. | |
5032 | */ | |
5033 | ||
19f2acc9 | 5034 | static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
d1822297 | 5035 | { |
19f2acc9 RH |
5036 | int len_align = QEMU_ALIGN_DOWN(len, 8); |
5037 | int len_remain = len % 8; | |
5038 | int nparts = len / 8 + ctpop8(len_remain); | |
d1822297 | 5039 | int midx = get_mem_index(s); |
b2aa8879 | 5040 | TCGv_i64 dirty_addr, clean_addr, t0, t1; |
d1822297 | 5041 | |
b2aa8879 RH |
5042 | dirty_addr = tcg_temp_new_i64(); |
5043 | tcg_gen_addi_i64(dirty_addr, cpu_reg_sp(s, rn), imm); | |
33e74c31 | 5044 | clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len); |
b2aa8879 | 5045 | tcg_temp_free_i64(dirty_addr); |
d1822297 | 5046 | |
b2aa8879 RH |
5047 | /* |
5048 | * Note that unpredicated load/store of vector/predicate registers | |
d1822297 | 5049 | * are defined as a stream of bytes, which equates to little-endian |
b2aa8879 | 5050 | * operations on larger quantities. |
d1822297 RH |
5051 | * Attempt to keep code expansion to a minimum by limiting the |
5052 | * amount of unrolling done. | |
5053 | */ | |
5054 | if (nparts <= 4) { | |
5055 | int i; | |
5056 | ||
b2aa8879 | 5057 | t0 = tcg_temp_new_i64(); |
d1822297 | 5058 | for (i = 0; i < len_align; i += 8) { |
fc313c64 | 5059 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEUQ); |
d1822297 | 5060 | tcg_gen_st_i64(t0, cpu_env, vofs + i); |
d8227b09 | 5061 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
d1822297 | 5062 | } |
b2aa8879 | 5063 | tcg_temp_free_i64(t0); |
d1822297 RH |
5064 | } else { |
5065 | TCGLabel *loop = gen_new_label(); | |
5066 | TCGv_ptr tp, i = tcg_const_local_ptr(0); | |
5067 | ||
b2aa8879 RH |
5068 | /* Copy the clean address into a local temp, live across the loop. */ |
5069 | t0 = clean_addr; | |
4b4dc975 | 5070 | clean_addr = new_tmp_a64_local(s); |
b2aa8879 | 5071 | tcg_gen_mov_i64(clean_addr, t0); |
d1822297 | 5072 | |
b2aa8879 | 5073 | gen_set_label(loop); |
d1822297 | 5074 | |
b2aa8879 | 5075 | t0 = tcg_temp_new_i64(); |
fc313c64 | 5076 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEUQ); |
b2aa8879 | 5077 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
d1822297 | 5078 | |
b2aa8879 | 5079 | tp = tcg_temp_new_ptr(); |
d1822297 RH |
5080 | tcg_gen_add_ptr(tp, cpu_env, i); |
5081 | tcg_gen_addi_ptr(i, i, 8); | |
5082 | tcg_gen_st_i64(t0, tp, vofs); | |
5083 | tcg_temp_free_ptr(tp); | |
b2aa8879 | 5084 | tcg_temp_free_i64(t0); |
d1822297 RH |
5085 | |
5086 | tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); | |
5087 | tcg_temp_free_ptr(i); | |
5088 | } | |
5089 | ||
b2aa8879 RH |
5090 | /* |
5091 | * Predicate register loads can be any multiple of 2. | |
d1822297 RH |
5092 | * Note that we still store the entire 64-bit unit into cpu_env. |
5093 | */ | |
5094 | if (len_remain) { | |
b2aa8879 | 5095 | t0 = tcg_temp_new_i64(); |
d1822297 RH |
5096 | switch (len_remain) { |
5097 | case 2: | |
5098 | case 4: | |
5099 | case 8: | |
b2aa8879 RH |
5100 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, |
5101 | MO_LE | ctz32(len_remain)); | |
d1822297 RH |
5102 | break; |
5103 | ||
5104 | case 6: | |
5105 | t1 = tcg_temp_new_i64(); | |
b2aa8879 RH |
5106 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEUL); |
5107 | tcg_gen_addi_i64(clean_addr, clean_addr, 4); | |
5108 | tcg_gen_qemu_ld_i64(t1, clean_addr, midx, MO_LEUW); | |
d1822297 RH |
5109 | tcg_gen_deposit_i64(t0, t0, t1, 32, 32); |
5110 | tcg_temp_free_i64(t1); | |
5111 | break; | |
5112 | ||
5113 | default: | |
5114 | g_assert_not_reached(); | |
5115 | } | |
5116 | tcg_gen_st_i64(t0, cpu_env, vofs + len_align); | |
b2aa8879 | 5117 | tcg_temp_free_i64(t0); |
d1822297 | 5118 | } |
d1822297 RH |
5119 | } |
5120 | ||
5047c204 | 5121 | /* Similarly for stores. */ |
19f2acc9 | 5122 | static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
5047c204 | 5123 | { |
19f2acc9 RH |
5124 | int len_align = QEMU_ALIGN_DOWN(len, 8); |
5125 | int len_remain = len % 8; | |
5126 | int nparts = len / 8 + ctpop8(len_remain); | |
5047c204 | 5127 | int midx = get_mem_index(s); |
bba87d0a | 5128 | TCGv_i64 dirty_addr, clean_addr, t0; |
5047c204 | 5129 | |
bba87d0a RH |
5130 | dirty_addr = tcg_temp_new_i64(); |
5131 | tcg_gen_addi_i64(dirty_addr, cpu_reg_sp(s, rn), imm); | |
33e74c31 | 5132 | clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len); |
bba87d0a | 5133 | tcg_temp_free_i64(dirty_addr); |
5047c204 RH |
5134 | |
5135 | /* Note that unpredicated load/store of vector/predicate registers | |
5136 | * are defined as a stream of bytes, which equates to little-endian | |
5137 | * operations on larger quantities. There is no nice way to force | |
5138 | * a little-endian store for aarch64_be-linux-user out of line. | |
5139 | * | |
5140 | * Attempt to keep code expansion to a minimum by limiting the | |
5141 | * amount of unrolling done. | |
5142 | */ | |
5143 | if (nparts <= 4) { | |
5144 | int i; | |
5145 | ||
bba87d0a | 5146 | t0 = tcg_temp_new_i64(); |
5047c204 RH |
5147 | for (i = 0; i < len_align; i += 8) { |
5148 | tcg_gen_ld_i64(t0, cpu_env, vofs + i); | |
fc313c64 | 5149 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUQ); |
d8227b09 | 5150 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
5047c204 | 5151 | } |
bba87d0a | 5152 | tcg_temp_free_i64(t0); |
5047c204 RH |
5153 | } else { |
5154 | TCGLabel *loop = gen_new_label(); | |
bba87d0a | 5155 | TCGv_ptr tp, i = tcg_const_local_ptr(0); |
5047c204 | 5156 | |
bba87d0a RH |
5157 | /* Copy the clean address into a local temp, live across the loop. */ |
5158 | t0 = clean_addr; | |
4b4dc975 | 5159 | clean_addr = new_tmp_a64_local(s); |
bba87d0a | 5160 | tcg_gen_mov_i64(clean_addr, t0); |
5047c204 | 5161 | |
bba87d0a | 5162 | gen_set_label(loop); |
5047c204 | 5163 | |
bba87d0a RH |
5164 | t0 = tcg_temp_new_i64(); |
5165 | tp = tcg_temp_new_ptr(); | |
5166 | tcg_gen_add_ptr(tp, cpu_env, i); | |
5167 | tcg_gen_ld_i64(t0, tp, vofs); | |
5047c204 | 5168 | tcg_gen_addi_ptr(i, i, 8); |
bba87d0a RH |
5169 | tcg_temp_free_ptr(tp); |
5170 | ||
fc313c64 | 5171 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUQ); |
bba87d0a RH |
5172 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
5173 | tcg_temp_free_i64(t0); | |
5047c204 RH |
5174 | |
5175 | tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); | |
5176 | tcg_temp_free_ptr(i); | |
5177 | } | |
5178 | ||
5179 | /* Predicate register stores can be any multiple of 2. */ | |
5180 | if (len_remain) { | |
bba87d0a | 5181 | t0 = tcg_temp_new_i64(); |
5047c204 | 5182 | tcg_gen_ld_i64(t0, cpu_env, vofs + len_align); |
5047c204 RH |
5183 | |
5184 | switch (len_remain) { | |
5185 | case 2: | |
5186 | case 4: | |
5187 | case 8: | |
bba87d0a RH |
5188 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, |
5189 | MO_LE | ctz32(len_remain)); | |
5047c204 RH |
5190 | break; |
5191 | ||
5192 | case 6: | |
bba87d0a RH |
5193 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUL); |
5194 | tcg_gen_addi_i64(clean_addr, clean_addr, 4); | |
5047c204 | 5195 | tcg_gen_shri_i64(t0, t0, 32); |
bba87d0a | 5196 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUW); |
5047c204 RH |
5197 | break; |
5198 | ||
5199 | default: | |
5200 | g_assert_not_reached(); | |
5201 | } | |
bba87d0a | 5202 | tcg_temp_free_i64(t0); |
5047c204 | 5203 | } |
5047c204 RH |
5204 | } |
5205 | ||
3a7be554 | 5206 | static bool trans_LDR_zri(DisasContext *s, arg_rri *a) |
d1822297 RH |
5207 | { |
5208 | if (sve_access_check(s)) { | |
5209 | int size = vec_full_reg_size(s); | |
5210 | int off = vec_full_reg_offset(s, a->rd); | |
5211 | do_ldr(s, off, size, a->rn, a->imm * size); | |
5212 | } | |
5213 | return true; | |
5214 | } | |
5215 | ||
3a7be554 | 5216 | static bool trans_LDR_pri(DisasContext *s, arg_rri *a) |
d1822297 RH |
5217 | { |
5218 | if (sve_access_check(s)) { | |
5219 | int size = pred_full_reg_size(s); | |
5220 | int off = pred_full_reg_offset(s, a->rd); | |
5221 | do_ldr(s, off, size, a->rn, a->imm * size); | |
5222 | } | |
5223 | return true; | |
5224 | } | |
c4e7c493 | 5225 | |
3a7be554 | 5226 | static bool trans_STR_zri(DisasContext *s, arg_rri *a) |
5047c204 RH |
5227 | { |
5228 | if (sve_access_check(s)) { | |
5229 | int size = vec_full_reg_size(s); | |
5230 | int off = vec_full_reg_offset(s, a->rd); | |
5231 | do_str(s, off, size, a->rn, a->imm * size); | |
5232 | } | |
5233 | return true; | |
5234 | } | |
5235 | ||
3a7be554 | 5236 | static bool trans_STR_pri(DisasContext *s, arg_rri *a) |
5047c204 RH |
5237 | { |
5238 | if (sve_access_check(s)) { | |
5239 | int size = pred_full_reg_size(s); | |
5240 | int off = pred_full_reg_offset(s, a->rd); | |
5241 | do_str(s, off, size, a->rn, a->imm * size); | |
5242 | } | |
5243 | return true; | |
5244 | } | |
5245 | ||
c4e7c493 RH |
5246 | /* |
5247 | *** SVE Memory - Contiguous Load Group | |
5248 | */ | |
5249 | ||
5250 | /* The memory mode of the dtype. */ | |
14776ab5 | 5251 | static const MemOp dtype_mop[16] = { |
c4e7c493 RH |
5252 | MO_UB, MO_UB, MO_UB, MO_UB, |
5253 | MO_SL, MO_UW, MO_UW, MO_UW, | |
5254 | MO_SW, MO_SW, MO_UL, MO_UL, | |
fc313c64 | 5255 | MO_SB, MO_SB, MO_SB, MO_UQ |
c4e7c493 RH |
5256 | }; |
5257 | ||
5258 | #define dtype_msz(x) (dtype_mop[x] & MO_SIZE) | |
5259 | ||
5260 | /* The vector element size of dtype. */ | |
5261 | static const uint8_t dtype_esz[16] = { | |
5262 | 0, 1, 2, 3, | |
5263 | 3, 1, 2, 3, | |
5264 | 3, 2, 2, 3, | |
5265 | 3, 2, 1, 3 | |
5266 | }; | |
5267 | ||
5268 | static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | |
206adacf RH |
5269 | int dtype, uint32_t mte_n, bool is_write, |
5270 | gen_helper_gvec_mem *fn) | |
c4e7c493 RH |
5271 | { |
5272 | unsigned vsz = vec_full_reg_size(s); | |
5273 | TCGv_ptr t_pg; | |
500d0484 | 5274 | TCGv_i32 t_desc; |
206adacf | 5275 | int desc = 0; |
c4e7c493 | 5276 | |
206adacf RH |
5277 | /* |
5278 | * For e.g. LD4, there are not enough arguments to pass all 4 | |
c4e7c493 RH |
5279 | * registers as pointers, so encode the regno into the data field. |
5280 | * For consistency, do this even for LD1. | |
5281 | */ | |
9473d0ec | 5282 | if (s->mte_active[0]) { |
206adacf RH |
5283 | int msz = dtype_msz(dtype); |
5284 | ||
5285 | desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | |
5286 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | |
5287 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | |
5288 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | |
28f32503 | 5289 | desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1); |
206adacf | 5290 | desc <<= SVE_MTEDESC_SHIFT; |
9473d0ec RH |
5291 | } else { |
5292 | addr = clean_data_tbi(s, addr); | |
206adacf | 5293 | } |
9473d0ec | 5294 | |
206adacf | 5295 | desc = simd_desc(vsz, vsz, zt | desc); |
500d0484 | 5296 | t_desc = tcg_const_i32(desc); |
c4e7c493 RH |
5297 | t_pg = tcg_temp_new_ptr(); |
5298 | ||
5299 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | |
500d0484 | 5300 | fn(cpu_env, t_pg, addr, t_desc); |
c4e7c493 RH |
5301 | |
5302 | tcg_temp_free_ptr(t_pg); | |
500d0484 | 5303 | tcg_temp_free_i32(t_desc); |
c4e7c493 RH |
5304 | } |
5305 | ||
c182c6db RH |
5306 | /* Indexed by [mte][be][dtype][nreg] */ |
5307 | static gen_helper_gvec_mem * const ldr_fns[2][2][16][4] = { | |
5308 | { /* mte inactive, little-endian */ | |
5309 | { { gen_helper_sve_ld1bb_r, gen_helper_sve_ld2bb_r, | |
5310 | gen_helper_sve_ld3bb_r, gen_helper_sve_ld4bb_r }, | |
5311 | { gen_helper_sve_ld1bhu_r, NULL, NULL, NULL }, | |
5312 | { gen_helper_sve_ld1bsu_r, NULL, NULL, NULL }, | |
5313 | { gen_helper_sve_ld1bdu_r, NULL, NULL, NULL }, | |
5314 | ||
5315 | { gen_helper_sve_ld1sds_le_r, NULL, NULL, NULL }, | |
5316 | { gen_helper_sve_ld1hh_le_r, gen_helper_sve_ld2hh_le_r, | |
5317 | gen_helper_sve_ld3hh_le_r, gen_helper_sve_ld4hh_le_r }, | |
5318 | { gen_helper_sve_ld1hsu_le_r, NULL, NULL, NULL }, | |
5319 | { gen_helper_sve_ld1hdu_le_r, NULL, NULL, NULL }, | |
5320 | ||
5321 | { gen_helper_sve_ld1hds_le_r, NULL, NULL, NULL }, | |
5322 | { gen_helper_sve_ld1hss_le_r, NULL, NULL, NULL }, | |
5323 | { gen_helper_sve_ld1ss_le_r, gen_helper_sve_ld2ss_le_r, | |
5324 | gen_helper_sve_ld3ss_le_r, gen_helper_sve_ld4ss_le_r }, | |
5325 | { gen_helper_sve_ld1sdu_le_r, NULL, NULL, NULL }, | |
5326 | ||
5327 | { gen_helper_sve_ld1bds_r, NULL, NULL, NULL }, | |
5328 | { gen_helper_sve_ld1bss_r, NULL, NULL, NULL }, | |
5329 | { gen_helper_sve_ld1bhs_r, NULL, NULL, NULL }, | |
5330 | { gen_helper_sve_ld1dd_le_r, gen_helper_sve_ld2dd_le_r, | |
5331 | gen_helper_sve_ld3dd_le_r, gen_helper_sve_ld4dd_le_r } }, | |
5332 | ||
5333 | /* mte inactive, big-endian */ | |
5334 | { { gen_helper_sve_ld1bb_r, gen_helper_sve_ld2bb_r, | |
5335 | gen_helper_sve_ld3bb_r, gen_helper_sve_ld4bb_r }, | |
5336 | { gen_helper_sve_ld1bhu_r, NULL, NULL, NULL }, | |
5337 | { gen_helper_sve_ld1bsu_r, NULL, NULL, NULL }, | |
5338 | { gen_helper_sve_ld1bdu_r, NULL, NULL, NULL }, | |
5339 | ||
5340 | { gen_helper_sve_ld1sds_be_r, NULL, NULL, NULL }, | |
5341 | { gen_helper_sve_ld1hh_be_r, gen_helper_sve_ld2hh_be_r, | |
5342 | gen_helper_sve_ld3hh_be_r, gen_helper_sve_ld4hh_be_r }, | |
5343 | { gen_helper_sve_ld1hsu_be_r, NULL, NULL, NULL }, | |
5344 | { gen_helper_sve_ld1hdu_be_r, NULL, NULL, NULL }, | |
5345 | ||
5346 | { gen_helper_sve_ld1hds_be_r, NULL, NULL, NULL }, | |
5347 | { gen_helper_sve_ld1hss_be_r, NULL, NULL, NULL }, | |
5348 | { gen_helper_sve_ld1ss_be_r, gen_helper_sve_ld2ss_be_r, | |
5349 | gen_helper_sve_ld3ss_be_r, gen_helper_sve_ld4ss_be_r }, | |
5350 | { gen_helper_sve_ld1sdu_be_r, NULL, NULL, NULL }, | |
5351 | ||
5352 | { gen_helper_sve_ld1bds_r, NULL, NULL, NULL }, | |
5353 | { gen_helper_sve_ld1bss_r, NULL, NULL, NULL }, | |
5354 | { gen_helper_sve_ld1bhs_r, NULL, NULL, NULL }, | |
5355 | { gen_helper_sve_ld1dd_be_r, gen_helper_sve_ld2dd_be_r, | |
5356 | gen_helper_sve_ld3dd_be_r, gen_helper_sve_ld4dd_be_r } } }, | |
5357 | ||
5358 | { /* mte active, little-endian */ | |
5359 | { { gen_helper_sve_ld1bb_r_mte, | |
5360 | gen_helper_sve_ld2bb_r_mte, | |
5361 | gen_helper_sve_ld3bb_r_mte, | |
5362 | gen_helper_sve_ld4bb_r_mte }, | |
5363 | { gen_helper_sve_ld1bhu_r_mte, NULL, NULL, NULL }, | |
5364 | { gen_helper_sve_ld1bsu_r_mte, NULL, NULL, NULL }, | |
5365 | { gen_helper_sve_ld1bdu_r_mte, NULL, NULL, NULL }, | |
5366 | ||
5367 | { gen_helper_sve_ld1sds_le_r_mte, NULL, NULL, NULL }, | |
5368 | { gen_helper_sve_ld1hh_le_r_mte, | |
5369 | gen_helper_sve_ld2hh_le_r_mte, | |
5370 | gen_helper_sve_ld3hh_le_r_mte, | |
5371 | gen_helper_sve_ld4hh_le_r_mte }, | |
5372 | { gen_helper_sve_ld1hsu_le_r_mte, NULL, NULL, NULL }, | |
5373 | { gen_helper_sve_ld1hdu_le_r_mte, NULL, NULL, NULL }, | |
5374 | ||
5375 | { gen_helper_sve_ld1hds_le_r_mte, NULL, NULL, NULL }, | |
5376 | { gen_helper_sve_ld1hss_le_r_mte, NULL, NULL, NULL }, | |
5377 | { gen_helper_sve_ld1ss_le_r_mte, | |
5378 | gen_helper_sve_ld2ss_le_r_mte, | |
5379 | gen_helper_sve_ld3ss_le_r_mte, | |
5380 | gen_helper_sve_ld4ss_le_r_mte }, | |
5381 | { gen_helper_sve_ld1sdu_le_r_mte, NULL, NULL, NULL }, | |
5382 | ||
5383 | { gen_helper_sve_ld1bds_r_mte, NULL, NULL, NULL }, | |
5384 | { gen_helper_sve_ld1bss_r_mte, NULL, NULL, NULL }, | |
5385 | { gen_helper_sve_ld1bhs_r_mte, NULL, NULL, NULL }, | |
5386 | { gen_helper_sve_ld1dd_le_r_mte, | |
5387 | gen_helper_sve_ld2dd_le_r_mte, | |
5388 | gen_helper_sve_ld3dd_le_r_mte, | |
5389 | gen_helper_sve_ld4dd_le_r_mte } }, | |
5390 | ||
5391 | /* mte active, big-endian */ | |
5392 | { { gen_helper_sve_ld1bb_r_mte, | |
5393 | gen_helper_sve_ld2bb_r_mte, | |
5394 | gen_helper_sve_ld3bb_r_mte, | |
5395 | gen_helper_sve_ld4bb_r_mte }, | |
5396 | { gen_helper_sve_ld1bhu_r_mte, NULL, NULL, NULL }, | |
5397 | { gen_helper_sve_ld1bsu_r_mte, NULL, NULL, NULL }, | |
5398 | { gen_helper_sve_ld1bdu_r_mte, NULL, NULL, NULL }, | |
5399 | ||
5400 | { gen_helper_sve_ld1sds_be_r_mte, NULL, NULL, NULL }, | |
5401 | { gen_helper_sve_ld1hh_be_r_mte, | |
5402 | gen_helper_sve_ld2hh_be_r_mte, | |
5403 | gen_helper_sve_ld3hh_be_r_mte, | |
5404 | gen_helper_sve_ld4hh_be_r_mte }, | |
5405 | { gen_helper_sve_ld1hsu_be_r_mte, NULL, NULL, NULL }, | |
5406 | { gen_helper_sve_ld1hdu_be_r_mte, NULL, NULL, NULL }, | |
5407 | ||
5408 | { gen_helper_sve_ld1hds_be_r_mte, NULL, NULL, NULL }, | |
5409 | { gen_helper_sve_ld1hss_be_r_mte, NULL, NULL, NULL }, | |
5410 | { gen_helper_sve_ld1ss_be_r_mte, | |
5411 | gen_helper_sve_ld2ss_be_r_mte, | |
5412 | gen_helper_sve_ld3ss_be_r_mte, | |
5413 | gen_helper_sve_ld4ss_be_r_mte }, | |
5414 | { gen_helper_sve_ld1sdu_be_r_mte, NULL, NULL, NULL }, | |
5415 | ||
5416 | { gen_helper_sve_ld1bds_r_mte, NULL, NULL, NULL }, | |
5417 | { gen_helper_sve_ld1bss_r_mte, NULL, NULL, NULL }, | |
5418 | { gen_helper_sve_ld1bhs_r_mte, NULL, NULL, NULL }, | |
5419 | { gen_helper_sve_ld1dd_be_r_mte, | |
5420 | gen_helper_sve_ld2dd_be_r_mte, | |
5421 | gen_helper_sve_ld3dd_be_r_mte, | |
5422 | gen_helper_sve_ld4dd_be_r_mte } } }, | |
5423 | }; | |
5424 | ||
c4e7c493 RH |
5425 | static void do_ld_zpa(DisasContext *s, int zt, int pg, |
5426 | TCGv_i64 addr, int dtype, int nreg) | |
5427 | { | |
206adacf | 5428 | gen_helper_gvec_mem *fn |
c182c6db | 5429 | = ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][nreg]; |
c4e7c493 | 5430 | |
206adacf RH |
5431 | /* |
5432 | * While there are holes in the table, they are not | |
c4e7c493 RH |
5433 | * accessible via the instruction encoding. |
5434 | */ | |
5435 | assert(fn != NULL); | |
206adacf | 5436 | do_mem_zpa(s, zt, pg, addr, dtype, nreg, false, fn); |
c4e7c493 RH |
5437 | } |
5438 | ||
3a7be554 | 5439 | static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a) |
c4e7c493 RH |
5440 | { |
5441 | if (a->rm == 31) { | |
5442 | return false; | |
5443 | } | |
5444 | if (sve_access_check(s)) { | |
5445 | TCGv_i64 addr = new_tmp_a64(s); | |
50ef1cbf | 5446 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); |
c4e7c493 RH |
5447 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); |
5448 | do_ld_zpa(s, a->rd, a->pg, addr, a->dtype, a->nreg); | |
5449 | } | |
5450 | return true; | |
5451 | } | |
5452 | ||
3a7be554 | 5453 | static bool trans_LD_zpri(DisasContext *s, arg_rpri_load *a) |
c4e7c493 RH |
5454 | { |
5455 | if (sve_access_check(s)) { | |
5456 | int vsz = vec_full_reg_size(s); | |
5457 | int elements = vsz >> dtype_esz[a->dtype]; | |
5458 | TCGv_i64 addr = new_tmp_a64(s); | |
5459 | ||
5460 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), | |
5461 | (a->imm * elements * (a->nreg + 1)) | |
5462 | << dtype_msz(a->dtype)); | |
5463 | do_ld_zpa(s, a->rd, a->pg, addr, a->dtype, a->nreg); | |
5464 | } | |
5465 | return true; | |
5466 | } | |
e2654d75 | 5467 | |
3a7be554 | 5468 | static bool trans_LDFF1_zprr(DisasContext *s, arg_rprr_load *a) |
e2654d75 | 5469 | { |
aa13f7c3 RH |
5470 | static gen_helper_gvec_mem * const fns[2][2][16] = { |
5471 | { /* mte inactive, little-endian */ | |
5472 | { gen_helper_sve_ldff1bb_r, | |
5473 | gen_helper_sve_ldff1bhu_r, | |
5474 | gen_helper_sve_ldff1bsu_r, | |
5475 | gen_helper_sve_ldff1bdu_r, | |
5476 | ||
5477 | gen_helper_sve_ldff1sds_le_r, | |
5478 | gen_helper_sve_ldff1hh_le_r, | |
5479 | gen_helper_sve_ldff1hsu_le_r, | |
5480 | gen_helper_sve_ldff1hdu_le_r, | |
5481 | ||
5482 | gen_helper_sve_ldff1hds_le_r, | |
5483 | gen_helper_sve_ldff1hss_le_r, | |
5484 | gen_helper_sve_ldff1ss_le_r, | |
5485 | gen_helper_sve_ldff1sdu_le_r, | |
5486 | ||
5487 | gen_helper_sve_ldff1bds_r, | |
5488 | gen_helper_sve_ldff1bss_r, | |
5489 | gen_helper_sve_ldff1bhs_r, | |
5490 | gen_helper_sve_ldff1dd_le_r }, | |
5491 | ||
5492 | /* mte inactive, big-endian */ | |
5493 | { gen_helper_sve_ldff1bb_r, | |
5494 | gen_helper_sve_ldff1bhu_r, | |
5495 | gen_helper_sve_ldff1bsu_r, | |
5496 | gen_helper_sve_ldff1bdu_r, | |
5497 | ||
5498 | gen_helper_sve_ldff1sds_be_r, | |
5499 | gen_helper_sve_ldff1hh_be_r, | |
5500 | gen_helper_sve_ldff1hsu_be_r, | |
5501 | gen_helper_sve_ldff1hdu_be_r, | |
5502 | ||
5503 | gen_helper_sve_ldff1hds_be_r, | |
5504 | gen_helper_sve_ldff1hss_be_r, | |
5505 | gen_helper_sve_ldff1ss_be_r, | |
5506 | gen_helper_sve_ldff1sdu_be_r, | |
5507 | ||
5508 | gen_helper_sve_ldff1bds_r, | |
5509 | gen_helper_sve_ldff1bss_r, | |
5510 | gen_helper_sve_ldff1bhs_r, | |
5511 | gen_helper_sve_ldff1dd_be_r } }, | |
5512 | ||
5513 | { /* mte active, little-endian */ | |
5514 | { gen_helper_sve_ldff1bb_r_mte, | |
5515 | gen_helper_sve_ldff1bhu_r_mte, | |
5516 | gen_helper_sve_ldff1bsu_r_mte, | |
5517 | gen_helper_sve_ldff1bdu_r_mte, | |
5518 | ||
5519 | gen_helper_sve_ldff1sds_le_r_mte, | |
5520 | gen_helper_sve_ldff1hh_le_r_mte, | |
5521 | gen_helper_sve_ldff1hsu_le_r_mte, | |
5522 | gen_helper_sve_ldff1hdu_le_r_mte, | |
5523 | ||
5524 | gen_helper_sve_ldff1hds_le_r_mte, | |
5525 | gen_helper_sve_ldff1hss_le_r_mte, | |
5526 | gen_helper_sve_ldff1ss_le_r_mte, | |
5527 | gen_helper_sve_ldff1sdu_le_r_mte, | |
5528 | ||
5529 | gen_helper_sve_ldff1bds_r_mte, | |
5530 | gen_helper_sve_ldff1bss_r_mte, | |
5531 | gen_helper_sve_ldff1bhs_r_mte, | |
5532 | gen_helper_sve_ldff1dd_le_r_mte }, | |
5533 | ||
5534 | /* mte active, big-endian */ | |
5535 | { gen_helper_sve_ldff1bb_r_mte, | |
5536 | gen_helper_sve_ldff1bhu_r_mte, | |
5537 | gen_helper_sve_ldff1bsu_r_mte, | |
5538 | gen_helper_sve_ldff1bdu_r_mte, | |
5539 | ||
5540 | gen_helper_sve_ldff1sds_be_r_mte, | |
5541 | gen_helper_sve_ldff1hh_be_r_mte, | |
5542 | gen_helper_sve_ldff1hsu_be_r_mte, | |
5543 | gen_helper_sve_ldff1hdu_be_r_mte, | |
5544 | ||
5545 | gen_helper_sve_ldff1hds_be_r_mte, | |
5546 | gen_helper_sve_ldff1hss_be_r_mte, | |
5547 | gen_helper_sve_ldff1ss_be_r_mte, | |
5548 | gen_helper_sve_ldff1sdu_be_r_mte, | |
5549 | ||
5550 | gen_helper_sve_ldff1bds_r_mte, | |
5551 | gen_helper_sve_ldff1bss_r_mte, | |
5552 | gen_helper_sve_ldff1bhs_r_mte, | |
5553 | gen_helper_sve_ldff1dd_be_r_mte } }, | |
e2654d75 RH |
5554 | }; |
5555 | ||
5556 | if (sve_access_check(s)) { | |
5557 | TCGv_i64 addr = new_tmp_a64(s); | |
5558 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); | |
5559 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | |
aa13f7c3 RH |
5560 | do_mem_zpa(s, a->rd, a->pg, addr, a->dtype, 1, false, |
5561 | fns[s->mte_active[0]][s->be_data == MO_BE][a->dtype]); | |
e2654d75 RH |
5562 | } |
5563 | return true; | |
5564 | } | |
5565 | ||
3a7be554 | 5566 | static bool trans_LDNF1_zpri(DisasContext *s, arg_rpri_load *a) |
e2654d75 | 5567 | { |
aa13f7c3 RH |
5568 | static gen_helper_gvec_mem * const fns[2][2][16] = { |
5569 | { /* mte inactive, little-endian */ | |
5570 | { gen_helper_sve_ldnf1bb_r, | |
5571 | gen_helper_sve_ldnf1bhu_r, | |
5572 | gen_helper_sve_ldnf1bsu_r, | |
5573 | gen_helper_sve_ldnf1bdu_r, | |
5574 | ||
5575 | gen_helper_sve_ldnf1sds_le_r, | |
5576 | gen_helper_sve_ldnf1hh_le_r, | |
5577 | gen_helper_sve_ldnf1hsu_le_r, | |
5578 | gen_helper_sve_ldnf1hdu_le_r, | |
5579 | ||
5580 | gen_helper_sve_ldnf1hds_le_r, | |
5581 | gen_helper_sve_ldnf1hss_le_r, | |
5582 | gen_helper_sve_ldnf1ss_le_r, | |
5583 | gen_helper_sve_ldnf1sdu_le_r, | |
5584 | ||
5585 | gen_helper_sve_ldnf1bds_r, | |
5586 | gen_helper_sve_ldnf1bss_r, | |
5587 | gen_helper_sve_ldnf1bhs_r, | |
5588 | gen_helper_sve_ldnf1dd_le_r }, | |
5589 | ||
5590 | /* mte inactive, big-endian */ | |
5591 | { gen_helper_sve_ldnf1bb_r, | |
5592 | gen_helper_sve_ldnf1bhu_r, | |
5593 | gen_helper_sve_ldnf1bsu_r, | |
5594 | gen_helper_sve_ldnf1bdu_r, | |
5595 | ||
5596 | gen_helper_sve_ldnf1sds_be_r, | |
5597 | gen_helper_sve_ldnf1hh_be_r, | |
5598 | gen_helper_sve_ldnf1hsu_be_r, | |
5599 | gen_helper_sve_ldnf1hdu_be_r, | |
5600 | ||
5601 | gen_helper_sve_ldnf1hds_be_r, | |
5602 | gen_helper_sve_ldnf1hss_be_r, | |
5603 | gen_helper_sve_ldnf1ss_be_r, | |
5604 | gen_helper_sve_ldnf1sdu_be_r, | |
5605 | ||
5606 | gen_helper_sve_ldnf1bds_r, | |
5607 | gen_helper_sve_ldnf1bss_r, | |
5608 | gen_helper_sve_ldnf1bhs_r, | |
5609 | gen_helper_sve_ldnf1dd_be_r } }, | |
5610 | ||
5611 | { /* mte inactive, little-endian */ | |
5612 | { gen_helper_sve_ldnf1bb_r_mte, | |
5613 | gen_helper_sve_ldnf1bhu_r_mte, | |
5614 | gen_helper_sve_ldnf1bsu_r_mte, | |
5615 | gen_helper_sve_ldnf1bdu_r_mte, | |
5616 | ||
5617 | gen_helper_sve_ldnf1sds_le_r_mte, | |
5618 | gen_helper_sve_ldnf1hh_le_r_mte, | |
5619 | gen_helper_sve_ldnf1hsu_le_r_mte, | |
5620 | gen_helper_sve_ldnf1hdu_le_r_mte, | |
5621 | ||
5622 | gen_helper_sve_ldnf1hds_le_r_mte, | |
5623 | gen_helper_sve_ldnf1hss_le_r_mte, | |
5624 | gen_helper_sve_ldnf1ss_le_r_mte, | |
5625 | gen_helper_sve_ldnf1sdu_le_r_mte, | |
5626 | ||
5627 | gen_helper_sve_ldnf1bds_r_mte, | |
5628 | gen_helper_sve_ldnf1bss_r_mte, | |
5629 | gen_helper_sve_ldnf1bhs_r_mte, | |
5630 | gen_helper_sve_ldnf1dd_le_r_mte }, | |
5631 | ||
5632 | /* mte inactive, big-endian */ | |
5633 | { gen_helper_sve_ldnf1bb_r_mte, | |
5634 | gen_helper_sve_ldnf1bhu_r_mte, | |
5635 | gen_helper_sve_ldnf1bsu_r_mte, | |
5636 | gen_helper_sve_ldnf1bdu_r_mte, | |
5637 | ||
5638 | gen_helper_sve_ldnf1sds_be_r_mte, | |
5639 | gen_helper_sve_ldnf1hh_be_r_mte, | |
5640 | gen_helper_sve_ldnf1hsu_be_r_mte, | |
5641 | gen_helper_sve_ldnf1hdu_be_r_mte, | |
5642 | ||
5643 | gen_helper_sve_ldnf1hds_be_r_mte, | |
5644 | gen_helper_sve_ldnf1hss_be_r_mte, | |
5645 | gen_helper_sve_ldnf1ss_be_r_mte, | |
5646 | gen_helper_sve_ldnf1sdu_be_r_mte, | |
5647 | ||
5648 | gen_helper_sve_ldnf1bds_r_mte, | |
5649 | gen_helper_sve_ldnf1bss_r_mte, | |
5650 | gen_helper_sve_ldnf1bhs_r_mte, | |
5651 | gen_helper_sve_ldnf1dd_be_r_mte } }, | |
e2654d75 RH |
5652 | }; |
5653 | ||
5654 | if (sve_access_check(s)) { | |
5655 | int vsz = vec_full_reg_size(s); | |
5656 | int elements = vsz >> dtype_esz[a->dtype]; | |
5657 | int off = (a->imm * elements) << dtype_msz(a->dtype); | |
5658 | TCGv_i64 addr = new_tmp_a64(s); | |
5659 | ||
5660 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), off); | |
aa13f7c3 RH |
5661 | do_mem_zpa(s, a->rd, a->pg, addr, a->dtype, 1, false, |
5662 | fns[s->mte_active[0]][s->be_data == MO_BE][a->dtype]); | |
e2654d75 RH |
5663 | } |
5664 | return true; | |
5665 | } | |
1a039c7e | 5666 | |
c182c6db | 5667 | static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) |
05abe304 | 5668 | { |
05abe304 RH |
5669 | unsigned vsz = vec_full_reg_size(s); |
5670 | TCGv_ptr t_pg; | |
7924d239 | 5671 | int poff; |
05abe304 RH |
5672 | |
5673 | /* Load the first quadword using the normal predicated load helpers. */ | |
2a99ab2b RH |
5674 | poff = pred_full_reg_offset(s, pg); |
5675 | if (vsz > 16) { | |
5676 | /* | |
5677 | * Zero-extend the first 16 bits of the predicate into a temporary. | |
5678 | * This avoids triggering an assert making sure we don't have bits | |
5679 | * set within a predicate beyond VQ, but we have lowered VQ to 1 | |
5680 | * for this load operation. | |
5681 | */ | |
5682 | TCGv_i64 tmp = tcg_temp_new_i64(); | |
e03b5686 | 5683 | #if HOST_BIG_ENDIAN |
2a99ab2b RH |
5684 | poff += 6; |
5685 | #endif | |
5686 | tcg_gen_ld16u_i64(tmp, cpu_env, poff); | |
5687 | ||
5688 | poff = offsetof(CPUARMState, vfp.preg_tmp); | |
5689 | tcg_gen_st_i64(tmp, cpu_env, poff); | |
5690 | tcg_temp_free_i64(tmp); | |
5691 | } | |
5692 | ||
05abe304 | 5693 | t_pg = tcg_temp_new_ptr(); |
2a99ab2b | 5694 | tcg_gen_addi_ptr(t_pg, cpu_env, poff); |
05abe304 | 5695 | |
c182c6db RH |
5696 | gen_helper_gvec_mem *fn |
5697 | = ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0]; | |
7924d239 | 5698 | fn(cpu_env, t_pg, addr, tcg_constant_i32(simd_desc(16, 16, zt))); |
05abe304 RH |
5699 | |
5700 | tcg_temp_free_ptr(t_pg); | |
05abe304 RH |
5701 | |
5702 | /* Replicate that first quadword. */ | |
5703 | if (vsz > 16) { | |
7924d239 RH |
5704 | int doff = vec_full_reg_offset(s, zt); |
5705 | tcg_gen_gvec_dup_mem(4, doff + 16, doff, vsz - 16, vsz - 16); | |
05abe304 RH |
5706 | } |
5707 | } | |
5708 | ||
3a7be554 | 5709 | static bool trans_LD1RQ_zprr(DisasContext *s, arg_rprr_load *a) |
05abe304 RH |
5710 | { |
5711 | if (a->rm == 31) { | |
5712 | return false; | |
5713 | } | |
5714 | if (sve_access_check(s)) { | |
5715 | int msz = dtype_msz(a->dtype); | |
5716 | TCGv_i64 addr = new_tmp_a64(s); | |
5717 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), msz); | |
5718 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | |
c182c6db | 5719 | do_ldrq(s, a->rd, a->pg, addr, a->dtype); |
05abe304 RH |
5720 | } |
5721 | return true; | |
5722 | } | |
5723 | ||
3a7be554 | 5724 | static bool trans_LD1RQ_zpri(DisasContext *s, arg_rpri_load *a) |
05abe304 RH |
5725 | { |
5726 | if (sve_access_check(s)) { | |
5727 | TCGv_i64 addr = new_tmp_a64(s); | |
5728 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), a->imm * 16); | |
c182c6db | 5729 | do_ldrq(s, a->rd, a->pg, addr, a->dtype); |
05abe304 RH |
5730 | } |
5731 | return true; | |
5732 | } | |
5733 | ||
12c563f6 RH |
5734 | static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) |
5735 | { | |
5736 | unsigned vsz = vec_full_reg_size(s); | |
5737 | unsigned vsz_r32; | |
5738 | TCGv_ptr t_pg; | |
5739 | int poff, doff; | |
5740 | ||
5741 | if (vsz < 32) { | |
5742 | /* | |
5743 | * Note that this UNDEFINED check comes after CheckSVEEnabled() | |
5744 | * in the ARM pseudocode, which is the sve_access_check() done | |
5745 | * in our caller. We should not now return false from the caller. | |
5746 | */ | |
5747 | unallocated_encoding(s); | |
5748 | return; | |
5749 | } | |
5750 | ||
5751 | /* Load the first octaword using the normal predicated load helpers. */ | |
5752 | ||
5753 | poff = pred_full_reg_offset(s, pg); | |
5754 | if (vsz > 32) { | |
5755 | /* | |
5756 | * Zero-extend the first 32 bits of the predicate into a temporary. | |
5757 | * This avoids triggering an assert making sure we don't have bits | |
5758 | * set within a predicate beyond VQ, but we have lowered VQ to 2 | |
5759 | * for this load operation. | |
5760 | */ | |
5761 | TCGv_i64 tmp = tcg_temp_new_i64(); | |
e03b5686 | 5762 | #if HOST_BIG_ENDIAN |
12c563f6 RH |
5763 | poff += 4; |
5764 | #endif | |
5765 | tcg_gen_ld32u_i64(tmp, cpu_env, poff); | |
5766 | ||
5767 | poff = offsetof(CPUARMState, vfp.preg_tmp); | |
5768 | tcg_gen_st_i64(tmp, cpu_env, poff); | |
5769 | tcg_temp_free_i64(tmp); | |
5770 | } | |
5771 | ||
5772 | t_pg = tcg_temp_new_ptr(); | |
5773 | tcg_gen_addi_ptr(t_pg, cpu_env, poff); | |
5774 | ||
5775 | gen_helper_gvec_mem *fn | |
5776 | = ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0]; | |
5777 | fn(cpu_env, t_pg, addr, tcg_constant_i32(simd_desc(32, 32, zt))); | |
5778 | ||
5779 | tcg_temp_free_ptr(t_pg); | |
5780 | ||
5781 | /* | |
5782 | * Replicate that first octaword. | |
5783 | * The replication happens in units of 32; if the full vector size | |
5784 | * is not a multiple of 32, the final bits are zeroed. | |
5785 | */ | |
5786 | doff = vec_full_reg_offset(s, zt); | |
5787 | vsz_r32 = QEMU_ALIGN_DOWN(vsz, 32); | |
5788 | if (vsz >= 64) { | |
5789 | tcg_gen_gvec_dup_mem(5, doff + 32, doff, vsz_r32 - 32, vsz_r32 - 32); | |
5790 | } | |
5791 | vsz -= vsz_r32; | |
5792 | if (vsz) { | |
5793 | tcg_gen_gvec_dup_imm(MO_64, doff + vsz_r32, vsz, vsz, 0); | |
5794 | } | |
5795 | } | |
5796 | ||
5797 | static bool trans_LD1RO_zprr(DisasContext *s, arg_rprr_load *a) | |
5798 | { | |
5799 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
5800 | return false; | |
5801 | } | |
5802 | if (a->rm == 31) { | |
5803 | return false; | |
5804 | } | |
5805 | if (sve_access_check(s)) { | |
5806 | TCGv_i64 addr = new_tmp_a64(s); | |
5807 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); | |
5808 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | |
5809 | do_ldro(s, a->rd, a->pg, addr, a->dtype); | |
5810 | } | |
5811 | return true; | |
5812 | } | |
5813 | ||
5814 | static bool trans_LD1RO_zpri(DisasContext *s, arg_rpri_load *a) | |
5815 | { | |
5816 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
5817 | return false; | |
5818 | } | |
5819 | if (sve_access_check(s)) { | |
5820 | TCGv_i64 addr = new_tmp_a64(s); | |
5821 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), a->imm * 32); | |
5822 | do_ldro(s, a->rd, a->pg, addr, a->dtype); | |
5823 | } | |
5824 | return true; | |
5825 | } | |
5826 | ||
68459864 | 5827 | /* Load and broadcast element. */ |
3a7be554 | 5828 | static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a) |
68459864 | 5829 | { |
68459864 RH |
5830 | unsigned vsz = vec_full_reg_size(s); |
5831 | unsigned psz = pred_full_reg_size(s); | |
5832 | unsigned esz = dtype_esz[a->dtype]; | |
d0e372b0 | 5833 | unsigned msz = dtype_msz(a->dtype); |
c0ed9166 | 5834 | TCGLabel *over; |
4ac430e1 | 5835 | TCGv_i64 temp, clean_addr; |
68459864 | 5836 | |
c0ed9166 RH |
5837 | if (!sve_access_check(s)) { |
5838 | return true; | |
5839 | } | |
5840 | ||
5841 | over = gen_new_label(); | |
5842 | ||
68459864 RH |
5843 | /* If the guarding predicate has no bits set, no load occurs. */ |
5844 | if (psz <= 8) { | |
5845 | /* Reduce the pred_esz_masks value simply to reduce the | |
5846 | * size of the code generated here. | |
5847 | */ | |
5848 | uint64_t psz_mask = MAKE_64BIT_MASK(0, psz * 8); | |
5849 | temp = tcg_temp_new_i64(); | |
5850 | tcg_gen_ld_i64(temp, cpu_env, pred_full_reg_offset(s, a->pg)); | |
5851 | tcg_gen_andi_i64(temp, temp, pred_esz_masks[esz] & psz_mask); | |
5852 | tcg_gen_brcondi_i64(TCG_COND_EQ, temp, 0, over); | |
5853 | tcg_temp_free_i64(temp); | |
5854 | } else { | |
5855 | TCGv_i32 t32 = tcg_temp_new_i32(); | |
5856 | find_last_active(s, t32, esz, a->pg); | |
5857 | tcg_gen_brcondi_i32(TCG_COND_LT, t32, 0, over); | |
5858 | tcg_temp_free_i32(t32); | |
5859 | } | |
5860 | ||
5861 | /* Load the data. */ | |
5862 | temp = tcg_temp_new_i64(); | |
d0e372b0 | 5863 | tcg_gen_addi_i64(temp, cpu_reg_sp(s, a->rn), a->imm << msz); |
4ac430e1 RH |
5864 | clean_addr = gen_mte_check1(s, temp, false, true, msz); |
5865 | ||
5866 | tcg_gen_qemu_ld_i64(temp, clean_addr, get_mem_index(s), | |
0ca0f872 | 5867 | finalize_memop(s, dtype_mop[a->dtype])); |
68459864 RH |
5868 | |
5869 | /* Broadcast to *all* elements. */ | |
5870 | tcg_gen_gvec_dup_i64(esz, vec_full_reg_offset(s, a->rd), | |
5871 | vsz, vsz, temp); | |
5872 | tcg_temp_free_i64(temp); | |
5873 | ||
5874 | /* Zero the inactive elements. */ | |
5875 | gen_set_label(over); | |
60245996 | 5876 | return do_movz_zpz(s, a->rd, a->rd, a->pg, esz, false); |
68459864 RH |
5877 | } |
5878 | ||
1a039c7e RH |
5879 | static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, |
5880 | int msz, int esz, int nreg) | |
5881 | { | |
71b9f394 RH |
5882 | static gen_helper_gvec_mem * const fn_single[2][2][4][4] = { |
5883 | { { { gen_helper_sve_st1bb_r, | |
5884 | gen_helper_sve_st1bh_r, | |
5885 | gen_helper_sve_st1bs_r, | |
5886 | gen_helper_sve_st1bd_r }, | |
5887 | { NULL, | |
5888 | gen_helper_sve_st1hh_le_r, | |
5889 | gen_helper_sve_st1hs_le_r, | |
5890 | gen_helper_sve_st1hd_le_r }, | |
5891 | { NULL, NULL, | |
5892 | gen_helper_sve_st1ss_le_r, | |
5893 | gen_helper_sve_st1sd_le_r }, | |
5894 | { NULL, NULL, NULL, | |
5895 | gen_helper_sve_st1dd_le_r } }, | |
5896 | { { gen_helper_sve_st1bb_r, | |
5897 | gen_helper_sve_st1bh_r, | |
5898 | gen_helper_sve_st1bs_r, | |
5899 | gen_helper_sve_st1bd_r }, | |
5900 | { NULL, | |
5901 | gen_helper_sve_st1hh_be_r, | |
5902 | gen_helper_sve_st1hs_be_r, | |
5903 | gen_helper_sve_st1hd_be_r }, | |
5904 | { NULL, NULL, | |
5905 | gen_helper_sve_st1ss_be_r, | |
5906 | gen_helper_sve_st1sd_be_r }, | |
5907 | { NULL, NULL, NULL, | |
5908 | gen_helper_sve_st1dd_be_r } } }, | |
5909 | ||
5910 | { { { gen_helper_sve_st1bb_r_mte, | |
5911 | gen_helper_sve_st1bh_r_mte, | |
5912 | gen_helper_sve_st1bs_r_mte, | |
5913 | gen_helper_sve_st1bd_r_mte }, | |
5914 | { NULL, | |
5915 | gen_helper_sve_st1hh_le_r_mte, | |
5916 | gen_helper_sve_st1hs_le_r_mte, | |
5917 | gen_helper_sve_st1hd_le_r_mte }, | |
5918 | { NULL, NULL, | |
5919 | gen_helper_sve_st1ss_le_r_mte, | |
5920 | gen_helper_sve_st1sd_le_r_mte }, | |
5921 | { NULL, NULL, NULL, | |
5922 | gen_helper_sve_st1dd_le_r_mte } }, | |
5923 | { { gen_helper_sve_st1bb_r_mte, | |
5924 | gen_helper_sve_st1bh_r_mte, | |
5925 | gen_helper_sve_st1bs_r_mte, | |
5926 | gen_helper_sve_st1bd_r_mte }, | |
5927 | { NULL, | |
5928 | gen_helper_sve_st1hh_be_r_mte, | |
5929 | gen_helper_sve_st1hs_be_r_mte, | |
5930 | gen_helper_sve_st1hd_be_r_mte }, | |
5931 | { NULL, NULL, | |
5932 | gen_helper_sve_st1ss_be_r_mte, | |
5933 | gen_helper_sve_st1sd_be_r_mte }, | |
5934 | { NULL, NULL, NULL, | |
5935 | gen_helper_sve_st1dd_be_r_mte } } }, | |
1a039c7e | 5936 | }; |
71b9f394 RH |
5937 | static gen_helper_gvec_mem * const fn_multiple[2][2][3][4] = { |
5938 | { { { gen_helper_sve_st2bb_r, | |
5939 | gen_helper_sve_st2hh_le_r, | |
5940 | gen_helper_sve_st2ss_le_r, | |
5941 | gen_helper_sve_st2dd_le_r }, | |
5942 | { gen_helper_sve_st3bb_r, | |
5943 | gen_helper_sve_st3hh_le_r, | |
5944 | gen_helper_sve_st3ss_le_r, | |
5945 | gen_helper_sve_st3dd_le_r }, | |
5946 | { gen_helper_sve_st4bb_r, | |
5947 | gen_helper_sve_st4hh_le_r, | |
5948 | gen_helper_sve_st4ss_le_r, | |
5949 | gen_helper_sve_st4dd_le_r } }, | |
5950 | { { gen_helper_sve_st2bb_r, | |
5951 | gen_helper_sve_st2hh_be_r, | |
5952 | gen_helper_sve_st2ss_be_r, | |
5953 | gen_helper_sve_st2dd_be_r }, | |
5954 | { gen_helper_sve_st3bb_r, | |
5955 | gen_helper_sve_st3hh_be_r, | |
5956 | gen_helper_sve_st3ss_be_r, | |
5957 | gen_helper_sve_st3dd_be_r }, | |
5958 | { gen_helper_sve_st4bb_r, | |
5959 | gen_helper_sve_st4hh_be_r, | |
5960 | gen_helper_sve_st4ss_be_r, | |
5961 | gen_helper_sve_st4dd_be_r } } }, | |
5962 | { { { gen_helper_sve_st2bb_r_mte, | |
5963 | gen_helper_sve_st2hh_le_r_mte, | |
5964 | gen_helper_sve_st2ss_le_r_mte, | |
5965 | gen_helper_sve_st2dd_le_r_mte }, | |
5966 | { gen_helper_sve_st3bb_r_mte, | |
5967 | gen_helper_sve_st3hh_le_r_mte, | |
5968 | gen_helper_sve_st3ss_le_r_mte, | |
5969 | gen_helper_sve_st3dd_le_r_mte }, | |
5970 | { gen_helper_sve_st4bb_r_mte, | |
5971 | gen_helper_sve_st4hh_le_r_mte, | |
5972 | gen_helper_sve_st4ss_le_r_mte, | |
5973 | gen_helper_sve_st4dd_le_r_mte } }, | |
5974 | { { gen_helper_sve_st2bb_r_mte, | |
5975 | gen_helper_sve_st2hh_be_r_mte, | |
5976 | gen_helper_sve_st2ss_be_r_mte, | |
5977 | gen_helper_sve_st2dd_be_r_mte }, | |
5978 | { gen_helper_sve_st3bb_r_mte, | |
5979 | gen_helper_sve_st3hh_be_r_mte, | |
5980 | gen_helper_sve_st3ss_be_r_mte, | |
5981 | gen_helper_sve_st3dd_be_r_mte }, | |
5982 | { gen_helper_sve_st4bb_r_mte, | |
5983 | gen_helper_sve_st4hh_be_r_mte, | |
5984 | gen_helper_sve_st4ss_be_r_mte, | |
5985 | gen_helper_sve_st4dd_be_r_mte } } }, | |
1a039c7e RH |
5986 | }; |
5987 | gen_helper_gvec_mem *fn; | |
28d57f2d | 5988 | int be = s->be_data == MO_BE; |
1a039c7e RH |
5989 | |
5990 | if (nreg == 0) { | |
5991 | /* ST1 */ | |
71b9f394 RH |
5992 | fn = fn_single[s->mte_active[0]][be][msz][esz]; |
5993 | nreg = 1; | |
1a039c7e RH |
5994 | } else { |
5995 | /* ST2, ST3, ST4 -- msz == esz, enforced by encoding */ | |
5996 | assert(msz == esz); | |
71b9f394 | 5997 | fn = fn_multiple[s->mte_active[0]][be][nreg - 1][msz]; |
1a039c7e RH |
5998 | } |
5999 | assert(fn != NULL); | |
71b9f394 | 6000 | do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg, true, fn); |
1a039c7e RH |
6001 | } |
6002 | ||
3a7be554 | 6003 | static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a) |
1a039c7e RH |
6004 | { |
6005 | if (a->rm == 31 || a->msz > a->esz) { | |
6006 | return false; | |
6007 | } | |
6008 | if (sve_access_check(s)) { | |
6009 | TCGv_i64 addr = new_tmp_a64(s); | |
50ef1cbf | 6010 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->msz); |
1a039c7e RH |
6011 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); |
6012 | do_st_zpa(s, a->rd, a->pg, addr, a->msz, a->esz, a->nreg); | |
6013 | } | |
6014 | return true; | |
6015 | } | |
6016 | ||
3a7be554 | 6017 | static bool trans_ST_zpri(DisasContext *s, arg_rpri_store *a) |
1a039c7e RH |
6018 | { |
6019 | if (a->msz > a->esz) { | |
6020 | return false; | |
6021 | } | |
6022 | if (sve_access_check(s)) { | |
6023 | int vsz = vec_full_reg_size(s); | |
6024 | int elements = vsz >> a->esz; | |
6025 | TCGv_i64 addr = new_tmp_a64(s); | |
6026 | ||
6027 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), | |
6028 | (a->imm * elements * (a->nreg + 1)) << a->msz); | |
6029 | do_st_zpa(s, a->rd, a->pg, addr, a->msz, a->esz, a->nreg); | |
6030 | } | |
6031 | return true; | |
6032 | } | |
f6dbf62a RH |
6033 | |
6034 | /* | |
6035 | *** SVE gather loads / scatter stores | |
6036 | */ | |
6037 | ||
500d0484 | 6038 | static void do_mem_zpz(DisasContext *s, int zt, int pg, int zm, |
d28d12f0 | 6039 | int scale, TCGv_i64 scalar, int msz, bool is_write, |
500d0484 | 6040 | gen_helper_gvec_mem_scatter *fn) |
f6dbf62a RH |
6041 | { |
6042 | unsigned vsz = vec_full_reg_size(s); | |
f6dbf62a RH |
6043 | TCGv_ptr t_zm = tcg_temp_new_ptr(); |
6044 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | |
6045 | TCGv_ptr t_zt = tcg_temp_new_ptr(); | |
500d0484 | 6046 | TCGv_i32 t_desc; |
d28d12f0 | 6047 | int desc = 0; |
500d0484 | 6048 | |
d28d12f0 RH |
6049 | if (s->mte_active[0]) { |
6050 | desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | |
6051 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | |
6052 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | |
6053 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | |
28f32503 | 6054 | desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << msz) - 1); |
d28d12f0 RH |
6055 | desc <<= SVE_MTEDESC_SHIFT; |
6056 | } | |
cdecb3fc | 6057 | desc = simd_desc(vsz, vsz, desc | scale); |
500d0484 | 6058 | t_desc = tcg_const_i32(desc); |
f6dbf62a RH |
6059 | |
6060 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | |
6061 | tcg_gen_addi_ptr(t_zm, cpu_env, vec_full_reg_offset(s, zm)); | |
6062 | tcg_gen_addi_ptr(t_zt, cpu_env, vec_full_reg_offset(s, zt)); | |
500d0484 | 6063 | fn(cpu_env, t_zt, t_pg, t_zm, scalar, t_desc); |
f6dbf62a RH |
6064 | |
6065 | tcg_temp_free_ptr(t_zt); | |
6066 | tcg_temp_free_ptr(t_zm); | |
6067 | tcg_temp_free_ptr(t_pg); | |
500d0484 | 6068 | tcg_temp_free_i32(t_desc); |
f6dbf62a RH |
6069 | } |
6070 | ||
d28d12f0 RH |
6071 | /* Indexed by [mte][be][ff][xs][u][msz]. */ |
6072 | static gen_helper_gvec_mem_scatter * const | |
6073 | gather_load_fn32[2][2][2][2][2][3] = { | |
6074 | { /* MTE Inactive */ | |
6075 | { /* Little-endian */ | |
6076 | { { { gen_helper_sve_ldbss_zsu, | |
6077 | gen_helper_sve_ldhss_le_zsu, | |
6078 | NULL, }, | |
6079 | { gen_helper_sve_ldbsu_zsu, | |
6080 | gen_helper_sve_ldhsu_le_zsu, | |
6081 | gen_helper_sve_ldss_le_zsu, } }, | |
6082 | { { gen_helper_sve_ldbss_zss, | |
6083 | gen_helper_sve_ldhss_le_zss, | |
6084 | NULL, }, | |
6085 | { gen_helper_sve_ldbsu_zss, | |
6086 | gen_helper_sve_ldhsu_le_zss, | |
6087 | gen_helper_sve_ldss_le_zss, } } }, | |
6088 | ||
6089 | /* First-fault */ | |
6090 | { { { gen_helper_sve_ldffbss_zsu, | |
6091 | gen_helper_sve_ldffhss_le_zsu, | |
6092 | NULL, }, | |
6093 | { gen_helper_sve_ldffbsu_zsu, | |
6094 | gen_helper_sve_ldffhsu_le_zsu, | |
6095 | gen_helper_sve_ldffss_le_zsu, } }, | |
6096 | { { gen_helper_sve_ldffbss_zss, | |
6097 | gen_helper_sve_ldffhss_le_zss, | |
6098 | NULL, }, | |
6099 | { gen_helper_sve_ldffbsu_zss, | |
6100 | gen_helper_sve_ldffhsu_le_zss, | |
6101 | gen_helper_sve_ldffss_le_zss, } } } }, | |
6102 | ||
6103 | { /* Big-endian */ | |
6104 | { { { gen_helper_sve_ldbss_zsu, | |
6105 | gen_helper_sve_ldhss_be_zsu, | |
6106 | NULL, }, | |
6107 | { gen_helper_sve_ldbsu_zsu, | |
6108 | gen_helper_sve_ldhsu_be_zsu, | |
6109 | gen_helper_sve_ldss_be_zsu, } }, | |
6110 | { { gen_helper_sve_ldbss_zss, | |
6111 | gen_helper_sve_ldhss_be_zss, | |
6112 | NULL, }, | |
6113 | { gen_helper_sve_ldbsu_zss, | |
6114 | gen_helper_sve_ldhsu_be_zss, | |
6115 | gen_helper_sve_ldss_be_zss, } } }, | |
6116 | ||
6117 | /* First-fault */ | |
6118 | { { { gen_helper_sve_ldffbss_zsu, | |
6119 | gen_helper_sve_ldffhss_be_zsu, | |
6120 | NULL, }, | |
6121 | { gen_helper_sve_ldffbsu_zsu, | |
6122 | gen_helper_sve_ldffhsu_be_zsu, | |
6123 | gen_helper_sve_ldffss_be_zsu, } }, | |
6124 | { { gen_helper_sve_ldffbss_zss, | |
6125 | gen_helper_sve_ldffhss_be_zss, | |
6126 | NULL, }, | |
6127 | { gen_helper_sve_ldffbsu_zss, | |
6128 | gen_helper_sve_ldffhsu_be_zss, | |
6129 | gen_helper_sve_ldffss_be_zss, } } } } }, | |
6130 | { /* MTE Active */ | |
6131 | { /* Little-endian */ | |
6132 | { { { gen_helper_sve_ldbss_zsu_mte, | |
6133 | gen_helper_sve_ldhss_le_zsu_mte, | |
6134 | NULL, }, | |
6135 | { gen_helper_sve_ldbsu_zsu_mte, | |
6136 | gen_helper_sve_ldhsu_le_zsu_mte, | |
6137 | gen_helper_sve_ldss_le_zsu_mte, } }, | |
6138 | { { gen_helper_sve_ldbss_zss_mte, | |
6139 | gen_helper_sve_ldhss_le_zss_mte, | |
6140 | NULL, }, | |
6141 | { gen_helper_sve_ldbsu_zss_mte, | |
6142 | gen_helper_sve_ldhsu_le_zss_mte, | |
6143 | gen_helper_sve_ldss_le_zss_mte, } } }, | |
6144 | ||
6145 | /* First-fault */ | |
6146 | { { { gen_helper_sve_ldffbss_zsu_mte, | |
6147 | gen_helper_sve_ldffhss_le_zsu_mte, | |
6148 | NULL, }, | |
6149 | { gen_helper_sve_ldffbsu_zsu_mte, | |
6150 | gen_helper_sve_ldffhsu_le_zsu_mte, | |
6151 | gen_helper_sve_ldffss_le_zsu_mte, } }, | |
6152 | { { gen_helper_sve_ldffbss_zss_mte, | |
6153 | gen_helper_sve_ldffhss_le_zss_mte, | |
6154 | NULL, }, | |
6155 | { gen_helper_sve_ldffbsu_zss_mte, | |
6156 | gen_helper_sve_ldffhsu_le_zss_mte, | |
6157 | gen_helper_sve_ldffss_le_zss_mte, } } } }, | |
6158 | ||
6159 | { /* Big-endian */ | |
6160 | { { { gen_helper_sve_ldbss_zsu_mte, | |
6161 | gen_helper_sve_ldhss_be_zsu_mte, | |
6162 | NULL, }, | |
6163 | { gen_helper_sve_ldbsu_zsu_mte, | |
6164 | gen_helper_sve_ldhsu_be_zsu_mte, | |
6165 | gen_helper_sve_ldss_be_zsu_mte, } }, | |
6166 | { { gen_helper_sve_ldbss_zss_mte, | |
6167 | gen_helper_sve_ldhss_be_zss_mte, | |
6168 | NULL, }, | |
6169 | { gen_helper_sve_ldbsu_zss_mte, | |
6170 | gen_helper_sve_ldhsu_be_zss_mte, | |
6171 | gen_helper_sve_ldss_be_zss_mte, } } }, | |
6172 | ||
6173 | /* First-fault */ | |
6174 | { { { gen_helper_sve_ldffbss_zsu_mte, | |
6175 | gen_helper_sve_ldffhss_be_zsu_mte, | |
6176 | NULL, }, | |
6177 | { gen_helper_sve_ldffbsu_zsu_mte, | |
6178 | gen_helper_sve_ldffhsu_be_zsu_mte, | |
6179 | gen_helper_sve_ldffss_be_zsu_mte, } }, | |
6180 | { { gen_helper_sve_ldffbss_zss_mte, | |
6181 | gen_helper_sve_ldffhss_be_zss_mte, | |
6182 | NULL, }, | |
6183 | { gen_helper_sve_ldffbsu_zss_mte, | |
6184 | gen_helper_sve_ldffhsu_be_zss_mte, | |
6185 | gen_helper_sve_ldffss_be_zss_mte, } } } } }, | |
673e9fa6 RH |
6186 | }; |
6187 | ||
6188 | /* Note that we overload xs=2 to indicate 64-bit offset. */ | |
d28d12f0 RH |
6189 | static gen_helper_gvec_mem_scatter * const |
6190 | gather_load_fn64[2][2][2][3][2][4] = { | |
6191 | { /* MTE Inactive */ | |
6192 | { /* Little-endian */ | |
6193 | { { { gen_helper_sve_ldbds_zsu, | |
6194 | gen_helper_sve_ldhds_le_zsu, | |
6195 | gen_helper_sve_ldsds_le_zsu, | |
6196 | NULL, }, | |
6197 | { gen_helper_sve_ldbdu_zsu, | |
6198 | gen_helper_sve_ldhdu_le_zsu, | |
6199 | gen_helper_sve_ldsdu_le_zsu, | |
6200 | gen_helper_sve_lddd_le_zsu, } }, | |
6201 | { { gen_helper_sve_ldbds_zss, | |
6202 | gen_helper_sve_ldhds_le_zss, | |
6203 | gen_helper_sve_ldsds_le_zss, | |
6204 | NULL, }, | |
6205 | { gen_helper_sve_ldbdu_zss, | |
6206 | gen_helper_sve_ldhdu_le_zss, | |
6207 | gen_helper_sve_ldsdu_le_zss, | |
6208 | gen_helper_sve_lddd_le_zss, } }, | |
6209 | { { gen_helper_sve_ldbds_zd, | |
6210 | gen_helper_sve_ldhds_le_zd, | |
6211 | gen_helper_sve_ldsds_le_zd, | |
6212 | NULL, }, | |
6213 | { gen_helper_sve_ldbdu_zd, | |
6214 | gen_helper_sve_ldhdu_le_zd, | |
6215 | gen_helper_sve_ldsdu_le_zd, | |
6216 | gen_helper_sve_lddd_le_zd, } } }, | |
6217 | ||
6218 | /* First-fault */ | |
6219 | { { { gen_helper_sve_ldffbds_zsu, | |
6220 | gen_helper_sve_ldffhds_le_zsu, | |
6221 | gen_helper_sve_ldffsds_le_zsu, | |
6222 | NULL, }, | |
6223 | { gen_helper_sve_ldffbdu_zsu, | |
6224 | gen_helper_sve_ldffhdu_le_zsu, | |
6225 | gen_helper_sve_ldffsdu_le_zsu, | |
6226 | gen_helper_sve_ldffdd_le_zsu, } }, | |
6227 | { { gen_helper_sve_ldffbds_zss, | |
6228 | gen_helper_sve_ldffhds_le_zss, | |
6229 | gen_helper_sve_ldffsds_le_zss, | |
6230 | NULL, }, | |
6231 | { gen_helper_sve_ldffbdu_zss, | |
6232 | gen_helper_sve_ldffhdu_le_zss, | |
6233 | gen_helper_sve_ldffsdu_le_zss, | |
6234 | gen_helper_sve_ldffdd_le_zss, } }, | |
6235 | { { gen_helper_sve_ldffbds_zd, | |
6236 | gen_helper_sve_ldffhds_le_zd, | |
6237 | gen_helper_sve_ldffsds_le_zd, | |
6238 | NULL, }, | |
6239 | { gen_helper_sve_ldffbdu_zd, | |
6240 | gen_helper_sve_ldffhdu_le_zd, | |
6241 | gen_helper_sve_ldffsdu_le_zd, | |
6242 | gen_helper_sve_ldffdd_le_zd, } } } }, | |
6243 | { /* Big-endian */ | |
6244 | { { { gen_helper_sve_ldbds_zsu, | |
6245 | gen_helper_sve_ldhds_be_zsu, | |
6246 | gen_helper_sve_ldsds_be_zsu, | |
6247 | NULL, }, | |
6248 | { gen_helper_sve_ldbdu_zsu, | |
6249 | gen_helper_sve_ldhdu_be_zsu, | |
6250 | gen_helper_sve_ldsdu_be_zsu, | |
6251 | gen_helper_sve_lddd_be_zsu, } }, | |
6252 | { { gen_helper_sve_ldbds_zss, | |
6253 | gen_helper_sve_ldhds_be_zss, | |
6254 | gen_helper_sve_ldsds_be_zss, | |
6255 | NULL, }, | |
6256 | { gen_helper_sve_ldbdu_zss, | |
6257 | gen_helper_sve_ldhdu_be_zss, | |
6258 | gen_helper_sve_ldsdu_be_zss, | |
6259 | gen_helper_sve_lddd_be_zss, } }, | |
6260 | { { gen_helper_sve_ldbds_zd, | |
6261 | gen_helper_sve_ldhds_be_zd, | |
6262 | gen_helper_sve_ldsds_be_zd, | |
6263 | NULL, }, | |
6264 | { gen_helper_sve_ldbdu_zd, | |
6265 | gen_helper_sve_ldhdu_be_zd, | |
6266 | gen_helper_sve_ldsdu_be_zd, | |
6267 | gen_helper_sve_lddd_be_zd, } } }, | |
6268 | ||
6269 | /* First-fault */ | |
6270 | { { { gen_helper_sve_ldffbds_zsu, | |
6271 | gen_helper_sve_ldffhds_be_zsu, | |
6272 | gen_helper_sve_ldffsds_be_zsu, | |
6273 | NULL, }, | |
6274 | { gen_helper_sve_ldffbdu_zsu, | |
6275 | gen_helper_sve_ldffhdu_be_zsu, | |
6276 | gen_helper_sve_ldffsdu_be_zsu, | |
6277 | gen_helper_sve_ldffdd_be_zsu, } }, | |
6278 | { { gen_helper_sve_ldffbds_zss, | |
6279 | gen_helper_sve_ldffhds_be_zss, | |
6280 | gen_helper_sve_ldffsds_be_zss, | |
6281 | NULL, }, | |
6282 | { gen_helper_sve_ldffbdu_zss, | |
6283 | gen_helper_sve_ldffhdu_be_zss, | |
6284 | gen_helper_sve_ldffsdu_be_zss, | |
6285 | gen_helper_sve_ldffdd_be_zss, } }, | |
6286 | { { gen_helper_sve_ldffbds_zd, | |
6287 | gen_helper_sve_ldffhds_be_zd, | |
6288 | gen_helper_sve_ldffsds_be_zd, | |
6289 | NULL, }, | |
6290 | { gen_helper_sve_ldffbdu_zd, | |
6291 | gen_helper_sve_ldffhdu_be_zd, | |
6292 | gen_helper_sve_ldffsdu_be_zd, | |
6293 | gen_helper_sve_ldffdd_be_zd, } } } } }, | |
6294 | { /* MTE Active */ | |
6295 | { /* Little-endian */ | |
6296 | { { { gen_helper_sve_ldbds_zsu_mte, | |
6297 | gen_helper_sve_ldhds_le_zsu_mte, | |
6298 | gen_helper_sve_ldsds_le_zsu_mte, | |
6299 | NULL, }, | |
6300 | { gen_helper_sve_ldbdu_zsu_mte, | |
6301 | gen_helper_sve_ldhdu_le_zsu_mte, | |
6302 | gen_helper_sve_ldsdu_le_zsu_mte, | |
6303 | gen_helper_sve_lddd_le_zsu_mte, } }, | |
6304 | { { gen_helper_sve_ldbds_zss_mte, | |
6305 | gen_helper_sve_ldhds_le_zss_mte, | |
6306 | gen_helper_sve_ldsds_le_zss_mte, | |
6307 | NULL, }, | |
6308 | { gen_helper_sve_ldbdu_zss_mte, | |
6309 | gen_helper_sve_ldhdu_le_zss_mte, | |
6310 | gen_helper_sve_ldsdu_le_zss_mte, | |
6311 | gen_helper_sve_lddd_le_zss_mte, } }, | |
6312 | { { gen_helper_sve_ldbds_zd_mte, | |
6313 | gen_helper_sve_ldhds_le_zd_mte, | |
6314 | gen_helper_sve_ldsds_le_zd_mte, | |
6315 | NULL, }, | |
6316 | { gen_helper_sve_ldbdu_zd_mte, | |
6317 | gen_helper_sve_ldhdu_le_zd_mte, | |
6318 | gen_helper_sve_ldsdu_le_zd_mte, | |
6319 | gen_helper_sve_lddd_le_zd_mte, } } }, | |
6320 | ||
6321 | /* First-fault */ | |
6322 | { { { gen_helper_sve_ldffbds_zsu_mte, | |
6323 | gen_helper_sve_ldffhds_le_zsu_mte, | |
6324 | gen_helper_sve_ldffsds_le_zsu_mte, | |
6325 | NULL, }, | |
6326 | { gen_helper_sve_ldffbdu_zsu_mte, | |
6327 | gen_helper_sve_ldffhdu_le_zsu_mte, | |
6328 | gen_helper_sve_ldffsdu_le_zsu_mte, | |
6329 | gen_helper_sve_ldffdd_le_zsu_mte, } }, | |
6330 | { { gen_helper_sve_ldffbds_zss_mte, | |
6331 | gen_helper_sve_ldffhds_le_zss_mte, | |
6332 | gen_helper_sve_ldffsds_le_zss_mte, | |
6333 | NULL, }, | |
6334 | { gen_helper_sve_ldffbdu_zss_mte, | |
6335 | gen_helper_sve_ldffhdu_le_zss_mte, | |
6336 | gen_helper_sve_ldffsdu_le_zss_mte, | |
6337 | gen_helper_sve_ldffdd_le_zss_mte, } }, | |
6338 | { { gen_helper_sve_ldffbds_zd_mte, | |
6339 | gen_helper_sve_ldffhds_le_zd_mte, | |
6340 | gen_helper_sve_ldffsds_le_zd_mte, | |
6341 | NULL, }, | |
6342 | { gen_helper_sve_ldffbdu_zd_mte, | |
6343 | gen_helper_sve_ldffhdu_le_zd_mte, | |
6344 | gen_helper_sve_ldffsdu_le_zd_mte, | |
6345 | gen_helper_sve_ldffdd_le_zd_mte, } } } }, | |
6346 | { /* Big-endian */ | |
6347 | { { { gen_helper_sve_ldbds_zsu_mte, | |
6348 | gen_helper_sve_ldhds_be_zsu_mte, | |
6349 | gen_helper_sve_ldsds_be_zsu_mte, | |
6350 | NULL, }, | |
6351 | { gen_helper_sve_ldbdu_zsu_mte, | |
6352 | gen_helper_sve_ldhdu_be_zsu_mte, | |
6353 | gen_helper_sve_ldsdu_be_zsu_mte, | |
6354 | gen_helper_sve_lddd_be_zsu_mte, } }, | |
6355 | { { gen_helper_sve_ldbds_zss_mte, | |
6356 | gen_helper_sve_ldhds_be_zss_mte, | |
6357 | gen_helper_sve_ldsds_be_zss_mte, | |
6358 | NULL, }, | |
6359 | { gen_helper_sve_ldbdu_zss_mte, | |
6360 | gen_helper_sve_ldhdu_be_zss_mte, | |
6361 | gen_helper_sve_ldsdu_be_zss_mte, | |
6362 | gen_helper_sve_lddd_be_zss_mte, } }, | |
6363 | { { gen_helper_sve_ldbds_zd_mte, | |
6364 | gen_helper_sve_ldhds_be_zd_mte, | |
6365 | gen_helper_sve_ldsds_be_zd_mte, | |
6366 | NULL, }, | |
6367 | { gen_helper_sve_ldbdu_zd_mte, | |
6368 | gen_helper_sve_ldhdu_be_zd_mte, | |
6369 | gen_helper_sve_ldsdu_be_zd_mte, | |
6370 | gen_helper_sve_lddd_be_zd_mte, } } }, | |
6371 | ||
6372 | /* First-fault */ | |
6373 | { { { gen_helper_sve_ldffbds_zsu_mte, | |
6374 | gen_helper_sve_ldffhds_be_zsu_mte, | |
6375 | gen_helper_sve_ldffsds_be_zsu_mte, | |
6376 | NULL, }, | |
6377 | { gen_helper_sve_ldffbdu_zsu_mte, | |
6378 | gen_helper_sve_ldffhdu_be_zsu_mte, | |
6379 | gen_helper_sve_ldffsdu_be_zsu_mte, | |
6380 | gen_helper_sve_ldffdd_be_zsu_mte, } }, | |
6381 | { { gen_helper_sve_ldffbds_zss_mte, | |
6382 | gen_helper_sve_ldffhds_be_zss_mte, | |
6383 | gen_helper_sve_ldffsds_be_zss_mte, | |
6384 | NULL, }, | |
6385 | { gen_helper_sve_ldffbdu_zss_mte, | |
6386 | gen_helper_sve_ldffhdu_be_zss_mte, | |
6387 | gen_helper_sve_ldffsdu_be_zss_mte, | |
6388 | gen_helper_sve_ldffdd_be_zss_mte, } }, | |
6389 | { { gen_helper_sve_ldffbds_zd_mte, | |
6390 | gen_helper_sve_ldffhds_be_zd_mte, | |
6391 | gen_helper_sve_ldffsds_be_zd_mte, | |
6392 | NULL, }, | |
6393 | { gen_helper_sve_ldffbdu_zd_mte, | |
6394 | gen_helper_sve_ldffhdu_be_zd_mte, | |
6395 | gen_helper_sve_ldffsdu_be_zd_mte, | |
6396 | gen_helper_sve_ldffdd_be_zd_mte, } } } } }, | |
673e9fa6 RH |
6397 | }; |
6398 | ||
3a7be554 | 6399 | static bool trans_LD1_zprz(DisasContext *s, arg_LD1_zprz *a) |
673e9fa6 RH |
6400 | { |
6401 | gen_helper_gvec_mem_scatter *fn = NULL; | |
d28d12f0 RH |
6402 | bool be = s->be_data == MO_BE; |
6403 | bool mte = s->mte_active[0]; | |
673e9fa6 RH |
6404 | |
6405 | if (!sve_access_check(s)) { | |
6406 | return true; | |
6407 | } | |
6408 | ||
6409 | switch (a->esz) { | |
6410 | case MO_32: | |
d28d12f0 | 6411 | fn = gather_load_fn32[mte][be][a->ff][a->xs][a->u][a->msz]; |
673e9fa6 RH |
6412 | break; |
6413 | case MO_64: | |
d28d12f0 | 6414 | fn = gather_load_fn64[mte][be][a->ff][a->xs][a->u][a->msz]; |
673e9fa6 RH |
6415 | break; |
6416 | } | |
6417 | assert(fn != NULL); | |
6418 | ||
6419 | do_mem_zpz(s, a->rd, a->pg, a->rm, a->scale * a->msz, | |
d28d12f0 | 6420 | cpu_reg_sp(s, a->rn), a->msz, false, fn); |
673e9fa6 RH |
6421 | return true; |
6422 | } | |
6423 | ||
3a7be554 | 6424 | static bool trans_LD1_zpiz(DisasContext *s, arg_LD1_zpiz *a) |
673e9fa6 RH |
6425 | { |
6426 | gen_helper_gvec_mem_scatter *fn = NULL; | |
d28d12f0 RH |
6427 | bool be = s->be_data == MO_BE; |
6428 | bool mte = s->mte_active[0]; | |
673e9fa6 RH |
6429 | TCGv_i64 imm; |
6430 | ||
6431 | if (a->esz < a->msz || (a->esz == a->msz && !a->u)) { | |
6432 | return false; | |
6433 | } | |
6434 | if (!sve_access_check(s)) { | |
6435 | return true; | |
6436 | } | |
6437 | ||
6438 | switch (a->esz) { | |
6439 | case MO_32: | |
d28d12f0 | 6440 | fn = gather_load_fn32[mte][be][a->ff][0][a->u][a->msz]; |
673e9fa6 RH |
6441 | break; |
6442 | case MO_64: | |
d28d12f0 | 6443 | fn = gather_load_fn64[mte][be][a->ff][2][a->u][a->msz]; |
673e9fa6 RH |
6444 | break; |
6445 | } | |
6446 | assert(fn != NULL); | |
6447 | ||
6448 | /* Treat LD1_zpiz (zn[x] + imm) the same way as LD1_zprz (rn + zm[x]) | |
6449 | * by loading the immediate into the scalar parameter. | |
6450 | */ | |
6451 | imm = tcg_const_i64(a->imm << a->msz); | |
d28d12f0 | 6452 | do_mem_zpz(s, a->rd, a->pg, a->rn, 0, imm, a->msz, false, fn); |
673e9fa6 RH |
6453 | tcg_temp_free_i64(imm); |
6454 | return true; | |
6455 | } | |
6456 | ||
cf327449 SL |
6457 | static bool trans_LDNT1_zprz(DisasContext *s, arg_LD1_zprz *a) |
6458 | { | |
b17ab470 RH |
6459 | gen_helper_gvec_mem_scatter *fn = NULL; |
6460 | bool be = s->be_data == MO_BE; | |
6461 | bool mte = s->mte_active[0]; | |
6462 | ||
6463 | if (a->esz < a->msz + !a->u) { | |
6464 | return false; | |
6465 | } | |
cf327449 SL |
6466 | if (!dc_isar_feature(aa64_sve2, s)) { |
6467 | return false; | |
6468 | } | |
b17ab470 RH |
6469 | if (!sve_access_check(s)) { |
6470 | return true; | |
6471 | } | |
6472 | ||
6473 | switch (a->esz) { | |
6474 | case MO_32: | |
6475 | fn = gather_load_fn32[mte][be][0][0][a->u][a->msz]; | |
6476 | break; | |
6477 | case MO_64: | |
6478 | fn = gather_load_fn64[mte][be][0][2][a->u][a->msz]; | |
6479 | break; | |
6480 | } | |
6481 | assert(fn != NULL); | |
6482 | ||
6483 | do_mem_zpz(s, a->rd, a->pg, a->rn, 0, | |
6484 | cpu_reg(s, a->rm), a->msz, false, fn); | |
6485 | return true; | |
cf327449 SL |
6486 | } |
6487 | ||
d28d12f0 RH |
6488 | /* Indexed by [mte][be][xs][msz]. */ |
6489 | static gen_helper_gvec_mem_scatter * const scatter_store_fn32[2][2][2][3] = { | |
6490 | { /* MTE Inactive */ | |
6491 | { /* Little-endian */ | |
6492 | { gen_helper_sve_stbs_zsu, | |
6493 | gen_helper_sve_sths_le_zsu, | |
6494 | gen_helper_sve_stss_le_zsu, }, | |
6495 | { gen_helper_sve_stbs_zss, | |
6496 | gen_helper_sve_sths_le_zss, | |
6497 | gen_helper_sve_stss_le_zss, } }, | |
6498 | { /* Big-endian */ | |
6499 | { gen_helper_sve_stbs_zsu, | |
6500 | gen_helper_sve_sths_be_zsu, | |
6501 | gen_helper_sve_stss_be_zsu, }, | |
6502 | { gen_helper_sve_stbs_zss, | |
6503 | gen_helper_sve_sths_be_zss, | |
6504 | gen_helper_sve_stss_be_zss, } } }, | |
6505 | { /* MTE Active */ | |
6506 | { /* Little-endian */ | |
6507 | { gen_helper_sve_stbs_zsu_mte, | |
6508 | gen_helper_sve_sths_le_zsu_mte, | |
6509 | gen_helper_sve_stss_le_zsu_mte, }, | |
6510 | { gen_helper_sve_stbs_zss_mte, | |
6511 | gen_helper_sve_sths_le_zss_mte, | |
6512 | gen_helper_sve_stss_le_zss_mte, } }, | |
6513 | { /* Big-endian */ | |
6514 | { gen_helper_sve_stbs_zsu_mte, | |
6515 | gen_helper_sve_sths_be_zsu_mte, | |
6516 | gen_helper_sve_stss_be_zsu_mte, }, | |
6517 | { gen_helper_sve_stbs_zss_mte, | |
6518 | gen_helper_sve_sths_be_zss_mte, | |
6519 | gen_helper_sve_stss_be_zss_mte, } } }, | |
408ecde9 RH |
6520 | }; |
6521 | ||
6522 | /* Note that we overload xs=2 to indicate 64-bit offset. */ | |
d28d12f0 RH |
6523 | static gen_helper_gvec_mem_scatter * const scatter_store_fn64[2][2][3][4] = { |
6524 | { /* MTE Inactive */ | |
6525 | { /* Little-endian */ | |
6526 | { gen_helper_sve_stbd_zsu, | |
6527 | gen_helper_sve_sthd_le_zsu, | |
6528 | gen_helper_sve_stsd_le_zsu, | |
6529 | gen_helper_sve_stdd_le_zsu, }, | |
6530 | { gen_helper_sve_stbd_zss, | |
6531 | gen_helper_sve_sthd_le_zss, | |
6532 | gen_helper_sve_stsd_le_zss, | |
6533 | gen_helper_sve_stdd_le_zss, }, | |
6534 | { gen_helper_sve_stbd_zd, | |
6535 | gen_helper_sve_sthd_le_zd, | |
6536 | gen_helper_sve_stsd_le_zd, | |
6537 | gen_helper_sve_stdd_le_zd, } }, | |
6538 | { /* Big-endian */ | |
6539 | { gen_helper_sve_stbd_zsu, | |
6540 | gen_helper_sve_sthd_be_zsu, | |
6541 | gen_helper_sve_stsd_be_zsu, | |
6542 | gen_helper_sve_stdd_be_zsu, }, | |
6543 | { gen_helper_sve_stbd_zss, | |
6544 | gen_helper_sve_sthd_be_zss, | |
6545 | gen_helper_sve_stsd_be_zss, | |
6546 | gen_helper_sve_stdd_be_zss, }, | |
6547 | { gen_helper_sve_stbd_zd, | |
6548 | gen_helper_sve_sthd_be_zd, | |
6549 | gen_helper_sve_stsd_be_zd, | |
6550 | gen_helper_sve_stdd_be_zd, } } }, | |
6551 | { /* MTE Inactive */ | |
6552 | { /* Little-endian */ | |
6553 | { gen_helper_sve_stbd_zsu_mte, | |
6554 | gen_helper_sve_sthd_le_zsu_mte, | |
6555 | gen_helper_sve_stsd_le_zsu_mte, | |
6556 | gen_helper_sve_stdd_le_zsu_mte, }, | |
6557 | { gen_helper_sve_stbd_zss_mte, | |
6558 | gen_helper_sve_sthd_le_zss_mte, | |
6559 | gen_helper_sve_stsd_le_zss_mte, | |
6560 | gen_helper_sve_stdd_le_zss_mte, }, | |
6561 | { gen_helper_sve_stbd_zd_mte, | |
6562 | gen_helper_sve_sthd_le_zd_mte, | |
6563 | gen_helper_sve_stsd_le_zd_mte, | |
6564 | gen_helper_sve_stdd_le_zd_mte, } }, | |
6565 | { /* Big-endian */ | |
6566 | { gen_helper_sve_stbd_zsu_mte, | |
6567 | gen_helper_sve_sthd_be_zsu_mte, | |
6568 | gen_helper_sve_stsd_be_zsu_mte, | |
6569 | gen_helper_sve_stdd_be_zsu_mte, }, | |
6570 | { gen_helper_sve_stbd_zss_mte, | |
6571 | gen_helper_sve_sthd_be_zss_mte, | |
6572 | gen_helper_sve_stsd_be_zss_mte, | |
6573 | gen_helper_sve_stdd_be_zss_mte, }, | |
6574 | { gen_helper_sve_stbd_zd_mte, | |
6575 | gen_helper_sve_sthd_be_zd_mte, | |
6576 | gen_helper_sve_stsd_be_zd_mte, | |
6577 | gen_helper_sve_stdd_be_zd_mte, } } }, | |
408ecde9 RH |
6578 | }; |
6579 | ||
3a7be554 | 6580 | static bool trans_ST1_zprz(DisasContext *s, arg_ST1_zprz *a) |
f6dbf62a | 6581 | { |
f6dbf62a | 6582 | gen_helper_gvec_mem_scatter *fn; |
d28d12f0 RH |
6583 | bool be = s->be_data == MO_BE; |
6584 | bool mte = s->mte_active[0]; | |
f6dbf62a RH |
6585 | |
6586 | if (a->esz < a->msz || (a->msz == 0 && a->scale)) { | |
6587 | return false; | |
6588 | } | |
6589 | if (!sve_access_check(s)) { | |
6590 | return true; | |
6591 | } | |
6592 | switch (a->esz) { | |
6593 | case MO_32: | |
d28d12f0 | 6594 | fn = scatter_store_fn32[mte][be][a->xs][a->msz]; |
f6dbf62a RH |
6595 | break; |
6596 | case MO_64: | |
d28d12f0 | 6597 | fn = scatter_store_fn64[mte][be][a->xs][a->msz]; |
f6dbf62a RH |
6598 | break; |
6599 | default: | |
6600 | g_assert_not_reached(); | |
6601 | } | |
6602 | do_mem_zpz(s, a->rd, a->pg, a->rm, a->scale * a->msz, | |
d28d12f0 | 6603 | cpu_reg_sp(s, a->rn), a->msz, true, fn); |
f6dbf62a RH |
6604 | return true; |
6605 | } | |
dec6cf6b | 6606 | |
3a7be554 | 6607 | static bool trans_ST1_zpiz(DisasContext *s, arg_ST1_zpiz *a) |
408ecde9 RH |
6608 | { |
6609 | gen_helper_gvec_mem_scatter *fn = NULL; | |
d28d12f0 RH |
6610 | bool be = s->be_data == MO_BE; |
6611 | bool mte = s->mte_active[0]; | |
408ecde9 RH |
6612 | TCGv_i64 imm; |
6613 | ||
6614 | if (a->esz < a->msz) { | |
6615 | return false; | |
6616 | } | |
6617 | if (!sve_access_check(s)) { | |
6618 | return true; | |
6619 | } | |
6620 | ||
6621 | switch (a->esz) { | |
6622 | case MO_32: | |
d28d12f0 | 6623 | fn = scatter_store_fn32[mte][be][0][a->msz]; |
408ecde9 RH |
6624 | break; |
6625 | case MO_64: | |
d28d12f0 | 6626 | fn = scatter_store_fn64[mte][be][2][a->msz]; |
408ecde9 RH |
6627 | break; |
6628 | } | |
6629 | assert(fn != NULL); | |
6630 | ||
6631 | /* Treat ST1_zpiz (zn[x] + imm) the same way as ST1_zprz (rn + zm[x]) | |
6632 | * by loading the immediate into the scalar parameter. | |
6633 | */ | |
6634 | imm = tcg_const_i64(a->imm << a->msz); | |
d28d12f0 | 6635 | do_mem_zpz(s, a->rd, a->pg, a->rn, 0, imm, a->msz, true, fn); |
408ecde9 RH |
6636 | tcg_temp_free_i64(imm); |
6637 | return true; | |
6638 | } | |
6639 | ||
6ebca45f SL |
6640 | static bool trans_STNT1_zprz(DisasContext *s, arg_ST1_zprz *a) |
6641 | { | |
b17ab470 RH |
6642 | gen_helper_gvec_mem_scatter *fn; |
6643 | bool be = s->be_data == MO_BE; | |
6644 | bool mte = s->mte_active[0]; | |
6645 | ||
6646 | if (a->esz < a->msz) { | |
6647 | return false; | |
6648 | } | |
6ebca45f SL |
6649 | if (!dc_isar_feature(aa64_sve2, s)) { |
6650 | return false; | |
6651 | } | |
b17ab470 RH |
6652 | if (!sve_access_check(s)) { |
6653 | return true; | |
6654 | } | |
6655 | ||
6656 | switch (a->esz) { | |
6657 | case MO_32: | |
6658 | fn = scatter_store_fn32[mte][be][0][a->msz]; | |
6659 | break; | |
6660 | case MO_64: | |
6661 | fn = scatter_store_fn64[mte][be][2][a->msz]; | |
6662 | break; | |
6663 | default: | |
6664 | g_assert_not_reached(); | |
6665 | } | |
6666 | ||
6667 | do_mem_zpz(s, a->rd, a->pg, a->rn, 0, | |
6668 | cpu_reg(s, a->rm), a->msz, true, fn); | |
6669 | return true; | |
6ebca45f SL |
6670 | } |
6671 | ||
dec6cf6b RH |
6672 | /* |
6673 | * Prefetches | |
6674 | */ | |
6675 | ||
3a7be554 | 6676 | static bool trans_PRF(DisasContext *s, arg_PRF *a) |
dec6cf6b RH |
6677 | { |
6678 | /* Prefetch is a nop within QEMU. */ | |
2f95a3b0 | 6679 | (void)sve_access_check(s); |
dec6cf6b RH |
6680 | return true; |
6681 | } | |
6682 | ||
3a7be554 | 6683 | static bool trans_PRF_rr(DisasContext *s, arg_PRF_rr *a) |
dec6cf6b RH |
6684 | { |
6685 | if (a->rm == 31) { | |
6686 | return false; | |
6687 | } | |
6688 | /* Prefetch is a nop within QEMU. */ | |
2f95a3b0 | 6689 | (void)sve_access_check(s); |
dec6cf6b RH |
6690 | return true; |
6691 | } | |
a2103582 RH |
6692 | |
6693 | /* | |
6694 | * Move Prefix | |
6695 | * | |
6696 | * TODO: The implementation so far could handle predicated merging movprfx. | |
6697 | * The helper functions as written take an extra source register to | |
6698 | * use in the operation, but the result is only written when predication | |
6699 | * succeeds. For unpredicated movprfx, we need to rearrange the helpers | |
6700 | * to allow the final write back to the destination to be unconditional. | |
6701 | * For predicated zeroing movprfx, we need to rearrange the helpers to | |
6702 | * allow the final write back to zero inactives. | |
6703 | * | |
6704 | * In the meantime, just emit the moves. | |
6705 | */ | |
6706 | ||
3a7be554 | 6707 | static bool trans_MOVPRFX(DisasContext *s, arg_MOVPRFX *a) |
a2103582 RH |
6708 | { |
6709 | return do_mov_z(s, a->rd, a->rn); | |
6710 | } | |
6711 | ||
3a7be554 | 6712 | static bool trans_MOVPRFX_m(DisasContext *s, arg_rpr_esz *a) |
a2103582 RH |
6713 | { |
6714 | if (sve_access_check(s)) { | |
6715 | do_sel_z(s, a->rd, a->rn, a->rd, a->pg, a->esz); | |
6716 | } | |
6717 | return true; | |
6718 | } | |
6719 | ||
3a7be554 | 6720 | static bool trans_MOVPRFX_z(DisasContext *s, arg_rpr_esz *a) |
a2103582 | 6721 | { |
60245996 | 6722 | return do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz, false); |
a2103582 | 6723 | } |
5dad1ba5 RH |
6724 | |
6725 | /* | |
6726 | * SVE2 Integer Multiply - Unpredicated | |
6727 | */ | |
6728 | ||
6729 | static bool trans_MUL_zzz(DisasContext *s, arg_rrr_esz *a) | |
6730 | { | |
6731 | if (!dc_isar_feature(aa64_sve2, s)) { | |
6732 | return false; | |
6733 | } | |
6734 | if (sve_access_check(s)) { | |
6735 | gen_gvec_fn_zzz(s, tcg_gen_gvec_mul, a->esz, a->rd, a->rn, a->rm); | |
6736 | } | |
6737 | return true; | |
6738 | } | |
6739 | ||
6740 | static bool do_sve2_zzz_ool(DisasContext *s, arg_rrr_esz *a, | |
6741 | gen_helper_gvec_3 *fn) | |
6742 | { | |
6743 | if (fn == NULL || !dc_isar_feature(aa64_sve2, s)) { | |
6744 | return false; | |
6745 | } | |
6746 | if (sve_access_check(s)) { | |
6747 | gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0); | |
6748 | } | |
6749 | return true; | |
6750 | } | |
6751 | ||
6752 | static bool trans_SMULH_zzz(DisasContext *s, arg_rrr_esz *a) | |
6753 | { | |
6754 | static gen_helper_gvec_3 * const fns[4] = { | |
6755 | gen_helper_gvec_smulh_b, gen_helper_gvec_smulh_h, | |
6756 | gen_helper_gvec_smulh_s, gen_helper_gvec_smulh_d, | |
6757 | }; | |
6758 | return do_sve2_zzz_ool(s, a, fns[a->esz]); | |
6759 | } | |
6760 | ||
6761 | static bool trans_UMULH_zzz(DisasContext *s, arg_rrr_esz *a) | |
6762 | { | |
6763 | static gen_helper_gvec_3 * const fns[4] = { | |
6764 | gen_helper_gvec_umulh_b, gen_helper_gvec_umulh_h, | |
6765 | gen_helper_gvec_umulh_s, gen_helper_gvec_umulh_d, | |
6766 | }; | |
6767 | return do_sve2_zzz_ool(s, a, fns[a->esz]); | |
6768 | } | |
6769 | ||
6770 | static bool trans_PMUL_zzz(DisasContext *s, arg_rrr_esz *a) | |
6771 | { | |
6772 | return do_sve2_zzz_ool(s, a, gen_helper_gvec_pmul_b); | |
6773 | } | |
d4b1e59d | 6774 | |
169d7c58 RH |
6775 | static bool trans_SQDMULH_zzz(DisasContext *s, arg_rrr_esz *a) |
6776 | { | |
6777 | static gen_helper_gvec_3 * const fns[4] = { | |
6778 | gen_helper_sve2_sqdmulh_b, gen_helper_sve2_sqdmulh_h, | |
6779 | gen_helper_sve2_sqdmulh_s, gen_helper_sve2_sqdmulh_d, | |
6780 | }; | |
6781 | return do_sve2_zzz_ool(s, a, fns[a->esz]); | |
6782 | } | |
6783 | ||
6784 | static bool trans_SQRDMULH_zzz(DisasContext *s, arg_rrr_esz *a) | |
6785 | { | |
6786 | static gen_helper_gvec_3 * const fns[4] = { | |
6787 | gen_helper_sve2_sqrdmulh_b, gen_helper_sve2_sqrdmulh_h, | |
6788 | gen_helper_sve2_sqrdmulh_s, gen_helper_sve2_sqrdmulh_d, | |
6789 | }; | |
6790 | return do_sve2_zzz_ool(s, a, fns[a->esz]); | |
6791 | } | |
6792 | ||
d4b1e59d RH |
6793 | /* |
6794 | * SVE2 Integer - Predicated | |
6795 | */ | |
6796 | ||
6797 | static bool do_sve2_zpzz_ool(DisasContext *s, arg_rprr_esz *a, | |
6798 | gen_helper_gvec_4 *fn) | |
6799 | { | |
6800 | if (!dc_isar_feature(aa64_sve2, s)) { | |
6801 | return false; | |
6802 | } | |
6803 | return do_zpzz_ool(s, a, fn); | |
6804 | } | |
6805 | ||
6806 | static bool trans_SADALP_zpzz(DisasContext *s, arg_rprr_esz *a) | |
6807 | { | |
6808 | static gen_helper_gvec_4 * const fns[3] = { | |
6809 | gen_helper_sve2_sadalp_zpzz_h, | |
6810 | gen_helper_sve2_sadalp_zpzz_s, | |
6811 | gen_helper_sve2_sadalp_zpzz_d, | |
6812 | }; | |
6813 | if (a->esz == 0) { | |
6814 | return false; | |
6815 | } | |
6816 | return do_sve2_zpzz_ool(s, a, fns[a->esz - 1]); | |
6817 | } | |
6818 | ||
6819 | static bool trans_UADALP_zpzz(DisasContext *s, arg_rprr_esz *a) | |
6820 | { | |
6821 | static gen_helper_gvec_4 * const fns[3] = { | |
6822 | gen_helper_sve2_uadalp_zpzz_h, | |
6823 | gen_helper_sve2_uadalp_zpzz_s, | |
6824 | gen_helper_sve2_uadalp_zpzz_d, | |
6825 | }; | |
6826 | if (a->esz == 0) { | |
6827 | return false; | |
6828 | } | |
6829 | return do_sve2_zpzz_ool(s, a, fns[a->esz - 1]); | |
6830 | } | |
db366da8 RH |
6831 | |
6832 | /* | |
6833 | * SVE2 integer unary operations (predicated) | |
6834 | */ | |
6835 | ||
6836 | static bool do_sve2_zpz_ool(DisasContext *s, arg_rpr_esz *a, | |
6837 | gen_helper_gvec_3 *fn) | |
6838 | { | |
6839 | if (!dc_isar_feature(aa64_sve2, s)) { | |
6840 | return false; | |
6841 | } | |
6842 | return do_zpz_ool(s, a, fn); | |
6843 | } | |
6844 | ||
6845 | static bool trans_URECPE(DisasContext *s, arg_rpr_esz *a) | |
6846 | { | |
6847 | if (a->esz != 2) { | |
6848 | return false; | |
6849 | } | |
6850 | return do_sve2_zpz_ool(s, a, gen_helper_sve2_urecpe_s); | |
6851 | } | |
6852 | ||
6853 | static bool trans_URSQRTE(DisasContext *s, arg_rpr_esz *a) | |
6854 | { | |
6855 | if (a->esz != 2) { | |
6856 | return false; | |
6857 | } | |
6858 | return do_sve2_zpz_ool(s, a, gen_helper_sve2_ursqrte_s); | |
6859 | } | |
6860 | ||
6861 | static bool trans_SQABS(DisasContext *s, arg_rpr_esz *a) | |
6862 | { | |
6863 | static gen_helper_gvec_3 * const fns[4] = { | |
6864 | gen_helper_sve2_sqabs_b, gen_helper_sve2_sqabs_h, | |
6865 | gen_helper_sve2_sqabs_s, gen_helper_sve2_sqabs_d, | |
6866 | }; | |
6867 | return do_sve2_zpz_ool(s, a, fns[a->esz]); | |
6868 | } | |
6869 | ||
6870 | static bool trans_SQNEG(DisasContext *s, arg_rpr_esz *a) | |
6871 | { | |
6872 | static gen_helper_gvec_3 * const fns[4] = { | |
6873 | gen_helper_sve2_sqneg_b, gen_helper_sve2_sqneg_h, | |
6874 | gen_helper_sve2_sqneg_s, gen_helper_sve2_sqneg_d, | |
6875 | }; | |
6876 | return do_sve2_zpz_ool(s, a, fns[a->esz]); | |
6877 | } | |
45d9503d RH |
6878 | |
6879 | #define DO_SVE2_ZPZZ(NAME, name) \ | |
6880 | static bool trans_##NAME(DisasContext *s, arg_rprr_esz *a) \ | |
6881 | { \ | |
6882 | static gen_helper_gvec_4 * const fns[4] = { \ | |
6883 | gen_helper_sve2_##name##_zpzz_b, gen_helper_sve2_##name##_zpzz_h, \ | |
6884 | gen_helper_sve2_##name##_zpzz_s, gen_helper_sve2_##name##_zpzz_d, \ | |
6885 | }; \ | |
6886 | return do_sve2_zpzz_ool(s, a, fns[a->esz]); \ | |
6887 | } | |
6888 | ||
6889 | DO_SVE2_ZPZZ(SQSHL, sqshl) | |
6890 | DO_SVE2_ZPZZ(SQRSHL, sqrshl) | |
6891 | DO_SVE2_ZPZZ(SRSHL, srshl) | |
6892 | ||
6893 | DO_SVE2_ZPZZ(UQSHL, uqshl) | |
6894 | DO_SVE2_ZPZZ(UQRSHL, uqrshl) | |
6895 | DO_SVE2_ZPZZ(URSHL, urshl) | |
a47dc220 RH |
6896 | |
6897 | DO_SVE2_ZPZZ(SHADD, shadd) | |
6898 | DO_SVE2_ZPZZ(SRHADD, srhadd) | |
6899 | DO_SVE2_ZPZZ(SHSUB, shsub) | |
6900 | ||
6901 | DO_SVE2_ZPZZ(UHADD, uhadd) | |
6902 | DO_SVE2_ZPZZ(URHADD, urhadd) | |
6903 | DO_SVE2_ZPZZ(UHSUB, uhsub) | |
8597dc8b RH |
6904 | |
6905 | DO_SVE2_ZPZZ(ADDP, addp) | |
6906 | DO_SVE2_ZPZZ(SMAXP, smaxp) | |
6907 | DO_SVE2_ZPZZ(UMAXP, umaxp) | |
6908 | DO_SVE2_ZPZZ(SMINP, sminp) | |
6909 | DO_SVE2_ZPZZ(UMINP, uminp) | |
4f07fbeb RH |
6910 | |
6911 | DO_SVE2_ZPZZ(SQADD_zpzz, sqadd) | |
6912 | DO_SVE2_ZPZZ(UQADD_zpzz, uqadd) | |
6913 | DO_SVE2_ZPZZ(SQSUB_zpzz, sqsub) | |
6914 | DO_SVE2_ZPZZ(UQSUB_zpzz, uqsub) | |
6915 | DO_SVE2_ZPZZ(SUQADD, suqadd) | |
6916 | DO_SVE2_ZPZZ(USQADD, usqadd) | |
0ce1dda8 RH |
6917 | |
6918 | /* | |
6919 | * SVE2 Widening Integer Arithmetic | |
6920 | */ | |
6921 | ||
6922 | static bool do_sve2_zzw_ool(DisasContext *s, arg_rrr_esz *a, | |
6923 | gen_helper_gvec_3 *fn, int data) | |
6924 | { | |
6925 | if (fn == NULL || !dc_isar_feature(aa64_sve2, s)) { | |
6926 | return false; | |
6927 | } | |
6928 | if (sve_access_check(s)) { | |
6929 | unsigned vsz = vec_full_reg_size(s); | |
6930 | tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), | |
6931 | vec_full_reg_offset(s, a->rn), | |
6932 | vec_full_reg_offset(s, a->rm), | |
6933 | vsz, vsz, data, fn); | |
6934 | } | |
6935 | return true; | |
6936 | } | |
6937 | ||
6938 | #define DO_SVE2_ZZZ_TB(NAME, name, SEL1, SEL2) \ | |
6939 | static bool trans_##NAME(DisasContext *s, arg_rrr_esz *a) \ | |
6940 | { \ | |
6941 | static gen_helper_gvec_3 * const fns[4] = { \ | |
6942 | NULL, gen_helper_sve2_##name##_h, \ | |
6943 | gen_helper_sve2_##name##_s, gen_helper_sve2_##name##_d, \ | |
6944 | }; \ | |
6945 | return do_sve2_zzw_ool(s, a, fns[a->esz], (SEL2 << 1) | SEL1); \ | |
6946 | } | |
6947 | ||
6948 | DO_SVE2_ZZZ_TB(SADDLB, saddl, false, false) | |
6949 | DO_SVE2_ZZZ_TB(SSUBLB, ssubl, false, false) | |
6950 | DO_SVE2_ZZZ_TB(SABDLB, sabdl, false, false) | |
6951 | ||
6952 | DO_SVE2_ZZZ_TB(UADDLB, uaddl, false, false) | |
6953 | DO_SVE2_ZZZ_TB(USUBLB, usubl, false, false) | |
6954 | DO_SVE2_ZZZ_TB(UABDLB, uabdl, false, false) | |
6955 | ||
6956 | DO_SVE2_ZZZ_TB(SADDLT, saddl, true, true) | |
6957 | DO_SVE2_ZZZ_TB(SSUBLT, ssubl, true, true) | |
6958 | DO_SVE2_ZZZ_TB(SABDLT, sabdl, true, true) | |
6959 | ||
6960 | DO_SVE2_ZZZ_TB(UADDLT, uaddl, true, true) | |
6961 | DO_SVE2_ZZZ_TB(USUBLT, usubl, true, true) | |
6962 | DO_SVE2_ZZZ_TB(UABDLT, uabdl, true, true) | |
daec426b RH |
6963 | |
6964 | DO_SVE2_ZZZ_TB(SADDLBT, saddl, false, true) | |
6965 | DO_SVE2_ZZZ_TB(SSUBLBT, ssubl, false, true) | |
6966 | DO_SVE2_ZZZ_TB(SSUBLTB, ssubl, true, false) | |
81fccf09 | 6967 | |
69ccc099 RH |
6968 | DO_SVE2_ZZZ_TB(SQDMULLB_zzz, sqdmull_zzz, false, false) |
6969 | DO_SVE2_ZZZ_TB(SQDMULLT_zzz, sqdmull_zzz, true, true) | |
6970 | ||
6971 | DO_SVE2_ZZZ_TB(SMULLB_zzz, smull_zzz, false, false) | |
6972 | DO_SVE2_ZZZ_TB(SMULLT_zzz, smull_zzz, true, true) | |
6973 | ||
6974 | DO_SVE2_ZZZ_TB(UMULLB_zzz, umull_zzz, false, false) | |
6975 | DO_SVE2_ZZZ_TB(UMULLT_zzz, umull_zzz, true, true) | |
6976 | ||
2df3ca55 RH |
6977 | static bool do_eor_tb(DisasContext *s, arg_rrr_esz *a, bool sel1) |
6978 | { | |
6979 | static gen_helper_gvec_3 * const fns[4] = { | |
6980 | gen_helper_sve2_eoril_b, gen_helper_sve2_eoril_h, | |
6981 | gen_helper_sve2_eoril_s, gen_helper_sve2_eoril_d, | |
6982 | }; | |
6983 | return do_sve2_zzw_ool(s, a, fns[a->esz], (!sel1 << 1) | sel1); | |
6984 | } | |
6985 | ||
6986 | static bool trans_EORBT(DisasContext *s, arg_rrr_esz *a) | |
6987 | { | |
6988 | return do_eor_tb(s, a, false); | |
6989 | } | |
6990 | ||
6991 | static bool trans_EORTB(DisasContext *s, arg_rrr_esz *a) | |
6992 | { | |
6993 | return do_eor_tb(s, a, true); | |
6994 | } | |
6995 | ||
e3a56131 RH |
6996 | static bool do_trans_pmull(DisasContext *s, arg_rrr_esz *a, bool sel) |
6997 | { | |
6998 | static gen_helper_gvec_3 * const fns[4] = { | |
6999 | gen_helper_gvec_pmull_q, gen_helper_sve2_pmull_h, | |
7000 | NULL, gen_helper_sve2_pmull_d, | |
7001 | }; | |
7002 | if (a->esz == 0 && !dc_isar_feature(aa64_sve2_pmull128, s)) { | |
7003 | return false; | |
7004 | } | |
7005 | return do_sve2_zzw_ool(s, a, fns[a->esz], sel); | |
7006 | } | |
7007 | ||
7008 | static bool trans_PMULLB(DisasContext *s, arg_rrr_esz *a) | |
7009 | { | |
7010 | return do_trans_pmull(s, a, false); | |
7011 | } | |
7012 | ||
7013 | static bool trans_PMULLT(DisasContext *s, arg_rrr_esz *a) | |
7014 | { | |
7015 | return do_trans_pmull(s, a, true); | |
7016 | } | |
7017 | ||
81fccf09 RH |
7018 | #define DO_SVE2_ZZZ_WTB(NAME, name, SEL2) \ |
7019 | static bool trans_##NAME(DisasContext *s, arg_rrr_esz *a) \ | |
7020 | { \ | |
7021 | static gen_helper_gvec_3 * const fns[4] = { \ | |
7022 | NULL, gen_helper_sve2_##name##_h, \ | |
7023 | gen_helper_sve2_##name##_s, gen_helper_sve2_##name##_d, \ | |
7024 | }; \ | |
7025 | return do_sve2_zzw_ool(s, a, fns[a->esz], SEL2); \ | |
7026 | } | |
7027 | ||
7028 | DO_SVE2_ZZZ_WTB(SADDWB, saddw, false) | |
7029 | DO_SVE2_ZZZ_WTB(SADDWT, saddw, true) | |
7030 | DO_SVE2_ZZZ_WTB(SSUBWB, ssubw, false) | |
7031 | DO_SVE2_ZZZ_WTB(SSUBWT, ssubw, true) | |
7032 | ||
7033 | DO_SVE2_ZZZ_WTB(UADDWB, uaddw, false) | |
7034 | DO_SVE2_ZZZ_WTB(UADDWT, uaddw, true) | |
7035 | DO_SVE2_ZZZ_WTB(USUBWB, usubw, false) | |
7036 | DO_SVE2_ZZZ_WTB(USUBWT, usubw, true) | |
4269fef1 RH |
7037 | |
7038 | static void gen_sshll_vec(unsigned vece, TCGv_vec d, TCGv_vec n, int64_t imm) | |
7039 | { | |
7040 | int top = imm & 1; | |
7041 | int shl = imm >> 1; | |
7042 | int halfbits = 4 << vece; | |
7043 | ||
7044 | if (top) { | |
7045 | if (shl == halfbits) { | |
7046 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7047 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(halfbits, halfbits)); | |
7048 | tcg_gen_and_vec(vece, d, n, t); | |
7049 | tcg_temp_free_vec(t); | |
7050 | } else { | |
7051 | tcg_gen_sari_vec(vece, d, n, halfbits); | |
7052 | tcg_gen_shli_vec(vece, d, d, shl); | |
7053 | } | |
7054 | } else { | |
7055 | tcg_gen_shli_vec(vece, d, n, halfbits); | |
7056 | tcg_gen_sari_vec(vece, d, d, halfbits - shl); | |
7057 | } | |
7058 | } | |
7059 | ||
7060 | static void gen_ushll_i64(unsigned vece, TCGv_i64 d, TCGv_i64 n, int imm) | |
7061 | { | |
7062 | int halfbits = 4 << vece; | |
7063 | int top = imm & 1; | |
7064 | int shl = (imm >> 1); | |
7065 | int shift; | |
7066 | uint64_t mask; | |
7067 | ||
7068 | mask = MAKE_64BIT_MASK(0, halfbits); | |
7069 | mask <<= shl; | |
7070 | mask = dup_const(vece, mask); | |
7071 | ||
7072 | shift = shl - top * halfbits; | |
7073 | if (shift < 0) { | |
7074 | tcg_gen_shri_i64(d, n, -shift); | |
7075 | } else { | |
7076 | tcg_gen_shli_i64(d, n, shift); | |
7077 | } | |
7078 | tcg_gen_andi_i64(d, d, mask); | |
7079 | } | |
7080 | ||
7081 | static void gen_ushll16_i64(TCGv_i64 d, TCGv_i64 n, int64_t imm) | |
7082 | { | |
7083 | gen_ushll_i64(MO_16, d, n, imm); | |
7084 | } | |
7085 | ||
7086 | static void gen_ushll32_i64(TCGv_i64 d, TCGv_i64 n, int64_t imm) | |
7087 | { | |
7088 | gen_ushll_i64(MO_32, d, n, imm); | |
7089 | } | |
7090 | ||
7091 | static void gen_ushll64_i64(TCGv_i64 d, TCGv_i64 n, int64_t imm) | |
7092 | { | |
7093 | gen_ushll_i64(MO_64, d, n, imm); | |
7094 | } | |
7095 | ||
7096 | static void gen_ushll_vec(unsigned vece, TCGv_vec d, TCGv_vec n, int64_t imm) | |
7097 | { | |
7098 | int halfbits = 4 << vece; | |
7099 | int top = imm & 1; | |
7100 | int shl = imm >> 1; | |
7101 | ||
7102 | if (top) { | |
7103 | if (shl == halfbits) { | |
7104 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7105 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(halfbits, halfbits)); | |
7106 | tcg_gen_and_vec(vece, d, n, t); | |
7107 | tcg_temp_free_vec(t); | |
7108 | } else { | |
7109 | tcg_gen_shri_vec(vece, d, n, halfbits); | |
7110 | tcg_gen_shli_vec(vece, d, d, shl); | |
7111 | } | |
7112 | } else { | |
7113 | if (shl == 0) { | |
7114 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7115 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
7116 | tcg_gen_and_vec(vece, d, n, t); | |
7117 | tcg_temp_free_vec(t); | |
7118 | } else { | |
7119 | tcg_gen_shli_vec(vece, d, n, halfbits); | |
7120 | tcg_gen_shri_vec(vece, d, d, halfbits - shl); | |
7121 | } | |
7122 | } | |
7123 | } | |
7124 | ||
7125 | static bool do_sve2_shll_tb(DisasContext *s, arg_rri_esz *a, | |
7126 | bool sel, bool uns) | |
7127 | { | |
7128 | static const TCGOpcode sshll_list[] = { | |
7129 | INDEX_op_shli_vec, INDEX_op_sari_vec, 0 | |
7130 | }; | |
7131 | static const TCGOpcode ushll_list[] = { | |
7132 | INDEX_op_shli_vec, INDEX_op_shri_vec, 0 | |
7133 | }; | |
7134 | static const GVecGen2i ops[2][3] = { | |
7135 | { { .fniv = gen_sshll_vec, | |
7136 | .opt_opc = sshll_list, | |
7137 | .fno = gen_helper_sve2_sshll_h, | |
7138 | .vece = MO_16 }, | |
7139 | { .fniv = gen_sshll_vec, | |
7140 | .opt_opc = sshll_list, | |
7141 | .fno = gen_helper_sve2_sshll_s, | |
7142 | .vece = MO_32 }, | |
7143 | { .fniv = gen_sshll_vec, | |
7144 | .opt_opc = sshll_list, | |
7145 | .fno = gen_helper_sve2_sshll_d, | |
7146 | .vece = MO_64 } }, | |
7147 | { { .fni8 = gen_ushll16_i64, | |
7148 | .fniv = gen_ushll_vec, | |
7149 | .opt_opc = ushll_list, | |
7150 | .fno = gen_helper_sve2_ushll_h, | |
7151 | .vece = MO_16 }, | |
7152 | { .fni8 = gen_ushll32_i64, | |
7153 | .fniv = gen_ushll_vec, | |
7154 | .opt_opc = ushll_list, | |
7155 | .fno = gen_helper_sve2_ushll_s, | |
7156 | .vece = MO_32 }, | |
7157 | { .fni8 = gen_ushll64_i64, | |
7158 | .fniv = gen_ushll_vec, | |
7159 | .opt_opc = ushll_list, | |
7160 | .fno = gen_helper_sve2_ushll_d, | |
7161 | .vece = MO_64 } }, | |
7162 | }; | |
7163 | ||
7164 | if (a->esz < 0 || a->esz > 2 || !dc_isar_feature(aa64_sve2, s)) { | |
7165 | return false; | |
7166 | } | |
7167 | if (sve_access_check(s)) { | |
7168 | unsigned vsz = vec_full_reg_size(s); | |
7169 | tcg_gen_gvec_2i(vec_full_reg_offset(s, a->rd), | |
7170 | vec_full_reg_offset(s, a->rn), | |
7171 | vsz, vsz, (a->imm << 1) | sel, | |
7172 | &ops[uns][a->esz]); | |
7173 | } | |
7174 | return true; | |
7175 | } | |
7176 | ||
7177 | static bool trans_SSHLLB(DisasContext *s, arg_rri_esz *a) | |
7178 | { | |
7179 | return do_sve2_shll_tb(s, a, false, false); | |
7180 | } | |
7181 | ||
7182 | static bool trans_SSHLLT(DisasContext *s, arg_rri_esz *a) | |
7183 | { | |
7184 | return do_sve2_shll_tb(s, a, true, false); | |
7185 | } | |
7186 | ||
7187 | static bool trans_USHLLB(DisasContext *s, arg_rri_esz *a) | |
7188 | { | |
7189 | return do_sve2_shll_tb(s, a, false, true); | |
7190 | } | |
7191 | ||
7192 | static bool trans_USHLLT(DisasContext *s, arg_rri_esz *a) | |
7193 | { | |
7194 | return do_sve2_shll_tb(s, a, true, true); | |
7195 | } | |
cb9c33b8 RH |
7196 | |
7197 | static bool trans_BEXT(DisasContext *s, arg_rrr_esz *a) | |
7198 | { | |
7199 | static gen_helper_gvec_3 * const fns[4] = { | |
7200 | gen_helper_sve2_bext_b, gen_helper_sve2_bext_h, | |
7201 | gen_helper_sve2_bext_s, gen_helper_sve2_bext_d, | |
7202 | }; | |
7203 | if (!dc_isar_feature(aa64_sve2_bitperm, s)) { | |
7204 | return false; | |
7205 | } | |
7206 | return do_sve2_zzw_ool(s, a, fns[a->esz], 0); | |
7207 | } | |
7208 | ||
7209 | static bool trans_BDEP(DisasContext *s, arg_rrr_esz *a) | |
7210 | { | |
7211 | static gen_helper_gvec_3 * const fns[4] = { | |
7212 | gen_helper_sve2_bdep_b, gen_helper_sve2_bdep_h, | |
7213 | gen_helper_sve2_bdep_s, gen_helper_sve2_bdep_d, | |
7214 | }; | |
7215 | if (!dc_isar_feature(aa64_sve2_bitperm, s)) { | |
7216 | return false; | |
7217 | } | |
7218 | return do_sve2_zzw_ool(s, a, fns[a->esz], 0); | |
7219 | } | |
7220 | ||
7221 | static bool trans_BGRP(DisasContext *s, arg_rrr_esz *a) | |
7222 | { | |
7223 | static gen_helper_gvec_3 * const fns[4] = { | |
7224 | gen_helper_sve2_bgrp_b, gen_helper_sve2_bgrp_h, | |
7225 | gen_helper_sve2_bgrp_s, gen_helper_sve2_bgrp_d, | |
7226 | }; | |
7227 | if (!dc_isar_feature(aa64_sve2_bitperm, s)) { | |
7228 | return false; | |
7229 | } | |
7230 | return do_sve2_zzw_ool(s, a, fns[a->esz], 0); | |
7231 | } | |
ed4a6387 RH |
7232 | |
7233 | static bool do_cadd(DisasContext *s, arg_rrr_esz *a, bool sq, bool rot) | |
7234 | { | |
7235 | static gen_helper_gvec_3 * const fns[2][4] = { | |
7236 | { gen_helper_sve2_cadd_b, gen_helper_sve2_cadd_h, | |
7237 | gen_helper_sve2_cadd_s, gen_helper_sve2_cadd_d }, | |
7238 | { gen_helper_sve2_sqcadd_b, gen_helper_sve2_sqcadd_h, | |
7239 | gen_helper_sve2_sqcadd_s, gen_helper_sve2_sqcadd_d }, | |
7240 | }; | |
7241 | return do_sve2_zzw_ool(s, a, fns[sq][a->esz], rot); | |
7242 | } | |
7243 | ||
7244 | static bool trans_CADD_rot90(DisasContext *s, arg_rrr_esz *a) | |
7245 | { | |
7246 | return do_cadd(s, a, false, false); | |
7247 | } | |
7248 | ||
7249 | static bool trans_CADD_rot270(DisasContext *s, arg_rrr_esz *a) | |
7250 | { | |
7251 | return do_cadd(s, a, false, true); | |
7252 | } | |
7253 | ||
7254 | static bool trans_SQCADD_rot90(DisasContext *s, arg_rrr_esz *a) | |
7255 | { | |
7256 | return do_cadd(s, a, true, false); | |
7257 | } | |
7258 | ||
7259 | static bool trans_SQCADD_rot270(DisasContext *s, arg_rrr_esz *a) | |
7260 | { | |
7261 | return do_cadd(s, a, true, true); | |
7262 | } | |
38650638 RH |
7263 | |
7264 | static bool do_sve2_zzzz_ool(DisasContext *s, arg_rrrr_esz *a, | |
7265 | gen_helper_gvec_4 *fn, int data) | |
7266 | { | |
7267 | if (fn == NULL || !dc_isar_feature(aa64_sve2, s)) { | |
7268 | return false; | |
7269 | } | |
7270 | if (sve_access_check(s)) { | |
7271 | gen_gvec_ool_zzzz(s, fn, a->rd, a->rn, a->rm, a->ra, data); | |
7272 | } | |
7273 | return true; | |
7274 | } | |
7275 | ||
7276 | static bool do_abal(DisasContext *s, arg_rrrr_esz *a, bool uns, bool sel) | |
7277 | { | |
7278 | static gen_helper_gvec_4 * const fns[2][4] = { | |
7279 | { NULL, gen_helper_sve2_sabal_h, | |
7280 | gen_helper_sve2_sabal_s, gen_helper_sve2_sabal_d }, | |
7281 | { NULL, gen_helper_sve2_uabal_h, | |
7282 | gen_helper_sve2_uabal_s, gen_helper_sve2_uabal_d }, | |
7283 | }; | |
7284 | return do_sve2_zzzz_ool(s, a, fns[uns][a->esz], sel); | |
7285 | } | |
7286 | ||
7287 | static bool trans_SABALB(DisasContext *s, arg_rrrr_esz *a) | |
7288 | { | |
7289 | return do_abal(s, a, false, false); | |
7290 | } | |
7291 | ||
7292 | static bool trans_SABALT(DisasContext *s, arg_rrrr_esz *a) | |
7293 | { | |
7294 | return do_abal(s, a, false, true); | |
7295 | } | |
7296 | ||
7297 | static bool trans_UABALB(DisasContext *s, arg_rrrr_esz *a) | |
7298 | { | |
7299 | return do_abal(s, a, true, false); | |
7300 | } | |
7301 | ||
7302 | static bool trans_UABALT(DisasContext *s, arg_rrrr_esz *a) | |
7303 | { | |
7304 | return do_abal(s, a, true, true); | |
7305 | } | |
b8295dfb RH |
7306 | |
7307 | static bool do_adcl(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
7308 | { | |
7309 | static gen_helper_gvec_4 * const fns[2] = { | |
7310 | gen_helper_sve2_adcl_s, | |
7311 | gen_helper_sve2_adcl_d, | |
7312 | }; | |
7313 | /* | |
7314 | * Note that in this case the ESZ field encodes both size and sign. | |
7315 | * Split out 'subtract' into bit 1 of the data field for the helper. | |
7316 | */ | |
7317 | return do_sve2_zzzz_ool(s, a, fns[a->esz & 1], (a->esz & 2) | sel); | |
7318 | } | |
7319 | ||
7320 | static bool trans_ADCLB(DisasContext *s, arg_rrrr_esz *a) | |
7321 | { | |
7322 | return do_adcl(s, a, false); | |
7323 | } | |
7324 | ||
7325 | static bool trans_ADCLT(DisasContext *s, arg_rrrr_esz *a) | |
7326 | { | |
7327 | return do_adcl(s, a, true); | |
7328 | } | |
a7e3a90e RH |
7329 | |
7330 | static bool do_sve2_fn2i(DisasContext *s, arg_rri_esz *a, GVecGen2iFn *fn) | |
7331 | { | |
7332 | if (a->esz < 0 || !dc_isar_feature(aa64_sve2, s)) { | |
7333 | return false; | |
7334 | } | |
7335 | if (sve_access_check(s)) { | |
7336 | unsigned vsz = vec_full_reg_size(s); | |
7337 | unsigned rd_ofs = vec_full_reg_offset(s, a->rd); | |
7338 | unsigned rn_ofs = vec_full_reg_offset(s, a->rn); | |
7339 | fn(a->esz, rd_ofs, rn_ofs, a->imm, vsz, vsz); | |
7340 | } | |
7341 | return true; | |
7342 | } | |
7343 | ||
7344 | static bool trans_SSRA(DisasContext *s, arg_rri_esz *a) | |
7345 | { | |
7346 | return do_sve2_fn2i(s, a, gen_gvec_ssra); | |
7347 | } | |
7348 | ||
7349 | static bool trans_USRA(DisasContext *s, arg_rri_esz *a) | |
7350 | { | |
7351 | return do_sve2_fn2i(s, a, gen_gvec_usra); | |
7352 | } | |
7353 | ||
7354 | static bool trans_SRSRA(DisasContext *s, arg_rri_esz *a) | |
7355 | { | |
7356 | return do_sve2_fn2i(s, a, gen_gvec_srsra); | |
7357 | } | |
7358 | ||
7359 | static bool trans_URSRA(DisasContext *s, arg_rri_esz *a) | |
7360 | { | |
7361 | return do_sve2_fn2i(s, a, gen_gvec_ursra); | |
7362 | } | |
fc12b46a RH |
7363 | |
7364 | static bool trans_SRI(DisasContext *s, arg_rri_esz *a) | |
7365 | { | |
7366 | return do_sve2_fn2i(s, a, gen_gvec_sri); | |
7367 | } | |
7368 | ||
7369 | static bool trans_SLI(DisasContext *s, arg_rri_esz *a) | |
7370 | { | |
7371 | return do_sve2_fn2i(s, a, gen_gvec_sli); | |
7372 | } | |
289a1797 RH |
7373 | |
7374 | static bool do_sve2_fn_zzz(DisasContext *s, arg_rrr_esz *a, GVecGen3Fn *fn) | |
7375 | { | |
7376 | if (!dc_isar_feature(aa64_sve2, s)) { | |
7377 | return false; | |
7378 | } | |
7379 | if (sve_access_check(s)) { | |
7380 | gen_gvec_fn_zzz(s, fn, a->esz, a->rd, a->rn, a->rm); | |
7381 | } | |
7382 | return true; | |
7383 | } | |
7384 | ||
7385 | static bool trans_SABA(DisasContext *s, arg_rrr_esz *a) | |
7386 | { | |
7387 | return do_sve2_fn_zzz(s, a, gen_gvec_saba); | |
7388 | } | |
7389 | ||
7390 | static bool trans_UABA(DisasContext *s, arg_rrr_esz *a) | |
7391 | { | |
7392 | return do_sve2_fn_zzz(s, a, gen_gvec_uaba); | |
7393 | } | |
5ff2838d RH |
7394 | |
7395 | static bool do_sve2_narrow_extract(DisasContext *s, arg_rri_esz *a, | |
7396 | const GVecGen2 ops[3]) | |
7397 | { | |
7398 | if (a->esz < 0 || a->esz > MO_32 || a->imm != 0 || | |
7399 | !dc_isar_feature(aa64_sve2, s)) { | |
7400 | return false; | |
7401 | } | |
7402 | if (sve_access_check(s)) { | |
7403 | unsigned vsz = vec_full_reg_size(s); | |
7404 | tcg_gen_gvec_2(vec_full_reg_offset(s, a->rd), | |
7405 | vec_full_reg_offset(s, a->rn), | |
7406 | vsz, vsz, &ops[a->esz]); | |
7407 | } | |
7408 | return true; | |
7409 | } | |
7410 | ||
7411 | static const TCGOpcode sqxtn_list[] = { | |
7412 | INDEX_op_shli_vec, INDEX_op_smin_vec, INDEX_op_smax_vec, 0 | |
7413 | }; | |
7414 | ||
7415 | static void gen_sqxtnb_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7416 | { | |
7417 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7418 | int halfbits = 4 << vece; | |
7419 | int64_t mask = (1ull << halfbits) - 1; | |
7420 | int64_t min = -1ull << (halfbits - 1); | |
7421 | int64_t max = -min - 1; | |
7422 | ||
7423 | tcg_gen_dupi_vec(vece, t, min); | |
7424 | tcg_gen_smax_vec(vece, d, n, t); | |
7425 | tcg_gen_dupi_vec(vece, t, max); | |
7426 | tcg_gen_smin_vec(vece, d, d, t); | |
7427 | tcg_gen_dupi_vec(vece, t, mask); | |
7428 | tcg_gen_and_vec(vece, d, d, t); | |
7429 | tcg_temp_free_vec(t); | |
7430 | } | |
7431 | ||
7432 | static bool trans_SQXTNB(DisasContext *s, arg_rri_esz *a) | |
7433 | { | |
7434 | static const GVecGen2 ops[3] = { | |
7435 | { .fniv = gen_sqxtnb_vec, | |
7436 | .opt_opc = sqxtn_list, | |
7437 | .fno = gen_helper_sve2_sqxtnb_h, | |
7438 | .vece = MO_16 }, | |
7439 | { .fniv = gen_sqxtnb_vec, | |
7440 | .opt_opc = sqxtn_list, | |
7441 | .fno = gen_helper_sve2_sqxtnb_s, | |
7442 | .vece = MO_32 }, | |
7443 | { .fniv = gen_sqxtnb_vec, | |
7444 | .opt_opc = sqxtn_list, | |
7445 | .fno = gen_helper_sve2_sqxtnb_d, | |
7446 | .vece = MO_64 }, | |
7447 | }; | |
7448 | return do_sve2_narrow_extract(s, a, ops); | |
7449 | } | |
7450 | ||
7451 | static void gen_sqxtnt_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7452 | { | |
7453 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7454 | int halfbits = 4 << vece; | |
7455 | int64_t mask = (1ull << halfbits) - 1; | |
7456 | int64_t min = -1ull << (halfbits - 1); | |
7457 | int64_t max = -min - 1; | |
7458 | ||
7459 | tcg_gen_dupi_vec(vece, t, min); | |
7460 | tcg_gen_smax_vec(vece, n, n, t); | |
7461 | tcg_gen_dupi_vec(vece, t, max); | |
7462 | tcg_gen_smin_vec(vece, n, n, t); | |
7463 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
7464 | tcg_gen_dupi_vec(vece, t, mask); | |
7465 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7466 | tcg_temp_free_vec(t); | |
7467 | } | |
7468 | ||
7469 | static bool trans_SQXTNT(DisasContext *s, arg_rri_esz *a) | |
7470 | { | |
7471 | static const GVecGen2 ops[3] = { | |
7472 | { .fniv = gen_sqxtnt_vec, | |
7473 | .opt_opc = sqxtn_list, | |
7474 | .load_dest = true, | |
7475 | .fno = gen_helper_sve2_sqxtnt_h, | |
7476 | .vece = MO_16 }, | |
7477 | { .fniv = gen_sqxtnt_vec, | |
7478 | .opt_opc = sqxtn_list, | |
7479 | .load_dest = true, | |
7480 | .fno = gen_helper_sve2_sqxtnt_s, | |
7481 | .vece = MO_32 }, | |
7482 | { .fniv = gen_sqxtnt_vec, | |
7483 | .opt_opc = sqxtn_list, | |
7484 | .load_dest = true, | |
7485 | .fno = gen_helper_sve2_sqxtnt_d, | |
7486 | .vece = MO_64 }, | |
7487 | }; | |
7488 | return do_sve2_narrow_extract(s, a, ops); | |
7489 | } | |
7490 | ||
7491 | static const TCGOpcode uqxtn_list[] = { | |
7492 | INDEX_op_shli_vec, INDEX_op_umin_vec, 0 | |
7493 | }; | |
7494 | ||
7495 | static void gen_uqxtnb_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7496 | { | |
7497 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7498 | int halfbits = 4 << vece; | |
7499 | int64_t max = (1ull << halfbits) - 1; | |
7500 | ||
7501 | tcg_gen_dupi_vec(vece, t, max); | |
7502 | tcg_gen_umin_vec(vece, d, n, t); | |
7503 | tcg_temp_free_vec(t); | |
7504 | } | |
7505 | ||
7506 | static bool trans_UQXTNB(DisasContext *s, arg_rri_esz *a) | |
7507 | { | |
7508 | static const GVecGen2 ops[3] = { | |
7509 | { .fniv = gen_uqxtnb_vec, | |
7510 | .opt_opc = uqxtn_list, | |
7511 | .fno = gen_helper_sve2_uqxtnb_h, | |
7512 | .vece = MO_16 }, | |
7513 | { .fniv = gen_uqxtnb_vec, | |
7514 | .opt_opc = uqxtn_list, | |
7515 | .fno = gen_helper_sve2_uqxtnb_s, | |
7516 | .vece = MO_32 }, | |
7517 | { .fniv = gen_uqxtnb_vec, | |
7518 | .opt_opc = uqxtn_list, | |
7519 | .fno = gen_helper_sve2_uqxtnb_d, | |
7520 | .vece = MO_64 }, | |
7521 | }; | |
7522 | return do_sve2_narrow_extract(s, a, ops); | |
7523 | } | |
7524 | ||
7525 | static void gen_uqxtnt_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7526 | { | |
7527 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7528 | int halfbits = 4 << vece; | |
7529 | int64_t max = (1ull << halfbits) - 1; | |
7530 | ||
7531 | tcg_gen_dupi_vec(vece, t, max); | |
7532 | tcg_gen_umin_vec(vece, n, n, t); | |
7533 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
7534 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7535 | tcg_temp_free_vec(t); | |
7536 | } | |
7537 | ||
7538 | static bool trans_UQXTNT(DisasContext *s, arg_rri_esz *a) | |
7539 | { | |
7540 | static const GVecGen2 ops[3] = { | |
7541 | { .fniv = gen_uqxtnt_vec, | |
7542 | .opt_opc = uqxtn_list, | |
7543 | .load_dest = true, | |
7544 | .fno = gen_helper_sve2_uqxtnt_h, | |
7545 | .vece = MO_16 }, | |
7546 | { .fniv = gen_uqxtnt_vec, | |
7547 | .opt_opc = uqxtn_list, | |
7548 | .load_dest = true, | |
7549 | .fno = gen_helper_sve2_uqxtnt_s, | |
7550 | .vece = MO_32 }, | |
7551 | { .fniv = gen_uqxtnt_vec, | |
7552 | .opt_opc = uqxtn_list, | |
7553 | .load_dest = true, | |
7554 | .fno = gen_helper_sve2_uqxtnt_d, | |
7555 | .vece = MO_64 }, | |
7556 | }; | |
7557 | return do_sve2_narrow_extract(s, a, ops); | |
7558 | } | |
7559 | ||
7560 | static const TCGOpcode sqxtun_list[] = { | |
7561 | INDEX_op_shli_vec, INDEX_op_umin_vec, INDEX_op_smax_vec, 0 | |
7562 | }; | |
7563 | ||
7564 | static void gen_sqxtunb_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7565 | { | |
7566 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7567 | int halfbits = 4 << vece; | |
7568 | int64_t max = (1ull << halfbits) - 1; | |
7569 | ||
7570 | tcg_gen_dupi_vec(vece, t, 0); | |
7571 | tcg_gen_smax_vec(vece, d, n, t); | |
7572 | tcg_gen_dupi_vec(vece, t, max); | |
7573 | tcg_gen_umin_vec(vece, d, d, t); | |
7574 | tcg_temp_free_vec(t); | |
7575 | } | |
7576 | ||
7577 | static bool trans_SQXTUNB(DisasContext *s, arg_rri_esz *a) | |
7578 | { | |
7579 | static const GVecGen2 ops[3] = { | |
7580 | { .fniv = gen_sqxtunb_vec, | |
7581 | .opt_opc = sqxtun_list, | |
7582 | .fno = gen_helper_sve2_sqxtunb_h, | |
7583 | .vece = MO_16 }, | |
7584 | { .fniv = gen_sqxtunb_vec, | |
7585 | .opt_opc = sqxtun_list, | |
7586 | .fno = gen_helper_sve2_sqxtunb_s, | |
7587 | .vece = MO_32 }, | |
7588 | { .fniv = gen_sqxtunb_vec, | |
7589 | .opt_opc = sqxtun_list, | |
7590 | .fno = gen_helper_sve2_sqxtunb_d, | |
7591 | .vece = MO_64 }, | |
7592 | }; | |
7593 | return do_sve2_narrow_extract(s, a, ops); | |
7594 | } | |
7595 | ||
7596 | static void gen_sqxtunt_vec(unsigned vece, TCGv_vec d, TCGv_vec n) | |
7597 | { | |
7598 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7599 | int halfbits = 4 << vece; | |
7600 | int64_t max = (1ull << halfbits) - 1; | |
7601 | ||
7602 | tcg_gen_dupi_vec(vece, t, 0); | |
7603 | tcg_gen_smax_vec(vece, n, n, t); | |
7604 | tcg_gen_dupi_vec(vece, t, max); | |
7605 | tcg_gen_umin_vec(vece, n, n, t); | |
7606 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
7607 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7608 | tcg_temp_free_vec(t); | |
7609 | } | |
7610 | ||
7611 | static bool trans_SQXTUNT(DisasContext *s, arg_rri_esz *a) | |
7612 | { | |
7613 | static const GVecGen2 ops[3] = { | |
7614 | { .fniv = gen_sqxtunt_vec, | |
7615 | .opt_opc = sqxtun_list, | |
7616 | .load_dest = true, | |
7617 | .fno = gen_helper_sve2_sqxtunt_h, | |
7618 | .vece = MO_16 }, | |
7619 | { .fniv = gen_sqxtunt_vec, | |
7620 | .opt_opc = sqxtun_list, | |
7621 | .load_dest = true, | |
7622 | .fno = gen_helper_sve2_sqxtunt_s, | |
7623 | .vece = MO_32 }, | |
7624 | { .fniv = gen_sqxtunt_vec, | |
7625 | .opt_opc = sqxtun_list, | |
7626 | .load_dest = true, | |
7627 | .fno = gen_helper_sve2_sqxtunt_d, | |
7628 | .vece = MO_64 }, | |
7629 | }; | |
7630 | return do_sve2_narrow_extract(s, a, ops); | |
46d111b2 RH |
7631 | } |
7632 | ||
7633 | static bool do_sve2_shr_narrow(DisasContext *s, arg_rri_esz *a, | |
7634 | const GVecGen2i ops[3]) | |
7635 | { | |
7636 | if (a->esz < 0 || a->esz > MO_32 || !dc_isar_feature(aa64_sve2, s)) { | |
7637 | return false; | |
7638 | } | |
7639 | assert(a->imm > 0 && a->imm <= (8 << a->esz)); | |
7640 | if (sve_access_check(s)) { | |
7641 | unsigned vsz = vec_full_reg_size(s); | |
7642 | tcg_gen_gvec_2i(vec_full_reg_offset(s, a->rd), | |
7643 | vec_full_reg_offset(s, a->rn), | |
7644 | vsz, vsz, a->imm, &ops[a->esz]); | |
7645 | } | |
7646 | return true; | |
7647 | } | |
7648 | ||
7649 | static void gen_shrnb_i64(unsigned vece, TCGv_i64 d, TCGv_i64 n, int shr) | |
7650 | { | |
7651 | int halfbits = 4 << vece; | |
7652 | uint64_t mask = dup_const(vece, MAKE_64BIT_MASK(0, halfbits)); | |
7653 | ||
7654 | tcg_gen_shri_i64(d, n, shr); | |
7655 | tcg_gen_andi_i64(d, d, mask); | |
7656 | } | |
7657 | ||
7658 | static void gen_shrnb16_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7659 | { | |
7660 | gen_shrnb_i64(MO_16, d, n, shr); | |
7661 | } | |
7662 | ||
7663 | static void gen_shrnb32_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7664 | { | |
7665 | gen_shrnb_i64(MO_32, d, n, shr); | |
7666 | } | |
7667 | ||
7668 | static void gen_shrnb64_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7669 | { | |
7670 | gen_shrnb_i64(MO_64, d, n, shr); | |
7671 | } | |
7672 | ||
7673 | static void gen_shrnb_vec(unsigned vece, TCGv_vec d, TCGv_vec n, int64_t shr) | |
7674 | { | |
7675 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7676 | int halfbits = 4 << vece; | |
7677 | uint64_t mask = MAKE_64BIT_MASK(0, halfbits); | |
7678 | ||
7679 | tcg_gen_shri_vec(vece, n, n, shr); | |
7680 | tcg_gen_dupi_vec(vece, t, mask); | |
7681 | tcg_gen_and_vec(vece, d, n, t); | |
7682 | tcg_temp_free_vec(t); | |
7683 | } | |
7684 | ||
7685 | static bool trans_SHRNB(DisasContext *s, arg_rri_esz *a) | |
7686 | { | |
7687 | static const TCGOpcode vec_list[] = { INDEX_op_shri_vec, 0 }; | |
7688 | static const GVecGen2i ops[3] = { | |
7689 | { .fni8 = gen_shrnb16_i64, | |
7690 | .fniv = gen_shrnb_vec, | |
7691 | .opt_opc = vec_list, | |
7692 | .fno = gen_helper_sve2_shrnb_h, | |
7693 | .vece = MO_16 }, | |
7694 | { .fni8 = gen_shrnb32_i64, | |
7695 | .fniv = gen_shrnb_vec, | |
7696 | .opt_opc = vec_list, | |
7697 | .fno = gen_helper_sve2_shrnb_s, | |
7698 | .vece = MO_32 }, | |
7699 | { .fni8 = gen_shrnb64_i64, | |
7700 | .fniv = gen_shrnb_vec, | |
7701 | .opt_opc = vec_list, | |
7702 | .fno = gen_helper_sve2_shrnb_d, | |
7703 | .vece = MO_64 }, | |
7704 | }; | |
7705 | return do_sve2_shr_narrow(s, a, ops); | |
7706 | } | |
7707 | ||
7708 | static void gen_shrnt_i64(unsigned vece, TCGv_i64 d, TCGv_i64 n, int shr) | |
7709 | { | |
7710 | int halfbits = 4 << vece; | |
7711 | uint64_t mask = dup_const(vece, MAKE_64BIT_MASK(0, halfbits)); | |
7712 | ||
7713 | tcg_gen_shli_i64(n, n, halfbits - shr); | |
7714 | tcg_gen_andi_i64(n, n, ~mask); | |
7715 | tcg_gen_andi_i64(d, d, mask); | |
7716 | tcg_gen_or_i64(d, d, n); | |
7717 | } | |
7718 | ||
7719 | static void gen_shrnt16_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7720 | { | |
7721 | gen_shrnt_i64(MO_16, d, n, shr); | |
7722 | } | |
7723 | ||
7724 | static void gen_shrnt32_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7725 | { | |
7726 | gen_shrnt_i64(MO_32, d, n, shr); | |
7727 | } | |
7728 | ||
7729 | static void gen_shrnt64_i64(TCGv_i64 d, TCGv_i64 n, int64_t shr) | |
7730 | { | |
7731 | tcg_gen_shri_i64(n, n, shr); | |
7732 | tcg_gen_deposit_i64(d, d, n, 32, 32); | |
7733 | } | |
7734 | ||
7735 | static void gen_shrnt_vec(unsigned vece, TCGv_vec d, TCGv_vec n, int64_t shr) | |
7736 | { | |
7737 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7738 | int halfbits = 4 << vece; | |
7739 | uint64_t mask = MAKE_64BIT_MASK(0, halfbits); | |
7740 | ||
7741 | tcg_gen_shli_vec(vece, n, n, halfbits - shr); | |
7742 | tcg_gen_dupi_vec(vece, t, mask); | |
7743 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7744 | tcg_temp_free_vec(t); | |
7745 | } | |
7746 | ||
7747 | static bool trans_SHRNT(DisasContext *s, arg_rri_esz *a) | |
7748 | { | |
7749 | static const TCGOpcode vec_list[] = { INDEX_op_shli_vec, 0 }; | |
7750 | static const GVecGen2i ops[3] = { | |
7751 | { .fni8 = gen_shrnt16_i64, | |
7752 | .fniv = gen_shrnt_vec, | |
7753 | .opt_opc = vec_list, | |
7754 | .load_dest = true, | |
7755 | .fno = gen_helper_sve2_shrnt_h, | |
7756 | .vece = MO_16 }, | |
7757 | { .fni8 = gen_shrnt32_i64, | |
7758 | .fniv = gen_shrnt_vec, | |
7759 | .opt_opc = vec_list, | |
7760 | .load_dest = true, | |
7761 | .fno = gen_helper_sve2_shrnt_s, | |
7762 | .vece = MO_32 }, | |
7763 | { .fni8 = gen_shrnt64_i64, | |
7764 | .fniv = gen_shrnt_vec, | |
7765 | .opt_opc = vec_list, | |
7766 | .load_dest = true, | |
7767 | .fno = gen_helper_sve2_shrnt_d, | |
7768 | .vece = MO_64 }, | |
7769 | }; | |
7770 | return do_sve2_shr_narrow(s, a, ops); | |
7771 | } | |
7772 | ||
7773 | static bool trans_RSHRNB(DisasContext *s, arg_rri_esz *a) | |
7774 | { | |
7775 | static const GVecGen2i ops[3] = { | |
7776 | { .fno = gen_helper_sve2_rshrnb_h }, | |
7777 | { .fno = gen_helper_sve2_rshrnb_s }, | |
7778 | { .fno = gen_helper_sve2_rshrnb_d }, | |
7779 | }; | |
7780 | return do_sve2_shr_narrow(s, a, ops); | |
7781 | } | |
7782 | ||
7783 | static bool trans_RSHRNT(DisasContext *s, arg_rri_esz *a) | |
7784 | { | |
7785 | static const GVecGen2i ops[3] = { | |
7786 | { .fno = gen_helper_sve2_rshrnt_h }, | |
7787 | { .fno = gen_helper_sve2_rshrnt_s }, | |
7788 | { .fno = gen_helper_sve2_rshrnt_d }, | |
7789 | }; | |
7790 | return do_sve2_shr_narrow(s, a, ops); | |
81fd3e6e RH |
7791 | } |
7792 | ||
7793 | static void gen_sqshrunb_vec(unsigned vece, TCGv_vec d, | |
7794 | TCGv_vec n, int64_t shr) | |
7795 | { | |
7796 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7797 | int halfbits = 4 << vece; | |
7798 | ||
7799 | tcg_gen_sari_vec(vece, n, n, shr); | |
7800 | tcg_gen_dupi_vec(vece, t, 0); | |
7801 | tcg_gen_smax_vec(vece, n, n, t); | |
7802 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
7803 | tcg_gen_umin_vec(vece, d, n, t); | |
7804 | tcg_temp_free_vec(t); | |
7805 | } | |
7806 | ||
7807 | static bool trans_SQSHRUNB(DisasContext *s, arg_rri_esz *a) | |
7808 | { | |
7809 | static const TCGOpcode vec_list[] = { | |
7810 | INDEX_op_sari_vec, INDEX_op_smax_vec, INDEX_op_umin_vec, 0 | |
7811 | }; | |
7812 | static const GVecGen2i ops[3] = { | |
7813 | { .fniv = gen_sqshrunb_vec, | |
7814 | .opt_opc = vec_list, | |
7815 | .fno = gen_helper_sve2_sqshrunb_h, | |
7816 | .vece = MO_16 }, | |
7817 | { .fniv = gen_sqshrunb_vec, | |
7818 | .opt_opc = vec_list, | |
7819 | .fno = gen_helper_sve2_sqshrunb_s, | |
7820 | .vece = MO_32 }, | |
7821 | { .fniv = gen_sqshrunb_vec, | |
7822 | .opt_opc = vec_list, | |
7823 | .fno = gen_helper_sve2_sqshrunb_d, | |
7824 | .vece = MO_64 }, | |
7825 | }; | |
7826 | return do_sve2_shr_narrow(s, a, ops); | |
7827 | } | |
7828 | ||
7829 | static void gen_sqshrunt_vec(unsigned vece, TCGv_vec d, | |
7830 | TCGv_vec n, int64_t shr) | |
7831 | { | |
7832 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7833 | int halfbits = 4 << vece; | |
7834 | ||
7835 | tcg_gen_sari_vec(vece, n, n, shr); | |
7836 | tcg_gen_dupi_vec(vece, t, 0); | |
7837 | tcg_gen_smax_vec(vece, n, n, t); | |
7838 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
7839 | tcg_gen_umin_vec(vece, n, n, t); | |
7840 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
7841 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7842 | tcg_temp_free_vec(t); | |
7843 | } | |
7844 | ||
7845 | static bool trans_SQSHRUNT(DisasContext *s, arg_rri_esz *a) | |
7846 | { | |
7847 | static const TCGOpcode vec_list[] = { | |
7848 | INDEX_op_shli_vec, INDEX_op_sari_vec, | |
7849 | INDEX_op_smax_vec, INDEX_op_umin_vec, 0 | |
7850 | }; | |
7851 | static const GVecGen2i ops[3] = { | |
7852 | { .fniv = gen_sqshrunt_vec, | |
7853 | .opt_opc = vec_list, | |
7854 | .load_dest = true, | |
7855 | .fno = gen_helper_sve2_sqshrunt_h, | |
7856 | .vece = MO_16 }, | |
7857 | { .fniv = gen_sqshrunt_vec, | |
7858 | .opt_opc = vec_list, | |
7859 | .load_dest = true, | |
7860 | .fno = gen_helper_sve2_sqshrunt_s, | |
7861 | .vece = MO_32 }, | |
7862 | { .fniv = gen_sqshrunt_vec, | |
7863 | .opt_opc = vec_list, | |
7864 | .load_dest = true, | |
7865 | .fno = gen_helper_sve2_sqshrunt_d, | |
7866 | .vece = MO_64 }, | |
7867 | }; | |
7868 | return do_sve2_shr_narrow(s, a, ops); | |
7869 | } | |
7870 | ||
7871 | static bool trans_SQRSHRUNB(DisasContext *s, arg_rri_esz *a) | |
7872 | { | |
7873 | static const GVecGen2i ops[3] = { | |
7874 | { .fno = gen_helper_sve2_sqrshrunb_h }, | |
7875 | { .fno = gen_helper_sve2_sqrshrunb_s }, | |
7876 | { .fno = gen_helper_sve2_sqrshrunb_d }, | |
7877 | }; | |
7878 | return do_sve2_shr_narrow(s, a, ops); | |
7879 | } | |
7880 | ||
7881 | static bool trans_SQRSHRUNT(DisasContext *s, arg_rri_esz *a) | |
7882 | { | |
7883 | static const GVecGen2i ops[3] = { | |
7884 | { .fno = gen_helper_sve2_sqrshrunt_h }, | |
7885 | { .fno = gen_helper_sve2_sqrshrunt_s }, | |
7886 | { .fno = gen_helper_sve2_sqrshrunt_d }, | |
7887 | }; | |
7888 | return do_sve2_shr_narrow(s, a, ops); | |
c13418da RH |
7889 | } |
7890 | ||
743bb147 RH |
7891 | static void gen_sqshrnb_vec(unsigned vece, TCGv_vec d, |
7892 | TCGv_vec n, int64_t shr) | |
7893 | { | |
7894 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7895 | int halfbits = 4 << vece; | |
7896 | int64_t max = MAKE_64BIT_MASK(0, halfbits - 1); | |
7897 | int64_t min = -max - 1; | |
7898 | ||
7899 | tcg_gen_sari_vec(vece, n, n, shr); | |
7900 | tcg_gen_dupi_vec(vece, t, min); | |
7901 | tcg_gen_smax_vec(vece, n, n, t); | |
7902 | tcg_gen_dupi_vec(vece, t, max); | |
7903 | tcg_gen_smin_vec(vece, n, n, t); | |
7904 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
7905 | tcg_gen_and_vec(vece, d, n, t); | |
7906 | tcg_temp_free_vec(t); | |
7907 | } | |
7908 | ||
7909 | static bool trans_SQSHRNB(DisasContext *s, arg_rri_esz *a) | |
7910 | { | |
7911 | static const TCGOpcode vec_list[] = { | |
7912 | INDEX_op_sari_vec, INDEX_op_smax_vec, INDEX_op_smin_vec, 0 | |
7913 | }; | |
7914 | static const GVecGen2i ops[3] = { | |
7915 | { .fniv = gen_sqshrnb_vec, | |
7916 | .opt_opc = vec_list, | |
7917 | .fno = gen_helper_sve2_sqshrnb_h, | |
7918 | .vece = MO_16 }, | |
7919 | { .fniv = gen_sqshrnb_vec, | |
7920 | .opt_opc = vec_list, | |
7921 | .fno = gen_helper_sve2_sqshrnb_s, | |
7922 | .vece = MO_32 }, | |
7923 | { .fniv = gen_sqshrnb_vec, | |
7924 | .opt_opc = vec_list, | |
7925 | .fno = gen_helper_sve2_sqshrnb_d, | |
7926 | .vece = MO_64 }, | |
7927 | }; | |
7928 | return do_sve2_shr_narrow(s, a, ops); | |
7929 | } | |
7930 | ||
7931 | static void gen_sqshrnt_vec(unsigned vece, TCGv_vec d, | |
7932 | TCGv_vec n, int64_t shr) | |
7933 | { | |
7934 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
7935 | int halfbits = 4 << vece; | |
7936 | int64_t max = MAKE_64BIT_MASK(0, halfbits - 1); | |
7937 | int64_t min = -max - 1; | |
7938 | ||
7939 | tcg_gen_sari_vec(vece, n, n, shr); | |
7940 | tcg_gen_dupi_vec(vece, t, min); | |
7941 | tcg_gen_smax_vec(vece, n, n, t); | |
7942 | tcg_gen_dupi_vec(vece, t, max); | |
7943 | tcg_gen_smin_vec(vece, n, n, t); | |
7944 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
7945 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
7946 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
7947 | tcg_temp_free_vec(t); | |
7948 | } | |
7949 | ||
7950 | static bool trans_SQSHRNT(DisasContext *s, arg_rri_esz *a) | |
7951 | { | |
7952 | static const TCGOpcode vec_list[] = { | |
7953 | INDEX_op_shli_vec, INDEX_op_sari_vec, | |
7954 | INDEX_op_smax_vec, INDEX_op_smin_vec, 0 | |
7955 | }; | |
7956 | static const GVecGen2i ops[3] = { | |
7957 | { .fniv = gen_sqshrnt_vec, | |
7958 | .opt_opc = vec_list, | |
7959 | .load_dest = true, | |
7960 | .fno = gen_helper_sve2_sqshrnt_h, | |
7961 | .vece = MO_16 }, | |
7962 | { .fniv = gen_sqshrnt_vec, | |
7963 | .opt_opc = vec_list, | |
7964 | .load_dest = true, | |
7965 | .fno = gen_helper_sve2_sqshrnt_s, | |
7966 | .vece = MO_32 }, | |
7967 | { .fniv = gen_sqshrnt_vec, | |
7968 | .opt_opc = vec_list, | |
7969 | .load_dest = true, | |
7970 | .fno = gen_helper_sve2_sqshrnt_d, | |
7971 | .vece = MO_64 }, | |
7972 | }; | |
7973 | return do_sve2_shr_narrow(s, a, ops); | |
7974 | } | |
7975 | ||
7976 | static bool trans_SQRSHRNB(DisasContext *s, arg_rri_esz *a) | |
7977 | { | |
7978 | static const GVecGen2i ops[3] = { | |
7979 | { .fno = gen_helper_sve2_sqrshrnb_h }, | |
7980 | { .fno = gen_helper_sve2_sqrshrnb_s }, | |
7981 | { .fno = gen_helper_sve2_sqrshrnb_d }, | |
7982 | }; | |
7983 | return do_sve2_shr_narrow(s, a, ops); | |
7984 | } | |
7985 | ||
7986 | static bool trans_SQRSHRNT(DisasContext *s, arg_rri_esz *a) | |
7987 | { | |
7988 | static const GVecGen2i ops[3] = { | |
7989 | { .fno = gen_helper_sve2_sqrshrnt_h }, | |
7990 | { .fno = gen_helper_sve2_sqrshrnt_s }, | |
7991 | { .fno = gen_helper_sve2_sqrshrnt_d }, | |
7992 | }; | |
7993 | return do_sve2_shr_narrow(s, a, ops); | |
7994 | } | |
7995 | ||
c13418da RH |
7996 | static void gen_uqshrnb_vec(unsigned vece, TCGv_vec d, |
7997 | TCGv_vec n, int64_t shr) | |
7998 | { | |
7999 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
8000 | int halfbits = 4 << vece; | |
8001 | ||
8002 | tcg_gen_shri_vec(vece, n, n, shr); | |
8003 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
8004 | tcg_gen_umin_vec(vece, d, n, t); | |
8005 | tcg_temp_free_vec(t); | |
8006 | } | |
8007 | ||
8008 | static bool trans_UQSHRNB(DisasContext *s, arg_rri_esz *a) | |
8009 | { | |
8010 | static const TCGOpcode vec_list[] = { | |
8011 | INDEX_op_shri_vec, INDEX_op_umin_vec, 0 | |
8012 | }; | |
8013 | static const GVecGen2i ops[3] = { | |
8014 | { .fniv = gen_uqshrnb_vec, | |
8015 | .opt_opc = vec_list, | |
8016 | .fno = gen_helper_sve2_uqshrnb_h, | |
8017 | .vece = MO_16 }, | |
8018 | { .fniv = gen_uqshrnb_vec, | |
8019 | .opt_opc = vec_list, | |
8020 | .fno = gen_helper_sve2_uqshrnb_s, | |
8021 | .vece = MO_32 }, | |
8022 | { .fniv = gen_uqshrnb_vec, | |
8023 | .opt_opc = vec_list, | |
8024 | .fno = gen_helper_sve2_uqshrnb_d, | |
8025 | .vece = MO_64 }, | |
8026 | }; | |
8027 | return do_sve2_shr_narrow(s, a, ops); | |
8028 | } | |
8029 | ||
8030 | static void gen_uqshrnt_vec(unsigned vece, TCGv_vec d, | |
8031 | TCGv_vec n, int64_t shr) | |
8032 | { | |
8033 | TCGv_vec t = tcg_temp_new_vec_matching(d); | |
8034 | int halfbits = 4 << vece; | |
8035 | ||
8036 | tcg_gen_shri_vec(vece, n, n, shr); | |
8037 | tcg_gen_dupi_vec(vece, t, MAKE_64BIT_MASK(0, halfbits)); | |
8038 | tcg_gen_umin_vec(vece, n, n, t); | |
8039 | tcg_gen_shli_vec(vece, n, n, halfbits); | |
8040 | tcg_gen_bitsel_vec(vece, d, t, d, n); | |
8041 | tcg_temp_free_vec(t); | |
8042 | } | |
8043 | ||
8044 | static bool trans_UQSHRNT(DisasContext *s, arg_rri_esz *a) | |
8045 | { | |
8046 | static const TCGOpcode vec_list[] = { | |
8047 | INDEX_op_shli_vec, INDEX_op_shri_vec, INDEX_op_umin_vec, 0 | |
8048 | }; | |
8049 | static const GVecGen2i ops[3] = { | |
8050 | { .fniv = gen_uqshrnt_vec, | |
8051 | .opt_opc = vec_list, | |
8052 | .load_dest = true, | |
8053 | .fno = gen_helper_sve2_uqshrnt_h, | |
8054 | .vece = MO_16 }, | |
8055 | { .fniv = gen_uqshrnt_vec, | |
8056 | .opt_opc = vec_list, | |
8057 | .load_dest = true, | |
8058 | .fno = gen_helper_sve2_uqshrnt_s, | |
8059 | .vece = MO_32 }, | |
8060 | { .fniv = gen_uqshrnt_vec, | |
8061 | .opt_opc = vec_list, | |
8062 | .load_dest = true, | |
8063 | .fno = gen_helper_sve2_uqshrnt_d, | |
8064 | .vece = MO_64 }, | |
8065 | }; | |
8066 | return do_sve2_shr_narrow(s, a, ops); | |
8067 | } | |
8068 | ||
8069 | static bool trans_UQRSHRNB(DisasContext *s, arg_rri_esz *a) | |
8070 | { | |
8071 | static const GVecGen2i ops[3] = { | |
8072 | { .fno = gen_helper_sve2_uqrshrnb_h }, | |
8073 | { .fno = gen_helper_sve2_uqrshrnb_s }, | |
8074 | { .fno = gen_helper_sve2_uqrshrnb_d }, | |
8075 | }; | |
8076 | return do_sve2_shr_narrow(s, a, ops); | |
8077 | } | |
8078 | ||
8079 | static bool trans_UQRSHRNT(DisasContext *s, arg_rri_esz *a) | |
8080 | { | |
8081 | static const GVecGen2i ops[3] = { | |
8082 | { .fno = gen_helper_sve2_uqrshrnt_h }, | |
8083 | { .fno = gen_helper_sve2_uqrshrnt_s }, | |
8084 | { .fno = gen_helper_sve2_uqrshrnt_d }, | |
8085 | }; | |
8086 | return do_sve2_shr_narrow(s, a, ops); | |
5ff2838d | 8087 | } |
b87dbeeb | 8088 | |
40d5ea50 SL |
8089 | #define DO_SVE2_ZZZ_NARROW(NAME, name) \ |
8090 | static bool trans_##NAME(DisasContext *s, arg_rrr_esz *a) \ | |
8091 | { \ | |
8092 | static gen_helper_gvec_3 * const fns[4] = { \ | |
8093 | NULL, gen_helper_sve2_##name##_h, \ | |
8094 | gen_helper_sve2_##name##_s, gen_helper_sve2_##name##_d, \ | |
8095 | }; \ | |
8096 | return do_sve2_zzz_ool(s, a, fns[a->esz]); \ | |
8097 | } | |
8098 | ||
8099 | DO_SVE2_ZZZ_NARROW(ADDHNB, addhnb) | |
8100 | DO_SVE2_ZZZ_NARROW(ADDHNT, addhnt) | |
0ea3ff02 SL |
8101 | DO_SVE2_ZZZ_NARROW(RADDHNB, raddhnb) |
8102 | DO_SVE2_ZZZ_NARROW(RADDHNT, raddhnt) | |
40d5ea50 | 8103 | |
c3cd6766 SL |
8104 | DO_SVE2_ZZZ_NARROW(SUBHNB, subhnb) |
8105 | DO_SVE2_ZZZ_NARROW(SUBHNT, subhnt) | |
e9443d10 SL |
8106 | DO_SVE2_ZZZ_NARROW(RSUBHNB, rsubhnb) |
8107 | DO_SVE2_ZZZ_NARROW(RSUBHNT, rsubhnt) | |
c3cd6766 | 8108 | |
e0ae6ec3 SL |
8109 | static bool do_sve2_ppzz_flags(DisasContext *s, arg_rprr_esz *a, |
8110 | gen_helper_gvec_flags_4 *fn) | |
8111 | { | |
8112 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8113 | return false; | |
8114 | } | |
8115 | return do_ppzz_flags(s, a, fn); | |
8116 | } | |
8117 | ||
8118 | #define DO_SVE2_PPZZ_MATCH(NAME, name) \ | |
8119 | static bool trans_##NAME(DisasContext *s, arg_rprr_esz *a) \ | |
8120 | { \ | |
8121 | static gen_helper_gvec_flags_4 * const fns[4] = { \ | |
8122 | gen_helper_sve2_##name##_ppzz_b, gen_helper_sve2_##name##_ppzz_h, \ | |
8123 | NULL, NULL \ | |
8124 | }; \ | |
8125 | return do_sve2_ppzz_flags(s, a, fns[a->esz]); \ | |
8126 | } | |
8127 | ||
8128 | DO_SVE2_PPZZ_MATCH(MATCH, match) | |
8129 | DO_SVE2_PPZZ_MATCH(NMATCH, nmatch) | |
8130 | ||
7d47ac94 SL |
8131 | static bool trans_HISTCNT(DisasContext *s, arg_rprr_esz *a) |
8132 | { | |
8133 | static gen_helper_gvec_4 * const fns[2] = { | |
8134 | gen_helper_sve2_histcnt_s, gen_helper_sve2_histcnt_d | |
8135 | }; | |
8136 | if (a->esz < 2) { | |
8137 | return false; | |
8138 | } | |
8139 | return do_sve2_zpzz_ool(s, a, fns[a->esz - 2]); | |
8140 | } | |
8141 | ||
8142 | static bool trans_HISTSEG(DisasContext *s, arg_rrr_esz *a) | |
8143 | { | |
8144 | if (a->esz != 0) { | |
8145 | return false; | |
8146 | } | |
8147 | return do_sve2_zzz_ool(s, a, gen_helper_sve2_histseg); | |
8148 | } | |
8149 | ||
b87dbeeb SL |
8150 | static bool do_sve2_zpzz_fp(DisasContext *s, arg_rprr_esz *a, |
8151 | gen_helper_gvec_4_ptr *fn) | |
8152 | { | |
8153 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8154 | return false; | |
8155 | } | |
8156 | return do_zpzz_fp(s, a, fn); | |
8157 | } | |
8158 | ||
8159 | #define DO_SVE2_ZPZZ_FP(NAME, name) \ | |
8160 | static bool trans_##NAME(DisasContext *s, arg_rprr_esz *a) \ | |
8161 | { \ | |
8162 | static gen_helper_gvec_4_ptr * const fns[4] = { \ | |
8163 | NULL, gen_helper_sve2_##name##_zpzz_h, \ | |
8164 | gen_helper_sve2_##name##_zpzz_s, gen_helper_sve2_##name##_zpzz_d \ | |
8165 | }; \ | |
8166 | return do_sve2_zpzz_fp(s, a, fns[a->esz]); \ | |
8167 | } | |
8168 | ||
8169 | DO_SVE2_ZPZZ_FP(FADDP, faddp) | |
8170 | DO_SVE2_ZPZZ_FP(FMAXNMP, fmaxnmp) | |
8171 | DO_SVE2_ZPZZ_FP(FMINNMP, fminnmp) | |
8172 | DO_SVE2_ZPZZ_FP(FMAXP, fmaxp) | |
8173 | DO_SVE2_ZPZZ_FP(FMINP, fminp) | |
bfc9307e RH |
8174 | |
8175 | /* | |
8176 | * SVE Integer Multiply-Add (unpredicated) | |
8177 | */ | |
8178 | ||
4f26756b SL |
8179 | static bool trans_FMMLA(DisasContext *s, arg_rrrr_esz *a) |
8180 | { | |
8181 | gen_helper_gvec_4_ptr *fn; | |
8182 | ||
8183 | switch (a->esz) { | |
8184 | case MO_32: | |
8185 | if (!dc_isar_feature(aa64_sve_f32mm, s)) { | |
8186 | return false; | |
8187 | } | |
8188 | fn = gen_helper_fmmla_s; | |
8189 | break; | |
8190 | case MO_64: | |
8191 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | |
8192 | return false; | |
8193 | } | |
8194 | fn = gen_helper_fmmla_d; | |
8195 | break; | |
8196 | default: | |
8197 | return false; | |
8198 | } | |
8199 | ||
8200 | if (sve_access_check(s)) { | |
8201 | unsigned vsz = vec_full_reg_size(s); | |
8202 | TCGv_ptr status = fpstatus_ptr(FPST_FPCR); | |
8203 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | |
8204 | vec_full_reg_offset(s, a->rn), | |
8205 | vec_full_reg_offset(s, a->rm), | |
8206 | vec_full_reg_offset(s, a->ra), | |
8207 | status, vsz, vsz, 0, fn); | |
8208 | tcg_temp_free_ptr(status); | |
8209 | } | |
8210 | return true; | |
8211 | } | |
8212 | ||
bfc9307e RH |
8213 | static bool do_sqdmlal_zzzw(DisasContext *s, arg_rrrr_esz *a, |
8214 | bool sel1, bool sel2) | |
8215 | { | |
8216 | static gen_helper_gvec_4 * const fns[] = { | |
8217 | NULL, gen_helper_sve2_sqdmlal_zzzw_h, | |
8218 | gen_helper_sve2_sqdmlal_zzzw_s, gen_helper_sve2_sqdmlal_zzzw_d, | |
8219 | }; | |
8220 | return do_sve2_zzzz_ool(s, a, fns[a->esz], (sel2 << 1) | sel1); | |
8221 | } | |
8222 | ||
8223 | static bool do_sqdmlsl_zzzw(DisasContext *s, arg_rrrr_esz *a, | |
8224 | bool sel1, bool sel2) | |
8225 | { | |
8226 | static gen_helper_gvec_4 * const fns[] = { | |
8227 | NULL, gen_helper_sve2_sqdmlsl_zzzw_h, | |
8228 | gen_helper_sve2_sqdmlsl_zzzw_s, gen_helper_sve2_sqdmlsl_zzzw_d, | |
8229 | }; | |
8230 | return do_sve2_zzzz_ool(s, a, fns[a->esz], (sel2 << 1) | sel1); | |
8231 | } | |
8232 | ||
8233 | static bool trans_SQDMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8234 | { | |
8235 | return do_sqdmlal_zzzw(s, a, false, false); | |
8236 | } | |
8237 | ||
8238 | static bool trans_SQDMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8239 | { | |
8240 | return do_sqdmlal_zzzw(s, a, true, true); | |
8241 | } | |
8242 | ||
8243 | static bool trans_SQDMLALBT(DisasContext *s, arg_rrrr_esz *a) | |
8244 | { | |
8245 | return do_sqdmlal_zzzw(s, a, false, true); | |
8246 | } | |
8247 | ||
8248 | static bool trans_SQDMLSLB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8249 | { | |
8250 | return do_sqdmlsl_zzzw(s, a, false, false); | |
8251 | } | |
8252 | ||
8253 | static bool trans_SQDMLSLT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8254 | { | |
8255 | return do_sqdmlsl_zzzw(s, a, true, true); | |
8256 | } | |
8257 | ||
8258 | static bool trans_SQDMLSLBT(DisasContext *s, arg_rrrr_esz *a) | |
8259 | { | |
8260 | return do_sqdmlsl_zzzw(s, a, false, true); | |
8261 | } | |
ab3ddf31 RH |
8262 | |
8263 | static bool trans_SQRDMLAH_zzzz(DisasContext *s, arg_rrrr_esz *a) | |
8264 | { | |
8265 | static gen_helper_gvec_4 * const fns[] = { | |
8266 | gen_helper_sve2_sqrdmlah_b, gen_helper_sve2_sqrdmlah_h, | |
8267 | gen_helper_sve2_sqrdmlah_s, gen_helper_sve2_sqrdmlah_d, | |
8268 | }; | |
8269 | return do_sve2_zzzz_ool(s, a, fns[a->esz], 0); | |
8270 | } | |
8271 | ||
8272 | static bool trans_SQRDMLSH_zzzz(DisasContext *s, arg_rrrr_esz *a) | |
8273 | { | |
8274 | static gen_helper_gvec_4 * const fns[] = { | |
8275 | gen_helper_sve2_sqrdmlsh_b, gen_helper_sve2_sqrdmlsh_h, | |
8276 | gen_helper_sve2_sqrdmlsh_s, gen_helper_sve2_sqrdmlsh_d, | |
8277 | }; | |
8278 | return do_sve2_zzzz_ool(s, a, fns[a->esz], 0); | |
8279 | } | |
45a32e80 RH |
8280 | |
8281 | static bool do_smlal_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
8282 | { | |
8283 | static gen_helper_gvec_4 * const fns[] = { | |
8284 | NULL, gen_helper_sve2_smlal_zzzw_h, | |
8285 | gen_helper_sve2_smlal_zzzw_s, gen_helper_sve2_smlal_zzzw_d, | |
8286 | }; | |
8287 | return do_sve2_zzzz_ool(s, a, fns[a->esz], sel); | |
8288 | } | |
8289 | ||
8290 | static bool trans_SMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8291 | { | |
8292 | return do_smlal_zzzw(s, a, false); | |
8293 | } | |
8294 | ||
8295 | static bool trans_SMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8296 | { | |
8297 | return do_smlal_zzzw(s, a, true); | |
8298 | } | |
8299 | ||
8300 | static bool do_umlal_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
8301 | { | |
8302 | static gen_helper_gvec_4 * const fns[] = { | |
8303 | NULL, gen_helper_sve2_umlal_zzzw_h, | |
8304 | gen_helper_sve2_umlal_zzzw_s, gen_helper_sve2_umlal_zzzw_d, | |
8305 | }; | |
8306 | return do_sve2_zzzz_ool(s, a, fns[a->esz], sel); | |
8307 | } | |
8308 | ||
8309 | static bool trans_UMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8310 | { | |
8311 | return do_umlal_zzzw(s, a, false); | |
8312 | } | |
8313 | ||
8314 | static bool trans_UMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8315 | { | |
8316 | return do_umlal_zzzw(s, a, true); | |
8317 | } | |
8318 | ||
8319 | static bool do_smlsl_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
8320 | { | |
8321 | static gen_helper_gvec_4 * const fns[] = { | |
8322 | NULL, gen_helper_sve2_smlsl_zzzw_h, | |
8323 | gen_helper_sve2_smlsl_zzzw_s, gen_helper_sve2_smlsl_zzzw_d, | |
8324 | }; | |
8325 | return do_sve2_zzzz_ool(s, a, fns[a->esz], sel); | |
8326 | } | |
8327 | ||
8328 | static bool trans_SMLSLB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8329 | { | |
8330 | return do_smlsl_zzzw(s, a, false); | |
8331 | } | |
8332 | ||
8333 | static bool trans_SMLSLT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8334 | { | |
8335 | return do_smlsl_zzzw(s, a, true); | |
8336 | } | |
8337 | ||
8338 | static bool do_umlsl_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
8339 | { | |
8340 | static gen_helper_gvec_4 * const fns[] = { | |
8341 | NULL, gen_helper_sve2_umlsl_zzzw_h, | |
8342 | gen_helper_sve2_umlsl_zzzw_s, gen_helper_sve2_umlsl_zzzw_d, | |
8343 | }; | |
8344 | return do_sve2_zzzz_ool(s, a, fns[a->esz], sel); | |
8345 | } | |
8346 | ||
8347 | static bool trans_UMLSLB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8348 | { | |
8349 | return do_umlsl_zzzw(s, a, false); | |
8350 | } | |
8351 | ||
8352 | static bool trans_UMLSLT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8353 | { | |
8354 | return do_umlsl_zzzw(s, a, true); | |
8355 | } | |
d782d3ca RH |
8356 | |
8357 | static bool trans_CMLA_zzzz(DisasContext *s, arg_CMLA_zzzz *a) | |
8358 | { | |
8359 | static gen_helper_gvec_4 * const fns[] = { | |
8360 | gen_helper_sve2_cmla_zzzz_b, gen_helper_sve2_cmla_zzzz_h, | |
8361 | gen_helper_sve2_cmla_zzzz_s, gen_helper_sve2_cmla_zzzz_d, | |
8362 | }; | |
8363 | ||
8364 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8365 | return false; | |
8366 | } | |
8367 | if (sve_access_check(s)) { | |
8368 | gen_gvec_ool_zzzz(s, fns[a->esz], a->rd, a->rn, a->rm, a->ra, a->rot); | |
8369 | } | |
8370 | return true; | |
8371 | } | |
8372 | ||
21068f39 RH |
8373 | static bool trans_CDOT_zzzz(DisasContext *s, arg_CMLA_zzzz *a) |
8374 | { | |
8375 | if (!dc_isar_feature(aa64_sve2, s) || a->esz < MO_32) { | |
8376 | return false; | |
8377 | } | |
8378 | if (sve_access_check(s)) { | |
8379 | gen_helper_gvec_4 *fn = (a->esz == MO_32 | |
8380 | ? gen_helper_sve2_cdot_zzzz_s | |
8381 | : gen_helper_sve2_cdot_zzzz_d); | |
8382 | gen_gvec_ool_zzzz(s, fn, a->rd, a->rn, a->rm, a->ra, a->rot); | |
8383 | } | |
8384 | return true; | |
8385 | } | |
8386 | ||
d782d3ca RH |
8387 | static bool trans_SQRDCMLAH_zzzz(DisasContext *s, arg_SQRDCMLAH_zzzz *a) |
8388 | { | |
8389 | static gen_helper_gvec_4 * const fns[] = { | |
8390 | gen_helper_sve2_sqrdcmlah_zzzz_b, gen_helper_sve2_sqrdcmlah_zzzz_h, | |
8391 | gen_helper_sve2_sqrdcmlah_zzzz_s, gen_helper_sve2_sqrdcmlah_zzzz_d, | |
8392 | }; | |
8393 | ||
8394 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8395 | return false; | |
8396 | } | |
8397 | if (sve_access_check(s)) { | |
8398 | gen_gvec_ool_zzzz(s, fns[a->esz], a->rd, a->rn, a->rm, a->ra, a->rot); | |
8399 | } | |
8400 | return true; | |
8401 | } | |
6a98cb2a RH |
8402 | |
8403 | static bool trans_USDOT_zzzz(DisasContext *s, arg_USDOT_zzzz *a) | |
8404 | { | |
8405 | if (a->esz != 2 || !dc_isar_feature(aa64_sve_i8mm, s)) { | |
8406 | return false; | |
8407 | } | |
8408 | if (sve_access_check(s)) { | |
8409 | unsigned vsz = vec_full_reg_size(s); | |
8410 | tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd), | |
8411 | vec_full_reg_offset(s, a->rn), | |
8412 | vec_full_reg_offset(s, a->rm), | |
8413 | vec_full_reg_offset(s, a->ra), | |
8414 | vsz, vsz, 0, gen_helper_gvec_usdot_b); | |
8415 | } | |
8416 | return true; | |
8417 | } | |
b2bcd1be RH |
8418 | |
8419 | static bool trans_AESMC(DisasContext *s, arg_AESMC *a) | |
8420 | { | |
8421 | if (!dc_isar_feature(aa64_sve2_aes, s)) { | |
8422 | return false; | |
8423 | } | |
8424 | if (sve_access_check(s)) { | |
8425 | gen_gvec_ool_zz(s, gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt); | |
8426 | } | |
8427 | return true; | |
8428 | } | |
3cc7a88e RH |
8429 | |
8430 | static bool do_aese(DisasContext *s, arg_rrr_esz *a, bool decrypt) | |
8431 | { | |
8432 | if (!dc_isar_feature(aa64_sve2_aes, s)) { | |
8433 | return false; | |
8434 | } | |
8435 | if (sve_access_check(s)) { | |
8436 | gen_gvec_ool_zzz(s, gen_helper_crypto_aese, | |
8437 | a->rd, a->rn, a->rm, decrypt); | |
8438 | } | |
8439 | return true; | |
8440 | } | |
8441 | ||
8442 | static bool trans_AESE(DisasContext *s, arg_rrr_esz *a) | |
8443 | { | |
8444 | return do_aese(s, a, false); | |
8445 | } | |
8446 | ||
8447 | static bool trans_AESD(DisasContext *s, arg_rrr_esz *a) | |
8448 | { | |
8449 | return do_aese(s, a, true); | |
8450 | } | |
8451 | ||
8452 | static bool do_sm4(DisasContext *s, arg_rrr_esz *a, gen_helper_gvec_3 *fn) | |
8453 | { | |
8454 | if (!dc_isar_feature(aa64_sve2_sm4, s)) { | |
8455 | return false; | |
8456 | } | |
8457 | if (sve_access_check(s)) { | |
8458 | gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0); | |
8459 | } | |
8460 | return true; | |
8461 | } | |
8462 | ||
8463 | static bool trans_SM4E(DisasContext *s, arg_rrr_esz *a) | |
8464 | { | |
8465 | return do_sm4(s, a, gen_helper_crypto_sm4e); | |
8466 | } | |
3358eb3f RH |
8467 | |
8468 | static bool trans_SM4EKEY(DisasContext *s, arg_rrr_esz *a) | |
8469 | { | |
8470 | return do_sm4(s, a, gen_helper_crypto_sm4ekey); | |
8471 | } | |
8472 | ||
8473 | static bool trans_RAX1(DisasContext *s, arg_rrr_esz *a) | |
8474 | { | |
8475 | if (!dc_isar_feature(aa64_sve2_sha3, s)) { | |
8476 | return false; | |
8477 | } | |
8478 | if (sve_access_check(s)) { | |
8479 | gen_gvec_fn_zzz(s, gen_gvec_rax1, MO_64, a->rd, a->rn, a->rm); | |
8480 | } | |
8481 | return true; | |
8482 | } | |
5c1b7226 RH |
8483 | |
8484 | static bool trans_FCVTNT_sh(DisasContext *s, arg_rpr_esz *a) | |
8485 | { | |
8486 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8487 | return false; | |
8488 | } | |
8489 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve2_fcvtnt_sh); | |
8490 | } | |
8491 | ||
d29b17ca RH |
8492 | static bool trans_BFCVTNT(DisasContext *s, arg_rpr_esz *a) |
8493 | { | |
8494 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8495 | return false; | |
8496 | } | |
8497 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_bfcvtnt); | |
8498 | } | |
8499 | ||
5c1b7226 RH |
8500 | static bool trans_FCVTNT_ds(DisasContext *s, arg_rpr_esz *a) |
8501 | { | |
8502 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8503 | return false; | |
8504 | } | |
8505 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve2_fcvtnt_ds); | |
8506 | } | |
83c2523f SL |
8507 | |
8508 | static bool trans_FCVTLT_hs(DisasContext *s, arg_rpr_esz *a) | |
8509 | { | |
8510 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8511 | return false; | |
8512 | } | |
8513 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve2_fcvtlt_hs); | |
8514 | } | |
8515 | ||
8516 | static bool trans_FCVTLT_sd(DisasContext *s, arg_rpr_esz *a) | |
8517 | { | |
8518 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8519 | return false; | |
8520 | } | |
8521 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve2_fcvtlt_sd); | |
8522 | } | |
95365277 SL |
8523 | |
8524 | static bool trans_FCVTX_ds(DisasContext *s, arg_rpr_esz *a) | |
8525 | { | |
8526 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8527 | return false; | |
8528 | } | |
8529 | return do_frint_mode(s, a, float_round_to_odd, gen_helper_sve_fcvt_ds); | |
8530 | } | |
8531 | ||
8532 | static bool trans_FCVTXNT_ds(DisasContext *s, arg_rpr_esz *a) | |
8533 | { | |
8534 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8535 | return false; | |
8536 | } | |
8537 | return do_frint_mode(s, a, float_round_to_odd, gen_helper_sve2_fcvtnt_ds); | |
8538 | } | |
631be02e SL |
8539 | |
8540 | static bool trans_FLOGB(DisasContext *s, arg_rpr_esz *a) | |
8541 | { | |
8542 | static gen_helper_gvec_3_ptr * const fns[] = { | |
8543 | NULL, gen_helper_flogb_h, | |
8544 | gen_helper_flogb_s, gen_helper_flogb_d | |
8545 | }; | |
8546 | ||
8547 | if (!dc_isar_feature(aa64_sve2, s) || fns[a->esz] == NULL) { | |
8548 | return false; | |
8549 | } | |
8550 | if (sve_access_check(s)) { | |
8551 | TCGv_ptr status = | |
8552 | fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | |
8553 | unsigned vsz = vec_full_reg_size(s); | |
8554 | ||
8555 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), | |
8556 | vec_full_reg_offset(s, a->rn), | |
8557 | pred_full_reg_offset(s, a->pg), | |
8558 | status, vsz, vsz, 0, fns[a->esz]); | |
8559 | tcg_temp_free_ptr(status); | |
8560 | } | |
8561 | return true; | |
8562 | } | |
50d102bd SL |
8563 | |
8564 | static bool do_FMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sub, bool sel) | |
8565 | { | |
8566 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8567 | return false; | |
8568 | } | |
8569 | if (sve_access_check(s)) { | |
8570 | unsigned vsz = vec_full_reg_size(s); | |
8571 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | |
8572 | vec_full_reg_offset(s, a->rn), | |
8573 | vec_full_reg_offset(s, a->rm), | |
8574 | vec_full_reg_offset(s, a->ra), | |
8575 | cpu_env, vsz, vsz, (sel << 1) | sub, | |
8576 | gen_helper_sve2_fmlal_zzzw_s); | |
8577 | } | |
8578 | return true; | |
8579 | } | |
8580 | ||
8581 | static bool trans_FMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8582 | { | |
8583 | return do_FMLAL_zzzw(s, a, false, false); | |
8584 | } | |
8585 | ||
8586 | static bool trans_FMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8587 | { | |
8588 | return do_FMLAL_zzzw(s, a, false, true); | |
8589 | } | |
8590 | ||
8591 | static bool trans_FMLSLB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8592 | { | |
8593 | return do_FMLAL_zzzw(s, a, true, false); | |
8594 | } | |
8595 | ||
8596 | static bool trans_FMLSLT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8597 | { | |
8598 | return do_FMLAL_zzzw(s, a, true, true); | |
8599 | } | |
8600 | ||
8601 | static bool do_FMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sub, bool sel) | |
8602 | { | |
8603 | if (!dc_isar_feature(aa64_sve2, s)) { | |
8604 | return false; | |
8605 | } | |
8606 | if (sve_access_check(s)) { | |
8607 | unsigned vsz = vec_full_reg_size(s); | |
8608 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | |
8609 | vec_full_reg_offset(s, a->rn), | |
8610 | vec_full_reg_offset(s, a->rm), | |
8611 | vec_full_reg_offset(s, a->ra), | |
8612 | cpu_env, vsz, vsz, | |
8613 | (a->index << 2) | (sel << 1) | sub, | |
8614 | gen_helper_sve2_fmlal_zzxw_s); | |
8615 | } | |
8616 | return true; | |
8617 | } | |
8618 | ||
8619 | static bool trans_FMLALB_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8620 | { | |
8621 | return do_FMLAL_zzxw(s, a, false, false); | |
8622 | } | |
8623 | ||
8624 | static bool trans_FMLALT_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8625 | { | |
8626 | return do_FMLAL_zzxw(s, a, false, true); | |
8627 | } | |
8628 | ||
8629 | static bool trans_FMLSLB_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8630 | { | |
8631 | return do_FMLAL_zzxw(s, a, true, false); | |
8632 | } | |
8633 | ||
8634 | static bool trans_FMLSLT_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8635 | { | |
8636 | return do_FMLAL_zzxw(s, a, true, true); | |
8637 | } | |
2323c5ff RH |
8638 | |
8639 | static bool do_i8mm_zzzz_ool(DisasContext *s, arg_rrrr_esz *a, | |
8640 | gen_helper_gvec_4 *fn, int data) | |
8641 | { | |
8642 | if (!dc_isar_feature(aa64_sve_i8mm, s)) { | |
8643 | return false; | |
8644 | } | |
8645 | if (sve_access_check(s)) { | |
8646 | gen_gvec_ool_zzzz(s, fn, a->rd, a->rn, a->rm, a->ra, data); | |
8647 | } | |
8648 | return true; | |
8649 | } | |
8650 | ||
8651 | static bool trans_SMMLA(DisasContext *s, arg_rrrr_esz *a) | |
8652 | { | |
8653 | return do_i8mm_zzzz_ool(s, a, gen_helper_gvec_smmla_b, 0); | |
8654 | } | |
8655 | ||
8656 | static bool trans_USMMLA(DisasContext *s, arg_rrrr_esz *a) | |
8657 | { | |
8658 | return do_i8mm_zzzz_ool(s, a, gen_helper_gvec_usmmla_b, 0); | |
8659 | } | |
8660 | ||
8661 | static bool trans_UMMLA(DisasContext *s, arg_rrrr_esz *a) | |
8662 | { | |
8663 | return do_i8mm_zzzz_ool(s, a, gen_helper_gvec_ummla_b, 0); | |
8664 | } | |
cb8657f7 RH |
8665 | |
8666 | static bool trans_BFDOT_zzzz(DisasContext *s, arg_rrrr_esz *a) | |
8667 | { | |
8668 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8669 | return false; | |
8670 | } | |
8671 | if (sve_access_check(s)) { | |
8672 | gen_gvec_ool_zzzz(s, gen_helper_gvec_bfdot, | |
8673 | a->rd, a->rn, a->rm, a->ra, 0); | |
8674 | } | |
8675 | return true; | |
8676 | } | |
83914478 RH |
8677 | |
8678 | static bool trans_BFDOT_zzxz(DisasContext *s, arg_rrxr_esz *a) | |
8679 | { | |
8680 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8681 | return false; | |
8682 | } | |
8683 | if (sve_access_check(s)) { | |
8684 | gen_gvec_ool_zzzz(s, gen_helper_gvec_bfdot_idx, | |
8685 | a->rd, a->rn, a->rm, a->ra, a->index); | |
8686 | } | |
8687 | return true; | |
8688 | } | |
81266a1f RH |
8689 | |
8690 | static bool trans_BFMMLA(DisasContext *s, arg_rrrr_esz *a) | |
8691 | { | |
8692 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8693 | return false; | |
8694 | } | |
8695 | if (sve_access_check(s)) { | |
8696 | gen_gvec_ool_zzzz(s, gen_helper_gvec_bfmmla, | |
8697 | a->rd, a->rn, a->rm, a->ra, 0); | |
8698 | } | |
8699 | return true; | |
8700 | } | |
5693887f RH |
8701 | |
8702 | static bool do_BFMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | |
8703 | { | |
8704 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8705 | return false; | |
8706 | } | |
8707 | if (sve_access_check(s)) { | |
8708 | TCGv_ptr status = fpstatus_ptr(FPST_FPCR); | |
8709 | unsigned vsz = vec_full_reg_size(s); | |
8710 | ||
8711 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | |
8712 | vec_full_reg_offset(s, a->rn), | |
8713 | vec_full_reg_offset(s, a->rm), | |
8714 | vec_full_reg_offset(s, a->ra), | |
8715 | status, vsz, vsz, sel, | |
8716 | gen_helper_gvec_bfmlal); | |
8717 | tcg_temp_free_ptr(status); | |
8718 | } | |
8719 | return true; | |
8720 | } | |
8721 | ||
8722 | static bool trans_BFMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8723 | { | |
8724 | return do_BFMLAL_zzzw(s, a, false); | |
8725 | } | |
8726 | ||
8727 | static bool trans_BFMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | |
8728 | { | |
8729 | return do_BFMLAL_zzzw(s, a, true); | |
8730 | } | |
458d0ab6 RH |
8731 | |
8732 | static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel) | |
8733 | { | |
8734 | if (!dc_isar_feature(aa64_sve_bf16, s)) { | |
8735 | return false; | |
8736 | } | |
8737 | if (sve_access_check(s)) { | |
8738 | TCGv_ptr status = fpstatus_ptr(FPST_FPCR); | |
8739 | unsigned vsz = vec_full_reg_size(s); | |
8740 | ||
8741 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | |
8742 | vec_full_reg_offset(s, a->rn), | |
8743 | vec_full_reg_offset(s, a->rm), | |
8744 | vec_full_reg_offset(s, a->ra), | |
8745 | status, vsz, vsz, (a->index << 1) | sel, | |
8746 | gen_helper_gvec_bfmlal_idx); | |
8747 | tcg_temp_free_ptr(status); | |
8748 | } | |
8749 | return true; | |
8750 | } | |
8751 | ||
8752 | static bool trans_BFMLALB_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8753 | { | |
8754 | return do_BFMLAL_zzxw(s, a, false); | |
8755 | } | |
8756 | ||
8757 | static bool trans_BFMLALT_zzxw(DisasContext *s, arg_rrxr_esz *a) | |
8758 | { | |
8759 | return do_BFMLAL_zzxw(s, a, true); | |
8760 | } |