1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * LoongArch vector translate functions
4 * Copyright (c) 2022-2023 Loongson Technology Corporation Limited
7 #ifndef CONFIG_USER_ONLY
9 static bool check_vec(DisasContext *ctx, uint32_t oprsz)
11 if ((oprsz == 16) && ((ctx->base.tb->flags & HW_FLAGS_EUEN_SXE) == 0)) {
12 generate_exception(ctx, EXCCODE_SXD);
16 if ((oprsz == 32) && ((ctx->base.tb->flags & HW_FLAGS_EUEN_ASXE) == 0)) {
17 generate_exception(ctx, EXCCODE_ASXD);
26 static bool check_vec(DisasContext *ctx, uint32_t oprsz)
33 static bool gen_vvvv_ptr_vl(DisasContext *ctx, arg_vvvv *a, uint32_t oprsz,
34 gen_helper_gvec_4_ptr *fn)
36 if (!check_vec(ctx, oprsz)) {
40 tcg_gen_gvec_4_ptr(vec_full_offset(a->vd),
41 vec_full_offset(a->vj),
42 vec_full_offset(a->vk),
43 vec_full_offset(a->va),
45 oprsz, ctx->vl / 8, 0, fn);
49 static bool gen_vvvv_ptr(DisasContext *ctx, arg_vvvv *a,
50 gen_helper_gvec_4_ptr *fn)
52 return gen_vvvv_ptr_vl(ctx, a, 16, fn);
55 static bool gen_xxxx_ptr(DisasContext *ctx, arg_vvvv *a,
56 gen_helper_gvec_4_ptr *fn)
58 return gen_vvvv_ptr_vl(ctx, a, 32, fn);
61 static bool gen_vvvv_vl(DisasContext *ctx, arg_vvvv *a, uint32_t oprsz,
62 gen_helper_gvec_4 *fn)
64 if (!check_vec(ctx, oprsz)) {
68 tcg_gen_gvec_4_ool(vec_full_offset(a->vd),
69 vec_full_offset(a->vj),
70 vec_full_offset(a->vk),
71 vec_full_offset(a->va),
72 oprsz, ctx->vl / 8, 0, fn);
76 static bool gen_vvvv(DisasContext *ctx, arg_vvvv *a,
77 gen_helper_gvec_4 *fn)
79 return gen_vvvv_vl(ctx, a, 16, fn);
82 static bool gen_xxxx(DisasContext *ctx, arg_vvvv *a,
83 gen_helper_gvec_4 *fn)
85 return gen_vvvv_vl(ctx, a, 32, fn);
88 static bool gen_vvv_ptr_vl(DisasContext *ctx, arg_vvv *a, uint32_t oprsz,
89 gen_helper_gvec_3_ptr *fn)
91 if (!check_vec(ctx, oprsz)) {
94 tcg_gen_gvec_3_ptr(vec_full_offset(a->vd),
95 vec_full_offset(a->vj),
96 vec_full_offset(a->vk),
98 oprsz, ctx->vl / 8, 0, fn);
102 static bool gen_vvv_ptr(DisasContext *ctx, arg_vvv *a,
103 gen_helper_gvec_3_ptr *fn)
105 return gen_vvv_ptr_vl(ctx, a, 16, fn);
108 static bool gen_xxx_ptr(DisasContext *ctx, arg_vvv *a,
109 gen_helper_gvec_3_ptr *fn)
111 return gen_vvv_ptr_vl(ctx, a, 32, fn);
114 static bool gen_vvv_vl(DisasContext *ctx, arg_vvv *a, uint32_t oprsz,
115 gen_helper_gvec_3 *fn)
117 if (!check_vec(ctx, oprsz)) {
121 tcg_gen_gvec_3_ool(vec_full_offset(a->vd),
122 vec_full_offset(a->vj),
123 vec_full_offset(a->vk),
124 oprsz, ctx->vl / 8, 0, fn);
128 static bool gen_vvv(DisasContext *ctx, arg_vvv *a, gen_helper_gvec_3 *fn)
130 return gen_vvv_vl(ctx, a, 16, fn);
133 static bool gen_xxx(DisasContext *ctx, arg_vvv *a, gen_helper_gvec_3 *fn)
135 return gen_vvv_vl(ctx, a, 32, fn);
138 static bool gen_vv_ptr_vl(DisasContext *ctx, arg_vv *a, uint32_t oprsz,
139 gen_helper_gvec_2_ptr *fn)
141 if (!check_vec(ctx, oprsz)) {
145 tcg_gen_gvec_2_ptr(vec_full_offset(a->vd),
146 vec_full_offset(a->vj),
148 oprsz, ctx->vl / 8, 0, fn);
152 static bool gen_vv_ptr(DisasContext *ctx, arg_vv *a,
153 gen_helper_gvec_2_ptr *fn)
155 return gen_vv_ptr_vl(ctx, a, 16, fn);
158 static bool gen_xx_ptr(DisasContext *ctx, arg_vv *a,
159 gen_helper_gvec_2_ptr *fn)
161 return gen_vv_ptr_vl(ctx, a, 32, fn);
164 static bool gen_vv_vl(DisasContext *ctx, arg_vv *a, uint32_t oprsz,
165 gen_helper_gvec_2 *fn)
167 if (!check_vec(ctx, oprsz)) {
171 tcg_gen_gvec_2_ool(vec_full_offset(a->vd),
172 vec_full_offset(a->vj),
173 oprsz, ctx->vl / 8, 0, fn);
177 static bool gen_vv(DisasContext *ctx, arg_vv *a, gen_helper_gvec_2 *fn)
179 return gen_vv_vl(ctx, a, 16, fn);
182 static bool gen_xx(DisasContext *ctx, arg_vv *a, gen_helper_gvec_2 *fn)
184 return gen_vv_vl(ctx, a, 32, fn);
187 static bool gen_vv_i_vl(DisasContext *ctx, arg_vv_i *a, uint32_t oprsz,
188 gen_helper_gvec_2i *fn)
190 if (!check_vec(ctx, oprsz)) {
194 tcg_gen_gvec_2i_ool(vec_full_offset(a->vd),
195 vec_full_offset(a->vj),
196 tcg_constant_i64(a->imm),
197 oprsz, ctx->vl / 8, 0, fn);
201 static bool gen_vv_i(DisasContext *ctx, arg_vv_i *a, gen_helper_gvec_2i *fn)
203 return gen_vv_i_vl(ctx, a, 16, fn);
206 static bool gen_xx_i(DisasContext *ctx, arg_vv_i *a, gen_helper_gvec_2i *fn)
208 return gen_vv_i_vl(ctx, a, 32, fn);
211 static bool gen_cv_vl(DisasContext *ctx, arg_cv *a, uint32_t sz,
212 void (*func)(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32))
214 if (!check_vec(ctx, sz)) {
218 TCGv_i32 vj = tcg_constant_i32(a->vj);
219 TCGv_i32 cd = tcg_constant_i32(a->cd);
220 TCGv_i32 oprsz = tcg_constant_i32(sz);
222 func(tcg_env, oprsz, cd, vj);
226 static bool gen_cv(DisasContext *ctx, arg_cv *a,
227 void (*func)(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32))
229 return gen_cv_vl(ctx, a, 16, func);
232 static bool gen_cx(DisasContext *ctx, arg_cv *a,
233 void (*func)(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32))
235 return gen_cv_vl(ctx, a, 32, func);
238 static bool gvec_vvv_vl(DisasContext *ctx, arg_vvv *a,
239 uint32_t oprsz, MemOp mop,
240 void (*func)(unsigned, uint32_t, uint32_t,
241 uint32_t, uint32_t, uint32_t))
243 uint32_t vd_ofs = vec_full_offset(a->vd);
244 uint32_t vj_ofs = vec_full_offset(a->vj);
245 uint32_t vk_ofs = vec_full_offset(a->vk);
247 if (!check_vec(ctx, oprsz)) {
251 func(mop, vd_ofs, vj_ofs, vk_ofs, oprsz, ctx->vl / 8);
255 static bool gvec_vvv(DisasContext *ctx, arg_vvv *a, MemOp mop,
256 void (*func)(unsigned, uint32_t, uint32_t,
257 uint32_t, uint32_t, uint32_t))
259 return gvec_vvv_vl(ctx, a, 16, mop, func);
262 static bool gvec_xxx(DisasContext *ctx, arg_vvv *a, MemOp mop,
263 void (*func)(unsigned, uint32_t, uint32_t,
264 uint32_t, uint32_t, uint32_t))
266 return gvec_vvv_vl(ctx, a, 32, mop, func);
269 static bool gvec_vv_vl(DisasContext *ctx, arg_vv *a,
270 uint32_t oprsz, MemOp mop,
271 void (*func)(unsigned, uint32_t, uint32_t,
274 uint32_t vd_ofs = vec_full_offset(a->vd);
275 uint32_t vj_ofs = vec_full_offset(a->vj);
277 if (!check_vec(ctx, oprsz)) {
281 func(mop, vd_ofs, vj_ofs, oprsz, ctx->vl / 8);
286 static bool gvec_vv(DisasContext *ctx, arg_vv *a, MemOp mop,
287 void (*func)(unsigned, uint32_t, uint32_t,
290 return gvec_vv_vl(ctx, a, 16, mop, func);
293 static bool gvec_xx(DisasContext *ctx, arg_vv *a, MemOp mop,
294 void (*func)(unsigned, uint32_t, uint32_t,
297 return gvec_vv_vl(ctx, a, 32, mop, func);
300 static bool gvec_vv_i_vl(DisasContext *ctx, arg_vv_i *a,
301 uint32_t oprsz, MemOp mop,
302 void (*func)(unsigned, uint32_t, uint32_t,
303 int64_t, uint32_t, uint32_t))
305 uint32_t vd_ofs = vec_full_offset(a->vd);
306 uint32_t vj_ofs = vec_full_offset(a->vj);
308 if (!check_vec(ctx, oprsz)) {
312 func(mop, vd_ofs, vj_ofs, a->imm, oprsz, ctx->vl / 8);
316 static bool gvec_vv_i(DisasContext *ctx, arg_vv_i *a, MemOp mop,
317 void (*func)(unsigned, uint32_t, uint32_t,
318 int64_t, uint32_t, uint32_t))
320 return gvec_vv_i_vl(ctx, a, 16, mop, func);
323 static bool gvec_xx_i(DisasContext *ctx, arg_vv_i *a, MemOp mop,
324 void (*func)(unsigned, uint32_t, uint32_t,
325 int64_t, uint32_t, uint32_t))
327 return gvec_vv_i_vl(ctx,a, 32, mop, func);
330 static bool gvec_subi_vl(DisasContext *ctx, arg_vv_i *a,
331 uint32_t oprsz, MemOp mop)
333 uint32_t vd_ofs = vec_full_offset(a->vd);
334 uint32_t vj_ofs = vec_full_offset(a->vj);
336 if (!check_vec(ctx, oprsz)) {
340 tcg_gen_gvec_addi(mop, vd_ofs, vj_ofs, -a->imm, oprsz, ctx->vl / 8);
344 static bool gvec_subi(DisasContext *ctx, arg_vv_i *a, MemOp mop)
346 return gvec_subi_vl(ctx, a, 16, mop);
349 static bool gvec_xsubi(DisasContext *ctx, arg_vv_i *a, MemOp mop)
351 return gvec_subi_vl(ctx, a, 32, mop);
354 TRANS(vadd_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_add)
355 TRANS(vadd_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_add)
356 TRANS(vadd_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_add)
357 TRANS(vadd_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_add)
358 TRANS(xvadd_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_add)
359 TRANS(xvadd_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_add)
360 TRANS(xvadd_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_add)
361 TRANS(xvadd_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_add)
363 static bool gen_vaddsub_q_vl(DisasContext *ctx, arg_vvv *a, uint32_t oprsz,
364 void (*func)(TCGv_i64, TCGv_i64, TCGv_i64,
365 TCGv_i64, TCGv_i64, TCGv_i64))
368 TCGv_i64 rh, rl, ah, al, bh, bl;
370 if (!check_vec(ctx, oprsz)) {
374 rh = tcg_temp_new_i64();
375 rl = tcg_temp_new_i64();
376 ah = tcg_temp_new_i64();
377 al = tcg_temp_new_i64();
378 bh = tcg_temp_new_i64();
379 bl = tcg_temp_new_i64();
381 for (i = 0; i < oprsz / 16; i++) {
382 get_vreg64(ah, a->vj, 1 + i * 2);
383 get_vreg64(al, a->vj, i * 2);
384 get_vreg64(bh, a->vk, 1 + i * 2);
385 get_vreg64(bl, a->vk, i * 2);
387 func(rl, rh, al, ah, bl, bh);
389 set_vreg64(rh, a->vd, 1 + i * 2);
390 set_vreg64(rl, a->vd, i * 2);
395 static bool gen_vaddsub_q(DisasContext *ctx, arg_vvv *a,
396 void (*func)(TCGv_i64, TCGv_i64, TCGv_i64,
397 TCGv_i64, TCGv_i64, TCGv_i64))
399 return gen_vaddsub_q_vl(ctx, a, 16, func);
402 static bool gen_xvaddsub_q(DisasContext *ctx, arg_vvv *a,
403 void (*func)(TCGv_i64, TCGv_i64, TCGv_i64,
404 TCGv_i64, TCGv_i64, TCGv_i64))
406 return gen_vaddsub_q_vl(ctx, a, 32, func);
409 TRANS(vsub_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_sub)
410 TRANS(vsub_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_sub)
411 TRANS(vsub_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_sub)
412 TRANS(vsub_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_sub)
413 TRANS(xvsub_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_sub)
414 TRANS(xvsub_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_sub)
415 TRANS(xvsub_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_sub)
416 TRANS(xvsub_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_sub)
418 TRANS(vadd_q, LSX, gen_vaddsub_q, tcg_gen_add2_i64)
419 TRANS(vsub_q, LSX, gen_vaddsub_q, tcg_gen_sub2_i64)
420 TRANS(xvadd_q, LASX, gen_xvaddsub_q, tcg_gen_add2_i64)
421 TRANS(xvsub_q, LASX, gen_xvaddsub_q, tcg_gen_sub2_i64)
423 TRANS(vaddi_bu, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_addi)
424 TRANS(vaddi_hu, LSX, gvec_vv_i, MO_16, tcg_gen_gvec_addi)
425 TRANS(vaddi_wu, LSX, gvec_vv_i, MO_32, tcg_gen_gvec_addi)
426 TRANS(vaddi_du, LSX, gvec_vv_i, MO_64, tcg_gen_gvec_addi)
427 TRANS(vsubi_bu, LSX, gvec_subi, MO_8)
428 TRANS(vsubi_hu, LSX, gvec_subi, MO_16)
429 TRANS(vsubi_wu, LSX, gvec_subi, MO_32)
430 TRANS(vsubi_du, LSX, gvec_subi, MO_64)
431 TRANS(xvaddi_bu, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_addi)
432 TRANS(xvaddi_hu, LASX, gvec_xx_i, MO_16, tcg_gen_gvec_addi)
433 TRANS(xvaddi_wu, LASX, gvec_xx_i, MO_32, tcg_gen_gvec_addi)
434 TRANS(xvaddi_du, LASX, gvec_xx_i, MO_64, tcg_gen_gvec_addi)
435 TRANS(xvsubi_bu, LASX, gvec_xsubi, MO_8)
436 TRANS(xvsubi_hu, LASX, gvec_xsubi, MO_16)
437 TRANS(xvsubi_wu, LASX, gvec_xsubi, MO_32)
438 TRANS(xvsubi_du, LASX, gvec_xsubi, MO_64)
440 TRANS(vneg_b, LSX, gvec_vv, MO_8, tcg_gen_gvec_neg)
441 TRANS(vneg_h, LSX, gvec_vv, MO_16, tcg_gen_gvec_neg)
442 TRANS(vneg_w, LSX, gvec_vv, MO_32, tcg_gen_gvec_neg)
443 TRANS(vneg_d, LSX, gvec_vv, MO_64, tcg_gen_gvec_neg)
444 TRANS(xvneg_b, LASX, gvec_xx, MO_8, tcg_gen_gvec_neg)
445 TRANS(xvneg_h, LASX, gvec_xx, MO_16, tcg_gen_gvec_neg)
446 TRANS(xvneg_w, LASX, gvec_xx, MO_32, tcg_gen_gvec_neg)
447 TRANS(xvneg_d, LASX, gvec_xx, MO_64, tcg_gen_gvec_neg)
449 TRANS(vsadd_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_ssadd)
450 TRANS(vsadd_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_ssadd)
451 TRANS(vsadd_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_ssadd)
452 TRANS(vsadd_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_ssadd)
453 TRANS(vsadd_bu, LSX, gvec_vvv, MO_8, tcg_gen_gvec_usadd)
454 TRANS(vsadd_hu, LSX, gvec_vvv, MO_16, tcg_gen_gvec_usadd)
455 TRANS(vsadd_wu, LSX, gvec_vvv, MO_32, tcg_gen_gvec_usadd)
456 TRANS(vsadd_du, LSX, gvec_vvv, MO_64, tcg_gen_gvec_usadd)
457 TRANS(vssub_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_sssub)
458 TRANS(vssub_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_sssub)
459 TRANS(vssub_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_sssub)
460 TRANS(vssub_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_sssub)
461 TRANS(vssub_bu, LSX, gvec_vvv, MO_8, tcg_gen_gvec_ussub)
462 TRANS(vssub_hu, LSX, gvec_vvv, MO_16, tcg_gen_gvec_ussub)
463 TRANS(vssub_wu, LSX, gvec_vvv, MO_32, tcg_gen_gvec_ussub)
464 TRANS(vssub_du, LSX, gvec_vvv, MO_64, tcg_gen_gvec_ussub)
466 TRANS(xvsadd_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_ssadd)
467 TRANS(xvsadd_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_ssadd)
468 TRANS(xvsadd_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_ssadd)
469 TRANS(xvsadd_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_ssadd)
470 TRANS(xvsadd_bu, LASX, gvec_xxx, MO_8, tcg_gen_gvec_usadd)
471 TRANS(xvsadd_hu, LASX, gvec_xxx, MO_16, tcg_gen_gvec_usadd)
472 TRANS(xvsadd_wu, LASX, gvec_xxx, MO_32, tcg_gen_gvec_usadd)
473 TRANS(xvsadd_du, LASX, gvec_xxx, MO_64, tcg_gen_gvec_usadd)
474 TRANS(xvssub_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_sssub)
475 TRANS(xvssub_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_sssub)
476 TRANS(xvssub_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_sssub)
477 TRANS(xvssub_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_sssub)
478 TRANS(xvssub_bu, LASX, gvec_xxx, MO_8, tcg_gen_gvec_ussub)
479 TRANS(xvssub_hu, LASX, gvec_xxx, MO_16, tcg_gen_gvec_ussub)
480 TRANS(xvssub_wu, LASX, gvec_xxx, MO_32, tcg_gen_gvec_ussub)
481 TRANS(xvssub_du, LASX, gvec_xxx, MO_64, tcg_gen_gvec_ussub)
483 TRANS(vhaddw_h_b, LSX, gen_vvv, gen_helper_vhaddw_h_b)
484 TRANS(vhaddw_w_h, LSX, gen_vvv, gen_helper_vhaddw_w_h)
485 TRANS(vhaddw_d_w, LSX, gen_vvv, gen_helper_vhaddw_d_w)
486 TRANS(vhaddw_q_d, LSX, gen_vvv, gen_helper_vhaddw_q_d)
487 TRANS(vhaddw_hu_bu, LSX, gen_vvv, gen_helper_vhaddw_hu_bu)
488 TRANS(vhaddw_wu_hu, LSX, gen_vvv, gen_helper_vhaddw_wu_hu)
489 TRANS(vhaddw_du_wu, LSX, gen_vvv, gen_helper_vhaddw_du_wu)
490 TRANS(vhaddw_qu_du, LSX, gen_vvv, gen_helper_vhaddw_qu_du)
491 TRANS(vhsubw_h_b, LSX, gen_vvv, gen_helper_vhsubw_h_b)
492 TRANS(vhsubw_w_h, LSX, gen_vvv, gen_helper_vhsubw_w_h)
493 TRANS(vhsubw_d_w, LSX, gen_vvv, gen_helper_vhsubw_d_w)
494 TRANS(vhsubw_q_d, LSX, gen_vvv, gen_helper_vhsubw_q_d)
495 TRANS(vhsubw_hu_bu, LSX, gen_vvv, gen_helper_vhsubw_hu_bu)
496 TRANS(vhsubw_wu_hu, LSX, gen_vvv, gen_helper_vhsubw_wu_hu)
497 TRANS(vhsubw_du_wu, LSX, gen_vvv, gen_helper_vhsubw_du_wu)
498 TRANS(vhsubw_qu_du, LSX, gen_vvv, gen_helper_vhsubw_qu_du)
500 TRANS(xvhaddw_h_b, LASX, gen_xxx, gen_helper_vhaddw_h_b)
501 TRANS(xvhaddw_w_h, LASX, gen_xxx, gen_helper_vhaddw_w_h)
502 TRANS(xvhaddw_d_w, LASX, gen_xxx, gen_helper_vhaddw_d_w)
503 TRANS(xvhaddw_q_d, LASX, gen_xxx, gen_helper_vhaddw_q_d)
504 TRANS(xvhaddw_hu_bu, LASX, gen_xxx, gen_helper_vhaddw_hu_bu)
505 TRANS(xvhaddw_wu_hu, LASX, gen_xxx, gen_helper_vhaddw_wu_hu)
506 TRANS(xvhaddw_du_wu, LASX, gen_xxx, gen_helper_vhaddw_du_wu)
507 TRANS(xvhaddw_qu_du, LASX, gen_xxx, gen_helper_vhaddw_qu_du)
508 TRANS(xvhsubw_h_b, LASX, gen_xxx, gen_helper_vhsubw_h_b)
509 TRANS(xvhsubw_w_h, LASX, gen_xxx, gen_helper_vhsubw_w_h)
510 TRANS(xvhsubw_d_w, LASX, gen_xxx, gen_helper_vhsubw_d_w)
511 TRANS(xvhsubw_q_d, LASX, gen_xxx, gen_helper_vhsubw_q_d)
512 TRANS(xvhsubw_hu_bu, LASX, gen_xxx, gen_helper_vhsubw_hu_bu)
513 TRANS(xvhsubw_wu_hu, LASX, gen_xxx, gen_helper_vhsubw_wu_hu)
514 TRANS(xvhsubw_du_wu, LASX, gen_xxx, gen_helper_vhsubw_du_wu)
515 TRANS(xvhsubw_qu_du, LASX, gen_xxx, gen_helper_vhsubw_qu_du)
517 static void gen_vaddwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
521 int halfbits = 4 << vece;
523 t1 = tcg_temp_new_vec_matching(a);
524 t2 = tcg_temp_new_vec_matching(b);
526 /* Sign-extend the even elements from a */
527 tcg_gen_shli_vec(vece, t1, a, halfbits);
528 tcg_gen_sari_vec(vece, t1, t1, halfbits);
530 /* Sign-extend the even elements from b */
531 tcg_gen_shli_vec(vece, t2, b, halfbits);
532 tcg_gen_sari_vec(vece, t2, t2, halfbits);
534 tcg_gen_add_vec(vece, t, t1, t2);
537 static void gen_vaddwev_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
541 t1 = tcg_temp_new_i32();
542 t2 = tcg_temp_new_i32();
543 tcg_gen_ext16s_i32(t1, a);
544 tcg_gen_ext16s_i32(t2, b);
545 tcg_gen_add_i32(t, t1, t2);
548 static void gen_vaddwev_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
552 t1 = tcg_temp_new_i64();
553 t2 = tcg_temp_new_i64();
554 tcg_gen_ext32s_i64(t1, a);
555 tcg_gen_ext32s_i64(t2, b);
556 tcg_gen_add_i64(t, t1, t2);
559 static void do_vaddwev_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
560 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
562 static const TCGOpcode vecop_list[] = {
563 INDEX_op_shli_vec, INDEX_op_sari_vec, INDEX_op_add_vec, 0
565 static const GVecGen3 op[4] = {
567 .fniv = gen_vaddwev_s,
568 .fno = gen_helper_vaddwev_h_b,
569 .opt_opc = vecop_list,
573 .fni4 = gen_vaddwev_w_h,
574 .fniv = gen_vaddwev_s,
575 .fno = gen_helper_vaddwev_w_h,
576 .opt_opc = vecop_list,
580 .fni8 = gen_vaddwev_d_w,
581 .fniv = gen_vaddwev_s,
582 .fno = gen_helper_vaddwev_d_w,
583 .opt_opc = vecop_list,
587 .fno = gen_helper_vaddwev_q_d,
592 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
595 TRANS(vaddwev_h_b, LSX, gvec_vvv, MO_8, do_vaddwev_s)
596 TRANS(vaddwev_w_h, LSX, gvec_vvv, MO_16, do_vaddwev_s)
597 TRANS(vaddwev_d_w, LSX, gvec_vvv, MO_32, do_vaddwev_s)
598 TRANS(vaddwev_q_d, LSX, gvec_vvv, MO_64, do_vaddwev_s)
599 TRANS(xvaddwev_h_b, LASX, gvec_xxx, MO_8, do_vaddwev_s)
600 TRANS(xvaddwev_w_h, LASX, gvec_xxx, MO_16, do_vaddwev_s)
601 TRANS(xvaddwev_d_w, LASX, gvec_xxx, MO_32, do_vaddwev_s)
602 TRANS(xvaddwev_q_d, LASX, gvec_xxx, MO_64, do_vaddwev_s)
604 static void gen_vaddwod_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
608 t1 = tcg_temp_new_i32();
609 t2 = tcg_temp_new_i32();
610 tcg_gen_sari_i32(t1, a, 16);
611 tcg_gen_sari_i32(t2, b, 16);
612 tcg_gen_add_i32(t, t1, t2);
615 static void gen_vaddwod_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
619 t1 = tcg_temp_new_i64();
620 t2 = tcg_temp_new_i64();
621 tcg_gen_sari_i64(t1, a, 32);
622 tcg_gen_sari_i64(t2, b, 32);
623 tcg_gen_add_i64(t, t1, t2);
626 static void gen_vaddwod_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
630 int halfbits = 4 << vece;
632 t1 = tcg_temp_new_vec_matching(a);
633 t2 = tcg_temp_new_vec_matching(b);
635 /* Sign-extend the odd elements for vector */
636 tcg_gen_sari_vec(vece, t1, a, halfbits);
637 tcg_gen_sari_vec(vece, t2, b, halfbits);
639 tcg_gen_add_vec(vece, t, t1, t2);
642 static void do_vaddwod_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
643 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
645 static const TCGOpcode vecop_list[] = {
646 INDEX_op_sari_vec, INDEX_op_add_vec, 0
648 static const GVecGen3 op[4] = {
650 .fniv = gen_vaddwod_s,
651 .fno = gen_helper_vaddwod_h_b,
652 .opt_opc = vecop_list,
656 .fni4 = gen_vaddwod_w_h,
657 .fniv = gen_vaddwod_s,
658 .fno = gen_helper_vaddwod_w_h,
659 .opt_opc = vecop_list,
663 .fni8 = gen_vaddwod_d_w,
664 .fniv = gen_vaddwod_s,
665 .fno = gen_helper_vaddwod_d_w,
666 .opt_opc = vecop_list,
670 .fno = gen_helper_vaddwod_q_d,
675 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
678 TRANS(vaddwod_h_b, LSX, gvec_vvv, MO_8, do_vaddwod_s)
679 TRANS(vaddwod_w_h, LSX, gvec_vvv, MO_16, do_vaddwod_s)
680 TRANS(vaddwod_d_w, LSX, gvec_vvv, MO_32, do_vaddwod_s)
681 TRANS(vaddwod_q_d, LSX, gvec_vvv, MO_64, do_vaddwod_s)
682 TRANS(xvaddwod_h_b, LASX, gvec_xxx, MO_8, do_vaddwod_s)
683 TRANS(xvaddwod_w_h, LASX, gvec_xxx, MO_16, do_vaddwod_s)
684 TRANS(xvaddwod_d_w, LASX, gvec_xxx, MO_32, do_vaddwod_s)
685 TRANS(xvaddwod_q_d, LASX, gvec_xxx, MO_64, do_vaddwod_s)
688 static void gen_vsubwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
692 int halfbits = 4 << vece;
694 t1 = tcg_temp_new_vec_matching(a);
695 t2 = tcg_temp_new_vec_matching(b);
697 /* Sign-extend the even elements from a */
698 tcg_gen_shli_vec(vece, t1, a, halfbits);
699 tcg_gen_sari_vec(vece, t1, t1, halfbits);
701 /* Sign-extend the even elements from b */
702 tcg_gen_shli_vec(vece, t2, b, halfbits);
703 tcg_gen_sari_vec(vece, t2, t2, halfbits);
705 tcg_gen_sub_vec(vece, t, t1, t2);
708 static void gen_vsubwev_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
712 t1 = tcg_temp_new_i32();
713 t2 = tcg_temp_new_i32();
714 tcg_gen_ext16s_i32(t1, a);
715 tcg_gen_ext16s_i32(t2, b);
716 tcg_gen_sub_i32(t, t1, t2);
719 static void gen_vsubwev_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
723 t1 = tcg_temp_new_i64();
724 t2 = tcg_temp_new_i64();
725 tcg_gen_ext32s_i64(t1, a);
726 tcg_gen_ext32s_i64(t2, b);
727 tcg_gen_sub_i64(t, t1, t2);
730 static void do_vsubwev_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
731 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
733 static const TCGOpcode vecop_list[] = {
734 INDEX_op_shli_vec, INDEX_op_sari_vec, INDEX_op_sub_vec, 0
736 static const GVecGen3 op[4] = {
738 .fniv = gen_vsubwev_s,
739 .fno = gen_helper_vsubwev_h_b,
740 .opt_opc = vecop_list,
744 .fni4 = gen_vsubwev_w_h,
745 .fniv = gen_vsubwev_s,
746 .fno = gen_helper_vsubwev_w_h,
747 .opt_opc = vecop_list,
751 .fni8 = gen_vsubwev_d_w,
752 .fniv = gen_vsubwev_s,
753 .fno = gen_helper_vsubwev_d_w,
754 .opt_opc = vecop_list,
758 .fno = gen_helper_vsubwev_q_d,
763 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
766 TRANS(vsubwev_h_b, LSX, gvec_vvv, MO_8, do_vsubwev_s)
767 TRANS(vsubwev_w_h, LSX, gvec_vvv, MO_16, do_vsubwev_s)
768 TRANS(vsubwev_d_w, LSX, gvec_vvv, MO_32, do_vsubwev_s)
769 TRANS(vsubwev_q_d, LSX, gvec_vvv, MO_64, do_vsubwev_s)
770 TRANS(xvsubwev_h_b, LASX, gvec_xxx, MO_8, do_vsubwev_s)
771 TRANS(xvsubwev_w_h, LASX, gvec_xxx, MO_16, do_vsubwev_s)
772 TRANS(xvsubwev_d_w, LASX, gvec_xxx, MO_32, do_vsubwev_s)
773 TRANS(xvsubwev_q_d, LASX, gvec_xxx, MO_64, do_vsubwev_s)
775 static void gen_vsubwod_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
779 int halfbits = 4 << vece;
781 t1 = tcg_temp_new_vec_matching(a);
782 t2 = tcg_temp_new_vec_matching(b);
784 /* Sign-extend the odd elements for vector */
785 tcg_gen_sari_vec(vece, t1, a, halfbits);
786 tcg_gen_sari_vec(vece, t2, b, halfbits);
788 tcg_gen_sub_vec(vece, t, t1, t2);
791 static void gen_vsubwod_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
795 t1 = tcg_temp_new_i32();
796 t2 = tcg_temp_new_i32();
797 tcg_gen_sari_i32(t1, a, 16);
798 tcg_gen_sari_i32(t2, b, 16);
799 tcg_gen_sub_i32(t, t1, t2);
802 static void gen_vsubwod_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
806 t1 = tcg_temp_new_i64();
807 t2 = tcg_temp_new_i64();
808 tcg_gen_sari_i64(t1, a, 32);
809 tcg_gen_sari_i64(t2, b, 32);
810 tcg_gen_sub_i64(t, t1, t2);
813 static void do_vsubwod_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
814 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
816 static const TCGOpcode vecop_list[] = {
817 INDEX_op_sari_vec, INDEX_op_sub_vec, 0
819 static const GVecGen3 op[4] = {
821 .fniv = gen_vsubwod_s,
822 .fno = gen_helper_vsubwod_h_b,
823 .opt_opc = vecop_list,
827 .fni4 = gen_vsubwod_w_h,
828 .fniv = gen_vsubwod_s,
829 .fno = gen_helper_vsubwod_w_h,
830 .opt_opc = vecop_list,
834 .fni8 = gen_vsubwod_d_w,
835 .fniv = gen_vsubwod_s,
836 .fno = gen_helper_vsubwod_d_w,
837 .opt_opc = vecop_list,
841 .fno = gen_helper_vsubwod_q_d,
846 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
849 TRANS(vsubwod_h_b, LSX, gvec_vvv, MO_8, do_vsubwod_s)
850 TRANS(vsubwod_w_h, LSX, gvec_vvv, MO_16, do_vsubwod_s)
851 TRANS(vsubwod_d_w, LSX, gvec_vvv, MO_32, do_vsubwod_s)
852 TRANS(vsubwod_q_d, LSX, gvec_vvv, MO_64, do_vsubwod_s)
853 TRANS(xvsubwod_h_b, LASX, gvec_xxx, MO_8, do_vsubwod_s)
854 TRANS(xvsubwod_w_h, LASX, gvec_xxx, MO_16, do_vsubwod_s)
855 TRANS(xvsubwod_d_w, LASX, gvec_xxx, MO_32, do_vsubwod_s)
856 TRANS(xvsubwod_q_d, LASX, gvec_xxx, MO_64, do_vsubwod_s)
858 static void gen_vaddwev_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
862 t1 = tcg_temp_new_vec_matching(a);
863 t2 = tcg_temp_new_vec_matching(b);
864 t3 = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
865 tcg_gen_and_vec(vece, t1, a, t3);
866 tcg_gen_and_vec(vece, t2, b, t3);
867 tcg_gen_add_vec(vece, t, t1, t2);
870 static void gen_vaddwev_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
874 t1 = tcg_temp_new_i32();
875 t2 = tcg_temp_new_i32();
876 tcg_gen_ext16u_i32(t1, a);
877 tcg_gen_ext16u_i32(t2, b);
878 tcg_gen_add_i32(t, t1, t2);
881 static void gen_vaddwev_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
885 t1 = tcg_temp_new_i64();
886 t2 = tcg_temp_new_i64();
887 tcg_gen_ext32u_i64(t1, a);
888 tcg_gen_ext32u_i64(t2, b);
889 tcg_gen_add_i64(t, t1, t2);
892 static void do_vaddwev_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
893 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
895 static const TCGOpcode vecop_list[] = {
898 static const GVecGen3 op[4] = {
900 .fniv = gen_vaddwev_u,
901 .fno = gen_helper_vaddwev_h_bu,
902 .opt_opc = vecop_list,
906 .fni4 = gen_vaddwev_w_hu,
907 .fniv = gen_vaddwev_u,
908 .fno = gen_helper_vaddwev_w_hu,
909 .opt_opc = vecop_list,
913 .fni8 = gen_vaddwev_d_wu,
914 .fniv = gen_vaddwev_u,
915 .fno = gen_helper_vaddwev_d_wu,
916 .opt_opc = vecop_list,
920 .fno = gen_helper_vaddwev_q_du,
925 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
928 TRANS(vaddwev_h_bu, LSX, gvec_vvv, MO_8, do_vaddwev_u)
929 TRANS(vaddwev_w_hu, LSX, gvec_vvv, MO_16, do_vaddwev_u)
930 TRANS(vaddwev_d_wu, LSX, gvec_vvv, MO_32, do_vaddwev_u)
931 TRANS(vaddwev_q_du, LSX, gvec_vvv, MO_64, do_vaddwev_u)
932 TRANS(xvaddwev_h_bu, LASX, gvec_xxx, MO_8, do_vaddwev_u)
933 TRANS(xvaddwev_w_hu, LASX, gvec_xxx, MO_16, do_vaddwev_u)
934 TRANS(xvaddwev_d_wu, LASX, gvec_xxx, MO_32, do_vaddwev_u)
935 TRANS(xvaddwev_q_du, LASX, gvec_xxx, MO_64, do_vaddwev_u)
937 static void gen_vaddwod_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
941 int halfbits = 4 << vece;
943 t1 = tcg_temp_new_vec_matching(a);
944 t2 = tcg_temp_new_vec_matching(b);
946 /* Zero-extend the odd elements for vector */
947 tcg_gen_shri_vec(vece, t1, a, halfbits);
948 tcg_gen_shri_vec(vece, t2, b, halfbits);
950 tcg_gen_add_vec(vece, t, t1, t2);
953 static void gen_vaddwod_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
957 t1 = tcg_temp_new_i32();
958 t2 = tcg_temp_new_i32();
959 tcg_gen_shri_i32(t1, a, 16);
960 tcg_gen_shri_i32(t2, b, 16);
961 tcg_gen_add_i32(t, t1, t2);
964 static void gen_vaddwod_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
968 t1 = tcg_temp_new_i64();
969 t2 = tcg_temp_new_i64();
970 tcg_gen_shri_i64(t1, a, 32);
971 tcg_gen_shri_i64(t2, b, 32);
972 tcg_gen_add_i64(t, t1, t2);
975 static void do_vaddwod_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
976 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
978 static const TCGOpcode vecop_list[] = {
979 INDEX_op_shri_vec, INDEX_op_add_vec, 0
981 static const GVecGen3 op[4] = {
983 .fniv = gen_vaddwod_u,
984 .fno = gen_helper_vaddwod_h_bu,
985 .opt_opc = vecop_list,
989 .fni4 = gen_vaddwod_w_hu,
990 .fniv = gen_vaddwod_u,
991 .fno = gen_helper_vaddwod_w_hu,
992 .opt_opc = vecop_list,
996 .fni8 = gen_vaddwod_d_wu,
997 .fniv = gen_vaddwod_u,
998 .fno = gen_helper_vaddwod_d_wu,
999 .opt_opc = vecop_list,
1003 .fno = gen_helper_vaddwod_q_du,
1008 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1011 TRANS(vaddwod_h_bu, LSX, gvec_vvv, MO_8, do_vaddwod_u)
1012 TRANS(vaddwod_w_hu, LSX, gvec_vvv, MO_16, do_vaddwod_u)
1013 TRANS(vaddwod_d_wu, LSX, gvec_vvv, MO_32, do_vaddwod_u)
1014 TRANS(vaddwod_q_du, LSX, gvec_vvv, MO_64, do_vaddwod_u)
1015 TRANS(xvaddwod_h_bu, LASX, gvec_xxx, MO_8, do_vaddwod_u)
1016 TRANS(xvaddwod_w_hu, LASX, gvec_xxx, MO_16, do_vaddwod_u)
1017 TRANS(xvaddwod_d_wu, LASX, gvec_xxx, MO_32, do_vaddwod_u)
1018 TRANS(xvaddwod_q_du, LASX, gvec_xxx, MO_64, do_vaddwod_u)
1020 static void gen_vsubwev_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1022 TCGv_vec t1, t2, t3;
1024 t1 = tcg_temp_new_vec_matching(a);
1025 t2 = tcg_temp_new_vec_matching(b);
1026 t3 = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
1027 tcg_gen_and_vec(vece, t1, a, t3);
1028 tcg_gen_and_vec(vece, t2, b, t3);
1029 tcg_gen_sub_vec(vece, t, t1, t2);
1032 static void gen_vsubwev_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
1036 t1 = tcg_temp_new_i32();
1037 t2 = tcg_temp_new_i32();
1038 tcg_gen_ext16u_i32(t1, a);
1039 tcg_gen_ext16u_i32(t2, b);
1040 tcg_gen_sub_i32(t, t1, t2);
1043 static void gen_vsubwev_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
1047 t1 = tcg_temp_new_i64();
1048 t2 = tcg_temp_new_i64();
1049 tcg_gen_ext32u_i64(t1, a);
1050 tcg_gen_ext32u_i64(t2, b);
1051 tcg_gen_sub_i64(t, t1, t2);
1054 static void do_vsubwev_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1055 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1057 static const TCGOpcode vecop_list[] = {
1060 static const GVecGen3 op[4] = {
1062 .fniv = gen_vsubwev_u,
1063 .fno = gen_helper_vsubwev_h_bu,
1064 .opt_opc = vecop_list,
1068 .fni4 = gen_vsubwev_w_hu,
1069 .fniv = gen_vsubwev_u,
1070 .fno = gen_helper_vsubwev_w_hu,
1071 .opt_opc = vecop_list,
1075 .fni8 = gen_vsubwev_d_wu,
1076 .fniv = gen_vsubwev_u,
1077 .fno = gen_helper_vsubwev_d_wu,
1078 .opt_opc = vecop_list,
1082 .fno = gen_helper_vsubwev_q_du,
1087 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1090 TRANS(vsubwev_h_bu, LSX, gvec_vvv, MO_8, do_vsubwev_u)
1091 TRANS(vsubwev_w_hu, LSX, gvec_vvv, MO_16, do_vsubwev_u)
1092 TRANS(vsubwev_d_wu, LSX, gvec_vvv, MO_32, do_vsubwev_u)
1093 TRANS(vsubwev_q_du, LSX, gvec_vvv, MO_64, do_vsubwev_u)
1094 TRANS(xvsubwev_h_bu, LASX, gvec_xxx, MO_8, do_vsubwev_u)
1095 TRANS(xvsubwev_w_hu, LASX, gvec_xxx, MO_16, do_vsubwev_u)
1096 TRANS(xvsubwev_d_wu, LASX, gvec_xxx, MO_32, do_vsubwev_u)
1097 TRANS(xvsubwev_q_du, LASX, gvec_xxx, MO_64, do_vsubwev_u)
1099 static void gen_vsubwod_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1103 int halfbits = 4 << vece;
1105 t1 = tcg_temp_new_vec_matching(a);
1106 t2 = tcg_temp_new_vec_matching(b);
1108 /* Zero-extend the odd elements for vector */
1109 tcg_gen_shri_vec(vece, t1, a, halfbits);
1110 tcg_gen_shri_vec(vece, t2, b, halfbits);
1112 tcg_gen_sub_vec(vece, t, t1, t2);
1115 static void gen_vsubwod_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
1119 t1 = tcg_temp_new_i32();
1120 t2 = tcg_temp_new_i32();
1121 tcg_gen_shri_i32(t1, a, 16);
1122 tcg_gen_shri_i32(t2, b, 16);
1123 tcg_gen_sub_i32(t, t1, t2);
1126 static void gen_vsubwod_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
1130 t1 = tcg_temp_new_i64();
1131 t2 = tcg_temp_new_i64();
1132 tcg_gen_shri_i64(t1, a, 32);
1133 tcg_gen_shri_i64(t2, b, 32);
1134 tcg_gen_sub_i64(t, t1, t2);
1137 static void do_vsubwod_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1138 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1140 static const TCGOpcode vecop_list[] = {
1141 INDEX_op_shri_vec, INDEX_op_sub_vec, 0
1143 static const GVecGen3 op[4] = {
1145 .fniv = gen_vsubwod_u,
1146 .fno = gen_helper_vsubwod_h_bu,
1147 .opt_opc = vecop_list,
1151 .fni4 = gen_vsubwod_w_hu,
1152 .fniv = gen_vsubwod_u,
1153 .fno = gen_helper_vsubwod_w_hu,
1154 .opt_opc = vecop_list,
1158 .fni8 = gen_vsubwod_d_wu,
1159 .fniv = gen_vsubwod_u,
1160 .fno = gen_helper_vsubwod_d_wu,
1161 .opt_opc = vecop_list,
1165 .fno = gen_helper_vsubwod_q_du,
1170 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1173 TRANS(vsubwod_h_bu, LSX, gvec_vvv, MO_8, do_vsubwod_u)
1174 TRANS(vsubwod_w_hu, LSX, gvec_vvv, MO_16, do_vsubwod_u)
1175 TRANS(vsubwod_d_wu, LSX, gvec_vvv, MO_32, do_vsubwod_u)
1176 TRANS(vsubwod_q_du, LSX, gvec_vvv, MO_64, do_vsubwod_u)
1177 TRANS(xvsubwod_h_bu, LASX, gvec_xxx, MO_8, do_vsubwod_u)
1178 TRANS(xvsubwod_w_hu, LASX, gvec_xxx, MO_16, do_vsubwod_u)
1179 TRANS(xvsubwod_d_wu, LASX, gvec_xxx, MO_32, do_vsubwod_u)
1180 TRANS(xvsubwod_q_du, LASX, gvec_xxx, MO_64, do_vsubwod_u)
1182 static void gen_vaddwev_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1184 TCGv_vec t1, t2, t3;
1186 int halfbits = 4 << vece;
1188 t1 = tcg_temp_new_vec_matching(a);
1189 t2 = tcg_temp_new_vec_matching(b);
1190 t3 = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, halfbits));
1192 /* Zero-extend the even elements from a */
1193 tcg_gen_and_vec(vece, t1, a, t3);
1195 /* Sign-extend the even elements from b */
1196 tcg_gen_shli_vec(vece, t2, b, halfbits);
1197 tcg_gen_sari_vec(vece, t2, t2, halfbits);
1199 tcg_gen_add_vec(vece, t, t1, t2);
1202 static void gen_vaddwev_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
1206 t1 = tcg_temp_new_i32();
1207 t2 = tcg_temp_new_i32();
1208 tcg_gen_ext16u_i32(t1, a);
1209 tcg_gen_ext16s_i32(t2, b);
1210 tcg_gen_add_i32(t, t1, t2);
1213 static void gen_vaddwev_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
1217 t1 = tcg_temp_new_i64();
1218 t2 = tcg_temp_new_i64();
1219 tcg_gen_ext32u_i64(t1, a);
1220 tcg_gen_ext32s_i64(t2, b);
1221 tcg_gen_add_i64(t, t1, t2);
1224 static void do_vaddwev_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1225 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1227 static const TCGOpcode vecop_list[] = {
1228 INDEX_op_shli_vec, INDEX_op_sari_vec, INDEX_op_add_vec, 0
1230 static const GVecGen3 op[4] = {
1232 .fniv = gen_vaddwev_u_s,
1233 .fno = gen_helper_vaddwev_h_bu_b,
1234 .opt_opc = vecop_list,
1238 .fni4 = gen_vaddwev_w_hu_h,
1239 .fniv = gen_vaddwev_u_s,
1240 .fno = gen_helper_vaddwev_w_hu_h,
1241 .opt_opc = vecop_list,
1245 .fni8 = gen_vaddwev_d_wu_w,
1246 .fniv = gen_vaddwev_u_s,
1247 .fno = gen_helper_vaddwev_d_wu_w,
1248 .opt_opc = vecop_list,
1252 .fno = gen_helper_vaddwev_q_du_d,
1257 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1260 TRANS(vaddwev_h_bu_b, LSX, gvec_vvv, MO_8, do_vaddwev_u_s)
1261 TRANS(vaddwev_w_hu_h, LSX, gvec_vvv, MO_16, do_vaddwev_u_s)
1262 TRANS(vaddwev_d_wu_w, LSX, gvec_vvv, MO_32, do_vaddwev_u_s)
1263 TRANS(vaddwev_q_du_d, LSX, gvec_vvv, MO_64, do_vaddwev_u_s)
1264 TRANS(xvaddwev_h_bu_b, LASX, gvec_xxx, MO_8, do_vaddwev_u_s)
1265 TRANS(xvaddwev_w_hu_h, LASX, gvec_xxx, MO_16, do_vaddwev_u_s)
1266 TRANS(xvaddwev_d_wu_w, LASX, gvec_xxx, MO_32, do_vaddwev_u_s)
1267 TRANS(xvaddwev_q_du_d, LASX, gvec_xxx, MO_64, do_vaddwev_u_s)
1269 static void gen_vaddwod_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1273 int halfbits = 4 << vece;
1275 t1 = tcg_temp_new_vec_matching(a);
1276 t2 = tcg_temp_new_vec_matching(b);
1278 /* Zero-extend the odd elements from a */
1279 tcg_gen_shri_vec(vece, t1, a, halfbits);
1280 /* Sign-extend the odd elements from b */
1281 tcg_gen_sari_vec(vece, t2, b, halfbits);
1283 tcg_gen_add_vec(vece, t, t1, t2);
1286 static void gen_vaddwod_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
1290 t1 = tcg_temp_new_i32();
1291 t2 = tcg_temp_new_i32();
1292 tcg_gen_shri_i32(t1, a, 16);
1293 tcg_gen_sari_i32(t2, b, 16);
1294 tcg_gen_add_i32(t, t1, t2);
1297 static void gen_vaddwod_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
1301 t1 = tcg_temp_new_i64();
1302 t2 = tcg_temp_new_i64();
1303 tcg_gen_shri_i64(t1, a, 32);
1304 tcg_gen_sari_i64(t2, b, 32);
1305 tcg_gen_add_i64(t, t1, t2);
1308 static void do_vaddwod_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1309 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1311 static const TCGOpcode vecop_list[] = {
1312 INDEX_op_shri_vec, INDEX_op_sari_vec, INDEX_op_add_vec, 0
1314 static const GVecGen3 op[4] = {
1316 .fniv = gen_vaddwod_u_s,
1317 .fno = gen_helper_vaddwod_h_bu_b,
1318 .opt_opc = vecop_list,
1322 .fni4 = gen_vaddwod_w_hu_h,
1323 .fniv = gen_vaddwod_u_s,
1324 .fno = gen_helper_vaddwod_w_hu_h,
1325 .opt_opc = vecop_list,
1329 .fni8 = gen_vaddwod_d_wu_w,
1330 .fniv = gen_vaddwod_u_s,
1331 .fno = gen_helper_vaddwod_d_wu_w,
1332 .opt_opc = vecop_list,
1336 .fno = gen_helper_vaddwod_q_du_d,
1341 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1344 TRANS(vaddwod_h_bu_b, LSX, gvec_vvv, MO_8, do_vaddwod_u_s)
1345 TRANS(vaddwod_w_hu_h, LSX, gvec_vvv, MO_16, do_vaddwod_u_s)
1346 TRANS(vaddwod_d_wu_w, LSX, gvec_vvv, MO_32, do_vaddwod_u_s)
1347 TRANS(vaddwod_q_du_d, LSX, gvec_vvv, MO_64, do_vaddwod_u_s)
1348 TRANS(xvaddwod_h_bu_b, LSX, gvec_xxx, MO_8, do_vaddwod_u_s)
1349 TRANS(xvaddwod_w_hu_h, LSX, gvec_xxx, MO_16, do_vaddwod_u_s)
1350 TRANS(xvaddwod_d_wu_w, LSX, gvec_xxx, MO_32, do_vaddwod_u_s)
1351 TRANS(xvaddwod_q_du_d, LSX, gvec_xxx, MO_64, do_vaddwod_u_s)
1353 static void do_vavg(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b,
1354 void (*gen_shr_vec)(unsigned, TCGv_vec,
1356 void (*gen_round_vec)(unsigned, TCGv_vec,
1357 TCGv_vec, TCGv_vec))
1359 TCGv_vec tmp = tcg_temp_new_vec_matching(t);
1360 gen_round_vec(vece, tmp, a, b);
1361 tcg_gen_and_vec(vece, tmp, tmp, tcg_constant_vec_matching(t, vece, 1));
1362 gen_shr_vec(vece, a, a, 1);
1363 gen_shr_vec(vece, b, b, 1);
1364 tcg_gen_add_vec(vece, t, a, b);
1365 tcg_gen_add_vec(vece, t, t, tmp);
1368 static void gen_vavg_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1370 do_vavg(vece, t, a, b, tcg_gen_sari_vec, tcg_gen_and_vec);
1373 static void gen_vavg_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1375 do_vavg(vece, t, a, b, tcg_gen_shri_vec, tcg_gen_and_vec);
1378 static void gen_vavgr_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1380 do_vavg(vece, t, a, b, tcg_gen_sari_vec, tcg_gen_or_vec);
1383 static void gen_vavgr_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1385 do_vavg(vece, t, a, b, tcg_gen_shri_vec, tcg_gen_or_vec);
1388 static void do_vavg_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1389 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1391 static const TCGOpcode vecop_list[] = {
1392 INDEX_op_sari_vec, INDEX_op_add_vec, 0
1394 static const GVecGen3 op[4] = {
1397 .fno = gen_helper_vavg_b,
1398 .opt_opc = vecop_list,
1403 .fno = gen_helper_vavg_h,
1404 .opt_opc = vecop_list,
1409 .fno = gen_helper_vavg_w,
1410 .opt_opc = vecop_list,
1415 .fno = gen_helper_vavg_d,
1416 .opt_opc = vecop_list,
1421 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1424 static void do_vavg_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1425 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1427 static const TCGOpcode vecop_list[] = {
1428 INDEX_op_shri_vec, INDEX_op_add_vec, 0
1430 static const GVecGen3 op[4] = {
1433 .fno = gen_helper_vavg_bu,
1434 .opt_opc = vecop_list,
1439 .fno = gen_helper_vavg_hu,
1440 .opt_opc = vecop_list,
1445 .fno = gen_helper_vavg_wu,
1446 .opt_opc = vecop_list,
1451 .fno = gen_helper_vavg_du,
1452 .opt_opc = vecop_list,
1457 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1460 TRANS(vavg_b, LSX, gvec_vvv, MO_8, do_vavg_s)
1461 TRANS(vavg_h, LSX, gvec_vvv, MO_16, do_vavg_s)
1462 TRANS(vavg_w, LSX, gvec_vvv, MO_32, do_vavg_s)
1463 TRANS(vavg_d, LSX, gvec_vvv, MO_64, do_vavg_s)
1464 TRANS(vavg_bu, LSX, gvec_vvv, MO_8, do_vavg_u)
1465 TRANS(vavg_hu, LSX, gvec_vvv, MO_16, do_vavg_u)
1466 TRANS(vavg_wu, LSX, gvec_vvv, MO_32, do_vavg_u)
1467 TRANS(vavg_du, LSX, gvec_vvv, MO_64, do_vavg_u)
1468 TRANS(xvavg_b, LASX, gvec_xxx, MO_8, do_vavg_s)
1469 TRANS(xvavg_h, LASX, gvec_xxx, MO_16, do_vavg_s)
1470 TRANS(xvavg_w, LASX, gvec_xxx, MO_32, do_vavg_s)
1471 TRANS(xvavg_d, LASX, gvec_xxx, MO_64, do_vavg_s)
1472 TRANS(xvavg_bu, LASX, gvec_xxx, MO_8, do_vavg_u)
1473 TRANS(xvavg_hu, LASX, gvec_xxx, MO_16, do_vavg_u)
1474 TRANS(xvavg_wu, LASX, gvec_xxx, MO_32, do_vavg_u)
1475 TRANS(xvavg_du, LASX, gvec_xxx, MO_64, do_vavg_u)
1477 static void do_vavgr_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1478 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1480 static const TCGOpcode vecop_list[] = {
1481 INDEX_op_sari_vec, INDEX_op_add_vec, 0
1483 static const GVecGen3 op[4] = {
1485 .fniv = gen_vavgr_s,
1486 .fno = gen_helper_vavgr_b,
1487 .opt_opc = vecop_list,
1491 .fniv = gen_vavgr_s,
1492 .fno = gen_helper_vavgr_h,
1493 .opt_opc = vecop_list,
1497 .fniv = gen_vavgr_s,
1498 .fno = gen_helper_vavgr_w,
1499 .opt_opc = vecop_list,
1503 .fniv = gen_vavgr_s,
1504 .fno = gen_helper_vavgr_d,
1505 .opt_opc = vecop_list,
1510 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1513 static void do_vavgr_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1514 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1516 static const TCGOpcode vecop_list[] = {
1517 INDEX_op_shri_vec, INDEX_op_add_vec, 0
1519 static const GVecGen3 op[4] = {
1521 .fniv = gen_vavgr_u,
1522 .fno = gen_helper_vavgr_bu,
1523 .opt_opc = vecop_list,
1527 .fniv = gen_vavgr_u,
1528 .fno = gen_helper_vavgr_hu,
1529 .opt_opc = vecop_list,
1533 .fniv = gen_vavgr_u,
1534 .fno = gen_helper_vavgr_wu,
1535 .opt_opc = vecop_list,
1539 .fniv = gen_vavgr_u,
1540 .fno = gen_helper_vavgr_du,
1541 .opt_opc = vecop_list,
1546 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1549 TRANS(vavgr_b, LSX, gvec_vvv, MO_8, do_vavgr_s)
1550 TRANS(vavgr_h, LSX, gvec_vvv, MO_16, do_vavgr_s)
1551 TRANS(vavgr_w, LSX, gvec_vvv, MO_32, do_vavgr_s)
1552 TRANS(vavgr_d, LSX, gvec_vvv, MO_64, do_vavgr_s)
1553 TRANS(vavgr_bu, LSX, gvec_vvv, MO_8, do_vavgr_u)
1554 TRANS(vavgr_hu, LSX, gvec_vvv, MO_16, do_vavgr_u)
1555 TRANS(vavgr_wu, LSX, gvec_vvv, MO_32, do_vavgr_u)
1556 TRANS(vavgr_du, LSX, gvec_vvv, MO_64, do_vavgr_u)
1557 TRANS(xvavgr_b, LASX, gvec_xxx, MO_8, do_vavgr_s)
1558 TRANS(xvavgr_h, LASX, gvec_xxx, MO_16, do_vavgr_s)
1559 TRANS(xvavgr_w, LASX, gvec_xxx, MO_32, do_vavgr_s)
1560 TRANS(xvavgr_d, LASX, gvec_xxx, MO_64, do_vavgr_s)
1561 TRANS(xvavgr_bu, LASX, gvec_xxx, MO_8, do_vavgr_u)
1562 TRANS(xvavgr_hu, LASX, gvec_xxx, MO_16, do_vavgr_u)
1563 TRANS(xvavgr_wu, LASX, gvec_xxx, MO_32, do_vavgr_u)
1564 TRANS(xvavgr_du, LASX, gvec_xxx, MO_64, do_vavgr_u)
1566 static void gen_vabsd_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1568 tcg_gen_smax_vec(vece, t, a, b);
1569 tcg_gen_smin_vec(vece, a, a, b);
1570 tcg_gen_sub_vec(vece, t, t, a);
1573 static void do_vabsd_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1574 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1576 static const TCGOpcode vecop_list[] = {
1577 INDEX_op_smax_vec, INDEX_op_smin_vec, INDEX_op_sub_vec, 0
1579 static const GVecGen3 op[4] = {
1581 .fniv = gen_vabsd_s,
1582 .fno = gen_helper_vabsd_b,
1583 .opt_opc = vecop_list,
1587 .fniv = gen_vabsd_s,
1588 .fno = gen_helper_vabsd_h,
1589 .opt_opc = vecop_list,
1593 .fniv = gen_vabsd_s,
1594 .fno = gen_helper_vabsd_w,
1595 .opt_opc = vecop_list,
1599 .fniv = gen_vabsd_s,
1600 .fno = gen_helper_vabsd_d,
1601 .opt_opc = vecop_list,
1606 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1609 static void gen_vabsd_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1611 tcg_gen_umax_vec(vece, t, a, b);
1612 tcg_gen_umin_vec(vece, a, a, b);
1613 tcg_gen_sub_vec(vece, t, t, a);
1616 static void do_vabsd_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1617 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1619 static const TCGOpcode vecop_list[] = {
1620 INDEX_op_umax_vec, INDEX_op_umin_vec, INDEX_op_sub_vec, 0
1622 static const GVecGen3 op[4] = {
1624 .fniv = gen_vabsd_u,
1625 .fno = gen_helper_vabsd_bu,
1626 .opt_opc = vecop_list,
1630 .fniv = gen_vabsd_u,
1631 .fno = gen_helper_vabsd_hu,
1632 .opt_opc = vecop_list,
1636 .fniv = gen_vabsd_u,
1637 .fno = gen_helper_vabsd_wu,
1638 .opt_opc = vecop_list,
1642 .fniv = gen_vabsd_u,
1643 .fno = gen_helper_vabsd_du,
1644 .opt_opc = vecop_list,
1649 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1652 TRANS(vabsd_b, LSX, gvec_vvv, MO_8, do_vabsd_s)
1653 TRANS(vabsd_h, LSX, gvec_vvv, MO_16, do_vabsd_s)
1654 TRANS(vabsd_w, LSX, gvec_vvv, MO_32, do_vabsd_s)
1655 TRANS(vabsd_d, LSX, gvec_vvv, MO_64, do_vabsd_s)
1656 TRANS(vabsd_bu, LSX, gvec_vvv, MO_8, do_vabsd_u)
1657 TRANS(vabsd_hu, LSX, gvec_vvv, MO_16, do_vabsd_u)
1658 TRANS(vabsd_wu, LSX, gvec_vvv, MO_32, do_vabsd_u)
1659 TRANS(vabsd_du, LSX, gvec_vvv, MO_64, do_vabsd_u)
1660 TRANS(xvabsd_b, LASX, gvec_xxx, MO_8, do_vabsd_s)
1661 TRANS(xvabsd_h, LASX, gvec_xxx, MO_16, do_vabsd_s)
1662 TRANS(xvabsd_w, LASX, gvec_xxx, MO_32, do_vabsd_s)
1663 TRANS(xvabsd_d, LASX, gvec_xxx, MO_64, do_vabsd_s)
1664 TRANS(xvabsd_bu, LASX, gvec_xxx, MO_8, do_vabsd_u)
1665 TRANS(xvabsd_hu, LASX, gvec_xxx, MO_16, do_vabsd_u)
1666 TRANS(xvabsd_wu, LASX, gvec_xxx, MO_32, do_vabsd_u)
1667 TRANS(xvabsd_du, LASX, gvec_xxx, MO_64, do_vabsd_u)
1669 static void gen_vadda(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
1673 t1 = tcg_temp_new_vec_matching(a);
1674 t2 = tcg_temp_new_vec_matching(b);
1676 tcg_gen_abs_vec(vece, t1, a);
1677 tcg_gen_abs_vec(vece, t2, b);
1678 tcg_gen_add_vec(vece, t, t1, t2);
1681 static void do_vadda(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1682 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1684 static const TCGOpcode vecop_list[] = {
1685 INDEX_op_abs_vec, INDEX_op_add_vec, 0
1687 static const GVecGen3 op[4] = {
1690 .fno = gen_helper_vadda_b,
1691 .opt_opc = vecop_list,
1696 .fno = gen_helper_vadda_h,
1697 .opt_opc = vecop_list,
1702 .fno = gen_helper_vadda_w,
1703 .opt_opc = vecop_list,
1708 .fno = gen_helper_vadda_d,
1709 .opt_opc = vecop_list,
1714 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
1717 TRANS(vadda_b, LSX, gvec_vvv, MO_8, do_vadda)
1718 TRANS(vadda_h, LSX, gvec_vvv, MO_16, do_vadda)
1719 TRANS(vadda_w, LSX, gvec_vvv, MO_32, do_vadda)
1720 TRANS(vadda_d, LSX, gvec_vvv, MO_64, do_vadda)
1721 TRANS(xvadda_b, LASX, gvec_xxx, MO_8, do_vadda)
1722 TRANS(xvadda_h, LASX, gvec_xxx, MO_16, do_vadda)
1723 TRANS(xvadda_w, LASX, gvec_xxx, MO_32, do_vadda)
1724 TRANS(xvadda_d, LASX, gvec_xxx, MO_64, do_vadda)
1726 TRANS(vmax_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_smax)
1727 TRANS(vmax_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_smax)
1728 TRANS(vmax_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_smax)
1729 TRANS(vmax_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_smax)
1730 TRANS(vmax_bu, LSX, gvec_vvv, MO_8, tcg_gen_gvec_umax)
1731 TRANS(vmax_hu, LSX, gvec_vvv, MO_16, tcg_gen_gvec_umax)
1732 TRANS(vmax_wu, LSX, gvec_vvv, MO_32, tcg_gen_gvec_umax)
1733 TRANS(vmax_du, LSX, gvec_vvv, MO_64, tcg_gen_gvec_umax)
1734 TRANS(xvmax_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_smax)
1735 TRANS(xvmax_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_smax)
1736 TRANS(xvmax_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_smax)
1737 TRANS(xvmax_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_smax)
1738 TRANS(xvmax_bu, LASX, gvec_xxx, MO_8, tcg_gen_gvec_umax)
1739 TRANS(xvmax_hu, LASX, gvec_xxx, MO_16, tcg_gen_gvec_umax)
1740 TRANS(xvmax_wu, LASX, gvec_xxx, MO_32, tcg_gen_gvec_umax)
1741 TRANS(xvmax_du, LASX, gvec_xxx, MO_64, tcg_gen_gvec_umax)
1743 TRANS(vmin_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_smin)
1744 TRANS(vmin_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_smin)
1745 TRANS(vmin_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_smin)
1746 TRANS(vmin_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_smin)
1747 TRANS(vmin_bu, LSX, gvec_vvv, MO_8, tcg_gen_gvec_umin)
1748 TRANS(vmin_hu, LSX, gvec_vvv, MO_16, tcg_gen_gvec_umin)
1749 TRANS(vmin_wu, LSX, gvec_vvv, MO_32, tcg_gen_gvec_umin)
1750 TRANS(vmin_du, LSX, gvec_vvv, MO_64, tcg_gen_gvec_umin)
1751 TRANS(xvmin_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_smin)
1752 TRANS(xvmin_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_smin)
1753 TRANS(xvmin_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_smin)
1754 TRANS(xvmin_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_smin)
1755 TRANS(xvmin_bu, LASX, gvec_xxx, MO_8, tcg_gen_gvec_umin)
1756 TRANS(xvmin_hu, LASX, gvec_xxx, MO_16, tcg_gen_gvec_umin)
1757 TRANS(xvmin_wu, LASX, gvec_xxx, MO_32, tcg_gen_gvec_umin)
1758 TRANS(xvmin_du, LASX, gvec_xxx, MO_64, tcg_gen_gvec_umin)
1760 static void gen_vmini_s(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
1762 tcg_gen_smin_vec(vece, t, a, tcg_constant_vec_matching(t, vece, imm));
1765 static void gen_vmini_u(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
1767 tcg_gen_umin_vec(vece, t, a, tcg_constant_vec_matching(t, vece, imm));
1770 static void gen_vmaxi_s(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
1772 tcg_gen_smax_vec(vece, t, a, tcg_constant_vec_matching(t, vece, imm));
1775 static void gen_vmaxi_u(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
1777 tcg_gen_umax_vec(vece, t, a, tcg_constant_vec_matching(t, vece, imm));
1780 static void do_vmini_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1781 int64_t imm, uint32_t oprsz, uint32_t maxsz)
1783 static const TCGOpcode vecop_list[] = {
1784 INDEX_op_smin_vec, 0
1786 static const GVecGen2i op[4] = {
1788 .fniv = gen_vmini_s,
1789 .fnoi = gen_helper_vmini_b,
1790 .opt_opc = vecop_list,
1794 .fniv = gen_vmini_s,
1795 .fnoi = gen_helper_vmini_h,
1796 .opt_opc = vecop_list,
1800 .fniv = gen_vmini_s,
1801 .fnoi = gen_helper_vmini_w,
1802 .opt_opc = vecop_list,
1806 .fniv = gen_vmini_s,
1807 .fnoi = gen_helper_vmini_d,
1808 .opt_opc = vecop_list,
1813 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
1816 static void do_vmini_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1817 int64_t imm, uint32_t oprsz, uint32_t maxsz)
1819 static const TCGOpcode vecop_list[] = {
1820 INDEX_op_umin_vec, 0
1822 static const GVecGen2i op[4] = {
1824 .fniv = gen_vmini_u,
1825 .fnoi = gen_helper_vmini_bu,
1826 .opt_opc = vecop_list,
1830 .fniv = gen_vmini_u,
1831 .fnoi = gen_helper_vmini_hu,
1832 .opt_opc = vecop_list,
1836 .fniv = gen_vmini_u,
1837 .fnoi = gen_helper_vmini_wu,
1838 .opt_opc = vecop_list,
1842 .fniv = gen_vmini_u,
1843 .fnoi = gen_helper_vmini_du,
1844 .opt_opc = vecop_list,
1849 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
1852 TRANS(vmini_b, LSX, gvec_vv_i, MO_8, do_vmini_s)
1853 TRANS(vmini_h, LSX, gvec_vv_i, MO_16, do_vmini_s)
1854 TRANS(vmini_w, LSX, gvec_vv_i, MO_32, do_vmini_s)
1855 TRANS(vmini_d, LSX, gvec_vv_i, MO_64, do_vmini_s)
1856 TRANS(vmini_bu, LSX, gvec_vv_i, MO_8, do_vmini_u)
1857 TRANS(vmini_hu, LSX, gvec_vv_i, MO_16, do_vmini_u)
1858 TRANS(vmini_wu, LSX, gvec_vv_i, MO_32, do_vmini_u)
1859 TRANS(vmini_du, LSX, gvec_vv_i, MO_64, do_vmini_u)
1860 TRANS(xvmini_b, LASX, gvec_xx_i, MO_8, do_vmini_s)
1861 TRANS(xvmini_h, LASX, gvec_xx_i, MO_16, do_vmini_s)
1862 TRANS(xvmini_w, LASX, gvec_xx_i, MO_32, do_vmini_s)
1863 TRANS(xvmini_d, LASX, gvec_xx_i, MO_64, do_vmini_s)
1864 TRANS(xvmini_bu, LASX, gvec_xx_i, MO_8, do_vmini_u)
1865 TRANS(xvmini_hu, LASX, gvec_xx_i, MO_16, do_vmini_u)
1866 TRANS(xvmini_wu, LASX, gvec_xx_i, MO_32, do_vmini_u)
1867 TRANS(xvmini_du, LASX, gvec_xx_i, MO_64, do_vmini_u)
1869 static void do_vmaxi_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1870 int64_t imm, uint32_t oprsz, uint32_t maxsz)
1872 static const TCGOpcode vecop_list[] = {
1873 INDEX_op_smax_vec, 0
1875 static const GVecGen2i op[4] = {
1877 .fniv = gen_vmaxi_s,
1878 .fnoi = gen_helper_vmaxi_b,
1879 .opt_opc = vecop_list,
1883 .fniv = gen_vmaxi_s,
1884 .fnoi = gen_helper_vmaxi_h,
1885 .opt_opc = vecop_list,
1889 .fniv = gen_vmaxi_s,
1890 .fnoi = gen_helper_vmaxi_w,
1891 .opt_opc = vecop_list,
1895 .fniv = gen_vmaxi_s,
1896 .fnoi = gen_helper_vmaxi_d,
1897 .opt_opc = vecop_list,
1902 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
1905 static void do_vmaxi_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1906 int64_t imm, uint32_t oprsz, uint32_t maxsz)
1908 static const TCGOpcode vecop_list[] = {
1909 INDEX_op_umax_vec, 0
1911 static const GVecGen2i op[4] = {
1913 .fniv = gen_vmaxi_u,
1914 .fnoi = gen_helper_vmaxi_bu,
1915 .opt_opc = vecop_list,
1919 .fniv = gen_vmaxi_u,
1920 .fnoi = gen_helper_vmaxi_hu,
1921 .opt_opc = vecop_list,
1925 .fniv = gen_vmaxi_u,
1926 .fnoi = gen_helper_vmaxi_wu,
1927 .opt_opc = vecop_list,
1931 .fniv = gen_vmaxi_u,
1932 .fnoi = gen_helper_vmaxi_du,
1933 .opt_opc = vecop_list,
1938 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
1941 TRANS(vmaxi_b, LSX, gvec_vv_i, MO_8, do_vmaxi_s)
1942 TRANS(vmaxi_h, LSX, gvec_vv_i, MO_16, do_vmaxi_s)
1943 TRANS(vmaxi_w, LSX, gvec_vv_i, MO_32, do_vmaxi_s)
1944 TRANS(vmaxi_d, LSX, gvec_vv_i, MO_64, do_vmaxi_s)
1945 TRANS(vmaxi_bu, LSX, gvec_vv_i, MO_8, do_vmaxi_u)
1946 TRANS(vmaxi_hu, LSX, gvec_vv_i, MO_16, do_vmaxi_u)
1947 TRANS(vmaxi_wu, LSX, gvec_vv_i, MO_32, do_vmaxi_u)
1948 TRANS(vmaxi_du, LSX, gvec_vv_i, MO_64, do_vmaxi_u)
1949 TRANS(xvmaxi_b, LASX, gvec_xx_i, MO_8, do_vmaxi_s)
1950 TRANS(xvmaxi_h, LASX, gvec_xx_i, MO_16, do_vmaxi_s)
1951 TRANS(xvmaxi_w, LASX, gvec_xx_i, MO_32, do_vmaxi_s)
1952 TRANS(xvmaxi_d, LASX, gvec_xx_i, MO_64, do_vmaxi_s)
1953 TRANS(xvmaxi_bu, LASX, gvec_xx_i, MO_8, do_vmaxi_u)
1954 TRANS(xvmaxi_hu, LASX, gvec_xx_i, MO_16, do_vmaxi_u)
1955 TRANS(xvmaxi_wu, LASX, gvec_xx_i, MO_32, do_vmaxi_u)
1956 TRANS(xvmaxi_du, LASX, gvec_xx_i, MO_64, do_vmaxi_u)
1958 TRANS(vmul_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_mul)
1959 TRANS(vmul_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_mul)
1960 TRANS(vmul_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_mul)
1961 TRANS(vmul_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_mul)
1962 TRANS(xvmul_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_mul)
1963 TRANS(xvmul_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_mul)
1964 TRANS(xvmul_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_mul)
1965 TRANS(xvmul_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_mul)
1967 static void gen_vmuh_w(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
1969 TCGv_i32 discard = tcg_temp_new_i32();
1970 tcg_gen_muls2_i32(discard, t, a, b);
1973 static void gen_vmuh_d(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
1975 TCGv_i64 discard = tcg_temp_new_i64();
1976 tcg_gen_muls2_i64(discard, t, a, b);
1979 static void do_vmuh_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
1980 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
1982 static const GVecGen3 op[4] = {
1984 .fno = gen_helper_vmuh_b,
1988 .fno = gen_helper_vmuh_h,
1993 .fno = gen_helper_vmuh_w,
1998 .fno = gen_helper_vmuh_d,
2003 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2006 TRANS(vmuh_b, LSX, gvec_vvv, MO_8, do_vmuh_s)
2007 TRANS(vmuh_h, LSX, gvec_vvv, MO_16, do_vmuh_s)
2008 TRANS(vmuh_w, LSX, gvec_vvv, MO_32, do_vmuh_s)
2009 TRANS(vmuh_d, LSX, gvec_vvv, MO_64, do_vmuh_s)
2010 TRANS(xvmuh_b, LASX, gvec_xxx, MO_8, do_vmuh_s)
2011 TRANS(xvmuh_h, LASX, gvec_xxx, MO_16, do_vmuh_s)
2012 TRANS(xvmuh_w, LASX, gvec_xxx, MO_32, do_vmuh_s)
2013 TRANS(xvmuh_d, LASX, gvec_xxx, MO_64, do_vmuh_s)
2015 static void gen_vmuh_wu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2017 TCGv_i32 discard = tcg_temp_new_i32();
2018 tcg_gen_mulu2_i32(discard, t, a, b);
2021 static void gen_vmuh_du(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2023 TCGv_i64 discard = tcg_temp_new_i64();
2024 tcg_gen_mulu2_i64(discard, t, a, b);
2027 static void do_vmuh_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2028 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2030 static const GVecGen3 op[4] = {
2032 .fno = gen_helper_vmuh_bu,
2036 .fno = gen_helper_vmuh_hu,
2040 .fni4 = gen_vmuh_wu,
2041 .fno = gen_helper_vmuh_wu,
2045 .fni8 = gen_vmuh_du,
2046 .fno = gen_helper_vmuh_du,
2051 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2054 TRANS(vmuh_bu, LSX, gvec_vvv, MO_8, do_vmuh_u)
2055 TRANS(vmuh_hu, LSX, gvec_vvv, MO_16, do_vmuh_u)
2056 TRANS(vmuh_wu, LSX, gvec_vvv, MO_32, do_vmuh_u)
2057 TRANS(vmuh_du, LSX, gvec_vvv, MO_64, do_vmuh_u)
2058 TRANS(xvmuh_bu, LASX, gvec_xxx, MO_8, do_vmuh_u)
2059 TRANS(xvmuh_hu, LASX, gvec_xxx, MO_16, do_vmuh_u)
2060 TRANS(xvmuh_wu, LASX, gvec_xxx, MO_32, do_vmuh_u)
2061 TRANS(xvmuh_du, LASX, gvec_xxx, MO_64, do_vmuh_u)
2063 static void gen_vmulwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2066 int halfbits = 4 << vece;
2068 t1 = tcg_temp_new_vec_matching(a);
2069 t2 = tcg_temp_new_vec_matching(b);
2070 tcg_gen_shli_vec(vece, t1, a, halfbits);
2071 tcg_gen_sari_vec(vece, t1, t1, halfbits);
2072 tcg_gen_shli_vec(vece, t2, b, halfbits);
2073 tcg_gen_sari_vec(vece, t2, t2, halfbits);
2074 tcg_gen_mul_vec(vece, t, t1, t2);
2077 static void gen_vmulwev_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2081 t1 = tcg_temp_new_i32();
2082 t2 = tcg_temp_new_i32();
2083 tcg_gen_ext16s_i32(t1, a);
2084 tcg_gen_ext16s_i32(t2, b);
2085 tcg_gen_mul_i32(t, t1, t2);
2088 static void gen_vmulwev_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2092 t1 = tcg_temp_new_i64();
2093 t2 = tcg_temp_new_i64();
2094 tcg_gen_ext32s_i64(t1, a);
2095 tcg_gen_ext32s_i64(t2, b);
2096 tcg_gen_mul_i64(t, t1, t2);
2099 static void do_vmulwev_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2100 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2102 static const TCGOpcode vecop_list[] = {
2103 INDEX_op_shli_vec, INDEX_op_sari_vec, INDEX_op_mul_vec, 0
2105 static const GVecGen3 op[3] = {
2107 .fniv = gen_vmulwev_s,
2108 .fno = gen_helper_vmulwev_h_b,
2109 .opt_opc = vecop_list,
2113 .fni4 = gen_vmulwev_w_h,
2114 .fniv = gen_vmulwev_s,
2115 .fno = gen_helper_vmulwev_w_h,
2116 .opt_opc = vecop_list,
2120 .fni8 = gen_vmulwev_d_w,
2121 .fniv = gen_vmulwev_s,
2122 .fno = gen_helper_vmulwev_d_w,
2123 .opt_opc = vecop_list,
2128 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2131 TRANS(vmulwev_h_b, LSX, gvec_vvv, MO_8, do_vmulwev_s)
2132 TRANS(vmulwev_w_h, LSX, gvec_vvv, MO_16, do_vmulwev_s)
2133 TRANS(vmulwev_d_w, LSX, gvec_vvv, MO_32, do_vmulwev_s)
2134 TRANS(xvmulwev_h_b, LASX, gvec_xxx, MO_8, do_vmulwev_s)
2135 TRANS(xvmulwev_w_h, LASX, gvec_xxx, MO_16, do_vmulwev_s)
2136 TRANS(xvmulwev_d_w, LASX, gvec_xxx, MO_32, do_vmulwev_s)
2138 static void tcg_gen_mulus2_i64(TCGv_i64 rl, TCGv_i64 rh,
2139 TCGv_i64 arg1, TCGv_i64 arg2)
2141 tcg_gen_mulsu2_i64(rl, rh, arg2, arg1);
2144 static bool gen_vmul_q_vl(DisasContext *ctx,
2145 arg_vvv *a, uint32_t oprsz, int idx1, int idx2,
2146 void (*func)(TCGv_i64, TCGv_i64,
2147 TCGv_i64, TCGv_i64))
2149 TCGv_i64 rh, rl, arg1, arg2;
2152 if (!check_vec(ctx, oprsz)) {
2156 rh = tcg_temp_new_i64();
2157 rl = tcg_temp_new_i64();
2158 arg1 = tcg_temp_new_i64();
2159 arg2 = tcg_temp_new_i64();
2161 for (i = 0; i < oprsz / 16; i++) {
2162 get_vreg64(arg1, a->vj, 2 * i + idx1);
2163 get_vreg64(arg2, a->vk, 2 * i + idx2);
2165 func(rl, rh, arg1, arg2);
2167 set_vreg64(rh, a->vd, 2 * i + 1);
2168 set_vreg64(rl, a->vd, 2 * i);
2174 static bool gen_vmul_q(DisasContext *ctx, arg_vvv *a, int idx1, int idx2,
2175 void (*func)(TCGv_i64, TCGv_i64,
2176 TCGv_i64, TCGv_i64))
2178 return gen_vmul_q_vl(ctx, a, 16, idx1, idx2, func);
2181 static bool gen_xvmul_q(DisasContext *ctx, arg_vvv *a, int idx1, int idx2,
2182 void (*func)(TCGv_i64, TCGv_i64,
2183 TCGv_i64, TCGv_i64))
2185 return gen_vmul_q_vl(ctx, a, 32, idx1, idx2, func);
2188 TRANS(vmulwev_q_d, LSX, gen_vmul_q, 0, 0, tcg_gen_muls2_i64)
2189 TRANS(vmulwod_q_d, LSX, gen_vmul_q, 1, 1, tcg_gen_muls2_i64)
2190 TRANS(vmulwev_q_du, LSX, gen_vmul_q, 0, 0, tcg_gen_mulu2_i64)
2191 TRANS(vmulwod_q_du, LSX, gen_vmul_q, 1, 1, tcg_gen_mulu2_i64)
2192 TRANS(vmulwev_q_du_d, LSX, gen_vmul_q, 0, 0, tcg_gen_mulus2_i64)
2193 TRANS(vmulwod_q_du_d, LSX, gen_vmul_q, 1, 1, tcg_gen_mulus2_i64)
2194 TRANS(xvmulwev_q_d, LASX, gen_xvmul_q, 0, 0, tcg_gen_muls2_i64)
2195 TRANS(xvmulwod_q_d, LASX, gen_xvmul_q, 1, 1, tcg_gen_muls2_i64)
2196 TRANS(xvmulwev_q_du, LASX, gen_xvmul_q, 0, 0, tcg_gen_mulu2_i64)
2197 TRANS(xvmulwod_q_du, LASX, gen_xvmul_q, 1, 1, tcg_gen_mulu2_i64)
2198 TRANS(xvmulwev_q_du_d, LASX, gen_xvmul_q, 0, 0, tcg_gen_mulus2_i64)
2199 TRANS(xvmulwod_q_du_d, LASX, gen_xvmul_q, 1, 1, tcg_gen_mulus2_i64)
2201 static void gen_vmulwod_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2204 int halfbits = 4 << vece;
2206 t1 = tcg_temp_new_vec_matching(a);
2207 t2 = tcg_temp_new_vec_matching(b);
2208 tcg_gen_sari_vec(vece, t1, a, halfbits);
2209 tcg_gen_sari_vec(vece, t2, b, halfbits);
2210 tcg_gen_mul_vec(vece, t, t1, t2);
2213 static void gen_vmulwod_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2217 t1 = tcg_temp_new_i32();
2218 t2 = tcg_temp_new_i32();
2219 tcg_gen_sari_i32(t1, a, 16);
2220 tcg_gen_sari_i32(t2, b, 16);
2221 tcg_gen_mul_i32(t, t1, t2);
2224 static void gen_vmulwod_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2228 t1 = tcg_temp_new_i64();
2229 t2 = tcg_temp_new_i64();
2230 tcg_gen_sari_i64(t1, a, 32);
2231 tcg_gen_sari_i64(t2, b, 32);
2232 tcg_gen_mul_i64(t, t1, t2);
2235 static void do_vmulwod_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2236 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2238 static const TCGOpcode vecop_list[] = {
2239 INDEX_op_sari_vec, INDEX_op_mul_vec, 0
2241 static const GVecGen3 op[3] = {
2243 .fniv = gen_vmulwod_s,
2244 .fno = gen_helper_vmulwod_h_b,
2245 .opt_opc = vecop_list,
2249 .fni4 = gen_vmulwod_w_h,
2250 .fniv = gen_vmulwod_s,
2251 .fno = gen_helper_vmulwod_w_h,
2252 .opt_opc = vecop_list,
2256 .fni8 = gen_vmulwod_d_w,
2257 .fniv = gen_vmulwod_s,
2258 .fno = gen_helper_vmulwod_d_w,
2259 .opt_opc = vecop_list,
2264 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2267 TRANS(vmulwod_h_b, LSX, gvec_vvv, MO_8, do_vmulwod_s)
2268 TRANS(vmulwod_w_h, LSX, gvec_vvv, MO_16, do_vmulwod_s)
2269 TRANS(vmulwod_d_w, LSX, gvec_vvv, MO_32, do_vmulwod_s)
2270 TRANS(xvmulwod_h_b, LASX, gvec_xxx, MO_8, do_vmulwod_s)
2271 TRANS(xvmulwod_w_h, LASX, gvec_xxx, MO_16, do_vmulwod_s)
2272 TRANS(xvmulwod_d_w, LASX, gvec_xxx, MO_32, do_vmulwod_s)
2274 static void gen_vmulwev_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2276 TCGv_vec t1, t2, mask;
2278 t1 = tcg_temp_new_vec_matching(a);
2279 t2 = tcg_temp_new_vec_matching(b);
2280 mask = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
2281 tcg_gen_and_vec(vece, t1, a, mask);
2282 tcg_gen_and_vec(vece, t2, b, mask);
2283 tcg_gen_mul_vec(vece, t, t1, t2);
2286 static void gen_vmulwev_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2290 t1 = tcg_temp_new_i32();
2291 t2 = tcg_temp_new_i32();
2292 tcg_gen_ext16u_i32(t1, a);
2293 tcg_gen_ext16u_i32(t2, b);
2294 tcg_gen_mul_i32(t, t1, t2);
2297 static void gen_vmulwev_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2301 t1 = tcg_temp_new_i64();
2302 t2 = tcg_temp_new_i64();
2303 tcg_gen_ext32u_i64(t1, a);
2304 tcg_gen_ext32u_i64(t2, b);
2305 tcg_gen_mul_i64(t, t1, t2);
2308 static void do_vmulwev_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2309 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2311 static const TCGOpcode vecop_list[] = {
2314 static const GVecGen3 op[3] = {
2316 .fniv = gen_vmulwev_u,
2317 .fno = gen_helper_vmulwev_h_bu,
2318 .opt_opc = vecop_list,
2322 .fni4 = gen_vmulwev_w_hu,
2323 .fniv = gen_vmulwev_u,
2324 .fno = gen_helper_vmulwev_w_hu,
2325 .opt_opc = vecop_list,
2329 .fni8 = gen_vmulwev_d_wu,
2330 .fniv = gen_vmulwev_u,
2331 .fno = gen_helper_vmulwev_d_wu,
2332 .opt_opc = vecop_list,
2337 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2340 TRANS(vmulwev_h_bu, LSX, gvec_vvv, MO_8, do_vmulwev_u)
2341 TRANS(vmulwev_w_hu, LSX, gvec_vvv, MO_16, do_vmulwev_u)
2342 TRANS(vmulwev_d_wu, LSX, gvec_vvv, MO_32, do_vmulwev_u)
2343 TRANS(xvmulwev_h_bu, LASX, gvec_xxx, MO_8, do_vmulwev_u)
2344 TRANS(xvmulwev_w_hu, LASX, gvec_xxx, MO_16, do_vmulwev_u)
2345 TRANS(xvmulwev_d_wu, LASX, gvec_xxx, MO_32, do_vmulwev_u)
2347 static void gen_vmulwod_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2350 int halfbits = 4 << vece;
2352 t1 = tcg_temp_new_vec_matching(a);
2353 t2 = tcg_temp_new_vec_matching(b);
2354 tcg_gen_shri_vec(vece, t1, a, halfbits);
2355 tcg_gen_shri_vec(vece, t2, b, halfbits);
2356 tcg_gen_mul_vec(vece, t, t1, t2);
2359 static void gen_vmulwod_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2363 t1 = tcg_temp_new_i32();
2364 t2 = tcg_temp_new_i32();
2365 tcg_gen_shri_i32(t1, a, 16);
2366 tcg_gen_shri_i32(t2, b, 16);
2367 tcg_gen_mul_i32(t, t1, t2);
2370 static void gen_vmulwod_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2374 t1 = tcg_temp_new_i64();
2375 t2 = tcg_temp_new_i64();
2376 tcg_gen_shri_i64(t1, a, 32);
2377 tcg_gen_shri_i64(t2, b, 32);
2378 tcg_gen_mul_i64(t, t1, t2);
2381 static void do_vmulwod_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2382 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2384 static const TCGOpcode vecop_list[] = {
2385 INDEX_op_shri_vec, INDEX_op_mul_vec, 0
2387 static const GVecGen3 op[3] = {
2389 .fniv = gen_vmulwod_u,
2390 .fno = gen_helper_vmulwod_h_bu,
2391 .opt_opc = vecop_list,
2395 .fni4 = gen_vmulwod_w_hu,
2396 .fniv = gen_vmulwod_u,
2397 .fno = gen_helper_vmulwod_w_hu,
2398 .opt_opc = vecop_list,
2402 .fni8 = gen_vmulwod_d_wu,
2403 .fniv = gen_vmulwod_u,
2404 .fno = gen_helper_vmulwod_d_wu,
2405 .opt_opc = vecop_list,
2410 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2413 TRANS(vmulwod_h_bu, LSX, gvec_vvv, MO_8, do_vmulwod_u)
2414 TRANS(vmulwod_w_hu, LSX, gvec_vvv, MO_16, do_vmulwod_u)
2415 TRANS(vmulwod_d_wu, LSX, gvec_vvv, MO_32, do_vmulwod_u)
2416 TRANS(xvmulwod_h_bu, LASX, gvec_xxx, MO_8, do_vmulwod_u)
2417 TRANS(xvmulwod_w_hu, LASX, gvec_xxx, MO_16, do_vmulwod_u)
2418 TRANS(xvmulwod_d_wu, LASX, gvec_xxx, MO_32, do_vmulwod_u)
2420 static void gen_vmulwev_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2422 TCGv_vec t1, t2, mask;
2423 int halfbits = 4 << vece;
2425 t1 = tcg_temp_new_vec_matching(a);
2426 t2 = tcg_temp_new_vec_matching(b);
2427 mask = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
2428 tcg_gen_and_vec(vece, t1, a, mask);
2429 tcg_gen_shli_vec(vece, t2, b, halfbits);
2430 tcg_gen_sari_vec(vece, t2, t2, halfbits);
2431 tcg_gen_mul_vec(vece, t, t1, t2);
2434 static void gen_vmulwev_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2438 t1 = tcg_temp_new_i32();
2439 t2 = tcg_temp_new_i32();
2440 tcg_gen_ext16u_i32(t1, a);
2441 tcg_gen_ext16s_i32(t2, b);
2442 tcg_gen_mul_i32(t, t1, t2);
2445 static void gen_vmulwev_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2449 t1 = tcg_temp_new_i64();
2450 t2 = tcg_temp_new_i64();
2451 tcg_gen_ext32u_i64(t1, a);
2452 tcg_gen_ext32s_i64(t2, b);
2453 tcg_gen_mul_i64(t, t1, t2);
2456 static void do_vmulwev_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2457 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2459 static const TCGOpcode vecop_list[] = {
2460 INDEX_op_shli_vec, INDEX_op_sari_vec, INDEX_op_mul_vec, 0
2462 static const GVecGen3 op[3] = {
2464 .fniv = gen_vmulwev_u_s,
2465 .fno = gen_helper_vmulwev_h_bu_b,
2466 .opt_opc = vecop_list,
2470 .fni4 = gen_vmulwev_w_hu_h,
2471 .fniv = gen_vmulwev_u_s,
2472 .fno = gen_helper_vmulwev_w_hu_h,
2473 .opt_opc = vecop_list,
2477 .fni8 = gen_vmulwev_d_wu_w,
2478 .fniv = gen_vmulwev_u_s,
2479 .fno = gen_helper_vmulwev_d_wu_w,
2480 .opt_opc = vecop_list,
2485 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2488 TRANS(vmulwev_h_bu_b, LSX, gvec_vvv, MO_8, do_vmulwev_u_s)
2489 TRANS(vmulwev_w_hu_h, LSX, gvec_vvv, MO_16, do_vmulwev_u_s)
2490 TRANS(vmulwev_d_wu_w, LSX, gvec_vvv, MO_32, do_vmulwev_u_s)
2491 TRANS(xvmulwev_h_bu_b, LASX, gvec_xxx, MO_8, do_vmulwev_u_s)
2492 TRANS(xvmulwev_w_hu_h, LASX, gvec_xxx, MO_16, do_vmulwev_u_s)
2493 TRANS(xvmulwev_d_wu_w, LASX, gvec_xxx, MO_32, do_vmulwev_u_s)
2495 static void gen_vmulwod_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2498 int halfbits = 4 << vece;
2500 t1 = tcg_temp_new_vec_matching(a);
2501 t2 = tcg_temp_new_vec_matching(b);
2502 tcg_gen_shri_vec(vece, t1, a, halfbits);
2503 tcg_gen_sari_vec(vece, t2, b, halfbits);
2504 tcg_gen_mul_vec(vece, t, t1, t2);
2507 static void gen_vmulwod_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2511 t1 = tcg_temp_new_i32();
2512 t2 = tcg_temp_new_i32();
2513 tcg_gen_shri_i32(t1, a, 16);
2514 tcg_gen_sari_i32(t2, b, 16);
2515 tcg_gen_mul_i32(t, t1, t2);
2517 static void gen_vmulwod_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2521 t1 = tcg_temp_new_i64();
2522 t2 = tcg_temp_new_i64();
2523 tcg_gen_shri_i64(t1, a, 32);
2524 tcg_gen_sari_i64(t2, b, 32);
2525 tcg_gen_mul_i64(t, t1, t2);
2528 static void do_vmulwod_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2529 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2531 static const TCGOpcode vecop_list[] = {
2532 INDEX_op_shri_vec, INDEX_op_sari_vec, INDEX_op_mul_vec, 0
2534 static const GVecGen3 op[3] = {
2536 .fniv = gen_vmulwod_u_s,
2537 .fno = gen_helper_vmulwod_h_bu_b,
2538 .opt_opc = vecop_list,
2542 .fni4 = gen_vmulwod_w_hu_h,
2543 .fniv = gen_vmulwod_u_s,
2544 .fno = gen_helper_vmulwod_w_hu_h,
2545 .opt_opc = vecop_list,
2549 .fni8 = gen_vmulwod_d_wu_w,
2550 .fniv = gen_vmulwod_u_s,
2551 .fno = gen_helper_vmulwod_d_wu_w,
2552 .opt_opc = vecop_list,
2557 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2560 TRANS(vmulwod_h_bu_b, LSX, gvec_vvv, MO_8, do_vmulwod_u_s)
2561 TRANS(vmulwod_w_hu_h, LSX, gvec_vvv, MO_16, do_vmulwod_u_s)
2562 TRANS(vmulwod_d_wu_w, LSX, gvec_vvv, MO_32, do_vmulwod_u_s)
2563 TRANS(xvmulwod_h_bu_b, LASX, gvec_xxx, MO_8, do_vmulwod_u_s)
2564 TRANS(xvmulwod_w_hu_h, LASX, gvec_xxx, MO_16, do_vmulwod_u_s)
2565 TRANS(xvmulwod_d_wu_w, LASX, gvec_xxx, MO_32, do_vmulwod_u_s)
2567 static void gen_vmadd(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2571 t1 = tcg_temp_new_vec_matching(t);
2572 tcg_gen_mul_vec(vece, t1, a, b);
2573 tcg_gen_add_vec(vece, t, t, t1);
2576 static void gen_vmadd_w(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2580 t1 = tcg_temp_new_i32();
2581 tcg_gen_mul_i32(t1, a, b);
2582 tcg_gen_add_i32(t, t, t1);
2585 static void gen_vmadd_d(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2589 t1 = tcg_temp_new_i64();
2590 tcg_gen_mul_i64(t1, a, b);
2591 tcg_gen_add_i64(t, t, t1);
2594 static void do_vmadd(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2595 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2597 static const TCGOpcode vecop_list[] = {
2598 INDEX_op_mul_vec, INDEX_op_add_vec, 0
2600 static const GVecGen3 op[4] = {
2603 .fno = gen_helper_vmadd_b,
2605 .opt_opc = vecop_list,
2610 .fno = gen_helper_vmadd_h,
2612 .opt_opc = vecop_list,
2616 .fni4 = gen_vmadd_w,
2618 .fno = gen_helper_vmadd_w,
2620 .opt_opc = vecop_list,
2624 .fni8 = gen_vmadd_d,
2626 .fno = gen_helper_vmadd_d,
2628 .opt_opc = vecop_list,
2633 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2636 TRANS(vmadd_b, LSX, gvec_vvv, MO_8, do_vmadd)
2637 TRANS(vmadd_h, LSX, gvec_vvv, MO_16, do_vmadd)
2638 TRANS(vmadd_w, LSX, gvec_vvv, MO_32, do_vmadd)
2639 TRANS(vmadd_d, LSX, gvec_vvv, MO_64, do_vmadd)
2640 TRANS(xvmadd_b, LASX, gvec_xxx, MO_8, do_vmadd)
2641 TRANS(xvmadd_h, LASX, gvec_xxx, MO_16, do_vmadd)
2642 TRANS(xvmadd_w, LASX, gvec_xxx, MO_32, do_vmadd)
2643 TRANS(xvmadd_d, LASX, gvec_xxx, MO_64, do_vmadd)
2645 static void gen_vmsub(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2649 t1 = tcg_temp_new_vec_matching(t);
2650 tcg_gen_mul_vec(vece, t1, a, b);
2651 tcg_gen_sub_vec(vece, t, t, t1);
2654 static void gen_vmsub_w(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2658 t1 = tcg_temp_new_i32();
2659 tcg_gen_mul_i32(t1, a, b);
2660 tcg_gen_sub_i32(t, t, t1);
2663 static void gen_vmsub_d(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2667 t1 = tcg_temp_new_i64();
2668 tcg_gen_mul_i64(t1, a, b);
2669 tcg_gen_sub_i64(t, t, t1);
2672 static void do_vmsub(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2673 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2675 static const TCGOpcode vecop_list[] = {
2676 INDEX_op_mul_vec, INDEX_op_sub_vec, 0
2678 static const GVecGen3 op[4] = {
2681 .fno = gen_helper_vmsub_b,
2683 .opt_opc = vecop_list,
2688 .fno = gen_helper_vmsub_h,
2690 .opt_opc = vecop_list,
2694 .fni4 = gen_vmsub_w,
2696 .fno = gen_helper_vmsub_w,
2698 .opt_opc = vecop_list,
2702 .fni8 = gen_vmsub_d,
2704 .fno = gen_helper_vmsub_d,
2706 .opt_opc = vecop_list,
2711 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2714 TRANS(vmsub_b, LSX, gvec_vvv, MO_8, do_vmsub)
2715 TRANS(vmsub_h, LSX, gvec_vvv, MO_16, do_vmsub)
2716 TRANS(vmsub_w, LSX, gvec_vvv, MO_32, do_vmsub)
2717 TRANS(vmsub_d, LSX, gvec_vvv, MO_64, do_vmsub)
2718 TRANS(xvmsub_b, LASX, gvec_xxx, MO_8, do_vmsub)
2719 TRANS(xvmsub_h, LASX, gvec_xxx, MO_16, do_vmsub)
2720 TRANS(xvmsub_w, LASX, gvec_xxx, MO_32, do_vmsub)
2721 TRANS(xvmsub_d, LASX, gvec_xxx, MO_64, do_vmsub)
2723 static void gen_vmaddwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2725 TCGv_vec t1, t2, t3;
2726 int halfbits = 4 << vece;
2728 t1 = tcg_temp_new_vec_matching(a);
2729 t2 = tcg_temp_new_vec_matching(b);
2730 t3 = tcg_temp_new_vec_matching(t);
2731 tcg_gen_shli_vec(vece, t1, a, halfbits);
2732 tcg_gen_sari_vec(vece, t1, t1, halfbits);
2733 tcg_gen_shli_vec(vece, t2, b, halfbits);
2734 tcg_gen_sari_vec(vece, t2, t2, halfbits);
2735 tcg_gen_mul_vec(vece, t3, t1, t2);
2736 tcg_gen_add_vec(vece, t, t, t3);
2739 static void gen_vmaddwev_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2743 t1 = tcg_temp_new_i32();
2744 gen_vmulwev_w_h(t1, a, b);
2745 tcg_gen_add_i32(t, t, t1);
2748 static void gen_vmaddwev_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2752 t1 = tcg_temp_new_i64();
2753 gen_vmulwev_d_w(t1, a, b);
2754 tcg_gen_add_i64(t, t, t1);
2757 static void do_vmaddwev_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2758 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2760 static const TCGOpcode vecop_list[] = {
2761 INDEX_op_shli_vec, INDEX_op_sari_vec,
2762 INDEX_op_mul_vec, INDEX_op_add_vec, 0
2764 static const GVecGen3 op[3] = {
2766 .fniv = gen_vmaddwev_s,
2767 .fno = gen_helper_vmaddwev_h_b,
2769 .opt_opc = vecop_list,
2773 .fni4 = gen_vmaddwev_w_h,
2774 .fniv = gen_vmaddwev_s,
2775 .fno = gen_helper_vmaddwev_w_h,
2777 .opt_opc = vecop_list,
2781 .fni8 = gen_vmaddwev_d_w,
2782 .fniv = gen_vmaddwev_s,
2783 .fno = gen_helper_vmaddwev_d_w,
2785 .opt_opc = vecop_list,
2790 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2793 TRANS(vmaddwev_h_b, LSX, gvec_vvv, MO_8, do_vmaddwev_s)
2794 TRANS(vmaddwev_w_h, LSX, gvec_vvv, MO_16, do_vmaddwev_s)
2795 TRANS(vmaddwev_d_w, LSX, gvec_vvv, MO_32, do_vmaddwev_s)
2796 TRANS(xvmaddwev_h_b, LASX, gvec_xxx, MO_8, do_vmaddwev_s)
2797 TRANS(xvmaddwev_w_h, LASX, gvec_xxx, MO_16, do_vmaddwev_s)
2798 TRANS(xvmaddwev_d_w, LASX, gvec_xxx, MO_32, do_vmaddwev_s)
2800 static bool gen_vmadd_q_vl(DisasContext * ctx,
2801 arg_vvv *a, uint32_t oprsz, int idx1, int idx2,
2802 void (*func)(TCGv_i64, TCGv_i64,
2803 TCGv_i64, TCGv_i64))
2805 TCGv_i64 rh, rl, arg1, arg2, th, tl;
2808 if (!check_vec(ctx, oprsz)) {
2812 rh = tcg_temp_new_i64();
2813 rl = tcg_temp_new_i64();
2814 arg1 = tcg_temp_new_i64();
2815 arg2 = tcg_temp_new_i64();
2816 th = tcg_temp_new_i64();
2817 tl = tcg_temp_new_i64();
2819 for (i = 0; i < oprsz / 16; i++) {
2820 get_vreg64(arg1, a->vj, 2 * i + idx1);
2821 get_vreg64(arg2, a->vk, 2 * i + idx2);
2822 get_vreg64(rh, a->vd, 2 * i + 1);
2823 get_vreg64(rl, a->vd, 2 * i);
2825 func(tl, th, arg1, arg2);
2826 tcg_gen_add2_i64(rl, rh, rl, rh, tl, th);
2828 set_vreg64(rh, a->vd, 2 * i + 1);
2829 set_vreg64(rl, a->vd, 2 * i);
2835 static bool gen_vmadd_q(DisasContext *ctx, arg_vvv *a, int idx1, int idx2,
2836 void (*func)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
2838 return gen_vmadd_q_vl(ctx, a, 16, idx1, idx2, func);
2841 static bool gen_xvmadd_q(DisasContext *ctx, arg_vvv *a, int idx1, int idx2,
2842 void (*func)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
2844 return gen_vmadd_q_vl(ctx, a, 32, idx1, idx2, func);
2847 TRANS(vmaddwev_q_d, LSX, gen_vmadd_q, 0, 0, tcg_gen_muls2_i64)
2848 TRANS(vmaddwod_q_d, LSX, gen_vmadd_q, 1, 1, tcg_gen_muls2_i64)
2849 TRANS(vmaddwev_q_du, LSX, gen_vmadd_q, 0, 0, tcg_gen_mulu2_i64)
2850 TRANS(vmaddwod_q_du, LSX, gen_vmadd_q, 1, 1, tcg_gen_mulu2_i64)
2851 TRANS(vmaddwev_q_du_d, LSX, gen_vmadd_q, 0, 0, tcg_gen_mulus2_i64)
2852 TRANS(vmaddwod_q_du_d, LSX, gen_vmadd_q, 1, 1, tcg_gen_mulus2_i64)
2853 TRANS(xvmaddwev_q_d, LASX, gen_xvmadd_q, 0, 0, tcg_gen_muls2_i64)
2854 TRANS(xvmaddwod_q_d, LASX, gen_xvmadd_q, 1, 1, tcg_gen_muls2_i64)
2855 TRANS(xvmaddwev_q_du, LASX, gen_xvmadd_q, 0, 0, tcg_gen_mulu2_i64)
2856 TRANS(xvmaddwod_q_du, LASX, gen_xvmadd_q, 1, 1, tcg_gen_mulu2_i64)
2857 TRANS(xvmaddwev_q_du_d, LASX, gen_xvmadd_q, 0, 0, tcg_gen_mulus2_i64)
2858 TRANS(xvmaddwod_q_du_d, LASX, gen_xvmadd_q, 1, 1, tcg_gen_mulus2_i64)
2860 static void gen_vmaddwod_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2862 TCGv_vec t1, t2, t3;
2863 int halfbits = 4 << vece;
2865 t1 = tcg_temp_new_vec_matching(a);
2866 t2 = tcg_temp_new_vec_matching(b);
2867 t3 = tcg_temp_new_vec_matching(t);
2868 tcg_gen_sari_vec(vece, t1, a, halfbits);
2869 tcg_gen_sari_vec(vece, t2, b, halfbits);
2870 tcg_gen_mul_vec(vece, t3, t1, t2);
2871 tcg_gen_add_vec(vece, t, t, t3);
2874 static void gen_vmaddwod_w_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2878 t1 = tcg_temp_new_i32();
2879 gen_vmulwod_w_h(t1, a, b);
2880 tcg_gen_add_i32(t, t, t1);
2883 static void gen_vmaddwod_d_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2887 t1 = tcg_temp_new_i64();
2888 gen_vmulwod_d_w(t1, a, b);
2889 tcg_gen_add_i64(t, t, t1);
2892 static void do_vmaddwod_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2893 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2895 static const TCGOpcode vecop_list[] = {
2896 INDEX_op_sari_vec, INDEX_op_mul_vec, INDEX_op_add_vec, 0
2898 static const GVecGen3 op[3] = {
2900 .fniv = gen_vmaddwod_s,
2901 .fno = gen_helper_vmaddwod_h_b,
2903 .opt_opc = vecop_list,
2907 .fni4 = gen_vmaddwod_w_h,
2908 .fniv = gen_vmaddwod_s,
2909 .fno = gen_helper_vmaddwod_w_h,
2911 .opt_opc = vecop_list,
2915 .fni8 = gen_vmaddwod_d_w,
2916 .fniv = gen_vmaddwod_s,
2917 .fno = gen_helper_vmaddwod_d_w,
2919 .opt_opc = vecop_list,
2924 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
2927 TRANS(vmaddwod_h_b, LSX, gvec_vvv, MO_8, do_vmaddwod_s)
2928 TRANS(vmaddwod_w_h, LSX, gvec_vvv, MO_16, do_vmaddwod_s)
2929 TRANS(vmaddwod_d_w, LSX, gvec_vvv, MO_32, do_vmaddwod_s)
2930 TRANS(xvmaddwod_h_b, LASX, gvec_xxx, MO_8, do_vmaddwod_s)
2931 TRANS(xvmaddwod_w_h, LASX, gvec_xxx, MO_16, do_vmaddwod_s)
2932 TRANS(xvmaddwod_d_w, LASX, gvec_xxx, MO_32, do_vmaddwod_s)
2934 static void gen_vmaddwev_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
2936 TCGv_vec t1, t2, mask;
2938 t1 = tcg_temp_new_vec_matching(t);
2939 t2 = tcg_temp_new_vec_matching(b);
2940 mask = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
2941 tcg_gen_and_vec(vece, t1, a, mask);
2942 tcg_gen_and_vec(vece, t2, b, mask);
2943 tcg_gen_mul_vec(vece, t1, t1, t2);
2944 tcg_gen_add_vec(vece, t, t, t1);
2947 static void gen_vmaddwev_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
2951 t1 = tcg_temp_new_i32();
2952 gen_vmulwev_w_hu(t1, a, b);
2953 tcg_gen_add_i32(t, t, t1);
2956 static void gen_vmaddwev_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
2960 t1 = tcg_temp_new_i64();
2961 gen_vmulwev_d_wu(t1, a, b);
2962 tcg_gen_add_i64(t, t, t1);
2965 static void do_vmaddwev_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
2966 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
2968 static const TCGOpcode vecop_list[] = {
2969 INDEX_op_mul_vec, INDEX_op_add_vec, 0
2971 static const GVecGen3 op[3] = {
2973 .fniv = gen_vmaddwev_u,
2974 .fno = gen_helper_vmaddwev_h_bu,
2976 .opt_opc = vecop_list,
2980 .fni4 = gen_vmaddwev_w_hu,
2981 .fniv = gen_vmaddwev_u,
2982 .fno = gen_helper_vmaddwev_w_hu,
2984 .opt_opc = vecop_list,
2988 .fni8 = gen_vmaddwev_d_wu,
2989 .fniv = gen_vmaddwev_u,
2990 .fno = gen_helper_vmaddwev_d_wu,
2992 .opt_opc = vecop_list,
2997 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
3000 TRANS(vmaddwev_h_bu, LSX, gvec_vvv, MO_8, do_vmaddwev_u)
3001 TRANS(vmaddwev_w_hu, LSX, gvec_vvv, MO_16, do_vmaddwev_u)
3002 TRANS(vmaddwev_d_wu, LSX, gvec_vvv, MO_32, do_vmaddwev_u)
3003 TRANS(xvmaddwev_h_bu, LASX, gvec_xxx, MO_8, do_vmaddwev_u)
3004 TRANS(xvmaddwev_w_hu, LASX, gvec_xxx, MO_16, do_vmaddwev_u)
3005 TRANS(xvmaddwev_d_wu, LASX, gvec_xxx, MO_32, do_vmaddwev_u)
3007 static void gen_vmaddwod_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
3009 TCGv_vec t1, t2, t3;
3010 int halfbits = 4 << vece;
3012 t1 = tcg_temp_new_vec_matching(a);
3013 t2 = tcg_temp_new_vec_matching(b);
3014 t3 = tcg_temp_new_vec_matching(t);
3015 tcg_gen_shri_vec(vece, t1, a, halfbits);
3016 tcg_gen_shri_vec(vece, t2, b, halfbits);
3017 tcg_gen_mul_vec(vece, t3, t1, t2);
3018 tcg_gen_add_vec(vece, t, t, t3);
3021 static void gen_vmaddwod_w_hu(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
3025 t1 = tcg_temp_new_i32();
3026 gen_vmulwod_w_hu(t1, a, b);
3027 tcg_gen_add_i32(t, t, t1);
3030 static void gen_vmaddwod_d_wu(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
3034 t1 = tcg_temp_new_i64();
3035 gen_vmulwod_d_wu(t1, a, b);
3036 tcg_gen_add_i64(t, t, t1);
3039 static void do_vmaddwod_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3040 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
3042 static const TCGOpcode vecop_list[] = {
3043 INDEX_op_shri_vec, INDEX_op_mul_vec, INDEX_op_add_vec, 0
3045 static const GVecGen3 op[3] = {
3047 .fniv = gen_vmaddwod_u,
3048 .fno = gen_helper_vmaddwod_h_bu,
3050 .opt_opc = vecop_list,
3054 .fni4 = gen_vmaddwod_w_hu,
3055 .fniv = gen_vmaddwod_u,
3056 .fno = gen_helper_vmaddwod_w_hu,
3058 .opt_opc = vecop_list,
3062 .fni8 = gen_vmaddwod_d_wu,
3063 .fniv = gen_vmaddwod_u,
3064 .fno = gen_helper_vmaddwod_d_wu,
3066 .opt_opc = vecop_list,
3071 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
3074 TRANS(vmaddwod_h_bu, LSX, gvec_vvv, MO_8, do_vmaddwod_u)
3075 TRANS(vmaddwod_w_hu, LSX, gvec_vvv, MO_16, do_vmaddwod_u)
3076 TRANS(vmaddwod_d_wu, LSX, gvec_vvv, MO_32, do_vmaddwod_u)
3077 TRANS(xvmaddwod_h_bu, LASX, gvec_xxx, MO_8, do_vmaddwod_u)
3078 TRANS(xvmaddwod_w_hu, LASX, gvec_xxx, MO_16, do_vmaddwod_u)
3079 TRANS(xvmaddwod_d_wu, LASX, gvec_xxx, MO_32, do_vmaddwod_u)
3081 static void gen_vmaddwev_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
3083 TCGv_vec t1, t2, mask;
3084 int halfbits = 4 << vece;
3086 t1 = tcg_temp_new_vec_matching(a);
3087 t2 = tcg_temp_new_vec_matching(b);
3088 mask = tcg_constant_vec_matching(t, vece, MAKE_64BIT_MASK(0, 4 << vece));
3089 tcg_gen_and_vec(vece, t1, a, mask);
3090 tcg_gen_shli_vec(vece, t2, b, halfbits);
3091 tcg_gen_sari_vec(vece, t2, t2, halfbits);
3092 tcg_gen_mul_vec(vece, t1, t1, t2);
3093 tcg_gen_add_vec(vece, t, t, t1);
3096 static void gen_vmaddwev_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
3100 t1 = tcg_temp_new_i32();
3101 gen_vmulwev_w_hu_h(t1, a, b);
3102 tcg_gen_add_i32(t, t, t1);
3105 static void gen_vmaddwev_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
3109 t1 = tcg_temp_new_i64();
3110 gen_vmulwev_d_wu_w(t1, a, b);
3111 tcg_gen_add_i64(t, t, t1);
3114 static void do_vmaddwev_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3115 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
3117 static const TCGOpcode vecop_list[] = {
3118 INDEX_op_shli_vec, INDEX_op_sari_vec,
3119 INDEX_op_mul_vec, INDEX_op_add_vec, 0
3121 static const GVecGen3 op[3] = {
3123 .fniv = gen_vmaddwev_u_s,
3124 .fno = gen_helper_vmaddwev_h_bu_b,
3126 .opt_opc = vecop_list,
3130 .fni4 = gen_vmaddwev_w_hu_h,
3131 .fniv = gen_vmaddwev_u_s,
3132 .fno = gen_helper_vmaddwev_w_hu_h,
3134 .opt_opc = vecop_list,
3138 .fni8 = gen_vmaddwev_d_wu_w,
3139 .fniv = gen_vmaddwev_u_s,
3140 .fno = gen_helper_vmaddwev_d_wu_w,
3142 .opt_opc = vecop_list,
3147 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
3150 TRANS(vmaddwev_h_bu_b, LSX, gvec_vvv, MO_8, do_vmaddwev_u_s)
3151 TRANS(vmaddwev_w_hu_h, LSX, gvec_vvv, MO_16, do_vmaddwev_u_s)
3152 TRANS(vmaddwev_d_wu_w, LSX, gvec_vvv, MO_32, do_vmaddwev_u_s)
3153 TRANS(xvmaddwev_h_bu_b, LASX, gvec_xxx, MO_8, do_vmaddwev_u_s)
3154 TRANS(xvmaddwev_w_hu_h, LASX, gvec_xxx, MO_16, do_vmaddwev_u_s)
3155 TRANS(xvmaddwev_d_wu_w, LASX, gvec_xxx, MO_32, do_vmaddwev_u_s)
3157 static void gen_vmaddwod_u_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
3159 TCGv_vec t1, t2, t3;
3160 int halfbits = 4 << vece;
3162 t1 = tcg_temp_new_vec_matching(a);
3163 t2 = tcg_temp_new_vec_matching(b);
3164 t3 = tcg_temp_new_vec_matching(t);
3165 tcg_gen_shri_vec(vece, t1, a, halfbits);
3166 tcg_gen_sari_vec(vece, t2, b, halfbits);
3167 tcg_gen_mul_vec(vece, t3, t1, t2);
3168 tcg_gen_add_vec(vece, t, t, t3);
3171 static void gen_vmaddwod_w_hu_h(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
3175 t1 = tcg_temp_new_i32();
3176 gen_vmulwod_w_hu_h(t1, a, b);
3177 tcg_gen_add_i32(t, t, t1);
3180 static void gen_vmaddwod_d_wu_w(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b)
3184 t1 = tcg_temp_new_i64();
3185 gen_vmulwod_d_wu_w(t1, a, b);
3186 tcg_gen_add_i64(t, t, t1);
3189 static void do_vmaddwod_u_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3190 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
3192 static const TCGOpcode vecop_list[] = {
3193 INDEX_op_shri_vec, INDEX_op_sari_vec,
3194 INDEX_op_mul_vec, INDEX_op_add_vec, 0
3196 static const GVecGen3 op[3] = {
3198 .fniv = gen_vmaddwod_u_s,
3199 .fno = gen_helper_vmaddwod_h_bu_b,
3201 .opt_opc = vecop_list,
3205 .fni4 = gen_vmaddwod_w_hu_h,
3206 .fniv = gen_vmaddwod_u_s,
3207 .fno = gen_helper_vmaddwod_w_hu_h,
3209 .opt_opc = vecop_list,
3213 .fni8 = gen_vmaddwod_d_wu_w,
3214 .fniv = gen_vmaddwod_u_s,
3215 .fno = gen_helper_vmaddwod_d_wu_w,
3217 .opt_opc = vecop_list,
3222 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
3225 TRANS(vmaddwod_h_bu_b, LSX, gvec_vvv, MO_8, do_vmaddwod_u_s)
3226 TRANS(vmaddwod_w_hu_h, LSX, gvec_vvv, MO_16, do_vmaddwod_u_s)
3227 TRANS(vmaddwod_d_wu_w, LSX, gvec_vvv, MO_32, do_vmaddwod_u_s)
3228 TRANS(xvmaddwod_h_bu_b, LASX, gvec_xxx, MO_8, do_vmaddwod_u_s)
3229 TRANS(xvmaddwod_w_hu_h, LASX, gvec_xxx, MO_16, do_vmaddwod_u_s)
3230 TRANS(xvmaddwod_d_wu_w, LASX, gvec_xxx, MO_32, do_vmaddwod_u_s)
3232 TRANS(vdiv_b, LSX, gen_vvv, gen_helper_vdiv_b)
3233 TRANS(vdiv_h, LSX, gen_vvv, gen_helper_vdiv_h)
3234 TRANS(vdiv_w, LSX, gen_vvv, gen_helper_vdiv_w)
3235 TRANS(vdiv_d, LSX, gen_vvv, gen_helper_vdiv_d)
3236 TRANS(vdiv_bu, LSX, gen_vvv, gen_helper_vdiv_bu)
3237 TRANS(vdiv_hu, LSX, gen_vvv, gen_helper_vdiv_hu)
3238 TRANS(vdiv_wu, LSX, gen_vvv, gen_helper_vdiv_wu)
3239 TRANS(vdiv_du, LSX, gen_vvv, gen_helper_vdiv_du)
3240 TRANS(vmod_b, LSX, gen_vvv, gen_helper_vmod_b)
3241 TRANS(vmod_h, LSX, gen_vvv, gen_helper_vmod_h)
3242 TRANS(vmod_w, LSX, gen_vvv, gen_helper_vmod_w)
3243 TRANS(vmod_d, LSX, gen_vvv, gen_helper_vmod_d)
3244 TRANS(vmod_bu, LSX, gen_vvv, gen_helper_vmod_bu)
3245 TRANS(vmod_hu, LSX, gen_vvv, gen_helper_vmod_hu)
3246 TRANS(vmod_wu, LSX, gen_vvv, gen_helper_vmod_wu)
3247 TRANS(vmod_du, LSX, gen_vvv, gen_helper_vmod_du)
3248 TRANS(xvdiv_b, LASX, gen_xxx, gen_helper_vdiv_b)
3249 TRANS(xvdiv_h, LASX, gen_xxx, gen_helper_vdiv_h)
3250 TRANS(xvdiv_w, LASX, gen_xxx, gen_helper_vdiv_w)
3251 TRANS(xvdiv_d, LASX, gen_xxx, gen_helper_vdiv_d)
3252 TRANS(xvdiv_bu, LASX, gen_xxx, gen_helper_vdiv_bu)
3253 TRANS(xvdiv_hu, LASX, gen_xxx, gen_helper_vdiv_hu)
3254 TRANS(xvdiv_wu, LASX, gen_xxx, gen_helper_vdiv_wu)
3255 TRANS(xvdiv_du, LASX, gen_xxx, gen_helper_vdiv_du)
3256 TRANS(xvmod_b, LASX, gen_xxx, gen_helper_vmod_b)
3257 TRANS(xvmod_h, LASX, gen_xxx, gen_helper_vmod_h)
3258 TRANS(xvmod_w, LASX, gen_xxx, gen_helper_vmod_w)
3259 TRANS(xvmod_d, LASX, gen_xxx, gen_helper_vmod_d)
3260 TRANS(xvmod_bu, LASX, gen_xxx, gen_helper_vmod_bu)
3261 TRANS(xvmod_hu, LASX, gen_xxx, gen_helper_vmod_hu)
3262 TRANS(xvmod_wu, LASX, gen_xxx, gen_helper_vmod_wu)
3263 TRANS(xvmod_du, LASX, gen_xxx, gen_helper_vmod_du)
3265 static void gen_vsat_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec max)
3269 min = tcg_temp_new_vec_matching(t);
3270 tcg_gen_not_vec(vece, min, max);
3271 tcg_gen_smax_vec(vece, t, a, min);
3272 tcg_gen_smin_vec(vece, t, t, max);
3275 static void do_vsat_s(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3276 int64_t imm, uint32_t oprsz, uint32_t maxsz)
3278 static const TCGOpcode vecop_list[] = {
3279 INDEX_op_smax_vec, INDEX_op_smin_vec, 0
3281 static const GVecGen2s op[4] = {
3284 .fno = gen_helper_vsat_b,
3285 .opt_opc = vecop_list,
3290 .fno = gen_helper_vsat_h,
3291 .opt_opc = vecop_list,
3296 .fno = gen_helper_vsat_w,
3297 .opt_opc = vecop_list,
3302 .fno = gen_helper_vsat_d,
3303 .opt_opc = vecop_list,
3308 tcg_gen_gvec_2s(vd_ofs, vj_ofs, oprsz, maxsz,
3309 tcg_constant_i64((1ll<< imm) -1), &op[vece]);
3312 TRANS(vsat_b, LSX, gvec_vv_i, MO_8, do_vsat_s)
3313 TRANS(vsat_h, LSX, gvec_vv_i, MO_16, do_vsat_s)
3314 TRANS(vsat_w, LSX, gvec_vv_i, MO_32, do_vsat_s)
3315 TRANS(vsat_d, LSX, gvec_vv_i, MO_64, do_vsat_s)
3316 TRANS(xvsat_b, LASX, gvec_xx_i, MO_8, do_vsat_s)
3317 TRANS(xvsat_h, LASX, gvec_xx_i, MO_16, do_vsat_s)
3318 TRANS(xvsat_w, LASX, gvec_xx_i, MO_32, do_vsat_s)
3319 TRANS(xvsat_d, LASX, gvec_xx_i, MO_64, do_vsat_s)
3321 static void gen_vsat_u(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec max)
3323 tcg_gen_umin_vec(vece, t, a, max);
3326 static void do_vsat_u(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3327 int64_t imm, uint32_t oprsz, uint32_t maxsz)
3330 static const TCGOpcode vecop_list[] = {
3331 INDEX_op_umin_vec, 0
3333 static const GVecGen2s op[4] = {
3336 .fno = gen_helper_vsat_bu,
3337 .opt_opc = vecop_list,
3342 .fno = gen_helper_vsat_hu,
3343 .opt_opc = vecop_list,
3348 .fno = gen_helper_vsat_wu,
3349 .opt_opc = vecop_list,
3354 .fno = gen_helper_vsat_du,
3355 .opt_opc = vecop_list,
3360 max = (imm == 0x3f) ? UINT64_MAX : (1ull << (imm + 1)) - 1;
3361 tcg_gen_gvec_2s(vd_ofs, vj_ofs, oprsz, maxsz,
3362 tcg_constant_i64(max), &op[vece]);
3365 TRANS(vsat_bu, LSX, gvec_vv_i, MO_8, do_vsat_u)
3366 TRANS(vsat_hu, LSX, gvec_vv_i, MO_16, do_vsat_u)
3367 TRANS(vsat_wu, LSX, gvec_vv_i, MO_32, do_vsat_u)
3368 TRANS(vsat_du, LSX, gvec_vv_i, MO_64, do_vsat_u)
3369 TRANS(xvsat_bu, LASX, gvec_xx_i, MO_8, do_vsat_u)
3370 TRANS(xvsat_hu, LASX, gvec_xx_i, MO_16, do_vsat_u)
3371 TRANS(xvsat_wu, LASX, gvec_xx_i, MO_32, do_vsat_u)
3372 TRANS(xvsat_du, LASX, gvec_xx_i, MO_64, do_vsat_u)
3374 TRANS(vexth_h_b, LSX, gen_vv, gen_helper_vexth_h_b)
3375 TRANS(vexth_w_h, LSX, gen_vv, gen_helper_vexth_w_h)
3376 TRANS(vexth_d_w, LSX, gen_vv, gen_helper_vexth_d_w)
3377 TRANS(vexth_q_d, LSX, gen_vv, gen_helper_vexth_q_d)
3378 TRANS(vexth_hu_bu, LSX, gen_vv, gen_helper_vexth_hu_bu)
3379 TRANS(vexth_wu_hu, LSX, gen_vv, gen_helper_vexth_wu_hu)
3380 TRANS(vexth_du_wu, LSX, gen_vv, gen_helper_vexth_du_wu)
3381 TRANS(vexth_qu_du, LSX, gen_vv, gen_helper_vexth_qu_du)
3382 TRANS(xvexth_h_b, LASX, gen_xx, gen_helper_vexth_h_b)
3383 TRANS(xvexth_w_h, LASX, gen_xx, gen_helper_vexth_w_h)
3384 TRANS(xvexth_d_w, LASX, gen_xx, gen_helper_vexth_d_w)
3385 TRANS(xvexth_q_d, LASX, gen_xx, gen_helper_vexth_q_d)
3386 TRANS(xvexth_hu_bu, LASX, gen_xx, gen_helper_vexth_hu_bu)
3387 TRANS(xvexth_wu_hu, LASX, gen_xx, gen_helper_vexth_wu_hu)
3388 TRANS(xvexth_du_wu, LASX, gen_xx, gen_helper_vexth_du_wu)
3389 TRANS(xvexth_qu_du, LASX, gen_xx, gen_helper_vexth_qu_du)
3391 TRANS(vext2xv_h_b, LASX, gen_xx, gen_helper_vext2xv_h_b)
3392 TRANS(vext2xv_w_b, LASX, gen_xx, gen_helper_vext2xv_w_b)
3393 TRANS(vext2xv_d_b, LASX, gen_xx, gen_helper_vext2xv_d_b)
3394 TRANS(vext2xv_w_h, LASX, gen_xx, gen_helper_vext2xv_w_h)
3395 TRANS(vext2xv_d_h, LASX, gen_xx, gen_helper_vext2xv_d_h)
3396 TRANS(vext2xv_d_w, LASX, gen_xx, gen_helper_vext2xv_d_w)
3397 TRANS(vext2xv_hu_bu, LASX, gen_xx, gen_helper_vext2xv_hu_bu)
3398 TRANS(vext2xv_wu_bu, LASX, gen_xx, gen_helper_vext2xv_wu_bu)
3399 TRANS(vext2xv_du_bu, LASX, gen_xx, gen_helper_vext2xv_du_bu)
3400 TRANS(vext2xv_wu_hu, LASX, gen_xx, gen_helper_vext2xv_wu_hu)
3401 TRANS(vext2xv_du_hu, LASX, gen_xx, gen_helper_vext2xv_du_hu)
3402 TRANS(vext2xv_du_wu, LASX, gen_xx, gen_helper_vext2xv_du_wu)
3404 static void gen_vsigncov(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
3408 t1 = tcg_temp_new_vec_matching(t);
3409 zero = tcg_constant_vec_matching(t, vece, 0);
3411 tcg_gen_neg_vec(vece, t1, b);
3412 tcg_gen_cmpsel_vec(TCG_COND_LT, vece, t, a, zero, t1, b);
3413 tcg_gen_cmpsel_vec(TCG_COND_EQ, vece, t, a, zero, zero, t);
3416 static void do_vsigncov(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3417 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
3419 static const TCGOpcode vecop_list[] = {
3420 INDEX_op_neg_vec, INDEX_op_cmpsel_vec, 0
3422 static const GVecGen3 op[4] = {
3424 .fniv = gen_vsigncov,
3425 .fno = gen_helper_vsigncov_b,
3426 .opt_opc = vecop_list,
3430 .fniv = gen_vsigncov,
3431 .fno = gen_helper_vsigncov_h,
3432 .opt_opc = vecop_list,
3436 .fniv = gen_vsigncov,
3437 .fno = gen_helper_vsigncov_w,
3438 .opt_opc = vecop_list,
3442 .fniv = gen_vsigncov,
3443 .fno = gen_helper_vsigncov_d,
3444 .opt_opc = vecop_list,
3449 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
3452 TRANS(vsigncov_b, LSX, gvec_vvv, MO_8, do_vsigncov)
3453 TRANS(vsigncov_h, LSX, gvec_vvv, MO_16, do_vsigncov)
3454 TRANS(vsigncov_w, LSX, gvec_vvv, MO_32, do_vsigncov)
3455 TRANS(vsigncov_d, LSX, gvec_vvv, MO_64, do_vsigncov)
3456 TRANS(xvsigncov_b, LASX, gvec_xxx, MO_8, do_vsigncov)
3457 TRANS(xvsigncov_h, LASX, gvec_xxx, MO_16, do_vsigncov)
3458 TRANS(xvsigncov_w, LASX, gvec_xxx, MO_32, do_vsigncov)
3459 TRANS(xvsigncov_d, LASX, gvec_xxx, MO_64, do_vsigncov)
3461 TRANS(vmskltz_b, LSX, gen_vv, gen_helper_vmskltz_b)
3462 TRANS(vmskltz_h, LSX, gen_vv, gen_helper_vmskltz_h)
3463 TRANS(vmskltz_w, LSX, gen_vv, gen_helper_vmskltz_w)
3464 TRANS(vmskltz_d, LSX, gen_vv, gen_helper_vmskltz_d)
3465 TRANS(vmskgez_b, LSX, gen_vv, gen_helper_vmskgez_b)
3466 TRANS(vmsknz_b, LSX, gen_vv, gen_helper_vmsknz_b)
3467 TRANS(xvmskltz_b, LASX, gen_xx, gen_helper_vmskltz_b)
3468 TRANS(xvmskltz_h, LASX, gen_xx, gen_helper_vmskltz_h)
3469 TRANS(xvmskltz_w, LASX, gen_xx, gen_helper_vmskltz_w)
3470 TRANS(xvmskltz_d, LASX, gen_xx, gen_helper_vmskltz_d)
3471 TRANS(xvmskgez_b, LASX, gen_xx, gen_helper_vmskgez_b)
3472 TRANS(xvmsknz_b, LASX, gen_xx, gen_helper_vmsknz_b)
3474 #define EXPAND_BYTE(bit) ((uint64_t)(bit ? 0xff : 0))
3476 static uint64_t vldi_get_value(DisasContext *ctx, uint32_t imm)
3482 * imm bit [11:8] is mode, mode value is 0-12.
3483 * other values are invalid.
3485 mode = (imm >> 8) & 0xf;
3489 /* data: {2{24'0, imm[7:0]}} */
3490 data = (t << 32) | t ;
3493 /* data: {2{16'0, imm[7:0], 8'0}} */
3494 data = (t << 24) | (t << 8);
3497 /* data: {2{8'0, imm[7:0], 16'0}} */
3498 data = (t << 48) | (t << 16);
3501 /* data: {2{imm[7:0], 24'0}} */
3502 data = (t << 56) | (t << 24);
3505 /* data: {4{8'0, imm[7:0]}} */
3506 data = (t << 48) | (t << 32) | (t << 16) | t;
3509 /* data: {4{imm[7:0], 8'0}} */
3510 data = (t << 56) |(t << 40) | (t << 24) | (t << 8);
3513 /* data: {2{16'0, imm[7:0], 8'1}} */
3514 data = (t << 40) | ((uint64_t)0xff << 32) | (t << 8) | 0xff;
3517 /* data: {2{8'0, imm[7:0], 16'1}} */
3518 data = (t << 48) | ((uint64_t)0xffff << 32) | (t << 16) | 0xffff;
3521 /* data: {8{imm[7:0]}} */
3522 data =(t << 56) | (t << 48) | (t << 40) | (t << 32) |
3523 (t << 24) | (t << 16) | (t << 8) | t;
3526 /* data: {{8{imm[7]}, ..., 8{imm[0]}}} */
3528 uint64_t b0,b1,b2,b3,b4,b5,b6,b7;
3530 b1 = (t & 0x2) >> 1;
3531 b2 = (t & 0x4) >> 2;
3532 b3 = (t & 0x8) >> 3;
3533 b4 = (t & 0x10) >> 4;
3534 b5 = (t & 0x20) >> 5;
3535 b6 = (t & 0x40) >> 6;
3536 b7 = (t & 0x80) >> 7;
3537 data = (EXPAND_BYTE(b7) << 56) |
3538 (EXPAND_BYTE(b6) << 48) |
3539 (EXPAND_BYTE(b5) << 40) |
3540 (EXPAND_BYTE(b4) << 32) |
3541 (EXPAND_BYTE(b3) << 24) |
3542 (EXPAND_BYTE(b2) << 16) |
3543 (EXPAND_BYTE(b1) << 8) |
3548 /* data: {2{imm[7], ~imm[6], {5{imm[6]}}, imm[5:0], 19'0}} */
3552 b6 = (imm & 0x40) >> 6;
3553 b7 = (imm & 0x80) >> 7;
3555 t1 = (b7 << 6) | ((1-b6) << 5) | (uint64_t)(b6 ? 0x1f : 0);
3556 data = (t1 << 57) | (t0 << 51) | (t1 << 25) | (t0 << 19);
3560 /* data: {32'0, imm[7], ~{imm[6]}, 5{imm[6]}, imm[5:0], 19'0} */
3564 b6 = (imm & 0x40) >> 6;
3565 b7 = (imm & 0x80) >> 7;
3567 t1 = (b7 << 6) | ((1-b6) << 5) | (b6 ? 0x1f : 0);
3568 data = (t1 << 25) | (t0 << 19);
3572 /* data: {imm[7], ~imm[6], 8{imm[6]}, imm[5:0], 48'0} */
3576 b6 = (imm & 0x40) >> 6;
3577 b7 = (imm & 0x80) >> 7;
3579 t1 = (b7 << 9) | ((1-b6) << 8) | (b6 ? 0xff : 0);
3580 data = (t1 << 54) | (t0 << 48);
3584 generate_exception(ctx, EXCCODE_INE);
3585 g_assert_not_reached();
3590 static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
3595 if (!check_vec(ctx, oprsz)) {
3599 sel = (a->imm >> 12) & 0x1;
3602 value = vldi_get_value(ctx, a->imm);
3605 value = ((int32_t)(a->imm << 22)) >> 22;
3606 vece = (a->imm >> 10) & 0x3;
3609 tcg_gen_gvec_dup_i64(vece, vec_full_offset(a->vd), oprsz, ctx->vl/8,
3610 tcg_constant_i64(value));
3614 TRANS(vldi, LSX, gen_vldi, 16)
3615 TRANS(xvldi, LASX, gen_vldi, 32)
3617 static bool gen_vandn_v(DisasContext *ctx, arg_vvv *a, uint32_t oprsz)
3619 uint32_t vd_ofs, vj_ofs, vk_ofs;
3621 if (!check_vec(ctx, oprsz)) {
3625 vd_ofs = vec_full_offset(a->vd);
3626 vj_ofs = vec_full_offset(a->vj);
3627 vk_ofs = vec_full_offset(a->vk);
3629 tcg_gen_gvec_andc(MO_64, vd_ofs, vk_ofs, vj_ofs, oprsz, ctx->vl / 8);
3633 static void gen_vnori(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
3637 t1 = tcg_constant_vec_matching(t, vece, imm);
3638 tcg_gen_nor_vec(vece, t, a, t1);
3641 static void gen_vnori_b(TCGv_i64 t, TCGv_i64 a, int64_t imm)
3643 tcg_gen_movi_i64(t, dup_const(MO_8, imm));
3644 tcg_gen_nor_i64(t, a, t);
3647 static void do_vnori_b(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
3648 int64_t imm, uint32_t oprsz, uint32_t maxsz)
3650 static const TCGOpcode vecop_list[] = {
3653 static const GVecGen2i op = {
3654 .fni8 = gen_vnori_b,
3656 .fnoi = gen_helper_vnori_b,
3657 .opt_opc = vecop_list,
3661 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op);
3664 TRANS(vand_v, LSX, gvec_vvv, MO_64, tcg_gen_gvec_and)
3665 TRANS(vor_v, LSX, gvec_vvv, MO_64, tcg_gen_gvec_or)
3666 TRANS(vxor_v, LSX, gvec_vvv, MO_64, tcg_gen_gvec_xor)
3667 TRANS(vnor_v, LSX, gvec_vvv, MO_64, tcg_gen_gvec_nor)
3668 TRANS(vandn_v, LSX, gen_vandn_v, 16)
3669 TRANS(vorn_v, LSX, gvec_vvv, MO_64, tcg_gen_gvec_orc)
3670 TRANS(vandi_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_andi)
3671 TRANS(vori_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_ori)
3672 TRANS(vxori_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_xori)
3673 TRANS(vnori_b, LSX, gvec_vv_i, MO_8, do_vnori_b)
3674 TRANS(xvand_v, LASX, gvec_xxx, MO_64, tcg_gen_gvec_and)
3675 TRANS(xvor_v, LASX, gvec_xxx, MO_64, tcg_gen_gvec_or)
3676 TRANS(xvxor_v, LASX, gvec_xxx, MO_64, tcg_gen_gvec_xor)
3677 TRANS(xvnor_v, LASX, gvec_xxx, MO_64, tcg_gen_gvec_nor)
3678 TRANS(xvandn_v, LASX, gen_vandn_v, 32)
3679 TRANS(xvorn_v, LASX, gvec_xxx, MO_64, tcg_gen_gvec_orc)
3680 TRANS(xvandi_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_andi)
3681 TRANS(xvori_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_ori)
3682 TRANS(xvxori_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_xori)
3683 TRANS(xvnori_b, LASX, gvec_xx_i, MO_8, do_vnori_b)
3685 TRANS(vsll_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_shlv)
3686 TRANS(vsll_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_shlv)
3687 TRANS(vsll_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_shlv)
3688 TRANS(vsll_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_shlv)
3689 TRANS(vslli_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_shli)
3690 TRANS(vslli_h, LSX, gvec_vv_i, MO_16, tcg_gen_gvec_shli)
3691 TRANS(vslli_w, LSX, gvec_vv_i, MO_32, tcg_gen_gvec_shli)
3692 TRANS(vslli_d, LSX, gvec_vv_i, MO_64, tcg_gen_gvec_shli)
3693 TRANS(xvsll_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_shlv)
3694 TRANS(xvsll_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_shlv)
3695 TRANS(xvsll_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_shlv)
3696 TRANS(xvsll_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_shlv)
3697 TRANS(xvslli_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_shli)
3698 TRANS(xvslli_h, LASX, gvec_xx_i, MO_16, tcg_gen_gvec_shli)
3699 TRANS(xvslli_w, LASX, gvec_xx_i, MO_32, tcg_gen_gvec_shli)
3700 TRANS(xvslli_d, LASX, gvec_xx_i, MO_64, tcg_gen_gvec_shli)
3702 TRANS(vsrl_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_shrv)
3703 TRANS(vsrl_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_shrv)
3704 TRANS(vsrl_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_shrv)
3705 TRANS(vsrl_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_shrv)
3706 TRANS(vsrli_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_shri)
3707 TRANS(vsrli_h, LSX, gvec_vv_i, MO_16, tcg_gen_gvec_shri)
3708 TRANS(vsrli_w, LSX, gvec_vv_i, MO_32, tcg_gen_gvec_shri)
3709 TRANS(vsrli_d, LSX, gvec_vv_i, MO_64, tcg_gen_gvec_shri)
3710 TRANS(xvsrl_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_shrv)
3711 TRANS(xvsrl_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_shrv)
3712 TRANS(xvsrl_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_shrv)
3713 TRANS(xvsrl_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_shrv)
3714 TRANS(xvsrli_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_shri)
3715 TRANS(xvsrli_h, LASX, gvec_xx_i, MO_16, tcg_gen_gvec_shri)
3716 TRANS(xvsrli_w, LASX, gvec_xx_i, MO_32, tcg_gen_gvec_shri)
3717 TRANS(xvsrli_d, LASX, gvec_xx_i, MO_64, tcg_gen_gvec_shri)
3719 TRANS(vsra_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_sarv)
3720 TRANS(vsra_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_sarv)
3721 TRANS(vsra_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_sarv)
3722 TRANS(vsra_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_sarv)
3723 TRANS(vsrai_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_sari)
3724 TRANS(vsrai_h, LSX, gvec_vv_i, MO_16, tcg_gen_gvec_sari)
3725 TRANS(vsrai_w, LSX, gvec_vv_i, MO_32, tcg_gen_gvec_sari)
3726 TRANS(vsrai_d, LSX, gvec_vv_i, MO_64, tcg_gen_gvec_sari)
3727 TRANS(xvsra_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_sarv)
3728 TRANS(xvsra_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_sarv)
3729 TRANS(xvsra_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_sarv)
3730 TRANS(xvsra_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_sarv)
3731 TRANS(xvsrai_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_sari)
3732 TRANS(xvsrai_h, LASX, gvec_xx_i, MO_16, tcg_gen_gvec_sari)
3733 TRANS(xvsrai_w, LASX, gvec_xx_i, MO_32, tcg_gen_gvec_sari)
3734 TRANS(xvsrai_d, LASX, gvec_xx_i, MO_64, tcg_gen_gvec_sari)
3736 TRANS(vrotr_b, LSX, gvec_vvv, MO_8, tcg_gen_gvec_rotrv)
3737 TRANS(vrotr_h, LSX, gvec_vvv, MO_16, tcg_gen_gvec_rotrv)
3738 TRANS(vrotr_w, LSX, gvec_vvv, MO_32, tcg_gen_gvec_rotrv)
3739 TRANS(vrotr_d, LSX, gvec_vvv, MO_64, tcg_gen_gvec_rotrv)
3740 TRANS(vrotri_b, LSX, gvec_vv_i, MO_8, tcg_gen_gvec_rotri)
3741 TRANS(vrotri_h, LSX, gvec_vv_i, MO_16, tcg_gen_gvec_rotri)
3742 TRANS(vrotri_w, LSX, gvec_vv_i, MO_32, tcg_gen_gvec_rotri)
3743 TRANS(vrotri_d, LSX, gvec_vv_i, MO_64, tcg_gen_gvec_rotri)
3744 TRANS(xvrotr_b, LASX, gvec_xxx, MO_8, tcg_gen_gvec_rotrv)
3745 TRANS(xvrotr_h, LASX, gvec_xxx, MO_16, tcg_gen_gvec_rotrv)
3746 TRANS(xvrotr_w, LASX, gvec_xxx, MO_32, tcg_gen_gvec_rotrv)
3747 TRANS(xvrotr_d, LASX, gvec_xxx, MO_64, tcg_gen_gvec_rotrv)
3748 TRANS(xvrotri_b, LASX, gvec_xx_i, MO_8, tcg_gen_gvec_rotri)
3749 TRANS(xvrotri_h, LASX, gvec_xx_i, MO_16, tcg_gen_gvec_rotri)
3750 TRANS(xvrotri_w, LASX, gvec_xx_i, MO_32, tcg_gen_gvec_rotri)
3751 TRANS(xvrotri_d, LASX, gvec_xx_i, MO_64, tcg_gen_gvec_rotri)
3753 TRANS(vsllwil_h_b, LSX, gen_vv_i, gen_helper_vsllwil_h_b)
3754 TRANS(vsllwil_w_h, LSX, gen_vv_i, gen_helper_vsllwil_w_h)
3755 TRANS(vsllwil_d_w, LSX, gen_vv_i, gen_helper_vsllwil_d_w)
3756 TRANS(vextl_q_d, LSX, gen_vv, gen_helper_vextl_q_d)
3757 TRANS(vsllwil_hu_bu, LSX, gen_vv_i, gen_helper_vsllwil_hu_bu)
3758 TRANS(vsllwil_wu_hu, LSX, gen_vv_i, gen_helper_vsllwil_wu_hu)
3759 TRANS(vsllwil_du_wu, LSX, gen_vv_i, gen_helper_vsllwil_du_wu)
3760 TRANS(vextl_qu_du, LSX, gen_vv, gen_helper_vextl_qu_du)
3761 TRANS(xvsllwil_h_b, LASX, gen_xx_i, gen_helper_vsllwil_h_b)
3762 TRANS(xvsllwil_w_h, LASX, gen_xx_i, gen_helper_vsllwil_w_h)
3763 TRANS(xvsllwil_d_w, LASX, gen_xx_i, gen_helper_vsllwil_d_w)
3764 TRANS(xvextl_q_d, LASX, gen_xx, gen_helper_vextl_q_d)
3765 TRANS(xvsllwil_hu_bu, LASX, gen_xx_i, gen_helper_vsllwil_hu_bu)
3766 TRANS(xvsllwil_wu_hu, LASX, gen_xx_i, gen_helper_vsllwil_wu_hu)
3767 TRANS(xvsllwil_du_wu, LASX, gen_xx_i, gen_helper_vsllwil_du_wu)
3768 TRANS(xvextl_qu_du, LASX, gen_xx, gen_helper_vextl_qu_du)
3770 TRANS(vsrlr_b, LSX, gen_vvv, gen_helper_vsrlr_b)
3771 TRANS(vsrlr_h, LSX, gen_vvv, gen_helper_vsrlr_h)
3772 TRANS(vsrlr_w, LSX, gen_vvv, gen_helper_vsrlr_w)
3773 TRANS(vsrlr_d, LSX, gen_vvv, gen_helper_vsrlr_d)
3774 TRANS(vsrlri_b, LSX, gen_vv_i, gen_helper_vsrlri_b)
3775 TRANS(vsrlri_h, LSX, gen_vv_i, gen_helper_vsrlri_h)
3776 TRANS(vsrlri_w, LSX, gen_vv_i, gen_helper_vsrlri_w)
3777 TRANS(vsrlri_d, LSX, gen_vv_i, gen_helper_vsrlri_d)
3778 TRANS(xvsrlr_b, LASX, gen_xxx, gen_helper_vsrlr_b)
3779 TRANS(xvsrlr_h, LASX, gen_xxx, gen_helper_vsrlr_h)
3780 TRANS(xvsrlr_w, LASX, gen_xxx, gen_helper_vsrlr_w)
3781 TRANS(xvsrlr_d, LASX, gen_xxx, gen_helper_vsrlr_d)
3782 TRANS(xvsrlri_b, LASX, gen_xx_i, gen_helper_vsrlri_b)
3783 TRANS(xvsrlri_h, LASX, gen_xx_i, gen_helper_vsrlri_h)
3784 TRANS(xvsrlri_w, LASX, gen_xx_i, gen_helper_vsrlri_w)
3785 TRANS(xvsrlri_d, LASX, gen_xx_i, gen_helper_vsrlri_d)
3787 TRANS(vsrar_b, LSX, gen_vvv, gen_helper_vsrar_b)
3788 TRANS(vsrar_h, LSX, gen_vvv, gen_helper_vsrar_h)
3789 TRANS(vsrar_w, LSX, gen_vvv, gen_helper_vsrar_w)
3790 TRANS(vsrar_d, LSX, gen_vvv, gen_helper_vsrar_d)
3791 TRANS(vsrari_b, LSX, gen_vv_i, gen_helper_vsrari_b)
3792 TRANS(vsrari_h, LSX, gen_vv_i, gen_helper_vsrari_h)
3793 TRANS(vsrari_w, LSX, gen_vv_i, gen_helper_vsrari_w)
3794 TRANS(vsrari_d, LSX, gen_vv_i, gen_helper_vsrari_d)
3795 TRANS(xvsrar_b, LASX, gen_xxx, gen_helper_vsrar_b)
3796 TRANS(xvsrar_h, LASX, gen_xxx, gen_helper_vsrar_h)
3797 TRANS(xvsrar_w, LASX, gen_xxx, gen_helper_vsrar_w)
3798 TRANS(xvsrar_d, LASX, gen_xxx, gen_helper_vsrar_d)
3799 TRANS(xvsrari_b, LASX, gen_xx_i, gen_helper_vsrari_b)
3800 TRANS(xvsrari_h, LASX, gen_xx_i, gen_helper_vsrari_h)
3801 TRANS(xvsrari_w, LASX, gen_xx_i, gen_helper_vsrari_w)
3802 TRANS(xvsrari_d, LASX, gen_xx_i, gen_helper_vsrari_d)
3804 TRANS(vsrln_b_h, LSX, gen_vvv, gen_helper_vsrln_b_h)
3805 TRANS(vsrln_h_w, LSX, gen_vvv, gen_helper_vsrln_h_w)
3806 TRANS(vsrln_w_d, LSX, gen_vvv, gen_helper_vsrln_w_d)
3807 TRANS(vsran_b_h, LSX, gen_vvv, gen_helper_vsran_b_h)
3808 TRANS(vsran_h_w, LSX, gen_vvv, gen_helper_vsran_h_w)
3809 TRANS(vsran_w_d, LSX, gen_vvv, gen_helper_vsran_w_d)
3810 TRANS(xvsrln_b_h, LASX, gen_xxx, gen_helper_vsrln_b_h)
3811 TRANS(xvsrln_h_w, LASX, gen_xxx, gen_helper_vsrln_h_w)
3812 TRANS(xvsrln_w_d, LASX, gen_xxx, gen_helper_vsrln_w_d)
3813 TRANS(xvsran_b_h, LASX, gen_xxx, gen_helper_vsran_b_h)
3814 TRANS(xvsran_h_w, LASX, gen_xxx, gen_helper_vsran_h_w)
3815 TRANS(xvsran_w_d, LASX, gen_xxx, gen_helper_vsran_w_d)
3817 TRANS(vsrlni_b_h, LSX, gen_vv_i, gen_helper_vsrlni_b_h)
3818 TRANS(vsrlni_h_w, LSX, gen_vv_i, gen_helper_vsrlni_h_w)
3819 TRANS(vsrlni_w_d, LSX, gen_vv_i, gen_helper_vsrlni_w_d)
3820 TRANS(vsrlni_d_q, LSX, gen_vv_i, gen_helper_vsrlni_d_q)
3821 TRANS(vsrani_b_h, LSX, gen_vv_i, gen_helper_vsrani_b_h)
3822 TRANS(vsrani_h_w, LSX, gen_vv_i, gen_helper_vsrani_h_w)
3823 TRANS(vsrani_w_d, LSX, gen_vv_i, gen_helper_vsrani_w_d)
3824 TRANS(vsrani_d_q, LSX, gen_vv_i, gen_helper_vsrani_d_q)
3825 TRANS(xvsrlni_b_h, LASX, gen_xx_i, gen_helper_vsrlni_b_h)
3826 TRANS(xvsrlni_h_w, LASX, gen_xx_i, gen_helper_vsrlni_h_w)
3827 TRANS(xvsrlni_w_d, LASX, gen_xx_i, gen_helper_vsrlni_w_d)
3828 TRANS(xvsrlni_d_q, LASX, gen_xx_i, gen_helper_vsrlni_d_q)
3829 TRANS(xvsrani_b_h, LASX, gen_xx_i, gen_helper_vsrani_b_h)
3830 TRANS(xvsrani_h_w, LASX, gen_xx_i, gen_helper_vsrani_h_w)
3831 TRANS(xvsrani_w_d, LASX, gen_xx_i, gen_helper_vsrani_w_d)
3832 TRANS(xvsrani_d_q, LASX, gen_xx_i, gen_helper_vsrani_d_q)
3834 TRANS(vsrlrn_b_h, LSX, gen_vvv, gen_helper_vsrlrn_b_h)
3835 TRANS(vsrlrn_h_w, LSX, gen_vvv, gen_helper_vsrlrn_h_w)
3836 TRANS(vsrlrn_w_d, LSX, gen_vvv, gen_helper_vsrlrn_w_d)
3837 TRANS(vsrarn_b_h, LSX, gen_vvv, gen_helper_vsrarn_b_h)
3838 TRANS(vsrarn_h_w, LSX, gen_vvv, gen_helper_vsrarn_h_w)
3839 TRANS(vsrarn_w_d, LSX, gen_vvv, gen_helper_vsrarn_w_d)
3840 TRANS(xvsrlrn_b_h, LASX, gen_xxx, gen_helper_vsrlrn_b_h)
3841 TRANS(xvsrlrn_h_w, LASX, gen_xxx, gen_helper_vsrlrn_h_w)
3842 TRANS(xvsrlrn_w_d, LASX, gen_xxx, gen_helper_vsrlrn_w_d)
3843 TRANS(xvsrarn_b_h, LASX, gen_xxx, gen_helper_vsrarn_b_h)
3844 TRANS(xvsrarn_h_w, LASX, gen_xxx, gen_helper_vsrarn_h_w)
3845 TRANS(xvsrarn_w_d, LASX, gen_xxx, gen_helper_vsrarn_w_d)
3847 TRANS(vsrlrni_b_h, LSX, gen_vv_i, gen_helper_vsrlrni_b_h)
3848 TRANS(vsrlrni_h_w, LSX, gen_vv_i, gen_helper_vsrlrni_h_w)
3849 TRANS(vsrlrni_w_d, LSX, gen_vv_i, gen_helper_vsrlrni_w_d)
3850 TRANS(vsrlrni_d_q, LSX, gen_vv_i, gen_helper_vsrlrni_d_q)
3851 TRANS(vsrarni_b_h, LSX, gen_vv_i, gen_helper_vsrarni_b_h)
3852 TRANS(vsrarni_h_w, LSX, gen_vv_i, gen_helper_vsrarni_h_w)
3853 TRANS(vsrarni_w_d, LSX, gen_vv_i, gen_helper_vsrarni_w_d)
3854 TRANS(vsrarni_d_q, LSX, gen_vv_i, gen_helper_vsrarni_d_q)
3855 TRANS(xvsrlrni_b_h, LASX, gen_xx_i, gen_helper_vsrlrni_b_h)
3856 TRANS(xvsrlrni_h_w, LASX, gen_xx_i, gen_helper_vsrlrni_h_w)
3857 TRANS(xvsrlrni_w_d, LASX, gen_xx_i, gen_helper_vsrlrni_w_d)
3858 TRANS(xvsrlrni_d_q, LASX, gen_xx_i, gen_helper_vsrlrni_d_q)
3859 TRANS(xvsrarni_b_h, LASX, gen_xx_i, gen_helper_vsrarni_b_h)
3860 TRANS(xvsrarni_h_w, LASX, gen_xx_i, gen_helper_vsrarni_h_w)
3861 TRANS(xvsrarni_w_d, LASX, gen_xx_i, gen_helper_vsrarni_w_d)
3862 TRANS(xvsrarni_d_q, LASX, gen_xx_i, gen_helper_vsrarni_d_q)
3864 TRANS(vssrln_b_h, LSX, gen_vvv, gen_helper_vssrln_b_h)
3865 TRANS(vssrln_h_w, LSX, gen_vvv, gen_helper_vssrln_h_w)
3866 TRANS(vssrln_w_d, LSX, gen_vvv, gen_helper_vssrln_w_d)
3867 TRANS(vssran_b_h, LSX, gen_vvv, gen_helper_vssran_b_h)
3868 TRANS(vssran_h_w, LSX, gen_vvv, gen_helper_vssran_h_w)
3869 TRANS(vssran_w_d, LSX, gen_vvv, gen_helper_vssran_w_d)
3870 TRANS(vssrln_bu_h, LSX, gen_vvv, gen_helper_vssrln_bu_h)
3871 TRANS(vssrln_hu_w, LSX, gen_vvv, gen_helper_vssrln_hu_w)
3872 TRANS(vssrln_wu_d, LSX, gen_vvv, gen_helper_vssrln_wu_d)
3873 TRANS(vssran_bu_h, LSX, gen_vvv, gen_helper_vssran_bu_h)
3874 TRANS(vssran_hu_w, LSX, gen_vvv, gen_helper_vssran_hu_w)
3875 TRANS(vssran_wu_d, LSX, gen_vvv, gen_helper_vssran_wu_d)
3876 TRANS(xvssrln_b_h, LASX, gen_xxx, gen_helper_vssrln_b_h)
3877 TRANS(xvssrln_h_w, LASX, gen_xxx, gen_helper_vssrln_h_w)
3878 TRANS(xvssrln_w_d, LASX, gen_xxx, gen_helper_vssrln_w_d)
3879 TRANS(xvssran_b_h, LASX, gen_xxx, gen_helper_vssran_b_h)
3880 TRANS(xvssran_h_w, LASX, gen_xxx, gen_helper_vssran_h_w)
3881 TRANS(xvssran_w_d, LASX, gen_xxx, gen_helper_vssran_w_d)
3882 TRANS(xvssrln_bu_h, LASX, gen_xxx, gen_helper_vssrln_bu_h)
3883 TRANS(xvssrln_hu_w, LASX, gen_xxx, gen_helper_vssrln_hu_w)
3884 TRANS(xvssrln_wu_d, LASX, gen_xxx, gen_helper_vssrln_wu_d)
3885 TRANS(xvssran_bu_h, LASX, gen_xxx, gen_helper_vssran_bu_h)
3886 TRANS(xvssran_hu_w, LASX, gen_xxx, gen_helper_vssran_hu_w)
3887 TRANS(xvssran_wu_d, LASX, gen_xxx, gen_helper_vssran_wu_d)
3889 TRANS(vssrlni_b_h, LSX, gen_vv_i, gen_helper_vssrlni_b_h)
3890 TRANS(vssrlni_h_w, LSX, gen_vv_i, gen_helper_vssrlni_h_w)
3891 TRANS(vssrlni_w_d, LSX, gen_vv_i, gen_helper_vssrlni_w_d)
3892 TRANS(vssrlni_d_q, LSX, gen_vv_i, gen_helper_vssrlni_d_q)
3893 TRANS(vssrani_b_h, LSX, gen_vv_i, gen_helper_vssrani_b_h)
3894 TRANS(vssrani_h_w, LSX, gen_vv_i, gen_helper_vssrani_h_w)
3895 TRANS(vssrani_w_d, LSX, gen_vv_i, gen_helper_vssrani_w_d)
3896 TRANS(vssrani_d_q, LSX, gen_vv_i, gen_helper_vssrani_d_q)
3897 TRANS(vssrlni_bu_h, LSX, gen_vv_i, gen_helper_vssrlni_bu_h)
3898 TRANS(vssrlni_hu_w, LSX, gen_vv_i, gen_helper_vssrlni_hu_w)
3899 TRANS(vssrlni_wu_d, LSX, gen_vv_i, gen_helper_vssrlni_wu_d)
3900 TRANS(vssrlni_du_q, LSX, gen_vv_i, gen_helper_vssrlni_du_q)
3901 TRANS(vssrani_bu_h, LSX, gen_vv_i, gen_helper_vssrani_bu_h)
3902 TRANS(vssrani_hu_w, LSX, gen_vv_i, gen_helper_vssrani_hu_w)
3903 TRANS(vssrani_wu_d, LSX, gen_vv_i, gen_helper_vssrani_wu_d)
3904 TRANS(vssrani_du_q, LSX, gen_vv_i, gen_helper_vssrani_du_q)
3905 TRANS(xvssrlni_b_h, LASX, gen_xx_i, gen_helper_vssrlni_b_h)
3906 TRANS(xvssrlni_h_w, LASX, gen_xx_i, gen_helper_vssrlni_h_w)
3907 TRANS(xvssrlni_w_d, LASX, gen_xx_i, gen_helper_vssrlni_w_d)
3908 TRANS(xvssrlni_d_q, LASX, gen_xx_i, gen_helper_vssrlni_d_q)
3909 TRANS(xvssrani_b_h, LASX, gen_xx_i, gen_helper_vssrani_b_h)
3910 TRANS(xvssrani_h_w, LASX, gen_xx_i, gen_helper_vssrani_h_w)
3911 TRANS(xvssrani_w_d, LASX, gen_xx_i, gen_helper_vssrani_w_d)
3912 TRANS(xvssrani_d_q, LASX, gen_xx_i, gen_helper_vssrani_d_q)
3913 TRANS(xvssrlni_bu_h, LASX, gen_xx_i, gen_helper_vssrlni_bu_h)
3914 TRANS(xvssrlni_hu_w, LASX, gen_xx_i, gen_helper_vssrlni_hu_w)
3915 TRANS(xvssrlni_wu_d, LASX, gen_xx_i, gen_helper_vssrlni_wu_d)
3916 TRANS(xvssrlni_du_q, LASX, gen_xx_i, gen_helper_vssrlni_du_q)
3917 TRANS(xvssrani_bu_h, LASX, gen_xx_i, gen_helper_vssrani_bu_h)
3918 TRANS(xvssrani_hu_w, LASX, gen_xx_i, gen_helper_vssrani_hu_w)
3919 TRANS(xvssrani_wu_d, LASX, gen_xx_i, gen_helper_vssrani_wu_d)
3920 TRANS(xvssrani_du_q, LASX, gen_xx_i, gen_helper_vssrani_du_q)
3922 TRANS(vssrlrn_b_h, LSX, gen_vvv, gen_helper_vssrlrn_b_h)
3923 TRANS(vssrlrn_h_w, LSX, gen_vvv, gen_helper_vssrlrn_h_w)
3924 TRANS(vssrlrn_w_d, LSX, gen_vvv, gen_helper_vssrlrn_w_d)
3925 TRANS(vssrarn_b_h, LSX, gen_vvv, gen_helper_vssrarn_b_h)
3926 TRANS(vssrarn_h_w, LSX, gen_vvv, gen_helper_vssrarn_h_w)
3927 TRANS(vssrarn_w_d, LSX, gen_vvv, gen_helper_vssrarn_w_d)
3928 TRANS(vssrlrn_bu_h, LSX, gen_vvv, gen_helper_vssrlrn_bu_h)
3929 TRANS(vssrlrn_hu_w, LSX, gen_vvv, gen_helper_vssrlrn_hu_w)
3930 TRANS(vssrlrn_wu_d, LSX, gen_vvv, gen_helper_vssrlrn_wu_d)
3931 TRANS(vssrarn_bu_h, LSX, gen_vvv, gen_helper_vssrarn_bu_h)
3932 TRANS(vssrarn_hu_w, LSX, gen_vvv, gen_helper_vssrarn_hu_w)
3933 TRANS(vssrarn_wu_d, LSX, gen_vvv, gen_helper_vssrarn_wu_d)
3934 TRANS(xvssrlrn_b_h, LASX, gen_xxx, gen_helper_vssrlrn_b_h)
3935 TRANS(xvssrlrn_h_w, LASX, gen_xxx, gen_helper_vssrlrn_h_w)
3936 TRANS(xvssrlrn_w_d, LASX, gen_xxx, gen_helper_vssrlrn_w_d)
3937 TRANS(xvssrarn_b_h, LASX, gen_xxx, gen_helper_vssrarn_b_h)
3938 TRANS(xvssrarn_h_w, LASX, gen_xxx, gen_helper_vssrarn_h_w)
3939 TRANS(xvssrarn_w_d, LASX, gen_xxx, gen_helper_vssrarn_w_d)
3940 TRANS(xvssrlrn_bu_h, LASX, gen_xxx, gen_helper_vssrlrn_bu_h)
3941 TRANS(xvssrlrn_hu_w, LASX, gen_xxx, gen_helper_vssrlrn_hu_w)
3942 TRANS(xvssrlrn_wu_d, LASX, gen_xxx, gen_helper_vssrlrn_wu_d)
3943 TRANS(xvssrarn_bu_h, LASX, gen_xxx, gen_helper_vssrarn_bu_h)
3944 TRANS(xvssrarn_hu_w, LASX, gen_xxx, gen_helper_vssrarn_hu_w)
3945 TRANS(xvssrarn_wu_d, LASX, gen_xxx, gen_helper_vssrarn_wu_d)
3947 TRANS(vssrlrni_b_h, LSX, gen_vv_i, gen_helper_vssrlrni_b_h)
3948 TRANS(vssrlrni_h_w, LSX, gen_vv_i, gen_helper_vssrlrni_h_w)
3949 TRANS(vssrlrni_w_d, LSX, gen_vv_i, gen_helper_vssrlrni_w_d)
3950 TRANS(vssrlrni_d_q, LSX, gen_vv_i, gen_helper_vssrlrni_d_q)
3951 TRANS(vssrarni_b_h, LSX, gen_vv_i, gen_helper_vssrarni_b_h)
3952 TRANS(vssrarni_h_w, LSX, gen_vv_i, gen_helper_vssrarni_h_w)
3953 TRANS(vssrarni_w_d, LSX, gen_vv_i, gen_helper_vssrarni_w_d)
3954 TRANS(vssrarni_d_q, LSX, gen_vv_i, gen_helper_vssrarni_d_q)
3955 TRANS(vssrlrni_bu_h, LSX, gen_vv_i, gen_helper_vssrlrni_bu_h)
3956 TRANS(vssrlrni_hu_w, LSX, gen_vv_i, gen_helper_vssrlrni_hu_w)
3957 TRANS(vssrlrni_wu_d, LSX, gen_vv_i, gen_helper_vssrlrni_wu_d)
3958 TRANS(vssrlrni_du_q, LSX, gen_vv_i, gen_helper_vssrlrni_du_q)
3959 TRANS(vssrarni_bu_h, LSX, gen_vv_i, gen_helper_vssrarni_bu_h)
3960 TRANS(vssrarni_hu_w, LSX, gen_vv_i, gen_helper_vssrarni_hu_w)
3961 TRANS(vssrarni_wu_d, LSX, gen_vv_i, gen_helper_vssrarni_wu_d)
3962 TRANS(vssrarni_du_q, LSX, gen_vv_i, gen_helper_vssrarni_du_q)
3963 TRANS(xvssrlrni_b_h, LASX, gen_xx_i, gen_helper_vssrlrni_b_h)
3964 TRANS(xvssrlrni_h_w, LASX, gen_xx_i, gen_helper_vssrlrni_h_w)
3965 TRANS(xvssrlrni_w_d, LASX, gen_xx_i, gen_helper_vssrlrni_w_d)
3966 TRANS(xvssrlrni_d_q, LASX, gen_xx_i, gen_helper_vssrlrni_d_q)
3967 TRANS(xvssrarni_b_h, LASX, gen_xx_i, gen_helper_vssrarni_b_h)
3968 TRANS(xvssrarni_h_w, LASX, gen_xx_i, gen_helper_vssrarni_h_w)
3969 TRANS(xvssrarni_w_d, LASX, gen_xx_i, gen_helper_vssrarni_w_d)
3970 TRANS(xvssrarni_d_q, LASX, gen_xx_i, gen_helper_vssrarni_d_q)
3971 TRANS(xvssrlrni_bu_h, LASX, gen_xx_i, gen_helper_vssrlrni_bu_h)
3972 TRANS(xvssrlrni_hu_w, LASX, gen_xx_i, gen_helper_vssrlrni_hu_w)
3973 TRANS(xvssrlrni_wu_d, LASX, gen_xx_i, gen_helper_vssrlrni_wu_d)
3974 TRANS(xvssrlrni_du_q, LASX, gen_xx_i, gen_helper_vssrlrni_du_q)
3975 TRANS(xvssrarni_bu_h, LASX, gen_xx_i, gen_helper_vssrarni_bu_h)
3976 TRANS(xvssrarni_hu_w, LASX, gen_xx_i, gen_helper_vssrarni_hu_w)
3977 TRANS(xvssrarni_wu_d, LASX, gen_xx_i, gen_helper_vssrarni_wu_d)
3978 TRANS(xvssrarni_du_q, LASX, gen_xx_i, gen_helper_vssrarni_du_q)
3980 TRANS(vclo_b, LSX, gen_vv, gen_helper_vclo_b)
3981 TRANS(vclo_h, LSX, gen_vv, gen_helper_vclo_h)
3982 TRANS(vclo_w, LSX, gen_vv, gen_helper_vclo_w)
3983 TRANS(vclo_d, LSX, gen_vv, gen_helper_vclo_d)
3984 TRANS(vclz_b, LSX, gen_vv, gen_helper_vclz_b)
3985 TRANS(vclz_h, LSX, gen_vv, gen_helper_vclz_h)
3986 TRANS(vclz_w, LSX, gen_vv, gen_helper_vclz_w)
3987 TRANS(vclz_d, LSX, gen_vv, gen_helper_vclz_d)
3988 TRANS(xvclo_b, LASX, gen_xx, gen_helper_vclo_b)
3989 TRANS(xvclo_h, LASX, gen_xx, gen_helper_vclo_h)
3990 TRANS(xvclo_w, LASX, gen_xx, gen_helper_vclo_w)
3991 TRANS(xvclo_d, LASX, gen_xx, gen_helper_vclo_d)
3992 TRANS(xvclz_b, LASX, gen_xx, gen_helper_vclz_b)
3993 TRANS(xvclz_h, LASX, gen_xx, gen_helper_vclz_h)
3994 TRANS(xvclz_w, LASX, gen_xx, gen_helper_vclz_w)
3995 TRANS(xvclz_d, LASX, gen_xx, gen_helper_vclz_d)
3997 TRANS(vpcnt_b, LSX, gen_vv, gen_helper_vpcnt_b)
3998 TRANS(vpcnt_h, LSX, gen_vv, gen_helper_vpcnt_h)
3999 TRANS(vpcnt_w, LSX, gen_vv, gen_helper_vpcnt_w)
4000 TRANS(vpcnt_d, LSX, gen_vv, gen_helper_vpcnt_d)
4001 TRANS(xvpcnt_b, LASX, gen_xx, gen_helper_vpcnt_b)
4002 TRANS(xvpcnt_h, LASX, gen_xx, gen_helper_vpcnt_h)
4003 TRANS(xvpcnt_w, LASX, gen_xx, gen_helper_vpcnt_w)
4004 TRANS(xvpcnt_d, LASX, gen_xx, gen_helper_vpcnt_d)
4006 static void do_vbit(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b,
4007 void (*func)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec))
4009 TCGv_vec mask, lsh, t1, one;
4011 lsh = tcg_temp_new_vec_matching(t);
4012 t1 = tcg_temp_new_vec_matching(t);
4013 mask = tcg_constant_vec_matching(t, vece, (8 << vece) - 1);
4014 one = tcg_constant_vec_matching(t, vece, 1);
4016 tcg_gen_and_vec(vece, lsh, b, mask);
4017 tcg_gen_shlv_vec(vece, t1, one, lsh);
4018 func(vece, t, a, t1);
4021 static void gen_vbitclr(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
4023 do_vbit(vece, t, a, b, tcg_gen_andc_vec);
4026 static void gen_vbitset(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
4028 do_vbit(vece, t, a, b, tcg_gen_or_vec);
4031 static void gen_vbitrev(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
4033 do_vbit(vece, t, a, b, tcg_gen_xor_vec);
4036 static void do_vbitclr(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4037 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
4039 static const TCGOpcode vecop_list[] = {
4040 INDEX_op_shlv_vec, INDEX_op_andc_vec, 0
4042 static const GVecGen3 op[4] = {
4044 .fniv = gen_vbitclr,
4045 .fno = gen_helper_vbitclr_b,
4046 .opt_opc = vecop_list,
4050 .fniv = gen_vbitclr,
4051 .fno = gen_helper_vbitclr_h,
4052 .opt_opc = vecop_list,
4056 .fniv = gen_vbitclr,
4057 .fno = gen_helper_vbitclr_w,
4058 .opt_opc = vecop_list,
4062 .fniv = gen_vbitclr,
4063 .fno = gen_helper_vbitclr_d,
4064 .opt_opc = vecop_list,
4069 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
4072 TRANS(vbitclr_b, LSX, gvec_vvv, MO_8, do_vbitclr)
4073 TRANS(vbitclr_h, LSX, gvec_vvv, MO_16, do_vbitclr)
4074 TRANS(vbitclr_w, LSX, gvec_vvv, MO_32, do_vbitclr)
4075 TRANS(vbitclr_d, LSX, gvec_vvv, MO_64, do_vbitclr)
4076 TRANS(xvbitclr_b, LASX, gvec_xxx, MO_8, do_vbitclr)
4077 TRANS(xvbitclr_h, LASX, gvec_xxx, MO_16, do_vbitclr)
4078 TRANS(xvbitclr_w, LASX, gvec_xxx, MO_32, do_vbitclr)
4079 TRANS(xvbitclr_d, LASX, gvec_xxx, MO_64, do_vbitclr)
4081 static void do_vbiti(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm,
4082 void (*func)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec))
4087 lsh = imm & ((8 << vece) -1);
4088 t1 = tcg_temp_new_vec_matching(t);
4089 one = tcg_constant_vec_matching(t, vece, 1);
4091 tcg_gen_shli_vec(vece, t1, one, lsh);
4092 func(vece, t, a, t1);
4095 static void gen_vbitclri(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
4097 do_vbiti(vece, t, a, imm, tcg_gen_andc_vec);
4100 static void gen_vbitseti(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
4102 do_vbiti(vece, t, a, imm, tcg_gen_or_vec);
4105 static void gen_vbitrevi(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm)
4107 do_vbiti(vece, t, a, imm, tcg_gen_xor_vec);
4110 static void do_vbitclri(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4111 int64_t imm, uint32_t oprsz, uint32_t maxsz)
4113 static const TCGOpcode vecop_list[] = {
4114 INDEX_op_shli_vec, INDEX_op_andc_vec, 0
4116 static const GVecGen2i op[4] = {
4118 .fniv = gen_vbitclri,
4119 .fnoi = gen_helper_vbitclri_b,
4120 .opt_opc = vecop_list,
4124 .fniv = gen_vbitclri,
4125 .fnoi = gen_helper_vbitclri_h,
4126 .opt_opc = vecop_list,
4130 .fniv = gen_vbitclri,
4131 .fnoi = gen_helper_vbitclri_w,
4132 .opt_opc = vecop_list,
4136 .fniv = gen_vbitclri,
4137 .fnoi = gen_helper_vbitclri_d,
4138 .opt_opc = vecop_list,
4143 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
4146 TRANS(vbitclri_b, LSX, gvec_vv_i, MO_8, do_vbitclri)
4147 TRANS(vbitclri_h, LSX, gvec_vv_i, MO_16, do_vbitclri)
4148 TRANS(vbitclri_w, LSX, gvec_vv_i, MO_32, do_vbitclri)
4149 TRANS(vbitclri_d, LSX, gvec_vv_i, MO_64, do_vbitclri)
4150 TRANS(xvbitclri_b, LASX, gvec_xx_i, MO_8, do_vbitclri)
4151 TRANS(xvbitclri_h, LASX, gvec_xx_i, MO_16, do_vbitclri)
4152 TRANS(xvbitclri_w, LASX, gvec_xx_i, MO_32, do_vbitclri)
4153 TRANS(xvbitclri_d, LASX, gvec_xx_i, MO_64, do_vbitclri)
4155 static void do_vbitset(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4156 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
4158 static const TCGOpcode vecop_list[] = {
4159 INDEX_op_shlv_vec, 0
4161 static const GVecGen3 op[4] = {
4163 .fniv = gen_vbitset,
4164 .fno = gen_helper_vbitset_b,
4165 .opt_opc = vecop_list,
4169 .fniv = gen_vbitset,
4170 .fno = gen_helper_vbitset_h,
4171 .opt_opc = vecop_list,
4175 .fniv = gen_vbitset,
4176 .fno = gen_helper_vbitset_w,
4177 .opt_opc = vecop_list,
4181 .fniv = gen_vbitset,
4182 .fno = gen_helper_vbitset_d,
4183 .opt_opc = vecop_list,
4188 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
4191 TRANS(vbitset_b, LSX, gvec_vvv, MO_8, do_vbitset)
4192 TRANS(vbitset_h, LSX, gvec_vvv, MO_16, do_vbitset)
4193 TRANS(vbitset_w, LSX, gvec_vvv, MO_32, do_vbitset)
4194 TRANS(vbitset_d, LSX, gvec_vvv, MO_64, do_vbitset)
4195 TRANS(xvbitset_b, LASX, gvec_xxx, MO_8, do_vbitset)
4196 TRANS(xvbitset_h, LASX, gvec_xxx, MO_16, do_vbitset)
4197 TRANS(xvbitset_w, LASX, gvec_xxx, MO_32, do_vbitset)
4198 TRANS(xvbitset_d, LASX, gvec_xxx, MO_64, do_vbitset)
4200 static void do_vbitseti(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4201 int64_t imm, uint32_t oprsz, uint32_t maxsz)
4203 static const TCGOpcode vecop_list[] = {
4204 INDEX_op_shli_vec, 0
4206 static const GVecGen2i op[4] = {
4208 .fniv = gen_vbitseti,
4209 .fnoi = gen_helper_vbitseti_b,
4210 .opt_opc = vecop_list,
4214 .fniv = gen_vbitseti,
4215 .fnoi = gen_helper_vbitseti_h,
4216 .opt_opc = vecop_list,
4220 .fniv = gen_vbitseti,
4221 .fnoi = gen_helper_vbitseti_w,
4222 .opt_opc = vecop_list,
4226 .fniv = gen_vbitseti,
4227 .fnoi = gen_helper_vbitseti_d,
4228 .opt_opc = vecop_list,
4233 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
4236 TRANS(vbitseti_b, LSX, gvec_vv_i, MO_8, do_vbitseti)
4237 TRANS(vbitseti_h, LSX, gvec_vv_i, MO_16, do_vbitseti)
4238 TRANS(vbitseti_w, LSX, gvec_vv_i, MO_32, do_vbitseti)
4239 TRANS(vbitseti_d, LSX, gvec_vv_i, MO_64, do_vbitseti)
4240 TRANS(xvbitseti_b, LASX, gvec_xx_i, MO_8, do_vbitseti)
4241 TRANS(xvbitseti_h, LASX, gvec_xx_i, MO_16, do_vbitseti)
4242 TRANS(xvbitseti_w, LASX, gvec_xx_i, MO_32, do_vbitseti)
4243 TRANS(xvbitseti_d, LASX, gvec_xx_i, MO_64, do_vbitseti)
4245 static void do_vbitrev(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4246 uint32_t vk_ofs, uint32_t oprsz, uint32_t maxsz)
4248 static const TCGOpcode vecop_list[] = {
4249 INDEX_op_shlv_vec, 0
4251 static const GVecGen3 op[4] = {
4253 .fniv = gen_vbitrev,
4254 .fno = gen_helper_vbitrev_b,
4255 .opt_opc = vecop_list,
4259 .fniv = gen_vbitrev,
4260 .fno = gen_helper_vbitrev_h,
4261 .opt_opc = vecop_list,
4265 .fniv = gen_vbitrev,
4266 .fno = gen_helper_vbitrev_w,
4267 .opt_opc = vecop_list,
4271 .fniv = gen_vbitrev,
4272 .fno = gen_helper_vbitrev_d,
4273 .opt_opc = vecop_list,
4278 tcg_gen_gvec_3(vd_ofs, vj_ofs, vk_ofs, oprsz, maxsz, &op[vece]);
4281 TRANS(vbitrev_b, LSX, gvec_vvv, MO_8, do_vbitrev)
4282 TRANS(vbitrev_h, LSX, gvec_vvv, MO_16, do_vbitrev)
4283 TRANS(vbitrev_w, LSX, gvec_vvv, MO_32, do_vbitrev)
4284 TRANS(vbitrev_d, LSX, gvec_vvv, MO_64, do_vbitrev)
4285 TRANS(xvbitrev_b, LASX, gvec_xxx, MO_8, do_vbitrev)
4286 TRANS(xvbitrev_h, LASX, gvec_xxx, MO_16, do_vbitrev)
4287 TRANS(xvbitrev_w, LASX, gvec_xxx, MO_32, do_vbitrev)
4288 TRANS(xvbitrev_d, LASX, gvec_xxx, MO_64, do_vbitrev)
4290 static void do_vbitrevi(unsigned vece, uint32_t vd_ofs, uint32_t vj_ofs,
4291 int64_t imm, uint32_t oprsz, uint32_t maxsz)
4293 static const TCGOpcode vecop_list[] = {
4294 INDEX_op_shli_vec, 0
4296 static const GVecGen2i op[4] = {
4298 .fniv = gen_vbitrevi,
4299 .fnoi = gen_helper_vbitrevi_b,
4300 .opt_opc = vecop_list,
4304 .fniv = gen_vbitrevi,
4305 .fnoi = gen_helper_vbitrevi_h,
4306 .opt_opc = vecop_list,
4310 .fniv = gen_vbitrevi,
4311 .fnoi = gen_helper_vbitrevi_w,
4312 .opt_opc = vecop_list,
4316 .fniv = gen_vbitrevi,
4317 .fnoi = gen_helper_vbitrevi_d,
4318 .opt_opc = vecop_list,
4323 tcg_gen_gvec_2i(vd_ofs, vj_ofs, oprsz, maxsz, imm, &op[vece]);
4326 TRANS(vbitrevi_b, LSX, gvec_vv_i, MO_8, do_vbitrevi)
4327 TRANS(vbitrevi_h, LSX, gvec_vv_i, MO_16, do_vbitrevi)
4328 TRANS(vbitrevi_w, LSX, gvec_vv_i, MO_32, do_vbitrevi)
4329 TRANS(vbitrevi_d, LSX, gvec_vv_i, MO_64, do_vbitrevi)
4330 TRANS(xvbitrevi_b, LASX, gvec_xx_i, MO_8, do_vbitrevi)
4331 TRANS(xvbitrevi_h, LASX, gvec_xx_i, MO_16, do_vbitrevi)
4332 TRANS(xvbitrevi_w, LASX, gvec_xx_i, MO_32, do_vbitrevi)
4333 TRANS(xvbitrevi_d, LASX, gvec_xx_i, MO_64, do_vbitrevi)
4335 TRANS(vfrstp_b, LSX, gen_vvv, gen_helper_vfrstp_b)
4336 TRANS(vfrstp_h, LSX, gen_vvv, gen_helper_vfrstp_h)
4337 TRANS(vfrstpi_b, LSX, gen_vv_i, gen_helper_vfrstpi_b)
4338 TRANS(vfrstpi_h, LSX, gen_vv_i, gen_helper_vfrstpi_h)
4339 TRANS(xvfrstp_b, LASX, gen_xxx, gen_helper_vfrstp_b)
4340 TRANS(xvfrstp_h, LASX, gen_xxx, gen_helper_vfrstp_h)
4341 TRANS(xvfrstpi_b, LASX, gen_xx_i, gen_helper_vfrstpi_b)
4342 TRANS(xvfrstpi_h, LASX, gen_xx_i, gen_helper_vfrstpi_h)
4344 TRANS(vfadd_s, LSX, gen_vvv_ptr, gen_helper_vfadd_s)
4345 TRANS(vfadd_d, LSX, gen_vvv_ptr, gen_helper_vfadd_d)
4346 TRANS(vfsub_s, LSX, gen_vvv_ptr, gen_helper_vfsub_s)
4347 TRANS(vfsub_d, LSX, gen_vvv_ptr, gen_helper_vfsub_d)
4348 TRANS(vfmul_s, LSX, gen_vvv_ptr, gen_helper_vfmul_s)
4349 TRANS(vfmul_d, LSX, gen_vvv_ptr, gen_helper_vfmul_d)
4350 TRANS(vfdiv_s, LSX, gen_vvv_ptr, gen_helper_vfdiv_s)
4351 TRANS(vfdiv_d, LSX, gen_vvv_ptr, gen_helper_vfdiv_d)
4352 TRANS(xvfadd_s, LASX, gen_xxx_ptr, gen_helper_vfadd_s)
4353 TRANS(xvfadd_d, LASX, gen_xxx_ptr, gen_helper_vfadd_d)
4354 TRANS(xvfsub_s, LASX, gen_xxx_ptr, gen_helper_vfsub_s)
4355 TRANS(xvfsub_d, LASX, gen_xxx_ptr, gen_helper_vfsub_d)
4356 TRANS(xvfmul_s, LASX, gen_xxx_ptr, gen_helper_vfmul_s)
4357 TRANS(xvfmul_d, LASX, gen_xxx_ptr, gen_helper_vfmul_d)
4358 TRANS(xvfdiv_s, LASX, gen_xxx_ptr, gen_helper_vfdiv_s)
4359 TRANS(xvfdiv_d, LASX, gen_xxx_ptr, gen_helper_vfdiv_d)
4361 TRANS(vfmadd_s, LSX, gen_vvvv_ptr, gen_helper_vfmadd_s)
4362 TRANS(vfmadd_d, LSX, gen_vvvv_ptr, gen_helper_vfmadd_d)
4363 TRANS(vfmsub_s, LSX, gen_vvvv_ptr, gen_helper_vfmsub_s)
4364 TRANS(vfmsub_d, LSX, gen_vvvv_ptr, gen_helper_vfmsub_d)
4365 TRANS(vfnmadd_s, LSX, gen_vvvv_ptr, gen_helper_vfnmadd_s)
4366 TRANS(vfnmadd_d, LSX, gen_vvvv_ptr, gen_helper_vfnmadd_d)
4367 TRANS(vfnmsub_s, LSX, gen_vvvv_ptr, gen_helper_vfnmsub_s)
4368 TRANS(vfnmsub_d, LSX, gen_vvvv_ptr, gen_helper_vfnmsub_d)
4369 TRANS(xvfmadd_s, LASX, gen_xxxx_ptr, gen_helper_vfmadd_s)
4370 TRANS(xvfmadd_d, LASX, gen_xxxx_ptr, gen_helper_vfmadd_d)
4371 TRANS(xvfmsub_s, LASX, gen_xxxx_ptr, gen_helper_vfmsub_s)
4372 TRANS(xvfmsub_d, LASX, gen_xxxx_ptr, gen_helper_vfmsub_d)
4373 TRANS(xvfnmadd_s, LASX, gen_xxxx_ptr, gen_helper_vfnmadd_s)
4374 TRANS(xvfnmadd_d, LASX, gen_xxxx_ptr, gen_helper_vfnmadd_d)
4375 TRANS(xvfnmsub_s, LASX, gen_xxxx_ptr, gen_helper_vfnmsub_s)
4376 TRANS(xvfnmsub_d, LASX, gen_xxxx_ptr, gen_helper_vfnmsub_d)
4378 TRANS(vfmax_s, LSX, gen_vvv_ptr, gen_helper_vfmax_s)
4379 TRANS(vfmax_d, LSX, gen_vvv_ptr, gen_helper_vfmax_d)
4380 TRANS(vfmin_s, LSX, gen_vvv_ptr, gen_helper_vfmin_s)
4381 TRANS(vfmin_d, LSX, gen_vvv_ptr, gen_helper_vfmin_d)
4382 TRANS(xvfmax_s, LASX, gen_xxx_ptr, gen_helper_vfmax_s)
4383 TRANS(xvfmax_d, LASX, gen_xxx_ptr, gen_helper_vfmax_d)
4384 TRANS(xvfmin_s, LASX, gen_xxx_ptr, gen_helper_vfmin_s)
4385 TRANS(xvfmin_d, LASX, gen_xxx_ptr, gen_helper_vfmin_d)
4387 TRANS(vfmaxa_s, LSX, gen_vvv_ptr, gen_helper_vfmaxa_s)
4388 TRANS(vfmaxa_d, LSX, gen_vvv_ptr, gen_helper_vfmaxa_d)
4389 TRANS(vfmina_s, LSX, gen_vvv_ptr, gen_helper_vfmina_s)
4390 TRANS(vfmina_d, LSX, gen_vvv_ptr, gen_helper_vfmina_d)
4391 TRANS(xvfmaxa_s, LASX, gen_xxx_ptr, gen_helper_vfmaxa_s)
4392 TRANS(xvfmaxa_d, LASX, gen_xxx_ptr, gen_helper_vfmaxa_d)
4393 TRANS(xvfmina_s, LASX, gen_xxx_ptr, gen_helper_vfmina_s)
4394 TRANS(xvfmina_d, LASX, gen_xxx_ptr, gen_helper_vfmina_d)
4396 TRANS(vflogb_s, LSX, gen_vv_ptr, gen_helper_vflogb_s)
4397 TRANS(vflogb_d, LSX, gen_vv_ptr, gen_helper_vflogb_d)
4398 TRANS(xvflogb_s, LASX, gen_xx_ptr, gen_helper_vflogb_s)
4399 TRANS(xvflogb_d, LASX, gen_xx_ptr, gen_helper_vflogb_d)
4401 TRANS(vfclass_s, LSX, gen_vv_ptr, gen_helper_vfclass_s)
4402 TRANS(vfclass_d, LSX, gen_vv_ptr, gen_helper_vfclass_d)
4403 TRANS(xvfclass_s, LASX, gen_xx_ptr, gen_helper_vfclass_s)
4404 TRANS(xvfclass_d, LASX, gen_xx_ptr, gen_helper_vfclass_d)
4406 TRANS(vfsqrt_s, LSX, gen_vv_ptr, gen_helper_vfsqrt_s)
4407 TRANS(vfsqrt_d, LSX, gen_vv_ptr, gen_helper_vfsqrt_d)
4408 TRANS(vfrecip_s, LSX, gen_vv_ptr, gen_helper_vfrecip_s)
4409 TRANS(vfrecip_d, LSX, gen_vv_ptr, gen_helper_vfrecip_d)
4410 TRANS(vfrsqrt_s, LSX, gen_vv_ptr, gen_helper_vfrsqrt_s)
4411 TRANS(vfrsqrt_d, LSX, gen_vv_ptr, gen_helper_vfrsqrt_d)
4412 TRANS(xvfsqrt_s, LASX, gen_xx_ptr, gen_helper_vfsqrt_s)
4413 TRANS(xvfsqrt_d, LASX, gen_xx_ptr, gen_helper_vfsqrt_d)
4414 TRANS(xvfrecip_s, LASX, gen_xx_ptr, gen_helper_vfrecip_s)
4415 TRANS(xvfrecip_d, LASX, gen_xx_ptr, gen_helper_vfrecip_d)
4416 TRANS(xvfrsqrt_s, LASX, gen_xx_ptr, gen_helper_vfrsqrt_s)
4417 TRANS(xvfrsqrt_d, LASX, gen_xx_ptr, gen_helper_vfrsqrt_d)
4419 TRANS(vfcvtl_s_h, LSX, gen_vv_ptr, gen_helper_vfcvtl_s_h)
4420 TRANS(vfcvth_s_h, LSX, gen_vv_ptr, gen_helper_vfcvth_s_h)
4421 TRANS(vfcvtl_d_s, LSX, gen_vv_ptr, gen_helper_vfcvtl_d_s)
4422 TRANS(vfcvth_d_s, LSX, gen_vv_ptr, gen_helper_vfcvth_d_s)
4423 TRANS(vfcvt_h_s, LSX, gen_vvv_ptr, gen_helper_vfcvt_h_s)
4424 TRANS(vfcvt_s_d, LSX, gen_vvv_ptr, gen_helper_vfcvt_s_d)
4425 TRANS(xvfcvtl_s_h, LASX, gen_xx_ptr, gen_helper_vfcvtl_s_h)
4426 TRANS(xvfcvth_s_h, LASX, gen_xx_ptr, gen_helper_vfcvth_s_h)
4427 TRANS(xvfcvtl_d_s, LASX, gen_xx_ptr, gen_helper_vfcvtl_d_s)
4428 TRANS(xvfcvth_d_s, LASX, gen_xx_ptr, gen_helper_vfcvth_d_s)
4429 TRANS(xvfcvt_h_s, LASX, gen_xxx_ptr, gen_helper_vfcvt_h_s)
4430 TRANS(xvfcvt_s_d, LASX, gen_xxx_ptr, gen_helper_vfcvt_s_d)
4432 TRANS(vfrintrne_s, LSX, gen_vv_ptr, gen_helper_vfrintrne_s)
4433 TRANS(vfrintrne_d, LSX, gen_vv_ptr, gen_helper_vfrintrne_d)
4434 TRANS(vfrintrz_s, LSX, gen_vv_ptr, gen_helper_vfrintrz_s)
4435 TRANS(vfrintrz_d, LSX, gen_vv_ptr, gen_helper_vfrintrz_d)
4436 TRANS(vfrintrp_s, LSX, gen_vv_ptr, gen_helper_vfrintrp_s)
4437 TRANS(vfrintrp_d, LSX, gen_vv_ptr, gen_helper_vfrintrp_d)
4438 TRANS(vfrintrm_s, LSX, gen_vv_ptr, gen_helper_vfrintrm_s)
4439 TRANS(vfrintrm_d, LSX, gen_vv_ptr, gen_helper_vfrintrm_d)
4440 TRANS(vfrint_s, LSX, gen_vv_ptr, gen_helper_vfrint_s)
4441 TRANS(vfrint_d, LSX, gen_vv_ptr, gen_helper_vfrint_d)
4442 TRANS(xvfrintrne_s, LASX, gen_xx_ptr, gen_helper_vfrintrne_s)
4443 TRANS(xvfrintrne_d, LASX, gen_xx_ptr, gen_helper_vfrintrne_d)
4444 TRANS(xvfrintrz_s, LASX, gen_xx_ptr, gen_helper_vfrintrz_s)
4445 TRANS(xvfrintrz_d, LASX, gen_xx_ptr, gen_helper_vfrintrz_d)
4446 TRANS(xvfrintrp_s, LASX, gen_xx_ptr, gen_helper_vfrintrp_s)
4447 TRANS(xvfrintrp_d, LASX, gen_xx_ptr, gen_helper_vfrintrp_d)
4448 TRANS(xvfrintrm_s, LASX, gen_xx_ptr, gen_helper_vfrintrm_s)
4449 TRANS(xvfrintrm_d, LASX, gen_xx_ptr, gen_helper_vfrintrm_d)
4450 TRANS(xvfrint_s, LASX, gen_xx_ptr, gen_helper_vfrint_s)
4451 TRANS(xvfrint_d, LASX, gen_xx_ptr, gen_helper_vfrint_d)
4453 TRANS(vftintrne_w_s, LSX, gen_vv_ptr, gen_helper_vftintrne_w_s)
4454 TRANS(vftintrne_l_d, LSX, gen_vv_ptr, gen_helper_vftintrne_l_d)
4455 TRANS(vftintrz_w_s, LSX, gen_vv_ptr, gen_helper_vftintrz_w_s)
4456 TRANS(vftintrz_l_d, LSX, gen_vv_ptr, gen_helper_vftintrz_l_d)
4457 TRANS(vftintrp_w_s, LSX, gen_vv_ptr, gen_helper_vftintrp_w_s)
4458 TRANS(vftintrp_l_d, LSX, gen_vv_ptr, gen_helper_vftintrp_l_d)
4459 TRANS(vftintrm_w_s, LSX, gen_vv_ptr, gen_helper_vftintrm_w_s)
4460 TRANS(vftintrm_l_d, LSX, gen_vv_ptr, gen_helper_vftintrm_l_d)
4461 TRANS(vftint_w_s, LSX, gen_vv_ptr, gen_helper_vftint_w_s)
4462 TRANS(vftint_l_d, LSX, gen_vv_ptr, gen_helper_vftint_l_d)
4463 TRANS(vftintrz_wu_s, LSX, gen_vv_ptr, gen_helper_vftintrz_wu_s)
4464 TRANS(vftintrz_lu_d, LSX, gen_vv_ptr, gen_helper_vftintrz_lu_d)
4465 TRANS(vftint_wu_s, LSX, gen_vv_ptr, gen_helper_vftint_wu_s)
4466 TRANS(vftint_lu_d, LSX, gen_vv_ptr, gen_helper_vftint_lu_d)
4467 TRANS(vftintrne_w_d, LSX, gen_vvv_ptr, gen_helper_vftintrne_w_d)
4468 TRANS(vftintrz_w_d, LSX, gen_vvv_ptr, gen_helper_vftintrz_w_d)
4469 TRANS(vftintrp_w_d, LSX, gen_vvv_ptr, gen_helper_vftintrp_w_d)
4470 TRANS(vftintrm_w_d, LSX, gen_vvv_ptr, gen_helper_vftintrm_w_d)
4471 TRANS(vftint_w_d, LSX, gen_vvv_ptr, gen_helper_vftint_w_d)
4472 TRANS(vftintrnel_l_s, LSX, gen_vv_ptr, gen_helper_vftintrnel_l_s)
4473 TRANS(vftintrneh_l_s, LSX, gen_vv_ptr, gen_helper_vftintrneh_l_s)
4474 TRANS(vftintrzl_l_s, LSX, gen_vv_ptr, gen_helper_vftintrzl_l_s)
4475 TRANS(vftintrzh_l_s, LSX, gen_vv_ptr, gen_helper_vftintrzh_l_s)
4476 TRANS(vftintrpl_l_s, LSX, gen_vv_ptr, gen_helper_vftintrpl_l_s)
4477 TRANS(vftintrph_l_s, LSX, gen_vv_ptr, gen_helper_vftintrph_l_s)
4478 TRANS(vftintrml_l_s, LSX, gen_vv_ptr, gen_helper_vftintrml_l_s)
4479 TRANS(vftintrmh_l_s, LSX, gen_vv_ptr, gen_helper_vftintrmh_l_s)
4480 TRANS(vftintl_l_s, LSX, gen_vv_ptr, gen_helper_vftintl_l_s)
4481 TRANS(vftinth_l_s, LSX, gen_vv_ptr, gen_helper_vftinth_l_s)
4482 TRANS(xvftintrne_w_s, LASX, gen_xx_ptr, gen_helper_vftintrne_w_s)
4483 TRANS(xvftintrne_l_d, LASX, gen_xx_ptr, gen_helper_vftintrne_l_d)
4484 TRANS(xvftintrz_w_s, LASX, gen_xx_ptr, gen_helper_vftintrz_w_s)
4485 TRANS(xvftintrz_l_d, LASX, gen_xx_ptr, gen_helper_vftintrz_l_d)
4486 TRANS(xvftintrp_w_s, LASX, gen_xx_ptr, gen_helper_vftintrp_w_s)
4487 TRANS(xvftintrp_l_d, LASX, gen_xx_ptr, gen_helper_vftintrp_l_d)
4488 TRANS(xvftintrm_w_s, LASX, gen_xx_ptr, gen_helper_vftintrm_w_s)
4489 TRANS(xvftintrm_l_d, LASX, gen_xx_ptr, gen_helper_vftintrm_l_d)
4490 TRANS(xvftint_w_s, LASX, gen_xx_ptr, gen_helper_vftint_w_s)
4491 TRANS(xvftint_l_d, LASX, gen_xx_ptr, gen_helper_vftint_l_d)
4492 TRANS(xvftintrz_wu_s, LASX, gen_xx_ptr, gen_helper_vftintrz_wu_s)
4493 TRANS(xvftintrz_lu_d, LASX, gen_xx_ptr, gen_helper_vftintrz_lu_d)
4494 TRANS(xvftint_wu_s, LASX, gen_xx_ptr, gen_helper_vftint_wu_s)
4495 TRANS(xvftint_lu_d, LASX, gen_xx_ptr, gen_helper_vftint_lu_d)
4496 TRANS(xvftintrne_w_d, LASX, gen_xxx_ptr, gen_helper_vftintrne_w_d)
4497 TRANS(xvftintrz_w_d, LASX, gen_xxx_ptr, gen_helper_vftintrz_w_d)
4498 TRANS(xvftintrp_w_d, LASX, gen_xxx_ptr, gen_helper_vftintrp_w_d)
4499 TRANS(xvftintrm_w_d, LASX, gen_xxx_ptr, gen_helper_vftintrm_w_d)
4500 TRANS(xvftint_w_d, LASX, gen_xxx_ptr, gen_helper_vftint_w_d)
4501 TRANS(xvftintrnel_l_s, LASX, gen_xx_ptr, gen_helper_vftintrnel_l_s)
4502 TRANS(xvftintrneh_l_s, LASX, gen_xx_ptr, gen_helper_vftintrneh_l_s)
4503 TRANS(xvftintrzl_l_s, LASX, gen_xx_ptr, gen_helper_vftintrzl_l_s)
4504 TRANS(xvftintrzh_l_s, LASX, gen_xx_ptr, gen_helper_vftintrzh_l_s)
4505 TRANS(xvftintrpl_l_s, LASX, gen_xx_ptr, gen_helper_vftintrpl_l_s)
4506 TRANS(xvftintrph_l_s, LASX, gen_xx_ptr, gen_helper_vftintrph_l_s)
4507 TRANS(xvftintrml_l_s, LASX, gen_xx_ptr, gen_helper_vftintrml_l_s)
4508 TRANS(xvftintrmh_l_s, LASX, gen_xx_ptr, gen_helper_vftintrmh_l_s)
4509 TRANS(xvftintl_l_s, LASX, gen_xx_ptr, gen_helper_vftintl_l_s)
4510 TRANS(xvftinth_l_s, LASX, gen_xx_ptr, gen_helper_vftinth_l_s)
4512 TRANS(vffint_s_w, LSX, gen_vv_ptr, gen_helper_vffint_s_w)
4513 TRANS(vffint_d_l, LSX, gen_vv_ptr, gen_helper_vffint_d_l)
4514 TRANS(vffint_s_wu, LSX, gen_vv_ptr, gen_helper_vffint_s_wu)
4515 TRANS(vffint_d_lu, LSX, gen_vv_ptr, gen_helper_vffint_d_lu)
4516 TRANS(vffintl_d_w, LSX, gen_vv_ptr, gen_helper_vffintl_d_w)
4517 TRANS(vffinth_d_w, LSX, gen_vv_ptr, gen_helper_vffinth_d_w)
4518 TRANS(vffint_s_l, LSX, gen_vvv_ptr, gen_helper_vffint_s_l)
4519 TRANS(xvffint_s_w, LASX, gen_xx_ptr, gen_helper_vffint_s_w)
4520 TRANS(xvffint_d_l, LASX, gen_xx_ptr, gen_helper_vffint_d_l)
4521 TRANS(xvffint_s_wu, LASX, gen_xx_ptr, gen_helper_vffint_s_wu)
4522 TRANS(xvffint_d_lu, LASX, gen_xx_ptr, gen_helper_vffint_d_lu)
4523 TRANS(xvffintl_d_w, LASX, gen_xx_ptr, gen_helper_vffintl_d_w)
4524 TRANS(xvffinth_d_w, LASX, gen_xx_ptr, gen_helper_vffinth_d_w)
4525 TRANS(xvffint_s_l, LASX, gen_xxx_ptr, gen_helper_vffint_s_l)
4527 static bool do_cmp_vl(DisasContext *ctx, arg_vvv *a,
4528 uint32_t oprsz, MemOp mop, TCGCond cond)
4530 uint32_t vd_ofs, vj_ofs, vk_ofs;
4532 if (!check_vec(ctx, oprsz)) {
4536 vd_ofs = vec_full_offset(a->vd);
4537 vj_ofs = vec_full_offset(a->vj);
4538 vk_ofs = vec_full_offset(a->vk);
4540 tcg_gen_gvec_cmp(cond, mop, vd_ofs, vj_ofs, vk_ofs, oprsz, ctx->vl / 8);
4544 static bool do_cmp(DisasContext *ctx, arg_vvv *a,
4545 MemOp mop, TCGCond cond)
4547 return do_cmp_vl(ctx, a, 16, mop, cond);
4550 static bool do_xcmp(DisasContext *ctx, arg_vvv *a,
4551 MemOp mop, TCGCond cond)
4553 return do_cmp_vl(ctx, a, 32, mop, cond);
4556 static bool do_cmpi_vl(DisasContext *ctx, arg_vv_i *a,
4557 uint32_t oprsz, MemOp mop, TCGCond cond)
4559 uint32_t vd_ofs, vj_ofs;
4561 if (!check_vec(ctx, oprsz)) {
4565 vd_ofs = vec_full_offset(a->vd);
4566 vj_ofs = vec_full_offset(a->vj);
4568 tcg_gen_gvec_cmpi(cond, mop, vd_ofs, vj_ofs, a->imm, oprsz, ctx->vl / 8);
4572 static bool do_cmpi(DisasContext *ctx, arg_vv_i *a,
4573 MemOp mop, TCGCond cond)
4575 return do_cmpi_vl(ctx, a, 16, mop, cond);
4578 static bool do_xcmpi(DisasContext *ctx, arg_vv_i *a,
4579 MemOp mop, TCGCond cond)
4581 return do_cmpi_vl(ctx, a, 32, mop, cond);
4584 TRANS(vseq_b, LSX, do_cmp, MO_8, TCG_COND_EQ)
4585 TRANS(vseq_h, LSX, do_cmp, MO_16, TCG_COND_EQ)
4586 TRANS(vseq_w, LSX, do_cmp, MO_32, TCG_COND_EQ)
4587 TRANS(vseq_d, LSX, do_cmp, MO_64, TCG_COND_EQ)
4588 TRANS(vseqi_b, LSX, do_cmpi, MO_8, TCG_COND_EQ)
4589 TRANS(vseqi_h, LSX, do_cmpi, MO_16, TCG_COND_EQ)
4590 TRANS(vseqi_w, LSX, do_cmpi, MO_32, TCG_COND_EQ)
4591 TRANS(vseqi_d, LSX, do_cmpi, MO_64, TCG_COND_EQ)
4592 TRANS(xvseq_b, LASX, do_xcmp, MO_8, TCG_COND_EQ)
4593 TRANS(xvseq_h, LASX, do_xcmp, MO_16, TCG_COND_EQ)
4594 TRANS(xvseq_w, LASX, do_xcmp, MO_32, TCG_COND_EQ)
4595 TRANS(xvseq_d, LASX, do_xcmp, MO_64, TCG_COND_EQ)
4596 TRANS(xvseqi_b, LASX, do_xcmpi, MO_8, TCG_COND_EQ)
4597 TRANS(xvseqi_h, LASX, do_xcmpi, MO_16, TCG_COND_EQ)
4598 TRANS(xvseqi_w, LASX, do_xcmpi, MO_32, TCG_COND_EQ)
4599 TRANS(xvseqi_d, LASX, do_xcmpi, MO_64, TCG_COND_EQ)
4601 TRANS(vsle_b, LSX, do_cmp, MO_8, TCG_COND_LE)
4602 TRANS(vsle_h, LSX, do_cmp, MO_16, TCG_COND_LE)
4603 TRANS(vsle_w, LSX, do_cmp, MO_32, TCG_COND_LE)
4604 TRANS(vsle_d, LSX, do_cmp, MO_64, TCG_COND_LE)
4605 TRANS(vslei_b, LSX, do_cmpi, MO_8, TCG_COND_LE)
4606 TRANS(vslei_h, LSX, do_cmpi, MO_16, TCG_COND_LE)
4607 TRANS(vslei_w, LSX, do_cmpi, MO_32, TCG_COND_LE)
4608 TRANS(vslei_d, LSX, do_cmpi, MO_64, TCG_COND_LE)
4609 TRANS(vsle_bu, LSX, do_cmp, MO_8, TCG_COND_LEU)
4610 TRANS(vsle_hu, LSX, do_cmp, MO_16, TCG_COND_LEU)
4611 TRANS(vsle_wu, LSX, do_cmp, MO_32, TCG_COND_LEU)
4612 TRANS(vsle_du, LSX, do_cmp, MO_64, TCG_COND_LEU)
4613 TRANS(vslei_bu, LSX, do_cmpi, MO_8, TCG_COND_LEU)
4614 TRANS(vslei_hu, LSX, do_cmpi, MO_16, TCG_COND_LEU)
4615 TRANS(vslei_wu, LSX, do_cmpi, MO_32, TCG_COND_LEU)
4616 TRANS(vslei_du, LSX, do_cmpi, MO_64, TCG_COND_LEU)
4617 TRANS(xvsle_b, LASX, do_xcmp, MO_8, TCG_COND_LE)
4618 TRANS(xvsle_h, LASX, do_xcmp, MO_16, TCG_COND_LE)
4619 TRANS(xvsle_w, LASX, do_xcmp, MO_32, TCG_COND_LE)
4620 TRANS(xvsle_d, LASX, do_xcmp, MO_64, TCG_COND_LE)
4621 TRANS(xvslei_b, LASX, do_xcmpi, MO_8, TCG_COND_LE)
4622 TRANS(xvslei_h, LASX, do_xcmpi, MO_16, TCG_COND_LE)
4623 TRANS(xvslei_w, LASX, do_xcmpi, MO_32, TCG_COND_LE)
4624 TRANS(xvslei_d, LASX, do_xcmpi, MO_64, TCG_COND_LE)
4625 TRANS(xvsle_bu, LASX, do_xcmp, MO_8, TCG_COND_LEU)
4626 TRANS(xvsle_hu, LASX, do_xcmp, MO_16, TCG_COND_LEU)
4627 TRANS(xvsle_wu, LASX, do_xcmp, MO_32, TCG_COND_LEU)
4628 TRANS(xvsle_du, LASX, do_xcmp, MO_64, TCG_COND_LEU)
4629 TRANS(xvslei_bu, LASX, do_xcmpi, MO_8, TCG_COND_LEU)
4630 TRANS(xvslei_hu, LASX, do_xcmpi, MO_16, TCG_COND_LEU)
4631 TRANS(xvslei_wu, LASX, do_xcmpi, MO_32, TCG_COND_LEU)
4632 TRANS(xvslei_du, LASX, do_xcmpi, MO_64, TCG_COND_LEU)
4634 TRANS(vslt_b, LSX, do_cmp, MO_8, TCG_COND_LT)
4635 TRANS(vslt_h, LSX, do_cmp, MO_16, TCG_COND_LT)
4636 TRANS(vslt_w, LSX, do_cmp, MO_32, TCG_COND_LT)
4637 TRANS(vslt_d, LSX, do_cmp, MO_64, TCG_COND_LT)
4638 TRANS(vslti_b, LSX, do_cmpi, MO_8, TCG_COND_LT)
4639 TRANS(vslti_h, LSX, do_cmpi, MO_16, TCG_COND_LT)
4640 TRANS(vslti_w, LSX, do_cmpi, MO_32, TCG_COND_LT)
4641 TRANS(vslti_d, LSX, do_cmpi, MO_64, TCG_COND_LT)
4642 TRANS(vslt_bu, LSX, do_cmp, MO_8, TCG_COND_LTU)
4643 TRANS(vslt_hu, LSX, do_cmp, MO_16, TCG_COND_LTU)
4644 TRANS(vslt_wu, LSX, do_cmp, MO_32, TCG_COND_LTU)
4645 TRANS(vslt_du, LSX, do_cmp, MO_64, TCG_COND_LTU)
4646 TRANS(vslti_bu, LSX, do_cmpi, MO_8, TCG_COND_LTU)
4647 TRANS(vslti_hu, LSX, do_cmpi, MO_16, TCG_COND_LTU)
4648 TRANS(vslti_wu, LSX, do_cmpi, MO_32, TCG_COND_LTU)
4649 TRANS(vslti_du, LSX, do_cmpi, MO_64, TCG_COND_LTU)
4650 TRANS(xvslt_b, LASX, do_xcmp, MO_8, TCG_COND_LT)
4651 TRANS(xvslt_h, LASX, do_xcmp, MO_16, TCG_COND_LT)
4652 TRANS(xvslt_w, LASX, do_xcmp, MO_32, TCG_COND_LT)
4653 TRANS(xvslt_d, LASX, do_xcmp, MO_64, TCG_COND_LT)
4654 TRANS(xvslti_b, LASX, do_xcmpi, MO_8, TCG_COND_LT)
4655 TRANS(xvslti_h, LASX, do_xcmpi, MO_16, TCG_COND_LT)
4656 TRANS(xvslti_w, LASX, do_xcmpi, MO_32, TCG_COND_LT)
4657 TRANS(xvslti_d, LASX, do_xcmpi, MO_64, TCG_COND_LT)
4658 TRANS(xvslt_bu, LASX, do_xcmp, MO_8, TCG_COND_LTU)
4659 TRANS(xvslt_hu, LASX, do_xcmp, MO_16, TCG_COND_LTU)
4660 TRANS(xvslt_wu, LASX, do_xcmp, MO_32, TCG_COND_LTU)
4661 TRANS(xvslt_du, LASX, do_xcmp, MO_64, TCG_COND_LTU)
4662 TRANS(xvslti_bu, LASX, do_xcmpi, MO_8, TCG_COND_LTU)
4663 TRANS(xvslti_hu, LASX, do_xcmpi, MO_16, TCG_COND_LTU)
4664 TRANS(xvslti_wu, LASX, do_xcmpi, MO_32, TCG_COND_LTU)
4665 TRANS(xvslti_du, LASX, do_xcmpi, MO_64, TCG_COND_LTU)
4667 static bool do_vfcmp_cond_s(DisasContext *ctx, arg_vvv_fcond *a, uint32_t sz)
4670 void (*fn)(TCGv_env, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32);
4671 TCGv_i32 vd = tcg_constant_i32(a->vd);
4672 TCGv_i32 vj = tcg_constant_i32(a->vj);
4673 TCGv_i32 vk = tcg_constant_i32(a->vk);
4674 TCGv_i32 oprsz = tcg_constant_i32(sz);
4676 if (!check_vec(ctx, sz)) {
4680 fn = (a->fcond & 1 ? gen_helper_vfcmp_s_s : gen_helper_vfcmp_c_s);
4681 flags = get_fcmp_flags(a->fcond >> 1);
4682 fn(tcg_env, oprsz, vd, vj, vk, tcg_constant_i32(flags));
4687 static bool do_vfcmp_cond_d(DisasContext *ctx, arg_vvv_fcond *a, uint32_t sz)
4690 void (*fn)(TCGv_env, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32);
4691 TCGv_i32 vd = tcg_constant_i32(a->vd);
4692 TCGv_i32 vj = tcg_constant_i32(a->vj);
4693 TCGv_i32 vk = tcg_constant_i32(a->vk);
4694 TCGv_i32 oprsz = tcg_constant_i32(sz);
4696 if (!check_vec(ctx, sz)) {
4700 fn = (a->fcond & 1 ? gen_helper_vfcmp_s_d : gen_helper_vfcmp_c_d);
4701 flags = get_fcmp_flags(a->fcond >> 1);
4702 fn(tcg_env, oprsz, vd, vj, vk, tcg_constant_i32(flags));
4707 TRANS(vfcmp_cond_s, LSX, do_vfcmp_cond_s, 16)
4708 TRANS(vfcmp_cond_d, LSX, do_vfcmp_cond_d, 16)
4709 TRANS(xvfcmp_cond_s, LASX, do_vfcmp_cond_s, 32)
4710 TRANS(xvfcmp_cond_d, LASX, do_vfcmp_cond_d, 32)
4712 static bool do_vbitsel_v(DisasContext *ctx, arg_vvvv *a, uint32_t oprsz)
4714 if (!check_vec(ctx, oprsz)) {
4718 tcg_gen_gvec_bitsel(MO_64, vec_full_offset(a->vd), vec_full_offset(a->va),
4719 vec_full_offset(a->vk), vec_full_offset(a->vj),
4720 oprsz, ctx->vl / 8);
4724 TRANS(vbitsel_v, LSX, do_vbitsel_v, 16)
4725 TRANS(xvbitsel_v, LASX, do_vbitsel_v, 32)
4727 static void gen_vbitseli(unsigned vece, TCGv_vec a, TCGv_vec b, int64_t imm)
4729 tcg_gen_bitsel_vec(vece, a, a, tcg_constant_vec_matching(a, vece, imm), b);
4732 static bool do_vbitseli_b(DisasContext *ctx, arg_vv_i *a, uint32_t oprsz)
4734 static const GVecGen2i op = {
4735 .fniv = gen_vbitseli,
4736 .fnoi = gen_helper_vbitseli_b,
4741 if (!check_vec(ctx, oprsz)) {
4745 tcg_gen_gvec_2i(vec_full_offset(a->vd), vec_full_offset(a->vj),
4746 oprsz, ctx->vl / 8, a->imm , &op);
4750 TRANS(vbitseli_b, LSX, do_vbitseli_b, 16)
4751 TRANS(xvbitseli_b, LASX, do_vbitseli_b, 32)
4753 #define VSET(NAME, COND) \
4754 static bool trans_## NAME (DisasContext *ctx, arg_cv *a) \
4756 TCGv_i64 t1, al, ah; \
4758 al = tcg_temp_new_i64(); \
4759 ah = tcg_temp_new_i64(); \
4760 t1 = tcg_temp_new_i64(); \
4762 get_vreg64(ah, a->vj, 1); \
4763 get_vreg64(al, a->vj, 0); \
4765 if (!avail_LSX(ctx)) { \
4769 if (!check_vec(ctx, 16)) { \
4773 tcg_gen_or_i64(t1, al, ah); \
4774 tcg_gen_setcondi_i64(COND, t1, t1, 0); \
4775 tcg_gen_st8_tl(t1, tcg_env, offsetof(CPULoongArchState, cf[a->cd & 0x7])); \
4780 VSET(vseteqz_v, TCG_COND_EQ)
4781 VSET(vsetnez_v, TCG_COND_NE)
4783 TRANS(vsetanyeqz_b, LSX, gen_cv, gen_helper_vsetanyeqz_b)
4784 TRANS(vsetanyeqz_h, LSX, gen_cv, gen_helper_vsetanyeqz_h)
4785 TRANS(vsetanyeqz_w, LSX, gen_cv, gen_helper_vsetanyeqz_w)
4786 TRANS(vsetanyeqz_d, LSX, gen_cv, gen_helper_vsetanyeqz_d)
4787 TRANS(vsetallnez_b, LSX, gen_cv, gen_helper_vsetallnez_b)
4788 TRANS(vsetallnez_h, LSX, gen_cv, gen_helper_vsetallnez_h)
4789 TRANS(vsetallnez_w, LSX, gen_cv, gen_helper_vsetallnez_w)
4790 TRANS(vsetallnez_d, LSX, gen_cv, gen_helper_vsetallnez_d)
4792 #define XVSET(NAME, COND) \
4793 static bool trans_## NAME(DisasContext *ctx, arg_cv * a) \
4795 TCGv_i64 t1, t2, d[4]; \
4797 d[0] = tcg_temp_new_i64(); \
4798 d[1] = tcg_temp_new_i64(); \
4799 d[2] = tcg_temp_new_i64(); \
4800 d[3] = tcg_temp_new_i64(); \
4801 t1 = tcg_temp_new_i64(); \
4802 t2 = tcg_temp_new_i64(); \
4804 get_vreg64(d[0], a->vj, 0); \
4805 get_vreg64(d[1], a->vj, 1); \
4806 get_vreg64(d[2], a->vj, 2); \
4807 get_vreg64(d[3], a->vj, 3); \
4809 if (!avail_LASX(ctx)) { \
4813 if (!check_vec(ctx, 32)) { \
4817 tcg_gen_or_i64(t1, d[0], d[1]); \
4818 tcg_gen_or_i64(t2, d[2], d[3]); \
4819 tcg_gen_or_i64(t1, t2, t1); \
4820 tcg_gen_setcondi_i64(COND, t1, t1, 0); \
4821 tcg_gen_st8_tl(t1, tcg_env, offsetof(CPULoongArchState, cf[a->cd & 0x7])); \
4826 XVSET(xvseteqz_v, TCG_COND_EQ)
4827 XVSET(xvsetnez_v, TCG_COND_NE)
4829 TRANS(xvsetanyeqz_b, LASX, gen_cx, gen_helper_vsetanyeqz_b)
4830 TRANS(xvsetanyeqz_h, LASX, gen_cx, gen_helper_vsetanyeqz_h)
4831 TRANS(xvsetanyeqz_w, LASX, gen_cx, gen_helper_vsetanyeqz_w)
4832 TRANS(xvsetanyeqz_d, LASX, gen_cx, gen_helper_vsetanyeqz_d)
4833 TRANS(xvsetallnez_b, LASX, gen_cx, gen_helper_vsetallnez_b)
4834 TRANS(xvsetallnez_h, LASX, gen_cx, gen_helper_vsetallnez_h)
4835 TRANS(xvsetallnez_w, LASX, gen_cx, gen_helper_vsetallnez_w)
4836 TRANS(xvsetallnez_d, LASX, gen_cx, gen_helper_vsetallnez_d)
4838 static bool gen_g2v_vl(DisasContext *ctx, arg_vr_i *a, uint32_t oprsz, MemOp mop,
4839 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4841 TCGv src = gpr_src(ctx, a->rj, EXT_NONE);
4843 if (!check_vec(ctx, oprsz)) {
4847 func(src, tcg_env, vec_reg_offset(a->vd, a->imm, mop));
4852 static bool gen_g2v(DisasContext *ctx, arg_vr_i *a, MemOp mop,
4853 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4855 return gen_g2v_vl(ctx, a, 16, mop, func);
4858 static bool gen_g2x(DisasContext *ctx, arg_vr_i *a, MemOp mop,
4859 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4861 return gen_g2v_vl(ctx, a, 32, mop, func);
4864 TRANS(vinsgr2vr_b, LSX, gen_g2v, MO_8, tcg_gen_st8_i64)
4865 TRANS(vinsgr2vr_h, LSX, gen_g2v, MO_16, tcg_gen_st16_i64)
4866 TRANS(vinsgr2vr_w, LSX, gen_g2v, MO_32, tcg_gen_st32_i64)
4867 TRANS(vinsgr2vr_d, LSX, gen_g2v, MO_64, tcg_gen_st_i64)
4868 TRANS(xvinsgr2vr_w, LASX, gen_g2x, MO_32, tcg_gen_st32_i64)
4869 TRANS(xvinsgr2vr_d, LASX, gen_g2x, MO_64, tcg_gen_st_i64)
4871 static bool gen_v2g_vl(DisasContext *ctx, arg_rv_i *a, uint32_t oprsz, MemOp mop,
4872 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4874 TCGv dst = gpr_dst(ctx, a->rd, EXT_NONE);
4876 if (!check_vec(ctx, oprsz)) {
4880 func(dst, tcg_env, vec_reg_offset(a->vj, a->imm, mop));
4885 static bool gen_v2g(DisasContext *ctx, arg_rv_i *a, MemOp mop,
4886 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4888 return gen_v2g_vl(ctx, a, 16, mop, func);
4891 static bool gen_x2g(DisasContext *ctx, arg_rv_i *a, MemOp mop,
4892 void (*func)(TCGv, TCGv_ptr, tcg_target_long))
4894 return gen_v2g_vl(ctx, a, 32, mop, func);
4897 TRANS(vpickve2gr_b, LSX, gen_v2g, MO_8, tcg_gen_ld8s_i64)
4898 TRANS(vpickve2gr_h, LSX, gen_v2g, MO_16, tcg_gen_ld16s_i64)
4899 TRANS(vpickve2gr_w, LSX, gen_v2g, MO_32, tcg_gen_ld32s_i64)
4900 TRANS(vpickve2gr_d, LSX, gen_v2g, MO_64, tcg_gen_ld_i64)
4901 TRANS(vpickve2gr_bu, LSX, gen_v2g, MO_8, tcg_gen_ld8u_i64)
4902 TRANS(vpickve2gr_hu, LSX, gen_v2g, MO_16, tcg_gen_ld16u_i64)
4903 TRANS(vpickve2gr_wu, LSX, gen_v2g, MO_32, tcg_gen_ld32u_i64)
4904 TRANS(vpickve2gr_du, LSX, gen_v2g, MO_64, tcg_gen_ld_i64)
4905 TRANS(xvpickve2gr_w, LASX, gen_x2g, MO_32, tcg_gen_ld32s_i64)
4906 TRANS(xvpickve2gr_d, LASX, gen_x2g, MO_64, tcg_gen_ld_i64)
4907 TRANS(xvpickve2gr_wu, LASX, gen_x2g, MO_32, tcg_gen_ld32u_i64)
4908 TRANS(xvpickve2gr_du, LASX, gen_x2g, MO_64, tcg_gen_ld_i64)
4910 static bool gvec_dup_vl(DisasContext *ctx, arg_vr *a,
4911 uint32_t oprsz, MemOp mop)
4913 TCGv src = gpr_src(ctx, a->rj, EXT_NONE);
4915 if (!check_vec(ctx, oprsz)) {
4919 tcg_gen_gvec_dup_i64(mop, vec_full_offset(a->vd),
4920 oprsz, ctx->vl/8, src);
4924 static bool gvec_dup(DisasContext *ctx, arg_vr *a, MemOp mop)
4926 return gvec_dup_vl(ctx, a, 16, mop);
4929 static bool gvec_dupx(DisasContext *ctx, arg_vr *a, MemOp mop)
4931 return gvec_dup_vl(ctx, a, 32, mop);
4934 TRANS(vreplgr2vr_b, LSX, gvec_dup, MO_8)
4935 TRANS(vreplgr2vr_h, LSX, gvec_dup, MO_16)
4936 TRANS(vreplgr2vr_w, LSX, gvec_dup, MO_32)
4937 TRANS(vreplgr2vr_d, LSX, gvec_dup, MO_64)
4938 TRANS(xvreplgr2vr_b, LASX, gvec_dupx, MO_8)
4939 TRANS(xvreplgr2vr_h, LASX, gvec_dupx, MO_16)
4940 TRANS(xvreplgr2vr_w, LASX, gvec_dupx, MO_32)
4941 TRANS(xvreplgr2vr_d, LASX, gvec_dupx, MO_64)
4943 static bool trans_vreplvei_b(DisasContext *ctx, arg_vv_i *a)
4945 if (!avail_LSX(ctx)) {
4949 if (!check_vec(ctx, 16)) {
4953 tcg_gen_gvec_dup_mem(MO_8,vec_full_offset(a->vd),
4954 offsetof(CPULoongArchState,
4955 fpr[a->vj].vreg.B((a->imm))),
4960 static bool trans_vreplvei_h(DisasContext *ctx, arg_vv_i *a)
4962 if (!avail_LSX(ctx)) {
4966 if (!check_vec(ctx, 16)) {
4970 tcg_gen_gvec_dup_mem(MO_16, vec_full_offset(a->vd),
4971 offsetof(CPULoongArchState,
4972 fpr[a->vj].vreg.H((a->imm))),
4976 static bool trans_vreplvei_w(DisasContext *ctx, arg_vv_i *a)
4978 if (!avail_LSX(ctx)) {
4982 if (!check_vec(ctx, 16)) {
4986 tcg_gen_gvec_dup_mem(MO_32, vec_full_offset(a->vd),
4987 offsetof(CPULoongArchState,
4988 fpr[a->vj].vreg.W((a->imm))),
4992 static bool trans_vreplvei_d(DisasContext *ctx, arg_vv_i *a)
4994 if (!avail_LSX(ctx)) {
4998 if (!check_vec(ctx, 16)) {
5002 tcg_gen_gvec_dup_mem(MO_64, vec_full_offset(a->vd),
5003 offsetof(CPULoongArchState,
5004 fpr[a->vj].vreg.D((a->imm))),
5009 static bool gen_vreplve_vl(DisasContext *ctx, arg_vvr *a,
5010 uint32_t oprsz, int vece, int bit,
5011 void (*func)(TCGv_i64, TCGv_ptr, tcg_target_long))
5014 TCGv_i64 t0 = tcg_temp_new_i64();
5015 TCGv_ptr t1 = tcg_temp_new_ptr();
5016 TCGv_i64 t2 = tcg_temp_new_i64();
5018 if (!check_vec(ctx, oprsz)) {
5022 tcg_gen_andi_i64(t0, gpr_src(ctx, a->rk, EXT_NONE), (LSX_LEN / bit) - 1);
5023 tcg_gen_shli_i64(t0, t0, vece);
5024 if (HOST_BIG_ENDIAN) {
5025 tcg_gen_xori_i64(t0, t0, vece << ((LSX_LEN / bit) - 1));
5028 tcg_gen_trunc_i64_ptr(t1, t0);
5029 tcg_gen_add_ptr(t1, t1, tcg_env);
5031 for (i = 0; i < oprsz; i += 16) {
5032 func(t2, t1, vec_full_offset(a->vj) + i);
5033 tcg_gen_gvec_dup_i64(vece, vec_full_offset(a->vd) + i, 16, 16, t2);
5039 static bool gen_vreplve(DisasContext *ctx, arg_vvr *a, int vece, int bit,
5040 void (*func)(TCGv_i64, TCGv_ptr, tcg_target_long))
5042 return gen_vreplve_vl(ctx, a, 16, vece, bit, func);
5045 static bool gen_xvreplve(DisasContext *ctx, arg_vvr *a, int vece, int bit,
5046 void (*func)(TCGv_i64, TCGv_ptr, tcg_target_long))
5048 return gen_vreplve_vl(ctx, a, 32, vece, bit, func);
5051 TRANS(vreplve_b, LSX, gen_vreplve, MO_8, 8, tcg_gen_ld8u_i64)
5052 TRANS(vreplve_h, LSX, gen_vreplve, MO_16, 16, tcg_gen_ld16u_i64)
5053 TRANS(vreplve_w, LSX, gen_vreplve, MO_32, 32, tcg_gen_ld32u_i64)
5054 TRANS(vreplve_d, LSX, gen_vreplve, MO_64, 64, tcg_gen_ld_i64)
5055 TRANS(xvreplve_b, LASX, gen_xvreplve, MO_8, 8, tcg_gen_ld8u_i64)
5056 TRANS(xvreplve_h, LASX, gen_xvreplve, MO_16, 16, tcg_gen_ld16u_i64)
5057 TRANS(xvreplve_w, LASX, gen_xvreplve, MO_32, 32, tcg_gen_ld32u_i64)
5058 TRANS(xvreplve_d, LASX, gen_xvreplve, MO_64, 64, tcg_gen_ld_i64)
5060 static bool gen_xvrepl128(DisasContext *ctx, arg_vv_i *a, MemOp mop)
5064 if (!check_vec(ctx, 32)) {
5068 for (i = 0; i < 32; i += 16) {
5069 tcg_gen_gvec_dup_mem(mop, vec_full_offset(a->vd) + i,
5070 vec_reg_offset(a->vj, a->imm, mop) + i, 16, 16);
5076 TRANS(xvrepl128vei_b, LASX, gen_xvrepl128, MO_8)
5077 TRANS(xvrepl128vei_h, LASX, gen_xvrepl128, MO_16)
5078 TRANS(xvrepl128vei_w, LASX, gen_xvrepl128, MO_32)
5079 TRANS(xvrepl128vei_d, LASX, gen_xvrepl128, MO_64)
5081 static bool gen_xvreplve0(DisasContext *ctx, arg_vv *a, MemOp mop)
5083 if (!check_vec(ctx, 32)) {
5087 tcg_gen_gvec_dup_mem(mop, vec_full_offset(a->vd),
5088 vec_full_offset(a->vj), 32, 32);
5092 TRANS(xvreplve0_b, LASX, gen_xvreplve0, MO_8)
5093 TRANS(xvreplve0_h, LASX, gen_xvreplve0, MO_16)
5094 TRANS(xvreplve0_w, LASX, gen_xvreplve0, MO_32)
5095 TRANS(xvreplve0_d, LASX, gen_xvreplve0, MO_64)
5096 TRANS(xvreplve0_q, LASX, gen_xvreplve0, MO_128)
5098 TRANS(xvinsve0_w, LASX, gen_xx_i, gen_helper_xvinsve0_w)
5099 TRANS(xvinsve0_d, LASX, gen_xx_i, gen_helper_xvinsve0_d)
5101 TRANS(xvpickve_w, LASX, gen_xx_i, gen_helper_xvpickve_w)
5102 TRANS(xvpickve_d, LASX, gen_xx_i, gen_helper_xvpickve_d)
5104 static bool do_vbsll_v(DisasContext *ctx, arg_vv_i *a, uint32_t oprsz)
5108 if (!check_vec(ctx, oprsz)) {
5112 for (i = 0; i < oprsz / 16; i++) {
5113 TCGv desthigh = tcg_temp_new_i64();
5114 TCGv destlow = tcg_temp_new_i64();
5115 TCGv high = tcg_temp_new_i64();
5116 TCGv low = tcg_temp_new_i64();
5118 get_vreg64(low, a->vj, 2 * i);
5120 ofs = ((a->imm) & 0xf) * 8;
5122 get_vreg64(high, a->vj, 2 * i + 1);
5123 tcg_gen_extract2_i64(desthigh, low, high, 64 - ofs);
5124 tcg_gen_shli_i64(destlow, low, ofs);
5126 tcg_gen_shli_i64(desthigh, low, ofs - 64);
5127 destlow = tcg_constant_i64(0);
5129 set_vreg64(desthigh, a->vd, 2 * i + 1);
5130 set_vreg64(destlow, a->vd, 2 * i);
5136 static bool do_vbsrl_v(DisasContext *ctx, arg_vv_i *a, uint32_t oprsz)
5140 if (!check_vec(ctx, 32)) {
5144 for (i = 0; i < oprsz / 16; i++) {
5145 TCGv desthigh = tcg_temp_new_i64();
5146 TCGv destlow = tcg_temp_new_i64();
5147 TCGv high = tcg_temp_new_i64();
5148 TCGv low = tcg_temp_new_i64();
5149 get_vreg64(high, a->vj, 2 * i + 1);
5151 ofs = ((a->imm) & 0xf) * 8;
5153 get_vreg64(low, a->vj, 2 * i);
5154 tcg_gen_extract2_i64(destlow, low, high, ofs);
5155 tcg_gen_shri_i64(desthigh, high, ofs);
5157 tcg_gen_shri_i64(destlow, high, ofs - 64);
5158 desthigh = tcg_constant_i64(0);
5160 set_vreg64(desthigh, a->vd, 2 * i + 1);
5161 set_vreg64(destlow, a->vd, 2 * i);
5167 TRANS(vbsll_v, LSX, do_vbsll_v, 16)
5168 TRANS(vbsrl_v, LSX, do_vbsrl_v, 16)
5169 TRANS(xvbsll_v, LASX, do_vbsll_v, 32)
5170 TRANS(xvbsrl_v, LASX, do_vbsrl_v, 32)
5172 TRANS(vpackev_b, LSX, gen_vvv, gen_helper_vpackev_b)
5173 TRANS(vpackev_h, LSX, gen_vvv, gen_helper_vpackev_h)
5174 TRANS(vpackev_w, LSX, gen_vvv, gen_helper_vpackev_w)
5175 TRANS(vpackev_d, LSX, gen_vvv, gen_helper_vpackev_d)
5176 TRANS(vpackod_b, LSX, gen_vvv, gen_helper_vpackod_b)
5177 TRANS(vpackod_h, LSX, gen_vvv, gen_helper_vpackod_h)
5178 TRANS(vpackod_w, LSX, gen_vvv, gen_helper_vpackod_w)
5179 TRANS(vpackod_d, LSX, gen_vvv, gen_helper_vpackod_d)
5180 TRANS(xvpackev_b, LASX, gen_xxx, gen_helper_vpackev_b)
5181 TRANS(xvpackev_h, LASX, gen_xxx, gen_helper_vpackev_h)
5182 TRANS(xvpackev_w, LASX, gen_xxx, gen_helper_vpackev_w)
5183 TRANS(xvpackev_d, LASX, gen_xxx, gen_helper_vpackev_d)
5184 TRANS(xvpackod_b, LASX, gen_xxx, gen_helper_vpackod_b)
5185 TRANS(xvpackod_h, LASX, gen_xxx, gen_helper_vpackod_h)
5186 TRANS(xvpackod_w, LASX, gen_xxx, gen_helper_vpackod_w)
5187 TRANS(xvpackod_d, LASX, gen_xxx, gen_helper_vpackod_d)
5189 TRANS(vpickev_b, LSX, gen_vvv, gen_helper_vpickev_b)
5190 TRANS(vpickev_h, LSX, gen_vvv, gen_helper_vpickev_h)
5191 TRANS(vpickev_w, LSX, gen_vvv, gen_helper_vpickev_w)
5192 TRANS(vpickev_d, LSX, gen_vvv, gen_helper_vpickev_d)
5193 TRANS(vpickod_b, LSX, gen_vvv, gen_helper_vpickod_b)
5194 TRANS(vpickod_h, LSX, gen_vvv, gen_helper_vpickod_h)
5195 TRANS(vpickod_w, LSX, gen_vvv, gen_helper_vpickod_w)
5196 TRANS(vpickod_d, LSX, gen_vvv, gen_helper_vpickod_d)
5197 TRANS(xvpickev_b, LASX, gen_xxx, gen_helper_vpickev_b)
5198 TRANS(xvpickev_h, LASX, gen_xxx, gen_helper_vpickev_h)
5199 TRANS(xvpickev_w, LASX, gen_xxx, gen_helper_vpickev_w)
5200 TRANS(xvpickev_d, LASX, gen_xxx, gen_helper_vpickev_d)
5201 TRANS(xvpickod_b, LASX, gen_xxx, gen_helper_vpickod_b)
5202 TRANS(xvpickod_h, LASX, gen_xxx, gen_helper_vpickod_h)
5203 TRANS(xvpickod_w, LASX, gen_xxx, gen_helper_vpickod_w)
5204 TRANS(xvpickod_d, LASX, gen_xxx, gen_helper_vpickod_d)
5206 TRANS(vilvl_b, LSX, gen_vvv, gen_helper_vilvl_b)
5207 TRANS(vilvl_h, LSX, gen_vvv, gen_helper_vilvl_h)
5208 TRANS(vilvl_w, LSX, gen_vvv, gen_helper_vilvl_w)
5209 TRANS(vilvl_d, LSX, gen_vvv, gen_helper_vilvl_d)
5210 TRANS(vilvh_b, LSX, gen_vvv, gen_helper_vilvh_b)
5211 TRANS(vilvh_h, LSX, gen_vvv, gen_helper_vilvh_h)
5212 TRANS(vilvh_w, LSX, gen_vvv, gen_helper_vilvh_w)
5213 TRANS(vilvh_d, LSX, gen_vvv, gen_helper_vilvh_d)
5214 TRANS(xvilvl_b, LASX, gen_xxx, gen_helper_vilvl_b)
5215 TRANS(xvilvl_h, LASX, gen_xxx, gen_helper_vilvl_h)
5216 TRANS(xvilvl_w, LASX, gen_xxx, gen_helper_vilvl_w)
5217 TRANS(xvilvl_d, LASX, gen_xxx, gen_helper_vilvl_d)
5218 TRANS(xvilvh_b, LASX, gen_xxx, gen_helper_vilvh_b)
5219 TRANS(xvilvh_h, LASX, gen_xxx, gen_helper_vilvh_h)
5220 TRANS(xvilvh_w, LASX, gen_xxx, gen_helper_vilvh_w)
5221 TRANS(xvilvh_d, LASX, gen_xxx, gen_helper_vilvh_d)
5223 TRANS(vshuf_b, LSX, gen_vvvv, gen_helper_vshuf_b)
5224 TRANS(vshuf_h, LSX, gen_vvv, gen_helper_vshuf_h)
5225 TRANS(vshuf_w, LSX, gen_vvv, gen_helper_vshuf_w)
5226 TRANS(vshuf_d, LSX, gen_vvv, gen_helper_vshuf_d)
5227 TRANS(xvshuf_b, LASX, gen_xxxx, gen_helper_vshuf_b)
5228 TRANS(xvshuf_h, LASX, gen_xxx, gen_helper_vshuf_h)
5229 TRANS(xvshuf_w, LASX, gen_xxx, gen_helper_vshuf_w)
5230 TRANS(xvshuf_d, LASX, gen_xxx, gen_helper_vshuf_d)
5231 TRANS(vshuf4i_b, LSX, gen_vv_i, gen_helper_vshuf4i_b)
5232 TRANS(vshuf4i_h, LSX, gen_vv_i, gen_helper_vshuf4i_h)
5233 TRANS(vshuf4i_w, LSX, gen_vv_i, gen_helper_vshuf4i_w)
5234 TRANS(vshuf4i_d, LSX, gen_vv_i, gen_helper_vshuf4i_d)
5235 TRANS(xvshuf4i_b, LASX, gen_xx_i, gen_helper_vshuf4i_b)
5236 TRANS(xvshuf4i_h, LASX, gen_xx_i, gen_helper_vshuf4i_h)
5237 TRANS(xvshuf4i_w, LASX, gen_xx_i, gen_helper_vshuf4i_w)
5238 TRANS(xvshuf4i_d, LASX, gen_xx_i, gen_helper_vshuf4i_d)
5240 TRANS(xvperm_w, LASX, gen_xxx, gen_helper_vperm_w)
5241 TRANS(vpermi_w, LSX, gen_vv_i, gen_helper_vpermi_w)
5242 TRANS(xvpermi_w, LASX, gen_xx_i, gen_helper_vpermi_w)
5243 TRANS(xvpermi_d, LASX, gen_xx_i, gen_helper_vpermi_d)
5244 TRANS(xvpermi_q, LASX, gen_xx_i, gen_helper_vpermi_q)
5246 TRANS(vextrins_b, LSX, gen_vv_i, gen_helper_vextrins_b)
5247 TRANS(vextrins_h, LSX, gen_vv_i, gen_helper_vextrins_h)
5248 TRANS(vextrins_w, LSX, gen_vv_i, gen_helper_vextrins_w)
5249 TRANS(vextrins_d, LSX, gen_vv_i, gen_helper_vextrins_d)
5250 TRANS(xvextrins_b, LASX, gen_xx_i, gen_helper_vextrins_b)
5251 TRANS(xvextrins_h, LASX, gen_xx_i, gen_helper_vextrins_h)
5252 TRANS(xvextrins_w, LASX, gen_xx_i, gen_helper_vextrins_w)
5253 TRANS(xvextrins_d, LASX, gen_xx_i, gen_helper_vextrins_d)
5255 static bool trans_vld(DisasContext *ctx, arg_vr_i *a)
5261 if (!avail_LSX(ctx)) {
5265 if (!check_vec(ctx, 16)) {
5269 addr = gpr_src(ctx, a->rj, EXT_NONE);
5270 val = tcg_temp_new_i128();
5271 rl = tcg_temp_new_i64();
5272 rh = tcg_temp_new_i64();
5274 addr = make_address_i(ctx, addr, a->imm);
5276 tcg_gen_qemu_ld_i128(val, addr, ctx->mem_idx, MO_128 | MO_TE);
5277 tcg_gen_extr_i128_i64(rl, rh, val);
5278 set_vreg64(rh, a->vd, 1);
5279 set_vreg64(rl, a->vd, 0);
5284 static bool trans_vst(DisasContext *ctx, arg_vr_i *a)
5290 if (!avail_LSX(ctx)) {
5294 if (!check_vec(ctx, 16)) {
5298 addr = gpr_src(ctx, a->rj, EXT_NONE);
5299 val = tcg_temp_new_i128();
5300 ah = tcg_temp_new_i64();
5301 al = tcg_temp_new_i64();
5303 addr = make_address_i(ctx, addr, a->imm);
5305 get_vreg64(ah, a->vd, 1);
5306 get_vreg64(al, a->vd, 0);
5307 tcg_gen_concat_i64_i128(val, al, ah);
5308 tcg_gen_qemu_st_i128(val, addr, ctx->mem_idx, MO_128 | MO_TE);
5313 static bool trans_vldx(DisasContext *ctx, arg_vrr *a)
5315 TCGv addr, src1, src2;
5319 if (!avail_LSX(ctx)) {
5323 if (!check_vec(ctx, 16)) {
5327 src1 = gpr_src(ctx, a->rj, EXT_NONE);
5328 src2 = gpr_src(ctx, a->rk, EXT_NONE);
5329 val = tcg_temp_new_i128();
5330 rl = tcg_temp_new_i64();
5331 rh = tcg_temp_new_i64();
5333 addr = make_address_x(ctx, src1, src2);
5334 tcg_gen_qemu_ld_i128(val, addr, ctx->mem_idx, MO_128 | MO_TE);
5335 tcg_gen_extr_i128_i64(rl, rh, val);
5336 set_vreg64(rh, a->vd, 1);
5337 set_vreg64(rl, a->vd, 0);
5342 static bool trans_vstx(DisasContext *ctx, arg_vrr *a)
5344 TCGv addr, src1, src2;
5348 if (!avail_LSX(ctx)) {
5352 if (!check_vec(ctx, 16)) {
5356 src1 = gpr_src(ctx, a->rj, EXT_NONE);
5357 src2 = gpr_src(ctx, a->rk, EXT_NONE);
5358 val = tcg_temp_new_i128();
5359 ah = tcg_temp_new_i64();
5360 al = tcg_temp_new_i64();
5362 addr = make_address_x(ctx, src1, src2);
5363 get_vreg64(ah, a->vd, 1);
5364 get_vreg64(al, a->vd, 0);
5365 tcg_gen_concat_i64_i128(val, al, ah);
5366 tcg_gen_qemu_st_i128(val, addr, ctx->mem_idx, MO_128 | MO_TE);
5371 static bool do_vldrepl_vl(DisasContext *ctx, arg_vr_i *a,
5372 uint32_t oprsz, MemOp mop)
5377 if (!check_vec(ctx, oprsz)) {
5381 addr = gpr_src(ctx, a->rj, EXT_NONE);
5382 val = tcg_temp_new_i64();
5384 addr = make_address_i(ctx, addr, a->imm);
5386 tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx, mop);
5387 tcg_gen_gvec_dup_i64(mop, vec_full_offset(a->vd), oprsz, ctx->vl / 8, val);
5392 static bool do_vldrepl(DisasContext *ctx, arg_vr_i *a, MemOp mop)
5394 return do_vldrepl_vl(ctx, a, 16, mop);
5397 static bool do_xvldrepl(DisasContext *ctx, arg_vr_i *a, MemOp mop)
5399 return do_vldrepl_vl(ctx, a, 32, mop);
5402 TRANS(vldrepl_b, LSX, do_vldrepl, MO_8)
5403 TRANS(vldrepl_h, LSX, do_vldrepl, MO_16)
5404 TRANS(vldrepl_w, LSX, do_vldrepl, MO_32)
5405 TRANS(vldrepl_d, LSX, do_vldrepl, MO_64)
5406 TRANS(xvldrepl_b, LASX, do_xvldrepl, MO_8)
5407 TRANS(xvldrepl_h, LASX, do_xvldrepl, MO_16)
5408 TRANS(xvldrepl_w, LASX, do_xvldrepl, MO_32)
5409 TRANS(xvldrepl_d, LASX, do_xvldrepl, MO_64)
5411 static bool do_vstelm_vl(DisasContext *ctx,
5412 arg_vr_ii *a, uint32_t oprsz, MemOp mop)
5417 if (!check_vec(ctx, oprsz)) {
5421 addr = gpr_src(ctx, a->rj, EXT_NONE);
5422 val = tcg_temp_new_i64();
5424 addr = make_address_i(ctx, addr, a->imm);
5425 tcg_gen_ld_i64(val, tcg_env, vec_reg_offset(a->vd, a->imm2, mop));
5426 tcg_gen_qemu_st_i64(val, addr, ctx->mem_idx, mop);
5430 static bool do_vstelm(DisasContext *ctx, arg_vr_ii *a, MemOp mop)
5432 return do_vstelm_vl(ctx, a, 16, mop);
5435 static bool do_xvstelm(DisasContext *ctx, arg_vr_ii *a, MemOp mop)
5437 return do_vstelm_vl(ctx, a, 32, mop);
5440 TRANS(vstelm_b, LSX, do_vstelm, MO_8)
5441 TRANS(vstelm_h, LSX, do_vstelm, MO_16)
5442 TRANS(vstelm_w, LSX, do_vstelm, MO_32)
5443 TRANS(vstelm_d, LSX, do_vstelm, MO_64)
5444 TRANS(xvstelm_b, LASX, do_xvstelm, MO_8)
5445 TRANS(xvstelm_h, LASX, do_xvstelm, MO_16)
5446 TRANS(xvstelm_w, LASX, do_xvstelm, MO_32)
5447 TRANS(xvstelm_d, LASX, do_xvstelm, MO_64)
5449 static bool gen_lasx_memory(DisasContext *ctx, arg_vr_i *a,
5450 void (*func)(DisasContext *, int, TCGv))
5452 TCGv addr = gpr_src(ctx, a->rj, EXT_NONE);
5455 if (!check_vec(ctx, 32)) {
5460 temp = tcg_temp_new();
5461 tcg_gen_addi_tl(temp, addr, a->imm);
5465 func(ctx, a->vd, addr);
5469 static void gen_xvld(DisasContext *ctx, int vreg, TCGv addr)
5472 TCGv temp = tcg_temp_new();
5473 TCGv dest = tcg_temp_new();
5475 tcg_gen_qemu_ld_i64(dest, addr, ctx->mem_idx, MO_TEUQ);
5476 set_vreg64(dest, vreg, 0);
5478 for (i = 1; i < 4; i++) {
5479 tcg_gen_addi_tl(temp, addr, 8 * i);
5480 tcg_gen_qemu_ld_i64(dest, temp, ctx->mem_idx, MO_TEUQ);
5481 set_vreg64(dest, vreg, i);
5485 static void gen_xvst(DisasContext * ctx, int vreg, TCGv addr)
5488 TCGv temp = tcg_temp_new();
5489 TCGv dest = tcg_temp_new();
5491 get_vreg64(dest, vreg, 0);
5492 tcg_gen_qemu_st_i64(dest, addr, ctx->mem_idx, MO_TEUQ);
5494 for (i = 1; i < 4; i++) {
5495 tcg_gen_addi_tl(temp, addr, 8 * i);
5496 get_vreg64(dest, vreg, i);
5497 tcg_gen_qemu_st_i64(dest, temp, ctx->mem_idx, MO_TEUQ);
5501 TRANS(xvld, LASX, gen_lasx_memory, gen_xvld)
5502 TRANS(xvst, LASX, gen_lasx_memory, gen_xvst)
5504 static bool gen_lasx_memoryx(DisasContext *ctx, arg_vrr *a,
5505 void (*func)(DisasContext*, int, TCGv))
5507 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
5508 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
5509 TCGv addr = tcg_temp_new();
5511 if (!check_vec(ctx, 32)) {
5515 tcg_gen_add_tl(addr, src1, src2);
5516 func(ctx, a->vd, addr);
5521 TRANS(xvldx, LASX, gen_lasx_memoryx, gen_xvld)
5522 TRANS(xvstx, LASX, gen_lasx_memoryx, gen_xvst)