2 * ARM translation: AArch32 VFP instructions
4 * Copyright (c) 2003 Fabrice Bellard
5 * Copyright (c) 2005-2007 CodeSourcery
6 * Copyright (c) 2007 OpenedHand, Ltd.
7 * Copyright (c) 2019 Linaro, Ltd.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 * This file is intended to be included from translate.c; it uses
25 * some macros and definitions provided by that file.
26 * It might be possible to convert it to a standalone .c file eventually.
29 /* Include the generated VFP decoder */
30 #include "decode-vfp.c.inc"
31 #include "decode-vfp-uncond.c.inc"
34 * The imm8 encodes the sign bit, enough bits to represent an exponent in
35 * the range 01....1xx to 10....0xx, and the most significant 4 bits of
36 * the mantissa; see VFPExpandImm() in the v8 ARM ARM.
38 uint64_t vfp_expand_imm(int size, uint8_t imm8)
44 imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
45 (extract32(imm8, 6, 1) ? 0x3fc0 : 0x4000) |
46 extract32(imm8, 0, 6);
50 imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
51 (extract32(imm8, 6, 1) ? 0x3e00 : 0x4000) |
52 (extract32(imm8, 0, 6) << 3);
56 imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
57 (extract32(imm8, 6, 1) ? 0x3000 : 0x4000) |
58 (extract32(imm8, 0, 6) << 6);
61 g_assert_not_reached();
67 * Return the offset of a 16-bit half of the specified VFP single-precision
68 * register. If top is true, returns the top 16 bits; otherwise the bottom
71 static inline long vfp_f16_offset(unsigned reg, bool top)
73 long offs = vfp_reg_offset(false, reg);
74 #ifdef HOST_WORDS_BIGENDIAN
87 * Check that VFP access is enabled. If it is, do the necessary
88 * M-profile lazy-FP handling and then return true.
89 * If not, emit code to generate an appropriate exception and
91 * The ignore_vfp_enabled argument specifies that we should ignore
92 * whether VFP is enabled via FPEXC[EN]: this should be true for FMXR/FMRX
93 * accesses to FPSID, FPEXC, MVFR0, MVFR1, MVFR2, and false for all other insns.
95 static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled)
98 /* M-profile handled this earlier, in disas_m_nocp() */
99 assert (!arm_dc_feature(s, ARM_FEATURE_M));
100 gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
101 syn_fp_access_trap(1, 0xe, false),
106 if (!s->vfp_enabled && !ignore_vfp_enabled) {
107 assert(!arm_dc_feature(s, ARM_FEATURE_M));
108 unallocated_encoding(s);
112 if (arm_dc_feature(s, ARM_FEATURE_M)) {
113 /* Handle M-profile lazy FP state mechanics */
115 /* Trigger lazy-state preservation if necessary */
118 * Lazy state saving affects external memory and also the NVIC,
119 * so we must mark it as an IO operation for icount (and cause
120 * this to be the last insn in the TB).
122 if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
123 s->base.is_jmp = DISAS_UPDATE_EXIT;
126 gen_helper_v7m_preserve_fp_state(cpu_env);
128 * If the preserve_fp_state helper doesn't throw an exception
129 * then it will clear LSPACT; we don't need to repeat this for
130 * any further FP insns in this TB.
132 s->v7m_lspact = false;
135 /* Update ownership of FP context: set FPCCR.S to match current state */
136 if (s->v8m_fpccr_s_wrong) {
139 tmp = load_cpu_field(v7m.fpccr[M_REG_S]);
141 tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK);
143 tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK);
145 store_cpu_field(tmp, v7m.fpccr[M_REG_S]);
146 /* Don't need to do this for any further FP insns in this TB */
147 s->v8m_fpccr_s_wrong = false;
150 if (s->v7m_new_fp_ctxt_needed) {
152 * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
155 TCGv_i32 control, fpscr;
156 uint32_t bits = R_V7M_CONTROL_FPCA_MASK;
158 fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]);
159 gen_helper_vfp_set_fpscr(cpu_env, fpscr);
160 tcg_temp_free_i32(fpscr);
162 * We don't need to arrange to end the TB, because the only
163 * parts of FPSCR which we cache in the TB flags are the VECLEN
164 * and VECSTRIDE, and those don't exist for M-profile.
168 bits |= R_V7M_CONTROL_SFPA_MASK;
170 control = load_cpu_field(v7m.control[M_REG_S]);
171 tcg_gen_ori_i32(control, control, bits);
172 store_cpu_field(control, v7m.control[M_REG_S]);
173 /* Don't need to do this for any further FP insns in this TB */
174 s->v7m_new_fp_ctxt_needed = false;
182 * The most usual kind of VFP access check, for everything except
183 * FMXR/FMRX to the always-available special registers.
185 static bool vfp_access_check(DisasContext *s)
187 return full_vfp_access_check(s, false);
190 static bool trans_VSEL(DisasContext *s, arg_VSEL *a)
195 if (!dc_isar_feature(aa32_vsel, s)) {
199 if (sz == 3 && !dc_isar_feature(aa32_fpdp_v2, s)) {
203 if (sz == 1 && !dc_isar_feature(aa32_fp16_arith, s)) {
207 /* UNDEF accesses to D16-D31 if they don't exist */
208 if (sz == 3 && !dc_isar_feature(aa32_simd_r32, s) &&
209 ((a->vm | a->vn | a->vd) & 0x10)) {
217 if (!vfp_access_check(s)) {
222 TCGv_i64 frn, frm, dest;
223 TCGv_i64 tmp, zero, zf, nf, vf;
225 zero = tcg_const_i64(0);
227 frn = tcg_temp_new_i64();
228 frm = tcg_temp_new_i64();
229 dest = tcg_temp_new_i64();
231 zf = tcg_temp_new_i64();
232 nf = tcg_temp_new_i64();
233 vf = tcg_temp_new_i64();
235 tcg_gen_extu_i32_i64(zf, cpu_ZF);
236 tcg_gen_ext_i32_i64(nf, cpu_NF);
237 tcg_gen_ext_i32_i64(vf, cpu_VF);
239 neon_load_reg64(frn, rn);
240 neon_load_reg64(frm, rm);
243 tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero,
247 tcg_gen_movcond_i64(TCG_COND_LT, dest, vf, zero,
250 case 2: /* ge: N == V -> N ^ V == 0 */
251 tmp = tcg_temp_new_i64();
252 tcg_gen_xor_i64(tmp, vf, nf);
253 tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero,
255 tcg_temp_free_i64(tmp);
257 case 3: /* gt: !Z && N == V */
258 tcg_gen_movcond_i64(TCG_COND_NE, dest, zf, zero,
260 tmp = tcg_temp_new_i64();
261 tcg_gen_xor_i64(tmp, vf, nf);
262 tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero,
264 tcg_temp_free_i64(tmp);
267 neon_store_reg64(dest, rd);
268 tcg_temp_free_i64(frn);
269 tcg_temp_free_i64(frm);
270 tcg_temp_free_i64(dest);
272 tcg_temp_free_i64(zf);
273 tcg_temp_free_i64(nf);
274 tcg_temp_free_i64(vf);
276 tcg_temp_free_i64(zero);
278 TCGv_i32 frn, frm, dest;
281 zero = tcg_const_i32(0);
283 frn = tcg_temp_new_i32();
284 frm = tcg_temp_new_i32();
285 dest = tcg_temp_new_i32();
286 neon_load_reg32(frn, rn);
287 neon_load_reg32(frm, rm);
290 tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero,
294 tcg_gen_movcond_i32(TCG_COND_LT, dest, cpu_VF, zero,
297 case 2: /* ge: N == V -> N ^ V == 0 */
298 tmp = tcg_temp_new_i32();
299 tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);
300 tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero,
302 tcg_temp_free_i32(tmp);
304 case 3: /* gt: !Z && N == V */
305 tcg_gen_movcond_i32(TCG_COND_NE, dest, cpu_ZF, zero,
307 tmp = tcg_temp_new_i32();
308 tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);
309 tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero,
311 tcg_temp_free_i32(tmp);
314 /* For fp16 the top half is always zeroes */
316 tcg_gen_andi_i32(dest, dest, 0xffff);
318 neon_store_reg32(dest, rd);
319 tcg_temp_free_i32(frn);
320 tcg_temp_free_i32(frm);
321 tcg_temp_free_i32(dest);
323 tcg_temp_free_i32(zero);
330 * Table for converting the most common AArch32 encoding of
331 * rounding mode to arm_fprounding order (which matches the
332 * common AArch64 order); see ARM ARM pseudocode FPDecodeRM().
334 static const uint8_t fp_decode_rm[] = {
341 static bool trans_VRINT(DisasContext *s, arg_VRINT *a)
347 int rounding = fp_decode_rm[a->rm];
349 if (!dc_isar_feature(aa32_vrint, s)) {
353 if (sz == 3 && !dc_isar_feature(aa32_fpdp_v2, s)) {
357 if (sz == 1 && !dc_isar_feature(aa32_fp16_arith, s)) {
361 /* UNDEF accesses to D16-D31 if they don't exist */
362 if (sz == 3 && !dc_isar_feature(aa32_simd_r32, s) &&
363 ((a->vm | a->vd) & 0x10)) {
370 if (!vfp_access_check(s)) {
375 fpst = fpstatus_ptr(FPST_FPCR_F16);
377 fpst = fpstatus_ptr(FPST_FPCR);
380 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
381 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
386 tcg_op = tcg_temp_new_i64();
387 tcg_res = tcg_temp_new_i64();
388 neon_load_reg64(tcg_op, rm);
389 gen_helper_rintd(tcg_res, tcg_op, fpst);
390 neon_store_reg64(tcg_res, rd);
391 tcg_temp_free_i64(tcg_op);
392 tcg_temp_free_i64(tcg_res);
396 tcg_op = tcg_temp_new_i32();
397 tcg_res = tcg_temp_new_i32();
398 neon_load_reg32(tcg_op, rm);
400 gen_helper_rinth(tcg_res, tcg_op, fpst);
402 gen_helper_rints(tcg_res, tcg_op, fpst);
404 neon_store_reg32(tcg_res, rd);
405 tcg_temp_free_i32(tcg_op);
406 tcg_temp_free_i32(tcg_res);
409 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
410 tcg_temp_free_i32(tcg_rmode);
412 tcg_temp_free_ptr(fpst);
416 static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
421 TCGv_i32 tcg_rmode, tcg_shift;
422 int rounding = fp_decode_rm[a->rm];
423 bool is_signed = a->op;
425 if (!dc_isar_feature(aa32_vcvt_dr, s)) {
429 if (sz == 3 && !dc_isar_feature(aa32_fpdp_v2, s)) {
433 if (sz == 1 && !dc_isar_feature(aa32_fp16_arith, s)) {
437 /* UNDEF accesses to D16-D31 if they don't exist */
438 if (sz == 3 && !dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
445 if (!vfp_access_check(s)) {
450 fpst = fpstatus_ptr(FPST_FPCR_F16);
452 fpst = fpstatus_ptr(FPST_FPCR);
455 tcg_shift = tcg_const_i32(0);
457 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
458 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
461 TCGv_i64 tcg_double, tcg_res;
463 tcg_double = tcg_temp_new_i64();
464 tcg_res = tcg_temp_new_i64();
465 tcg_tmp = tcg_temp_new_i32();
466 neon_load_reg64(tcg_double, rm);
468 gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst);
470 gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst);
472 tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res);
473 neon_store_reg32(tcg_tmp, rd);
474 tcg_temp_free_i32(tcg_tmp);
475 tcg_temp_free_i64(tcg_res);
476 tcg_temp_free_i64(tcg_double);
478 TCGv_i32 tcg_single, tcg_res;
479 tcg_single = tcg_temp_new_i32();
480 tcg_res = tcg_temp_new_i32();
481 neon_load_reg32(tcg_single, rm);
484 gen_helper_vfp_toslh(tcg_res, tcg_single, tcg_shift, fpst);
486 gen_helper_vfp_toulh(tcg_res, tcg_single, tcg_shift, fpst);
490 gen_helper_vfp_tosls(tcg_res, tcg_single, tcg_shift, fpst);
492 gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst);
495 neon_store_reg32(tcg_res, rd);
496 tcg_temp_free_i32(tcg_res);
497 tcg_temp_free_i32(tcg_single);
500 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
501 tcg_temp_free_i32(tcg_rmode);
503 tcg_temp_free_i32(tcg_shift);
505 tcg_temp_free_ptr(fpst);
510 static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a)
512 /* VMOV scalar to general purpose register */
517 /* SIZE == 2 is a VFP instruction; otherwise NEON. */
519 ? !dc_isar_feature(aa32_fpsp_v2, s)
520 : !arm_dc_feature(s, ARM_FEATURE_NEON)) {
524 /* UNDEF accesses to D16-D31 if they don't exist */
525 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) {
529 offset = a->index << a->size;
530 pass = extract32(offset, 2, 1);
531 offset = extract32(offset, 0, 2) * 8;
533 if (!vfp_access_check(s)) {
537 tmp = neon_load_reg(a->vn, pass);
541 tcg_gen_shri_i32(tmp, tmp, offset);
552 tcg_gen_shri_i32(tmp, tmp, 16);
558 tcg_gen_sari_i32(tmp, tmp, 16);
567 store_reg(s, a->rt, tmp);
572 static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a)
574 /* VMOV general purpose register to scalar */
579 /* SIZE == 2 is a VFP instruction; otherwise NEON. */
581 ? !dc_isar_feature(aa32_fpsp_v2, s)
582 : !arm_dc_feature(s, ARM_FEATURE_NEON)) {
586 /* UNDEF accesses to D16-D31 if they don't exist */
587 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) {
591 offset = a->index << a->size;
592 pass = extract32(offset, 2, 1);
593 offset = extract32(offset, 0, 2) * 8;
595 if (!vfp_access_check(s)) {
599 tmp = load_reg(s, a->rt);
602 tmp2 = neon_load_reg(a->vn, pass);
603 tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);
604 tcg_temp_free_i32(tmp2);
607 tmp2 = neon_load_reg(a->vn, pass);
608 tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);
609 tcg_temp_free_i32(tmp2);
614 neon_store_reg(a->vn, pass, tmp);
619 static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
621 /* VDUP (general purpose register) */
625 if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
629 /* UNDEF accesses to D16-D31 if they don't exist */
630 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) {
638 if (a->q && (a->vn & 1)) {
642 vec_size = a->q ? 16 : 8;
651 if (!vfp_access_check(s)) {
655 tmp = load_reg(s, a->rt);
656 tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0),
657 vec_size, vec_size, tmp);
658 tcg_temp_free_i32(tmp);
663 static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a)
666 bool ignore_vfp_enabled = false;
668 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
672 if (arm_dc_feature(s, ARM_FEATURE_M)) {
674 * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
675 * Accesses to R15 are UNPREDICTABLE; we choose to undef.
676 * (FPSCR -> r15 is a special case which writes to the PSR flags.)
678 if (a->rt == 15 && (!a->l || a->reg != ARM_VFP_FPSCR)) {
686 * VFPv2 allows access to FPSID from userspace; VFPv3 restricts
687 * all ID registers to privileged access only.
689 if (IS_USER(s) && dc_isar_feature(aa32_fpsp_v3, s)) {
692 ignore_vfp_enabled = true;
696 if (IS_USER(s) || !arm_dc_feature(s, ARM_FEATURE_MVFR)) {
699 ignore_vfp_enabled = true;
702 if (IS_USER(s) || !arm_dc_feature(s, ARM_FEATURE_V8)) {
705 ignore_vfp_enabled = true;
713 ignore_vfp_enabled = true;
716 case ARM_VFP_FPINST2:
717 /* Not present in VFPv3 */
718 if (IS_USER(s) || dc_isar_feature(aa32_fpsp_v3, s)) {
726 if (!full_vfp_access_check(s, ignore_vfp_enabled)) {
731 /* VMRS, move VFP special register to gp register */
737 if (s->current_el == 1) {
738 TCGv_i32 tcg_reg, tcg_rt;
741 gen_set_pc_im(s, s->pc_curr);
742 tcg_reg = tcg_const_i32(a->reg);
743 tcg_rt = tcg_const_i32(a->rt);
744 gen_helper_check_hcr_el2_trap(cpu_env, tcg_rt, tcg_reg);
745 tcg_temp_free_i32(tcg_reg);
746 tcg_temp_free_i32(tcg_rt);
751 case ARM_VFP_FPINST2:
752 tmp = load_cpu_field(vfp.xregs[a->reg]);
756 tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
757 tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
759 tmp = tcg_temp_new_i32();
760 gen_helper_vfp_get_fpscr(tmp, cpu_env);
764 g_assert_not_reached();
768 /* Set the 4 flag bits in the CPSR. */
770 tcg_temp_free_i32(tmp);
772 store_reg(s, a->rt, tmp);
775 /* VMSR, move gp register to VFP special register */
781 /* Writes are ignored. */
784 tmp = load_reg(s, a->rt);
785 gen_helper_vfp_set_fpscr(cpu_env, tmp);
786 tcg_temp_free_i32(tmp);
791 * TODO: VFP subarchitecture support.
792 * For now, keep the EN bit only
794 tmp = load_reg(s, a->rt);
795 tcg_gen_andi_i32(tmp, tmp, 1 << 30);
796 store_cpu_field(tmp, vfp.xregs[a->reg]);
800 case ARM_VFP_FPINST2:
801 tmp = load_reg(s, a->rt);
802 store_cpu_field(tmp, vfp.xregs[a->reg]);
805 g_assert_not_reached();
812 static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a)
816 if (!dc_isar_feature(aa32_fp16_arith, s)) {
821 /* UNPREDICTABLE; we choose to UNDEF */
825 if (!vfp_access_check(s)) {
830 /* VFP to general purpose register */
831 tmp = tcg_temp_new_i32();
832 neon_load_reg32(tmp, a->vn);
833 tcg_gen_andi_i32(tmp, tmp, 0xffff);
834 store_reg(s, a->rt, tmp);
836 /* general purpose register to VFP */
837 tmp = load_reg(s, a->rt);
838 tcg_gen_andi_i32(tmp, tmp, 0xffff);
839 neon_store_reg32(tmp, a->vn);
840 tcg_temp_free_i32(tmp);
846 static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a)
850 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
854 if (!vfp_access_check(s)) {
859 /* VFP to general purpose register */
860 tmp = tcg_temp_new_i32();
861 neon_load_reg32(tmp, a->vn);
863 /* Set the 4 flag bits in the CPSR. */
865 tcg_temp_free_i32(tmp);
867 store_reg(s, a->rt, tmp);
870 /* general purpose register to VFP */
871 tmp = load_reg(s, a->rt);
872 neon_store_reg32(tmp, a->vn);
873 tcg_temp_free_i32(tmp);
879 static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a)
883 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
888 * VMOV between two general-purpose registers and two single precision
889 * floating point registers
891 if (!vfp_access_check(s)) {
897 tmp = tcg_temp_new_i32();
898 neon_load_reg32(tmp, a->vm);
899 store_reg(s, a->rt, tmp);
900 tmp = tcg_temp_new_i32();
901 neon_load_reg32(tmp, a->vm + 1);
902 store_reg(s, a->rt2, tmp);
905 tmp = load_reg(s, a->rt);
906 neon_store_reg32(tmp, a->vm);
907 tcg_temp_free_i32(tmp);
908 tmp = load_reg(s, a->rt2);
909 neon_store_reg32(tmp, a->vm + 1);
910 tcg_temp_free_i32(tmp);
916 static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a)
921 * VMOV between two general-purpose registers and one double precision
922 * floating point register. Note that this does not require support
923 * for double precision arithmetic.
925 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
929 /* UNDEF accesses to D16-D31 if they don't exist */
930 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
934 if (!vfp_access_check(s)) {
940 tmp = tcg_temp_new_i32();
941 neon_load_reg32(tmp, a->vm * 2);
942 store_reg(s, a->rt, tmp);
943 tmp = tcg_temp_new_i32();
944 neon_load_reg32(tmp, a->vm * 2 + 1);
945 store_reg(s, a->rt2, tmp);
948 tmp = load_reg(s, a->rt);
949 neon_store_reg32(tmp, a->vm * 2);
950 tcg_temp_free_i32(tmp);
951 tmp = load_reg(s, a->rt2);
952 neon_store_reg32(tmp, a->vm * 2 + 1);
953 tcg_temp_free_i32(tmp);
959 static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a)
964 if (!dc_isar_feature(aa32_fp16_arith, s)) {
968 if (!vfp_access_check(s)) {
972 /* imm8 field is offset/2 for fp16, unlike fp32 and fp64 */
973 offset = a->imm << 1;
978 /* For thumb, use of PC is UNPREDICTABLE. */
979 addr = add_reg_for_lit(s, a->rn, offset);
980 tmp = tcg_temp_new_i32();
982 gen_aa32_ld16u(s, tmp, addr, get_mem_index(s));
983 neon_store_reg32(tmp, a->vd);
985 neon_load_reg32(tmp, a->vd);
986 gen_aa32_st16(s, tmp, addr, get_mem_index(s));
988 tcg_temp_free_i32(tmp);
989 tcg_temp_free_i32(addr);
994 static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a)
999 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1003 if (!vfp_access_check(s)) {
1007 offset = a->imm << 2;
1012 /* For thumb, use of PC is UNPREDICTABLE. */
1013 addr = add_reg_for_lit(s, a->rn, offset);
1014 tmp = tcg_temp_new_i32();
1016 gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
1017 neon_store_reg32(tmp, a->vd);
1019 neon_load_reg32(tmp, a->vd);
1020 gen_aa32_st32(s, tmp, addr, get_mem_index(s));
1022 tcg_temp_free_i32(tmp);
1023 tcg_temp_free_i32(addr);
1028 static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a)
1034 /* Note that this does not require support for double arithmetic. */
1035 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1039 /* UNDEF accesses to D16-D31 if they don't exist */
1040 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
1044 if (!vfp_access_check(s)) {
1048 offset = a->imm << 2;
1053 /* For thumb, use of PC is UNPREDICTABLE. */
1054 addr = add_reg_for_lit(s, a->rn, offset);
1055 tmp = tcg_temp_new_i64();
1057 gen_aa32_ld64(s, tmp, addr, get_mem_index(s));
1058 neon_store_reg64(tmp, a->vd);
1060 neon_load_reg64(tmp, a->vd);
1061 gen_aa32_st64(s, tmp, addr, get_mem_index(s));
1063 tcg_temp_free_i64(tmp);
1064 tcg_temp_free_i32(addr);
1069 static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a)
1075 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1081 if (n == 0 || (a->vd + n) > 32) {
1083 * UNPREDICTABLE cases for bad immediates: we choose to
1084 * UNDEF to avoid generating huge numbers of TCG ops
1088 if (a->rn == 15 && a->w) {
1089 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1093 if (!vfp_access_check(s)) {
1097 /* For thumb, use of PC is UNPREDICTABLE. */
1098 addr = add_reg_for_lit(s, a->rn, 0);
1101 tcg_gen_addi_i32(addr, addr, -(a->imm << 2));
1104 if (s->v8m_stackcheck && a->rn == 13 && a->w) {
1106 * Here 'addr' is the lowest address we will store to,
1107 * and is either the old SP (if post-increment) or
1108 * the new SP (if pre-decrement). For post-increment
1109 * where the old value is below the limit and the new
1110 * value is above, it is UNKNOWN whether the limit check
1111 * triggers; we choose to trigger.
1113 gen_helper_v8m_stackcheck(cpu_env, addr);
1117 tmp = tcg_temp_new_i32();
1118 for (i = 0; i < n; i++) {
1121 gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
1122 neon_store_reg32(tmp, a->vd + i);
1125 neon_load_reg32(tmp, a->vd + i);
1126 gen_aa32_st32(s, tmp, addr, get_mem_index(s));
1128 tcg_gen_addi_i32(addr, addr, offset);
1130 tcg_temp_free_i32(tmp);
1134 offset = -offset * n;
1135 tcg_gen_addi_i32(addr, addr, offset);
1137 store_reg(s, a->rn, addr);
1139 tcg_temp_free_i32(addr);
1145 static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a)
1152 /* Note that this does not require support for double arithmetic. */
1153 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1159 if (n == 0 || (a->vd + n) > 32 || n > 16) {
1161 * UNPREDICTABLE cases for bad immediates: we choose to
1162 * UNDEF to avoid generating huge numbers of TCG ops
1166 if (a->rn == 15 && a->w) {
1167 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1171 /* UNDEF accesses to D16-D31 if they don't exist */
1172 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd + n) > 16) {
1176 if (!vfp_access_check(s)) {
1180 /* For thumb, use of PC is UNPREDICTABLE. */
1181 addr = add_reg_for_lit(s, a->rn, 0);
1184 tcg_gen_addi_i32(addr, addr, -(a->imm << 2));
1187 if (s->v8m_stackcheck && a->rn == 13 && a->w) {
1189 * Here 'addr' is the lowest address we will store to,
1190 * and is either the old SP (if post-increment) or
1191 * the new SP (if pre-decrement). For post-increment
1192 * where the old value is below the limit and the new
1193 * value is above, it is UNKNOWN whether the limit check
1194 * triggers; we choose to trigger.
1196 gen_helper_v8m_stackcheck(cpu_env, addr);
1200 tmp = tcg_temp_new_i64();
1201 for (i = 0; i < n; i++) {
1204 gen_aa32_ld64(s, tmp, addr, get_mem_index(s));
1205 neon_store_reg64(tmp, a->vd + i);
1208 neon_load_reg64(tmp, a->vd + i);
1209 gen_aa32_st64(s, tmp, addr, get_mem_index(s));
1211 tcg_gen_addi_i32(addr, addr, offset);
1213 tcg_temp_free_i64(tmp);
1217 offset = -offset * n;
1218 } else if (a->imm & 1) {
1225 tcg_gen_addi_i32(addr, addr, offset);
1227 store_reg(s, a->rn, addr);
1229 tcg_temp_free_i32(addr);
1236 * Types for callbacks for do_vfp_3op_sp() and do_vfp_3op_dp().
1237 * The callback should emit code to write a value to vd. If
1238 * do_vfp_3op_{sp,dp}() was passed reads_vd then the TCGv vd
1239 * will contain the old value of the relevant VFP register;
1240 * otherwise it must be written to only.
1242 typedef void VFPGen3OpSPFn(TCGv_i32 vd,
1243 TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst);
1244 typedef void VFPGen3OpDPFn(TCGv_i64 vd,
1245 TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst);
1248 * Types for callbacks for do_vfp_2op_sp() and do_vfp_2op_dp().
1249 * The callback should emit code to write a value to vd (which
1250 * should be written to only).
1252 typedef void VFPGen2OpSPFn(TCGv_i32 vd, TCGv_i32 vm);
1253 typedef void VFPGen2OpDPFn(TCGv_i64 vd, TCGv_i64 vm);
1256 * Return true if the specified S reg is in a scalar bank
1257 * (ie if it is s0..s7)
1259 static inline bool vfp_sreg_is_scalar(int reg)
1261 return (reg & 0x18) == 0;
1265 * Return true if the specified D reg is in a scalar bank
1266 * (ie if it is d0..d3 or d16..d19)
1268 static inline bool vfp_dreg_is_scalar(int reg)
1270 return (reg & 0xc) == 0;
1274 * Advance the S reg number forwards by delta within its bank
1275 * (ie increment the low 3 bits but leave the rest the same)
1277 static inline int vfp_advance_sreg(int reg, int delta)
1279 return ((reg + delta) & 0x7) | (reg & ~0x7);
1283 * Advance the D reg number forwards by delta within its bank
1284 * (ie increment the low 2 bits but leave the rest the same)
1286 static inline int vfp_advance_dreg(int reg, int delta)
1288 return ((reg + delta) & 0x3) | (reg & ~0x3);
1292 * Perform a 3-operand VFP data processing instruction. fn is the
1293 * callback to do the actual operation; this function deals with the
1294 * code to handle looping around for VFP vector processing.
1296 static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn,
1297 int vd, int vn, int vm, bool reads_vd)
1299 uint32_t delta_m = 0;
1300 uint32_t delta_d = 0;
1301 int veclen = s->vec_len;
1302 TCGv_i32 f0, f1, fd;
1305 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1309 if (!dc_isar_feature(aa32_fpshvec, s) &&
1310 (veclen != 0 || s->vec_stride != 0)) {
1314 if (!vfp_access_check(s)) {
1319 /* Figure out what type of vector operation this is. */
1320 if (vfp_sreg_is_scalar(vd)) {
1324 delta_d = s->vec_stride + 1;
1326 if (vfp_sreg_is_scalar(vm)) {
1327 /* mixed scalar/vector */
1336 f0 = tcg_temp_new_i32();
1337 f1 = tcg_temp_new_i32();
1338 fd = tcg_temp_new_i32();
1339 fpst = fpstatus_ptr(FPST_FPCR);
1341 neon_load_reg32(f0, vn);
1342 neon_load_reg32(f1, vm);
1346 neon_load_reg32(fd, vd);
1348 fn(fd, f0, f1, fpst);
1349 neon_store_reg32(fd, vd);
1355 /* Set up the operands for the next iteration */
1357 vd = vfp_advance_sreg(vd, delta_d);
1358 vn = vfp_advance_sreg(vn, delta_d);
1359 neon_load_reg32(f0, vn);
1361 vm = vfp_advance_sreg(vm, delta_m);
1362 neon_load_reg32(f1, vm);
1366 tcg_temp_free_i32(f0);
1367 tcg_temp_free_i32(f1);
1368 tcg_temp_free_i32(fd);
1369 tcg_temp_free_ptr(fpst);
1374 static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn,
1375 int vd, int vn, int vm, bool reads_vd)
1378 * Do a half-precision operation. Functionally this is
1379 * the same as do_vfp_3op_sp(), except:
1380 * - it uses the FPST_FPCR_F16
1381 * - it doesn't need the VFP vector handling (fp16 is a
1382 * v8 feature, and in v8 VFP vectors don't exist)
1383 * - it does the aa32_fp16_arith feature test
1385 TCGv_i32 f0, f1, fd;
1388 if (!dc_isar_feature(aa32_fp16_arith, s)) {
1392 if (s->vec_len != 0 || s->vec_stride != 0) {
1396 if (!vfp_access_check(s)) {
1400 f0 = tcg_temp_new_i32();
1401 f1 = tcg_temp_new_i32();
1402 fd = tcg_temp_new_i32();
1403 fpst = fpstatus_ptr(FPST_FPCR_F16);
1405 neon_load_reg32(f0, vn);
1406 neon_load_reg32(f1, vm);
1409 neon_load_reg32(fd, vd);
1411 fn(fd, f0, f1, fpst);
1412 neon_store_reg32(fd, vd);
1414 tcg_temp_free_i32(f0);
1415 tcg_temp_free_i32(f1);
1416 tcg_temp_free_i32(fd);
1417 tcg_temp_free_ptr(fpst);
1422 static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn,
1423 int vd, int vn, int vm, bool reads_vd)
1425 uint32_t delta_m = 0;
1426 uint32_t delta_d = 0;
1427 int veclen = s->vec_len;
1428 TCGv_i64 f0, f1, fd;
1431 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
1435 /* UNDEF accesses to D16-D31 if they don't exist */
1436 if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vn | vm) & 0x10)) {
1440 if (!dc_isar_feature(aa32_fpshvec, s) &&
1441 (veclen != 0 || s->vec_stride != 0)) {
1445 if (!vfp_access_check(s)) {
1450 /* Figure out what type of vector operation this is. */
1451 if (vfp_dreg_is_scalar(vd)) {
1455 delta_d = (s->vec_stride >> 1) + 1;
1457 if (vfp_dreg_is_scalar(vm)) {
1458 /* mixed scalar/vector */
1467 f0 = tcg_temp_new_i64();
1468 f1 = tcg_temp_new_i64();
1469 fd = tcg_temp_new_i64();
1470 fpst = fpstatus_ptr(FPST_FPCR);
1472 neon_load_reg64(f0, vn);
1473 neon_load_reg64(f1, vm);
1477 neon_load_reg64(fd, vd);
1479 fn(fd, f0, f1, fpst);
1480 neon_store_reg64(fd, vd);
1485 /* Set up the operands for the next iteration */
1487 vd = vfp_advance_dreg(vd, delta_d);
1488 vn = vfp_advance_dreg(vn, delta_d);
1489 neon_load_reg64(f0, vn);
1491 vm = vfp_advance_dreg(vm, delta_m);
1492 neon_load_reg64(f1, vm);
1496 tcg_temp_free_i64(f0);
1497 tcg_temp_free_i64(f1);
1498 tcg_temp_free_i64(fd);
1499 tcg_temp_free_ptr(fpst);
1504 static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
1506 uint32_t delta_m = 0;
1507 uint32_t delta_d = 0;
1508 int veclen = s->vec_len;
1511 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
1515 if (!dc_isar_feature(aa32_fpshvec, s) &&
1516 (veclen != 0 || s->vec_stride != 0)) {
1520 if (!vfp_access_check(s)) {
1525 /* Figure out what type of vector operation this is. */
1526 if (vfp_sreg_is_scalar(vd)) {
1530 delta_d = s->vec_stride + 1;
1532 if (vfp_sreg_is_scalar(vm)) {
1533 /* mixed scalar/vector */
1542 f0 = tcg_temp_new_i32();
1543 fd = tcg_temp_new_i32();
1545 neon_load_reg32(f0, vm);
1549 neon_store_reg32(fd, vd);
1556 /* single source one-many */
1558 vd = vfp_advance_sreg(vd, delta_d);
1559 neon_store_reg32(fd, vd);
1564 /* Set up the operands for the next iteration */
1566 vd = vfp_advance_sreg(vd, delta_d);
1567 vm = vfp_advance_sreg(vm, delta_m);
1568 neon_load_reg32(f0, vm);
1571 tcg_temp_free_i32(f0);
1572 tcg_temp_free_i32(fd);
1577 static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)
1580 * Do a half-precision operation. Functionally this is
1581 * the same as do_vfp_2op_sp(), except:
1582 * - it doesn't need the VFP vector handling (fp16 is a
1583 * v8 feature, and in v8 VFP vectors don't exist)
1584 * - it does the aa32_fp16_arith feature test
1588 if (!dc_isar_feature(aa32_fp16_arith, s)) {
1592 if (s->vec_len != 0 || s->vec_stride != 0) {
1596 if (!vfp_access_check(s)) {
1600 f0 = tcg_temp_new_i32();
1601 neon_load_reg32(f0, vm);
1603 neon_store_reg32(f0, vd);
1604 tcg_temp_free_i32(f0);
1609 static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)
1611 uint32_t delta_m = 0;
1612 uint32_t delta_d = 0;
1613 int veclen = s->vec_len;
1616 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
1620 /* UNDEF accesses to D16-D31 if they don't exist */
1621 if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vm) & 0x10)) {
1625 if (!dc_isar_feature(aa32_fpshvec, s) &&
1626 (veclen != 0 || s->vec_stride != 0)) {
1630 if (!vfp_access_check(s)) {
1635 /* Figure out what type of vector operation this is. */
1636 if (vfp_dreg_is_scalar(vd)) {
1640 delta_d = (s->vec_stride >> 1) + 1;
1642 if (vfp_dreg_is_scalar(vm)) {
1643 /* mixed scalar/vector */
1652 f0 = tcg_temp_new_i64();
1653 fd = tcg_temp_new_i64();
1655 neon_load_reg64(f0, vm);
1659 neon_store_reg64(fd, vd);
1666 /* single source one-many */
1668 vd = vfp_advance_dreg(vd, delta_d);
1669 neon_store_reg64(fd, vd);
1674 /* Set up the operands for the next iteration */
1676 vd = vfp_advance_dreg(vd, delta_d);
1677 vd = vfp_advance_dreg(vm, delta_m);
1678 neon_load_reg64(f0, vm);
1681 tcg_temp_free_i64(f0);
1682 tcg_temp_free_i64(fd);
1687 static void gen_VMLA_hp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1689 /* Note that order of inputs to the add matters for NaNs */
1690 TCGv_i32 tmp = tcg_temp_new_i32();
1692 gen_helper_vfp_mulh(tmp, vn, vm, fpst);
1693 gen_helper_vfp_addh(vd, vd, tmp, fpst);
1694 tcg_temp_free_i32(tmp);
1697 static bool trans_VMLA_hp(DisasContext *s, arg_VMLA_sp *a)
1699 return do_vfp_3op_hp(s, gen_VMLA_hp, a->vd, a->vn, a->vm, true);
1702 static void gen_VMLA_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1704 /* Note that order of inputs to the add matters for NaNs */
1705 TCGv_i32 tmp = tcg_temp_new_i32();
1707 gen_helper_vfp_muls(tmp, vn, vm, fpst);
1708 gen_helper_vfp_adds(vd, vd, tmp, fpst);
1709 tcg_temp_free_i32(tmp);
1712 static bool trans_VMLA_sp(DisasContext *s, arg_VMLA_sp *a)
1714 return do_vfp_3op_sp(s, gen_VMLA_sp, a->vd, a->vn, a->vm, true);
1717 static void gen_VMLA_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst)
1719 /* Note that order of inputs to the add matters for NaNs */
1720 TCGv_i64 tmp = tcg_temp_new_i64();
1722 gen_helper_vfp_muld(tmp, vn, vm, fpst);
1723 gen_helper_vfp_addd(vd, vd, tmp, fpst);
1724 tcg_temp_free_i64(tmp);
1727 static bool trans_VMLA_dp(DisasContext *s, arg_VMLA_dp *a)
1729 return do_vfp_3op_dp(s, gen_VMLA_dp, a->vd, a->vn, a->vm, true);
1732 static void gen_VMLS_hp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1735 * VMLS: vd = vd + -(vn * vm)
1736 * Note that order of inputs to the add matters for NaNs.
1738 TCGv_i32 tmp = tcg_temp_new_i32();
1740 gen_helper_vfp_mulh(tmp, vn, vm, fpst);
1741 gen_helper_vfp_negh(tmp, tmp);
1742 gen_helper_vfp_addh(vd, vd, tmp, fpst);
1743 tcg_temp_free_i32(tmp);
1746 static bool trans_VMLS_hp(DisasContext *s, arg_VMLS_sp *a)
1748 return do_vfp_3op_hp(s, gen_VMLS_hp, a->vd, a->vn, a->vm, true);
1751 static void gen_VMLS_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1754 * VMLS: vd = vd + -(vn * vm)
1755 * Note that order of inputs to the add matters for NaNs.
1757 TCGv_i32 tmp = tcg_temp_new_i32();
1759 gen_helper_vfp_muls(tmp, vn, vm, fpst);
1760 gen_helper_vfp_negs(tmp, tmp);
1761 gen_helper_vfp_adds(vd, vd, tmp, fpst);
1762 tcg_temp_free_i32(tmp);
1765 static bool trans_VMLS_sp(DisasContext *s, arg_VMLS_sp *a)
1767 return do_vfp_3op_sp(s, gen_VMLS_sp, a->vd, a->vn, a->vm, true);
1770 static void gen_VMLS_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst)
1773 * VMLS: vd = vd + -(vn * vm)
1774 * Note that order of inputs to the add matters for NaNs.
1776 TCGv_i64 tmp = tcg_temp_new_i64();
1778 gen_helper_vfp_muld(tmp, vn, vm, fpst);
1779 gen_helper_vfp_negd(tmp, tmp);
1780 gen_helper_vfp_addd(vd, vd, tmp, fpst);
1781 tcg_temp_free_i64(tmp);
1784 static bool trans_VMLS_dp(DisasContext *s, arg_VMLS_dp *a)
1786 return do_vfp_3op_dp(s, gen_VMLS_dp, a->vd, a->vn, a->vm, true);
1789 static void gen_VNMLS_hp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1792 * VNMLS: -fd + (fn * fm)
1793 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1794 * plausible looking simplifications because this will give wrong results
1797 TCGv_i32 tmp = tcg_temp_new_i32();
1799 gen_helper_vfp_mulh(tmp, vn, vm, fpst);
1800 gen_helper_vfp_negh(vd, vd);
1801 gen_helper_vfp_addh(vd, vd, tmp, fpst);
1802 tcg_temp_free_i32(tmp);
1805 static bool trans_VNMLS_hp(DisasContext *s, arg_VNMLS_sp *a)
1807 return do_vfp_3op_hp(s, gen_VNMLS_hp, a->vd, a->vn, a->vm, true);
1810 static void gen_VNMLS_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1813 * VNMLS: -fd + (fn * fm)
1814 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1815 * plausible looking simplifications because this will give wrong results
1818 TCGv_i32 tmp = tcg_temp_new_i32();
1820 gen_helper_vfp_muls(tmp, vn, vm, fpst);
1821 gen_helper_vfp_negs(vd, vd);
1822 gen_helper_vfp_adds(vd, vd, tmp, fpst);
1823 tcg_temp_free_i32(tmp);
1826 static bool trans_VNMLS_sp(DisasContext *s, arg_VNMLS_sp *a)
1828 return do_vfp_3op_sp(s, gen_VNMLS_sp, a->vd, a->vn, a->vm, true);
1831 static void gen_VNMLS_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst)
1834 * VNMLS: -fd + (fn * fm)
1835 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1836 * plausible looking simplifications because this will give wrong results
1839 TCGv_i64 tmp = tcg_temp_new_i64();
1841 gen_helper_vfp_muld(tmp, vn, vm, fpst);
1842 gen_helper_vfp_negd(vd, vd);
1843 gen_helper_vfp_addd(vd, vd, tmp, fpst);
1844 tcg_temp_free_i64(tmp);
1847 static bool trans_VNMLS_dp(DisasContext *s, arg_VNMLS_dp *a)
1849 return do_vfp_3op_dp(s, gen_VNMLS_dp, a->vd, a->vn, a->vm, true);
1852 static void gen_VNMLA_hp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1854 /* VNMLA: -fd + -(fn * fm) */
1855 TCGv_i32 tmp = tcg_temp_new_i32();
1857 gen_helper_vfp_mulh(tmp, vn, vm, fpst);
1858 gen_helper_vfp_negh(tmp, tmp);
1859 gen_helper_vfp_negh(vd, vd);
1860 gen_helper_vfp_addh(vd, vd, tmp, fpst);
1861 tcg_temp_free_i32(tmp);
1864 static bool trans_VNMLA_hp(DisasContext *s, arg_VNMLA_sp *a)
1866 return do_vfp_3op_hp(s, gen_VNMLA_hp, a->vd, a->vn, a->vm, true);
1869 static void gen_VNMLA_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1871 /* VNMLA: -fd + -(fn * fm) */
1872 TCGv_i32 tmp = tcg_temp_new_i32();
1874 gen_helper_vfp_muls(tmp, vn, vm, fpst);
1875 gen_helper_vfp_negs(tmp, tmp);
1876 gen_helper_vfp_negs(vd, vd);
1877 gen_helper_vfp_adds(vd, vd, tmp, fpst);
1878 tcg_temp_free_i32(tmp);
1881 static bool trans_VNMLA_sp(DisasContext *s, arg_VNMLA_sp *a)
1883 return do_vfp_3op_sp(s, gen_VNMLA_sp, a->vd, a->vn, a->vm, true);
1886 static void gen_VNMLA_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst)
1888 /* VNMLA: -fd + (fn * fm) */
1889 TCGv_i64 tmp = tcg_temp_new_i64();
1891 gen_helper_vfp_muld(tmp, vn, vm, fpst);
1892 gen_helper_vfp_negd(tmp, tmp);
1893 gen_helper_vfp_negd(vd, vd);
1894 gen_helper_vfp_addd(vd, vd, tmp, fpst);
1895 tcg_temp_free_i64(tmp);
1898 static bool trans_VNMLA_dp(DisasContext *s, arg_VNMLA_dp *a)
1900 return do_vfp_3op_dp(s, gen_VNMLA_dp, a->vd, a->vn, a->vm, true);
1903 static bool trans_VMUL_hp(DisasContext *s, arg_VMUL_sp *a)
1905 return do_vfp_3op_hp(s, gen_helper_vfp_mulh, a->vd, a->vn, a->vm, false);
1908 static bool trans_VMUL_sp(DisasContext *s, arg_VMUL_sp *a)
1910 return do_vfp_3op_sp(s, gen_helper_vfp_muls, a->vd, a->vn, a->vm, false);
1913 static bool trans_VMUL_dp(DisasContext *s, arg_VMUL_dp *a)
1915 return do_vfp_3op_dp(s, gen_helper_vfp_muld, a->vd, a->vn, a->vm, false);
1918 static void gen_VNMUL_hp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1920 /* VNMUL: -(fn * fm) */
1921 gen_helper_vfp_mulh(vd, vn, vm, fpst);
1922 gen_helper_vfp_negh(vd, vd);
1925 static bool trans_VNMUL_hp(DisasContext *s, arg_VNMUL_sp *a)
1927 return do_vfp_3op_hp(s, gen_VNMUL_hp, a->vd, a->vn, a->vm, false);
1930 static void gen_VNMUL_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst)
1932 /* VNMUL: -(fn * fm) */
1933 gen_helper_vfp_muls(vd, vn, vm, fpst);
1934 gen_helper_vfp_negs(vd, vd);
1937 static bool trans_VNMUL_sp(DisasContext *s, arg_VNMUL_sp *a)
1939 return do_vfp_3op_sp(s, gen_VNMUL_sp, a->vd, a->vn, a->vm, false);
1942 static void gen_VNMUL_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst)
1944 /* VNMUL: -(fn * fm) */
1945 gen_helper_vfp_muld(vd, vn, vm, fpst);
1946 gen_helper_vfp_negd(vd, vd);
1949 static bool trans_VNMUL_dp(DisasContext *s, arg_VNMUL_dp *a)
1951 return do_vfp_3op_dp(s, gen_VNMUL_dp, a->vd, a->vn, a->vm, false);
1954 static bool trans_VADD_hp(DisasContext *s, arg_VADD_sp *a)
1956 return do_vfp_3op_hp(s, gen_helper_vfp_addh, a->vd, a->vn, a->vm, false);
1959 static bool trans_VADD_sp(DisasContext *s, arg_VADD_sp *a)
1961 return do_vfp_3op_sp(s, gen_helper_vfp_adds, a->vd, a->vn, a->vm, false);
1964 static bool trans_VADD_dp(DisasContext *s, arg_VADD_dp *a)
1966 return do_vfp_3op_dp(s, gen_helper_vfp_addd, a->vd, a->vn, a->vm, false);
1969 static bool trans_VSUB_hp(DisasContext *s, arg_VSUB_sp *a)
1971 return do_vfp_3op_hp(s, gen_helper_vfp_subh, a->vd, a->vn, a->vm, false);
1974 static bool trans_VSUB_sp(DisasContext *s, arg_VSUB_sp *a)
1976 return do_vfp_3op_sp(s, gen_helper_vfp_subs, a->vd, a->vn, a->vm, false);
1979 static bool trans_VSUB_dp(DisasContext *s, arg_VSUB_dp *a)
1981 return do_vfp_3op_dp(s, gen_helper_vfp_subd, a->vd, a->vn, a->vm, false);
1984 static bool trans_VDIV_hp(DisasContext *s, arg_VDIV_sp *a)
1986 return do_vfp_3op_hp(s, gen_helper_vfp_divh, a->vd, a->vn, a->vm, false);
1989 static bool trans_VDIV_sp(DisasContext *s, arg_VDIV_sp *a)
1991 return do_vfp_3op_sp(s, gen_helper_vfp_divs, a->vd, a->vn, a->vm, false);
1994 static bool trans_VDIV_dp(DisasContext *s, arg_VDIV_dp *a)
1996 return do_vfp_3op_dp(s, gen_helper_vfp_divd, a->vd, a->vn, a->vm, false);
1999 static bool trans_VMINNM_hp(DisasContext *s, arg_VMINNM_sp *a)
2001 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2004 return do_vfp_3op_hp(s, gen_helper_vfp_minnumh,
2005 a->vd, a->vn, a->vm, false);
2008 static bool trans_VMAXNM_hp(DisasContext *s, arg_VMAXNM_sp *a)
2010 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2013 return do_vfp_3op_hp(s, gen_helper_vfp_maxnumh,
2014 a->vd, a->vn, a->vm, false);
2017 static bool trans_VMINNM_sp(DisasContext *s, arg_VMINNM_sp *a)
2019 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2022 return do_vfp_3op_sp(s, gen_helper_vfp_minnums,
2023 a->vd, a->vn, a->vm, false);
2026 static bool trans_VMAXNM_sp(DisasContext *s, arg_VMAXNM_sp *a)
2028 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2031 return do_vfp_3op_sp(s, gen_helper_vfp_maxnums,
2032 a->vd, a->vn, a->vm, false);
2035 static bool trans_VMINNM_dp(DisasContext *s, arg_VMINNM_dp *a)
2037 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2040 return do_vfp_3op_dp(s, gen_helper_vfp_minnumd,
2041 a->vd, a->vn, a->vm, false);
2044 static bool trans_VMAXNM_dp(DisasContext *s, arg_VMAXNM_dp *a)
2046 if (!dc_isar_feature(aa32_vminmaxnm, s)) {
2049 return do_vfp_3op_dp(s, gen_helper_vfp_maxnumd,
2050 a->vd, a->vn, a->vm, false);
2053 static bool do_vfm_hp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d)
2056 * VFNMA : fd = muladd(-fd, fn, fm)
2057 * VFNMS : fd = muladd(-fd, -fn, fm)
2058 * VFMA : fd = muladd( fd, fn, fm)
2059 * VFMS : fd = muladd( fd, -fn, fm)
2061 * These are fused multiply-add, and must be done as one floating
2062 * point operation with no rounding between the multiplication and
2063 * addition steps. NB that doing the negations here as separate
2064 * steps is correct : an input NaN should come out with its sign
2065 * bit flipped if it is a negated-input.
2068 TCGv_i32 vn, vm, vd;
2071 * Present in VFPv4 only, and only with the FP16 extension.
2072 * Note that we can't rely on the SIMDFMAC check alone, because
2073 * in a Neon-no-VFP core that ID register field will be non-zero.
2075 if (!dc_isar_feature(aa32_fp16_arith, s) ||
2076 !dc_isar_feature(aa32_simdfmac, s) ||
2077 !dc_isar_feature(aa32_fpsp_v2, s)) {
2081 if (s->vec_len != 0 || s->vec_stride != 0) {
2085 if (!vfp_access_check(s)) {
2089 vn = tcg_temp_new_i32();
2090 vm = tcg_temp_new_i32();
2091 vd = tcg_temp_new_i32();
2093 neon_load_reg32(vn, a->vn);
2094 neon_load_reg32(vm, a->vm);
2097 gen_helper_vfp_negh(vn, vn);
2099 neon_load_reg32(vd, a->vd);
2102 gen_helper_vfp_negh(vd, vd);
2104 fpst = fpstatus_ptr(FPST_FPCR_F16);
2105 gen_helper_vfp_muladdh(vd, vn, vm, vd, fpst);
2106 neon_store_reg32(vd, a->vd);
2108 tcg_temp_free_ptr(fpst);
2109 tcg_temp_free_i32(vn);
2110 tcg_temp_free_i32(vm);
2111 tcg_temp_free_i32(vd);
2116 static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d)
2119 * VFNMA : fd = muladd(-fd, fn, fm)
2120 * VFNMS : fd = muladd(-fd, -fn, fm)
2121 * VFMA : fd = muladd( fd, fn, fm)
2122 * VFMS : fd = muladd( fd, -fn, fm)
2124 * These are fused multiply-add, and must be done as one floating
2125 * point operation with no rounding between the multiplication and
2126 * addition steps. NB that doing the negations here as separate
2127 * steps is correct : an input NaN should come out with its sign
2128 * bit flipped if it is a negated-input.
2131 TCGv_i32 vn, vm, vd;
2134 * Present in VFPv4 only.
2135 * Note that we can't rely on the SIMDFMAC check alone, because
2136 * in a Neon-no-VFP core that ID register field will be non-zero.
2138 if (!dc_isar_feature(aa32_simdfmac, s) ||
2139 !dc_isar_feature(aa32_fpsp_v2, s)) {
2143 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
2144 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
2146 if (s->vec_len != 0 || s->vec_stride != 0) {
2150 if (!vfp_access_check(s)) {
2154 vn = tcg_temp_new_i32();
2155 vm = tcg_temp_new_i32();
2156 vd = tcg_temp_new_i32();
2158 neon_load_reg32(vn, a->vn);
2159 neon_load_reg32(vm, a->vm);
2162 gen_helper_vfp_negs(vn, vn);
2164 neon_load_reg32(vd, a->vd);
2167 gen_helper_vfp_negs(vd, vd);
2169 fpst = fpstatus_ptr(FPST_FPCR);
2170 gen_helper_vfp_muladds(vd, vn, vm, vd, fpst);
2171 neon_store_reg32(vd, a->vd);
2173 tcg_temp_free_ptr(fpst);
2174 tcg_temp_free_i32(vn);
2175 tcg_temp_free_i32(vm);
2176 tcg_temp_free_i32(vd);
2181 static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d)
2184 * VFNMA : fd = muladd(-fd, fn, fm)
2185 * VFNMS : fd = muladd(-fd, -fn, fm)
2186 * VFMA : fd = muladd( fd, fn, fm)
2187 * VFMS : fd = muladd( fd, -fn, fm)
2189 * These are fused multiply-add, and must be done as one floating
2190 * point operation with no rounding between the multiplication and
2191 * addition steps. NB that doing the negations here as separate
2192 * steps is correct : an input NaN should come out with its sign
2193 * bit flipped if it is a negated-input.
2196 TCGv_i64 vn, vm, vd;
2199 * Present in VFPv4 only.
2200 * Note that we can't rely on the SIMDFMAC check alone, because
2201 * in a Neon-no-VFP core that ID register field will be non-zero.
2203 if (!dc_isar_feature(aa32_simdfmac, s) ||
2204 !dc_isar_feature(aa32_fpdp_v2, s)) {
2208 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
2209 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
2211 if (s->vec_len != 0 || s->vec_stride != 0) {
2215 /* UNDEF accesses to D16-D31 if they don't exist. */
2216 if (!dc_isar_feature(aa32_simd_r32, s) &&
2217 ((a->vd | a->vn | a->vm) & 0x10)) {
2221 if (!vfp_access_check(s)) {
2225 vn = tcg_temp_new_i64();
2226 vm = tcg_temp_new_i64();
2227 vd = tcg_temp_new_i64();
2229 neon_load_reg64(vn, a->vn);
2230 neon_load_reg64(vm, a->vm);
2233 gen_helper_vfp_negd(vn, vn);
2235 neon_load_reg64(vd, a->vd);
2238 gen_helper_vfp_negd(vd, vd);
2240 fpst = fpstatus_ptr(FPST_FPCR);
2241 gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst);
2242 neon_store_reg64(vd, a->vd);
2244 tcg_temp_free_ptr(fpst);
2245 tcg_temp_free_i64(vn);
2246 tcg_temp_free_i64(vm);
2247 tcg_temp_free_i64(vd);
2252 #define MAKE_ONE_VFM_TRANS_FN(INSN, PREC, NEGN, NEGD) \
2253 static bool trans_##INSN##_##PREC(DisasContext *s, \
2254 arg_##INSN##_##PREC *a) \
2256 return do_vfm_##PREC(s, a, NEGN, NEGD); \
2259 #define MAKE_VFM_TRANS_FNS(PREC) \
2260 MAKE_ONE_VFM_TRANS_FN(VFMA, PREC, false, false) \
2261 MAKE_ONE_VFM_TRANS_FN(VFMS, PREC, true, false) \
2262 MAKE_ONE_VFM_TRANS_FN(VFNMA, PREC, false, true) \
2263 MAKE_ONE_VFM_TRANS_FN(VFNMS, PREC, true, true)
2265 MAKE_VFM_TRANS_FNS(hp)
2266 MAKE_VFM_TRANS_FNS(sp)
2267 MAKE_VFM_TRANS_FNS(dp)
2269 static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a)
2273 if (!dc_isar_feature(aa32_fp16_arith, s)) {
2277 if (s->vec_len != 0 || s->vec_stride != 0) {
2281 if (!vfp_access_check(s)) {
2285 fd = tcg_const_i32(vfp_expand_imm(MO_16, a->imm));
2286 neon_store_reg32(fd, a->vd);
2287 tcg_temp_free_i32(fd);
2291 static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a)
2293 uint32_t delta_d = 0;
2294 int veclen = s->vec_len;
2300 if (!dc_isar_feature(aa32_fpsp_v3, s)) {
2304 if (!dc_isar_feature(aa32_fpshvec, s) &&
2305 (veclen != 0 || s->vec_stride != 0)) {
2309 if (!vfp_access_check(s)) {
2314 /* Figure out what type of vector operation this is. */
2315 if (vfp_sreg_is_scalar(vd)) {
2319 delta_d = s->vec_stride + 1;
2323 fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm));
2326 neon_store_reg32(fd, vd);
2332 /* Set up the operands for the next iteration */
2334 vd = vfp_advance_sreg(vd, delta_d);
2337 tcg_temp_free_i32(fd);
2341 static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a)
2343 uint32_t delta_d = 0;
2344 int veclen = s->vec_len;
2350 if (!dc_isar_feature(aa32_fpdp_v3, s)) {
2354 /* UNDEF accesses to D16-D31 if they don't exist. */
2355 if (!dc_isar_feature(aa32_simd_r32, s) && (vd & 0x10)) {
2359 if (!dc_isar_feature(aa32_fpshvec, s) &&
2360 (veclen != 0 || s->vec_stride != 0)) {
2364 if (!vfp_access_check(s)) {
2369 /* Figure out what type of vector operation this is. */
2370 if (vfp_dreg_is_scalar(vd)) {
2374 delta_d = (s->vec_stride >> 1) + 1;
2378 fd = tcg_const_i64(vfp_expand_imm(MO_64, a->imm));
2381 neon_store_reg64(fd, vd);
2387 /* Set up the operands for the next iteration */
2389 vd = vfp_advance_dreg(vd, delta_d);
2392 tcg_temp_free_i64(fd);
2396 #define DO_VFP_2OP(INSN, PREC, FN) \
2397 static bool trans_##INSN##_##PREC(DisasContext *s, \
2398 arg_##INSN##_##PREC *a) \
2400 return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \
2403 DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32)
2404 DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64)
2406 DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh)
2407 DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss)
2408 DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd)
2410 DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh)
2411 DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs)
2412 DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd)
2414 static void gen_VSQRT_hp(TCGv_i32 vd, TCGv_i32 vm)
2416 gen_helper_vfp_sqrth(vd, vm, cpu_env);
2419 static void gen_VSQRT_sp(TCGv_i32 vd, TCGv_i32 vm)
2421 gen_helper_vfp_sqrts(vd, vm, cpu_env);
2424 static void gen_VSQRT_dp(TCGv_i64 vd, TCGv_i64 vm)
2426 gen_helper_vfp_sqrtd(vd, vm, cpu_env);
2429 DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp)
2430 DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp)
2431 DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp)
2433 static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a)
2437 if (!dc_isar_feature(aa32_fp16_arith, s)) {
2441 /* Vm/M bits must be zero for the Z variant */
2442 if (a->z && a->vm != 0) {
2446 if (!vfp_access_check(s)) {
2450 vd = tcg_temp_new_i32();
2451 vm = tcg_temp_new_i32();
2453 neon_load_reg32(vd, a->vd);
2455 tcg_gen_movi_i32(vm, 0);
2457 neon_load_reg32(vm, a->vm);
2461 gen_helper_vfp_cmpeh(vd, vm, cpu_env);
2463 gen_helper_vfp_cmph(vd, vm, cpu_env);
2466 tcg_temp_free_i32(vd);
2467 tcg_temp_free_i32(vm);
2472 static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a)
2476 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
2480 /* Vm/M bits must be zero for the Z variant */
2481 if (a->z && a->vm != 0) {
2485 if (!vfp_access_check(s)) {
2489 vd = tcg_temp_new_i32();
2490 vm = tcg_temp_new_i32();
2492 neon_load_reg32(vd, a->vd);
2494 tcg_gen_movi_i32(vm, 0);
2496 neon_load_reg32(vm, a->vm);
2500 gen_helper_vfp_cmpes(vd, vm, cpu_env);
2502 gen_helper_vfp_cmps(vd, vm, cpu_env);
2505 tcg_temp_free_i32(vd);
2506 tcg_temp_free_i32(vm);
2511 static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a)
2515 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2519 /* Vm/M bits must be zero for the Z variant */
2520 if (a->z && a->vm != 0) {
2524 /* UNDEF accesses to D16-D31 if they don't exist. */
2525 if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) {
2529 if (!vfp_access_check(s)) {
2533 vd = tcg_temp_new_i64();
2534 vm = tcg_temp_new_i64();
2536 neon_load_reg64(vd, a->vd);
2538 tcg_gen_movi_i64(vm, 0);
2540 neon_load_reg64(vm, a->vm);
2544 gen_helper_vfp_cmped(vd, vm, cpu_env);
2546 gen_helper_vfp_cmpd(vd, vm, cpu_env);
2549 tcg_temp_free_i64(vd);
2550 tcg_temp_free_i64(vm);
2555 static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a)
2561 if (!dc_isar_feature(aa32_fp16_spconv, s)) {
2565 if (!vfp_access_check(s)) {
2569 fpst = fpstatus_ptr(FPST_FPCR);
2570 ahp_mode = get_ahp_flag();
2571 tmp = tcg_temp_new_i32();
2572 /* The T bit tells us if we want the low or high 16 bits of Vm */
2573 tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t));
2574 gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode);
2575 neon_store_reg32(tmp, a->vd);
2576 tcg_temp_free_i32(ahp_mode);
2577 tcg_temp_free_ptr(fpst);
2578 tcg_temp_free_i32(tmp);
2582 static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a)
2589 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2593 if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
2597 /* UNDEF accesses to D16-D31 if they don't exist. */
2598 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
2602 if (!vfp_access_check(s)) {
2606 fpst = fpstatus_ptr(FPST_FPCR);
2607 ahp_mode = get_ahp_flag();
2608 tmp = tcg_temp_new_i32();
2609 /* The T bit tells us if we want the low or high 16 bits of Vm */
2610 tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t));
2611 vd = tcg_temp_new_i64();
2612 gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode);
2613 neon_store_reg64(vd, a->vd);
2614 tcg_temp_free_i32(ahp_mode);
2615 tcg_temp_free_ptr(fpst);
2616 tcg_temp_free_i32(tmp);
2617 tcg_temp_free_i64(vd);
2621 static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a)
2627 if (!dc_isar_feature(aa32_fp16_spconv, s)) {
2631 if (!vfp_access_check(s)) {
2635 fpst = fpstatus_ptr(FPST_FPCR);
2636 ahp_mode = get_ahp_flag();
2637 tmp = tcg_temp_new_i32();
2639 neon_load_reg32(tmp, a->vm);
2640 gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode);
2641 tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t));
2642 tcg_temp_free_i32(ahp_mode);
2643 tcg_temp_free_ptr(fpst);
2644 tcg_temp_free_i32(tmp);
2648 static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a)
2655 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2659 if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
2663 /* UNDEF accesses to D16-D31 if they don't exist. */
2664 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
2668 if (!vfp_access_check(s)) {
2672 fpst = fpstatus_ptr(FPST_FPCR);
2673 ahp_mode = get_ahp_flag();
2674 tmp = tcg_temp_new_i32();
2675 vm = tcg_temp_new_i64();
2677 neon_load_reg64(vm, a->vm);
2678 gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode);
2679 tcg_temp_free_i64(vm);
2680 tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t));
2681 tcg_temp_free_i32(ahp_mode);
2682 tcg_temp_free_ptr(fpst);
2683 tcg_temp_free_i32(tmp);
2687 static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a)
2692 if (!dc_isar_feature(aa32_fp16_arith, s)) {
2696 if (!vfp_access_check(s)) {
2700 tmp = tcg_temp_new_i32();
2701 neon_load_reg32(tmp, a->vm);
2702 fpst = fpstatus_ptr(FPST_FPCR_F16);
2703 gen_helper_rinth(tmp, tmp, fpst);
2704 neon_store_reg32(tmp, a->vd);
2705 tcg_temp_free_ptr(fpst);
2706 tcg_temp_free_i32(tmp);
2710 static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a)
2715 if (!dc_isar_feature(aa32_vrint, s)) {
2719 if (!vfp_access_check(s)) {
2723 tmp = tcg_temp_new_i32();
2724 neon_load_reg32(tmp, a->vm);
2725 fpst = fpstatus_ptr(FPST_FPCR);
2726 gen_helper_rints(tmp, tmp, fpst);
2727 neon_store_reg32(tmp, a->vd);
2728 tcg_temp_free_ptr(fpst);
2729 tcg_temp_free_i32(tmp);
2733 static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a)
2738 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2742 if (!dc_isar_feature(aa32_vrint, s)) {
2746 /* UNDEF accesses to D16-D31 if they don't exist. */
2747 if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) {
2751 if (!vfp_access_check(s)) {
2755 tmp = tcg_temp_new_i64();
2756 neon_load_reg64(tmp, a->vm);
2757 fpst = fpstatus_ptr(FPST_FPCR);
2758 gen_helper_rintd(tmp, tmp, fpst);
2759 neon_store_reg64(tmp, a->vd);
2760 tcg_temp_free_ptr(fpst);
2761 tcg_temp_free_i64(tmp);
2765 static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a)
2771 if (!dc_isar_feature(aa32_fp16_arith, s)) {
2775 if (!vfp_access_check(s)) {
2779 tmp = tcg_temp_new_i32();
2780 neon_load_reg32(tmp, a->vm);
2781 fpst = fpstatus_ptr(FPST_FPCR_F16);
2782 tcg_rmode = tcg_const_i32(float_round_to_zero);
2783 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2784 gen_helper_rinth(tmp, tmp, fpst);
2785 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2786 neon_store_reg32(tmp, a->vd);
2787 tcg_temp_free_ptr(fpst);
2788 tcg_temp_free_i32(tcg_rmode);
2789 tcg_temp_free_i32(tmp);
2793 static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a)
2799 if (!dc_isar_feature(aa32_vrint, s)) {
2803 if (!vfp_access_check(s)) {
2807 tmp = tcg_temp_new_i32();
2808 neon_load_reg32(tmp, a->vm);
2809 fpst = fpstatus_ptr(FPST_FPCR);
2810 tcg_rmode = tcg_const_i32(float_round_to_zero);
2811 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2812 gen_helper_rints(tmp, tmp, fpst);
2813 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2814 neon_store_reg32(tmp, a->vd);
2815 tcg_temp_free_ptr(fpst);
2816 tcg_temp_free_i32(tcg_rmode);
2817 tcg_temp_free_i32(tmp);
2821 static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a)
2827 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2831 if (!dc_isar_feature(aa32_vrint, s)) {
2835 /* UNDEF accesses to D16-D31 if they don't exist. */
2836 if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) {
2840 if (!vfp_access_check(s)) {
2844 tmp = tcg_temp_new_i64();
2845 neon_load_reg64(tmp, a->vm);
2846 fpst = fpstatus_ptr(FPST_FPCR);
2847 tcg_rmode = tcg_const_i32(float_round_to_zero);
2848 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2849 gen_helper_rintd(tmp, tmp, fpst);
2850 gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
2851 neon_store_reg64(tmp, a->vd);
2852 tcg_temp_free_ptr(fpst);
2853 tcg_temp_free_i64(tmp);
2854 tcg_temp_free_i32(tcg_rmode);
2858 static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a)
2863 if (!dc_isar_feature(aa32_fp16_arith, s)) {
2867 if (!vfp_access_check(s)) {
2871 tmp = tcg_temp_new_i32();
2872 neon_load_reg32(tmp, a->vm);
2873 fpst = fpstatus_ptr(FPST_FPCR_F16);
2874 gen_helper_rinth_exact(tmp, tmp, fpst);
2875 neon_store_reg32(tmp, a->vd);
2876 tcg_temp_free_ptr(fpst);
2877 tcg_temp_free_i32(tmp);
2881 static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a)
2886 if (!dc_isar_feature(aa32_vrint, s)) {
2890 if (!vfp_access_check(s)) {
2894 tmp = tcg_temp_new_i32();
2895 neon_load_reg32(tmp, a->vm);
2896 fpst = fpstatus_ptr(FPST_FPCR);
2897 gen_helper_rints_exact(tmp, tmp, fpst);
2898 neon_store_reg32(tmp, a->vd);
2899 tcg_temp_free_ptr(fpst);
2900 tcg_temp_free_i32(tmp);
2904 static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a)
2909 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2913 if (!dc_isar_feature(aa32_vrint, s)) {
2917 /* UNDEF accesses to D16-D31 if they don't exist. */
2918 if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) {
2922 if (!vfp_access_check(s)) {
2926 tmp = tcg_temp_new_i64();
2927 neon_load_reg64(tmp, a->vm);
2928 fpst = fpstatus_ptr(FPST_FPCR);
2929 gen_helper_rintd_exact(tmp, tmp, fpst);
2930 neon_store_reg64(tmp, a->vd);
2931 tcg_temp_free_ptr(fpst);
2932 tcg_temp_free_i64(tmp);
2936 static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a)
2941 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2945 /* UNDEF accesses to D16-D31 if they don't exist. */
2946 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
2950 if (!vfp_access_check(s)) {
2954 vm = tcg_temp_new_i32();
2955 vd = tcg_temp_new_i64();
2956 neon_load_reg32(vm, a->vm);
2957 gen_helper_vfp_fcvtds(vd, vm, cpu_env);
2958 neon_store_reg64(vd, a->vd);
2959 tcg_temp_free_i32(vm);
2960 tcg_temp_free_i64(vd);
2964 static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a)
2969 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
2973 /* UNDEF accesses to D16-D31 if they don't exist. */
2974 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
2978 if (!vfp_access_check(s)) {
2982 vd = tcg_temp_new_i32();
2983 vm = tcg_temp_new_i64();
2984 neon_load_reg64(vm, a->vm);
2985 gen_helper_vfp_fcvtsd(vd, vm, cpu_env);
2986 neon_store_reg32(vd, a->vd);
2987 tcg_temp_free_i32(vd);
2988 tcg_temp_free_i64(vm);
2992 static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a)
2997 if (!dc_isar_feature(aa32_fp16_arith, s)) {
3001 if (!vfp_access_check(s)) {
3005 vm = tcg_temp_new_i32();
3006 neon_load_reg32(vm, a->vm);
3007 fpst = fpstatus_ptr(FPST_FPCR_F16);
3010 gen_helper_vfp_sitoh(vm, vm, fpst);
3013 gen_helper_vfp_uitoh(vm, vm, fpst);
3015 neon_store_reg32(vm, a->vd);
3016 tcg_temp_free_i32(vm);
3017 tcg_temp_free_ptr(fpst);
3021 static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a)
3026 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
3030 if (!vfp_access_check(s)) {
3034 vm = tcg_temp_new_i32();
3035 neon_load_reg32(vm, a->vm);
3036 fpst = fpstatus_ptr(FPST_FPCR);
3039 gen_helper_vfp_sitos(vm, vm, fpst);
3042 gen_helper_vfp_uitos(vm, vm, fpst);
3044 neon_store_reg32(vm, a->vd);
3045 tcg_temp_free_i32(vm);
3046 tcg_temp_free_ptr(fpst);
3050 static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a)
3056 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
3060 /* UNDEF accesses to D16-D31 if they don't exist. */
3061 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
3065 if (!vfp_access_check(s)) {
3069 vm = tcg_temp_new_i32();
3070 vd = tcg_temp_new_i64();
3071 neon_load_reg32(vm, a->vm);
3072 fpst = fpstatus_ptr(FPST_FPCR);
3075 gen_helper_vfp_sitod(vd, vm, fpst);
3078 gen_helper_vfp_uitod(vd, vm, fpst);
3080 neon_store_reg64(vd, a->vd);
3081 tcg_temp_free_i32(vm);
3082 tcg_temp_free_i64(vd);
3083 tcg_temp_free_ptr(fpst);
3087 static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a)
3092 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
3096 if (!dc_isar_feature(aa32_jscvt, s)) {
3100 /* UNDEF accesses to D16-D31 if they don't exist. */
3101 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
3105 if (!vfp_access_check(s)) {
3109 vm = tcg_temp_new_i64();
3110 vd = tcg_temp_new_i32();
3111 neon_load_reg64(vm, a->vm);
3112 gen_helper_vjcvt(vd, vm, cpu_env);
3113 neon_store_reg32(vd, a->vd);
3114 tcg_temp_free_i64(vm);
3115 tcg_temp_free_i32(vd);
3119 static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a)
3125 if (!dc_isar_feature(aa32_fp16_arith, s)) {
3129 if (!vfp_access_check(s)) {
3133 frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
3135 vd = tcg_temp_new_i32();
3136 neon_load_reg32(vd, a->vd);
3138 fpst = fpstatus_ptr(FPST_FPCR_F16);
3139 shift = tcg_const_i32(frac_bits);
3141 /* Switch on op:U:sx bits */
3144 gen_helper_vfp_shtoh(vd, vd, shift, fpst);
3147 gen_helper_vfp_sltoh(vd, vd, shift, fpst);
3150 gen_helper_vfp_uhtoh(vd, vd, shift, fpst);
3153 gen_helper_vfp_ultoh(vd, vd, shift, fpst);
3156 gen_helper_vfp_toshh_round_to_zero(vd, vd, shift, fpst);
3159 gen_helper_vfp_toslh_round_to_zero(vd, vd, shift, fpst);
3162 gen_helper_vfp_touhh_round_to_zero(vd, vd, shift, fpst);
3165 gen_helper_vfp_toulh_round_to_zero(vd, vd, shift, fpst);
3168 g_assert_not_reached();
3171 neon_store_reg32(vd, a->vd);
3172 tcg_temp_free_i32(vd);
3173 tcg_temp_free_i32(shift);
3174 tcg_temp_free_ptr(fpst);
3178 static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a)
3184 if (!dc_isar_feature(aa32_fpsp_v3, s)) {
3188 if (!vfp_access_check(s)) {
3192 frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
3194 vd = tcg_temp_new_i32();
3195 neon_load_reg32(vd, a->vd);
3197 fpst = fpstatus_ptr(FPST_FPCR);
3198 shift = tcg_const_i32(frac_bits);
3200 /* Switch on op:U:sx bits */
3203 gen_helper_vfp_shtos(vd, vd, shift, fpst);
3206 gen_helper_vfp_sltos(vd, vd, shift, fpst);
3209 gen_helper_vfp_uhtos(vd, vd, shift, fpst);
3212 gen_helper_vfp_ultos(vd, vd, shift, fpst);
3215 gen_helper_vfp_toshs_round_to_zero(vd, vd, shift, fpst);
3218 gen_helper_vfp_tosls_round_to_zero(vd, vd, shift, fpst);
3221 gen_helper_vfp_touhs_round_to_zero(vd, vd, shift, fpst);
3224 gen_helper_vfp_touls_round_to_zero(vd, vd, shift, fpst);
3227 g_assert_not_reached();
3230 neon_store_reg32(vd, a->vd);
3231 tcg_temp_free_i32(vd);
3232 tcg_temp_free_i32(shift);
3233 tcg_temp_free_ptr(fpst);
3237 static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a)
3244 if (!dc_isar_feature(aa32_fpdp_v3, s)) {
3248 /* UNDEF accesses to D16-D31 if they don't exist. */
3249 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
3253 if (!vfp_access_check(s)) {
3257 frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm);
3259 vd = tcg_temp_new_i64();
3260 neon_load_reg64(vd, a->vd);
3262 fpst = fpstatus_ptr(FPST_FPCR);
3263 shift = tcg_const_i32(frac_bits);
3265 /* Switch on op:U:sx bits */
3268 gen_helper_vfp_shtod(vd, vd, shift, fpst);
3271 gen_helper_vfp_sltod(vd, vd, shift, fpst);
3274 gen_helper_vfp_uhtod(vd, vd, shift, fpst);
3277 gen_helper_vfp_ultod(vd, vd, shift, fpst);
3280 gen_helper_vfp_toshd_round_to_zero(vd, vd, shift, fpst);
3283 gen_helper_vfp_tosld_round_to_zero(vd, vd, shift, fpst);
3286 gen_helper_vfp_touhd_round_to_zero(vd, vd, shift, fpst);
3289 gen_helper_vfp_tould_round_to_zero(vd, vd, shift, fpst);
3292 g_assert_not_reached();
3295 neon_store_reg64(vd, a->vd);
3296 tcg_temp_free_i64(vd);
3297 tcg_temp_free_i32(shift);
3298 tcg_temp_free_ptr(fpst);
3302 static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a)
3307 if (!dc_isar_feature(aa32_fp16_arith, s)) {
3311 if (!vfp_access_check(s)) {
3315 fpst = fpstatus_ptr(FPST_FPCR_F16);
3316 vm = tcg_temp_new_i32();
3317 neon_load_reg32(vm, a->vm);
3321 gen_helper_vfp_tosizh(vm, vm, fpst);
3323 gen_helper_vfp_tosih(vm, vm, fpst);
3327 gen_helper_vfp_touizh(vm, vm, fpst);
3329 gen_helper_vfp_touih(vm, vm, fpst);
3332 neon_store_reg32(vm, a->vd);
3333 tcg_temp_free_i32(vm);
3334 tcg_temp_free_ptr(fpst);
3338 static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a)
3343 if (!dc_isar_feature(aa32_fpsp_v2, s)) {
3347 if (!vfp_access_check(s)) {
3351 fpst = fpstatus_ptr(FPST_FPCR);
3352 vm = tcg_temp_new_i32();
3353 neon_load_reg32(vm, a->vm);
3357 gen_helper_vfp_tosizs(vm, vm, fpst);
3359 gen_helper_vfp_tosis(vm, vm, fpst);
3363 gen_helper_vfp_touizs(vm, vm, fpst);
3365 gen_helper_vfp_touis(vm, vm, fpst);
3368 neon_store_reg32(vm, a->vd);
3369 tcg_temp_free_i32(vm);
3370 tcg_temp_free_ptr(fpst);
3374 static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a)
3380 if (!dc_isar_feature(aa32_fpdp_v2, s)) {
3384 /* UNDEF accesses to D16-D31 if they don't exist. */
3385 if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) {
3389 if (!vfp_access_check(s)) {
3393 fpst = fpstatus_ptr(FPST_FPCR);
3394 vm = tcg_temp_new_i64();
3395 vd = tcg_temp_new_i32();
3396 neon_load_reg64(vm, a->vm);
3400 gen_helper_vfp_tosizd(vd, vm, fpst);
3402 gen_helper_vfp_tosid(vd, vm, fpst);
3406 gen_helper_vfp_touizd(vd, vm, fpst);
3408 gen_helper_vfp_touid(vd, vm, fpst);
3411 neon_store_reg32(vd, a->vd);
3412 tcg_temp_free_i32(vd);
3413 tcg_temp_free_i64(vm);
3414 tcg_temp_free_ptr(fpst);
3419 * Decode VLLDM and VLSTM are nonstandard because:
3420 * * if there is no FPU then these insns must NOP in
3421 * Secure state and UNDEF in Nonsecure state
3422 * * if there is an FPU then these insns do not have
3423 * the usual behaviour that vfp_access_check() provides of
3424 * being controlled by CPACR/NSACR enable bits or the
3425 * lazy-stacking logic.
3427 static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a)
3431 if (!arm_dc_feature(s, ARM_FEATURE_M) ||
3432 !arm_dc_feature(s, ARM_FEATURE_V8)) {
3436 * If not secure, UNDEF. We must emit code for this
3437 * rather than returning false so that this takes
3438 * precedence over the m-nocp.decode NOCP fallback.
3440 if (!s->v8m_secure) {
3441 unallocated_encoding(s);
3444 /* If no fpu, NOP. */
3445 if (!dc_isar_feature(aa32_vfp, s)) {
3449 fptr = load_reg(s, a->rn);
3451 gen_helper_v7m_vlldm(cpu_env, fptr);
3453 gen_helper_v7m_vlstm(cpu_env, fptr);
3455 tcg_temp_free_i32(fptr);
3457 /* End the TB, because we have updated FP control bits */
3458 s->base.is_jmp = DISAS_UPDATE_EXIT;
3462 static bool trans_NOCP(DisasContext *s, arg_NOCP *a)
3465 * Handle M-profile early check for disabled coprocessor:
3466 * all we need to do here is emit the NOCP exception if
3467 * the coprocessor is disabled. Otherwise we return false
3468 * and the real VFP/etc decode will handle the insn.
3470 assert(arm_dc_feature(s, ARM_FEATURE_M));
3475 /* TODO: in v8.1M cp 8, 9, 14, 15 also are governed by the cp10 enable */
3478 gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
3479 syn_uncategorized(), default_exception_el(s));
3483 if (s->fp_excp_el != 0) {
3484 gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
3485 syn_uncategorized(), s->fp_excp_el);
3492 static bool trans_VINS(DisasContext *s, arg_VINS *a)
3496 if (!dc_isar_feature(aa32_fp16_arith, s)) {
3500 if (s->vec_len != 0 || s->vec_stride != 0) {
3504 if (!vfp_access_check(s)) {
3508 /* Insert low half of Vm into high half of Vd */
3509 rm = tcg_temp_new_i32();
3510 rd = tcg_temp_new_i32();
3511 neon_load_reg32(rm, a->vm);
3512 neon_load_reg32(rd, a->vd);
3513 tcg_gen_deposit_i32(rd, rd, rm, 16, 16);
3514 neon_store_reg32(rd, a->vd);
3515 tcg_temp_free_i32(rm);
3516 tcg_temp_free_i32(rd);
3520 static bool trans_VMOVX(DisasContext *s, arg_VINS *a)
3524 if (!dc_isar_feature(aa32_fp16_arith, s)) {
3528 if (s->vec_len != 0 || s->vec_stride != 0) {
3532 if (!vfp_access_check(s)) {
3536 /* Set Vd to high half of Vm */
3537 rm = tcg_temp_new_i32();
3538 neon_load_reg32(rm, a->vm);
3539 tcg_gen_shri_i32(rm, rm, 16);
3540 neon_store_reg32(rm, a->vd);
3541 tcg_temp_free_i32(rm);