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