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.inc.c"
31 #include "decode-vfp-uncond.inc.c"
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 if (arm_dc_feature(s
, ARM_FEATURE_M
)) {
99 gen_exception_insn(s
, s
->pc_curr
, EXCP_NOCP
, syn_uncategorized(),
102 gen_exception_insn(s
, s
->pc_curr
, EXCP_UDEF
,
103 syn_fp_access_trap(1, 0xe, false),
109 if (!s
->vfp_enabled
&& !ignore_vfp_enabled
) {
110 assert(!arm_dc_feature(s
, ARM_FEATURE_M
));
111 unallocated_encoding(s
);
115 if (arm_dc_feature(s
, ARM_FEATURE_M
)) {
116 /* Handle M-profile lazy FP state mechanics */
118 /* Trigger lazy-state preservation if necessary */
121 * Lazy state saving affects external memory and also the NVIC,
122 * so we must mark it as an IO operation for icount.
124 if (tb_cflags(s
->base
.tb
) & CF_USE_ICOUNT
) {
127 gen_helper_v7m_preserve_fp_state(cpu_env
);
128 if (tb_cflags(s
->base
.tb
) & CF_USE_ICOUNT
) {
132 * If the preserve_fp_state helper doesn't throw an exception
133 * then it will clear LSPACT; we don't need to repeat this for
134 * any further FP insns in this TB.
136 s
->v7m_lspact
= false;
139 /* Update ownership of FP context: set FPCCR.S to match current state */
140 if (s
->v8m_fpccr_s_wrong
) {
143 tmp
= load_cpu_field(v7m
.fpccr
[M_REG_S
]);
145 tcg_gen_ori_i32(tmp
, tmp
, R_V7M_FPCCR_S_MASK
);
147 tcg_gen_andi_i32(tmp
, tmp
, ~R_V7M_FPCCR_S_MASK
);
149 store_cpu_field(tmp
, v7m
.fpccr
[M_REG_S
]);
150 /* Don't need to do this for any further FP insns in this TB */
151 s
->v8m_fpccr_s_wrong
= false;
154 if (s
->v7m_new_fp_ctxt_needed
) {
156 * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
159 TCGv_i32 control
, fpscr
;
160 uint32_t bits
= R_V7M_CONTROL_FPCA_MASK
;
162 fpscr
= load_cpu_field(v7m
.fpdscr
[s
->v8m_secure
]);
163 gen_helper_vfp_set_fpscr(cpu_env
, fpscr
);
164 tcg_temp_free_i32(fpscr
);
166 * We don't need to arrange to end the TB, because the only
167 * parts of FPSCR which we cache in the TB flags are the VECLEN
168 * and VECSTRIDE, and those don't exist for M-profile.
172 bits
|= R_V7M_CONTROL_SFPA_MASK
;
174 control
= load_cpu_field(v7m
.control
[M_REG_S
]);
175 tcg_gen_ori_i32(control
, control
, bits
);
176 store_cpu_field(control
, v7m
.control
[M_REG_S
]);
177 /* Don't need to do this for any further FP insns in this TB */
178 s
->v7m_new_fp_ctxt_needed
= false;
186 * The most usual kind of VFP access check, for everything except
187 * FMXR/FMRX to the always-available special registers.
189 static bool vfp_access_check(DisasContext
*s
)
191 return full_vfp_access_check(s
, false);
194 static bool trans_VSEL(DisasContext
*s
, arg_VSEL
*a
)
199 if (!dc_isar_feature(aa32_vsel
, s
)) {
203 /* UNDEF accesses to D16-D31 if they don't exist */
204 if (dp
&& !dc_isar_feature(aa32_fp_d32
, s
) &&
205 ((a
->vm
| a
->vn
| a
->vd
) & 0x10)) {
209 if (dp
&& !dc_isar_feature(aa32_fpdp
, s
)) {
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 neon_store_reg32(dest
, rd
);
315 tcg_temp_free_i32(frn
);
316 tcg_temp_free_i32(frm
);
317 tcg_temp_free_i32(dest
);
319 tcg_temp_free_i32(zero
);
325 static bool trans_VMINMAXNM(DisasContext
*s
, arg_VMINMAXNM
*a
)
332 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
336 /* UNDEF accesses to D16-D31 if they don't exist */
337 if (dp
&& !dc_isar_feature(aa32_fp_d32
, s
) &&
338 ((a
->vm
| a
->vn
| a
->vd
) & 0x10)) {
342 if (dp
&& !dc_isar_feature(aa32_fpdp
, s
)) {
350 if (!vfp_access_check(s
)) {
354 fpst
= get_fpstatus_ptr(0);
357 TCGv_i64 frn
, frm
, dest
;
359 frn
= tcg_temp_new_i64();
360 frm
= tcg_temp_new_i64();
361 dest
= tcg_temp_new_i64();
363 neon_load_reg64(frn
, rn
);
364 neon_load_reg64(frm
, rm
);
366 gen_helper_vfp_minnumd(dest
, frn
, frm
, fpst
);
368 gen_helper_vfp_maxnumd(dest
, frn
, frm
, fpst
);
370 neon_store_reg64(dest
, rd
);
371 tcg_temp_free_i64(frn
);
372 tcg_temp_free_i64(frm
);
373 tcg_temp_free_i64(dest
);
375 TCGv_i32 frn
, frm
, dest
;
377 frn
= tcg_temp_new_i32();
378 frm
= tcg_temp_new_i32();
379 dest
= tcg_temp_new_i32();
381 neon_load_reg32(frn
, rn
);
382 neon_load_reg32(frm
, rm
);
384 gen_helper_vfp_minnums(dest
, frn
, frm
, fpst
);
386 gen_helper_vfp_maxnums(dest
, frn
, frm
, fpst
);
388 neon_store_reg32(dest
, rd
);
389 tcg_temp_free_i32(frn
);
390 tcg_temp_free_i32(frm
);
391 tcg_temp_free_i32(dest
);
394 tcg_temp_free_ptr(fpst
);
399 * Table for converting the most common AArch32 encoding of
400 * rounding mode to arm_fprounding order (which matches the
401 * common AArch64 order); see ARM ARM pseudocode FPDecodeRM().
403 static const uint8_t fp_decode_rm
[] = {
410 static bool trans_VRINT(DisasContext
*s
, arg_VRINT
*a
)
416 int rounding
= fp_decode_rm
[a
->rm
];
418 if (!dc_isar_feature(aa32_vrint
, s
)) {
422 /* UNDEF accesses to D16-D31 if they don't exist */
423 if (dp
&& !dc_isar_feature(aa32_fp_d32
, s
) &&
424 ((a
->vm
| a
->vd
) & 0x10)) {
428 if (dp
&& !dc_isar_feature(aa32_fpdp
, s
)) {
435 if (!vfp_access_check(s
)) {
439 fpst
= get_fpstatus_ptr(0);
441 tcg_rmode
= tcg_const_i32(arm_rmode_to_sf(rounding
));
442 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
447 tcg_op
= tcg_temp_new_i64();
448 tcg_res
= tcg_temp_new_i64();
449 neon_load_reg64(tcg_op
, rm
);
450 gen_helper_rintd(tcg_res
, tcg_op
, fpst
);
451 neon_store_reg64(tcg_res
, rd
);
452 tcg_temp_free_i64(tcg_op
);
453 tcg_temp_free_i64(tcg_res
);
457 tcg_op
= tcg_temp_new_i32();
458 tcg_res
= tcg_temp_new_i32();
459 neon_load_reg32(tcg_op
, rm
);
460 gen_helper_rints(tcg_res
, tcg_op
, fpst
);
461 neon_store_reg32(tcg_res
, rd
);
462 tcg_temp_free_i32(tcg_op
);
463 tcg_temp_free_i32(tcg_res
);
466 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
467 tcg_temp_free_i32(tcg_rmode
);
469 tcg_temp_free_ptr(fpst
);
473 static bool trans_VCVT(DisasContext
*s
, arg_VCVT
*a
)
478 TCGv_i32 tcg_rmode
, tcg_shift
;
479 int rounding
= fp_decode_rm
[a
->rm
];
480 bool is_signed
= a
->op
;
482 if (!dc_isar_feature(aa32_vcvt_dr
, s
)) {
486 /* UNDEF accesses to D16-D31 if they don't exist */
487 if (dp
&& !dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
491 if (dp
&& !dc_isar_feature(aa32_fpdp
, s
)) {
498 if (!vfp_access_check(s
)) {
502 fpst
= get_fpstatus_ptr(0);
504 tcg_shift
= tcg_const_i32(0);
506 tcg_rmode
= tcg_const_i32(arm_rmode_to_sf(rounding
));
507 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
510 TCGv_i64 tcg_double
, tcg_res
;
512 tcg_double
= tcg_temp_new_i64();
513 tcg_res
= tcg_temp_new_i64();
514 tcg_tmp
= tcg_temp_new_i32();
515 neon_load_reg64(tcg_double
, rm
);
517 gen_helper_vfp_tosld(tcg_res
, tcg_double
, tcg_shift
, fpst
);
519 gen_helper_vfp_tould(tcg_res
, tcg_double
, tcg_shift
, fpst
);
521 tcg_gen_extrl_i64_i32(tcg_tmp
, tcg_res
);
522 neon_store_reg32(tcg_tmp
, rd
);
523 tcg_temp_free_i32(tcg_tmp
);
524 tcg_temp_free_i64(tcg_res
);
525 tcg_temp_free_i64(tcg_double
);
527 TCGv_i32 tcg_single
, tcg_res
;
528 tcg_single
= tcg_temp_new_i32();
529 tcg_res
= tcg_temp_new_i32();
530 neon_load_reg32(tcg_single
, rm
);
532 gen_helper_vfp_tosls(tcg_res
, tcg_single
, tcg_shift
, fpst
);
534 gen_helper_vfp_touls(tcg_res
, tcg_single
, tcg_shift
, fpst
);
536 neon_store_reg32(tcg_res
, rd
);
537 tcg_temp_free_i32(tcg_res
);
538 tcg_temp_free_i32(tcg_single
);
541 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
542 tcg_temp_free_i32(tcg_rmode
);
544 tcg_temp_free_i32(tcg_shift
);
546 tcg_temp_free_ptr(fpst
);
551 static bool trans_VMOV_to_gp(DisasContext
*s
, arg_VMOV_to_gp
*a
)
553 /* VMOV scalar to general purpose register */
558 /* UNDEF accesses to D16-D31 if they don't exist */
559 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vn
& 0x10)) {
563 offset
= a
->index
<< a
->size
;
564 pass
= extract32(offset
, 2, 1);
565 offset
= extract32(offset
, 0, 2) * 8;
567 if (a
->size
!= 2 && !arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
571 if (!vfp_access_check(s
)) {
575 tmp
= neon_load_reg(a
->vn
, pass
);
579 tcg_gen_shri_i32(tmp
, tmp
, offset
);
590 tcg_gen_shri_i32(tmp
, tmp
, 16);
596 tcg_gen_sari_i32(tmp
, tmp
, 16);
605 store_reg(s
, a
->rt
, tmp
);
610 static bool trans_VMOV_from_gp(DisasContext
*s
, arg_VMOV_from_gp
*a
)
612 /* VMOV general purpose register to scalar */
617 /* UNDEF accesses to D16-D31 if they don't exist */
618 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vn
& 0x10)) {
622 offset
= a
->index
<< a
->size
;
623 pass
= extract32(offset
, 2, 1);
624 offset
= extract32(offset
, 0, 2) * 8;
626 if (a
->size
!= 2 && !arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
630 if (!vfp_access_check(s
)) {
634 tmp
= load_reg(s
, a
->rt
);
637 tmp2
= neon_load_reg(a
->vn
, pass
);
638 tcg_gen_deposit_i32(tmp
, tmp2
, tmp
, offset
, 8);
639 tcg_temp_free_i32(tmp2
);
642 tmp2
= neon_load_reg(a
->vn
, pass
);
643 tcg_gen_deposit_i32(tmp
, tmp2
, tmp
, offset
, 16);
644 tcg_temp_free_i32(tmp2
);
649 neon_store_reg(a
->vn
, pass
, tmp
);
654 static bool trans_VDUP(DisasContext
*s
, arg_VDUP
*a
)
656 /* VDUP (general purpose register) */
660 if (!arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
664 /* UNDEF accesses to D16-D31 if they don't exist */
665 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vn
& 0x10)) {
673 if (a
->q
&& (a
->vn
& 1)) {
677 vec_size
= a
->q
? 16 : 8;
686 if (!vfp_access_check(s
)) {
690 tmp
= load_reg(s
, a
->rt
);
691 tcg_gen_gvec_dup_i32(size
, neon_reg_offset(a
->vn
, 0),
692 vec_size
, vec_size
, tmp
);
693 tcg_temp_free_i32(tmp
);
698 static bool trans_VMSR_VMRS(DisasContext
*s
, arg_VMSR_VMRS
*a
)
701 bool ignore_vfp_enabled
= false;
703 if (arm_dc_feature(s
, ARM_FEATURE_M
)) {
705 * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
706 * Accesses to R15 are UNPREDICTABLE; we choose to undef.
707 * (FPSCR -> r15 is a special case which writes to the PSR flags.)
709 if (a
->rt
== 15 && (!a
->l
|| a
->reg
!= ARM_VFP_FPSCR
)) {
717 * VFPv2 allows access to FPSID from userspace; VFPv3 restricts
718 * all ID registers to privileged access only.
720 if (IS_USER(s
) && arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
723 ignore_vfp_enabled
= true;
727 if (IS_USER(s
) || !arm_dc_feature(s
, ARM_FEATURE_MVFR
)) {
730 ignore_vfp_enabled
= true;
733 if (IS_USER(s
) || !arm_dc_feature(s
, ARM_FEATURE_V8
)) {
736 ignore_vfp_enabled
= true;
744 ignore_vfp_enabled
= true;
747 case ARM_VFP_FPINST2
:
748 /* Not present in VFPv3 */
749 if (IS_USER(s
) || arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
757 if (!full_vfp_access_check(s
, ignore_vfp_enabled
)) {
762 /* VMRS, move VFP special register to gp register */
767 case ARM_VFP_FPINST2
:
771 tmp
= load_cpu_field(vfp
.xregs
[a
->reg
]);
775 tmp
= load_cpu_field(vfp
.xregs
[ARM_VFP_FPSCR
]);
776 tcg_gen_andi_i32(tmp
, tmp
, 0xf0000000);
778 tmp
= tcg_temp_new_i32();
779 gen_helper_vfp_get_fpscr(tmp
, cpu_env
);
783 g_assert_not_reached();
787 /* Set the 4 flag bits in the CPSR. */
789 tcg_temp_free_i32(tmp
);
791 store_reg(s
, a
->rt
, tmp
);
794 /* VMSR, move gp register to VFP special register */
800 /* Writes are ignored. */
803 tmp
= load_reg(s
, a
->rt
);
804 gen_helper_vfp_set_fpscr(cpu_env
, tmp
);
805 tcg_temp_free_i32(tmp
);
810 * TODO: VFP subarchitecture support.
811 * For now, keep the EN bit only
813 tmp
= load_reg(s
, a
->rt
);
814 tcg_gen_andi_i32(tmp
, tmp
, 1 << 30);
815 store_cpu_field(tmp
, vfp
.xregs
[a
->reg
]);
819 case ARM_VFP_FPINST2
:
820 tmp
= load_reg(s
, a
->rt
);
821 store_cpu_field(tmp
, vfp
.xregs
[a
->reg
]);
824 g_assert_not_reached();
831 static bool trans_VMOV_single(DisasContext
*s
, arg_VMOV_single
*a
)
835 if (!vfp_access_check(s
)) {
840 /* VFP to general purpose register */
841 tmp
= tcg_temp_new_i32();
842 neon_load_reg32(tmp
, a
->vn
);
844 /* Set the 4 flag bits in the CPSR. */
846 tcg_temp_free_i32(tmp
);
848 store_reg(s
, a
->rt
, tmp
);
851 /* general purpose register to VFP */
852 tmp
= load_reg(s
, a
->rt
);
853 neon_store_reg32(tmp
, a
->vn
);
854 tcg_temp_free_i32(tmp
);
860 static bool trans_VMOV_64_sp(DisasContext
*s
, arg_VMOV_64_sp
*a
)
865 * VMOV between two general-purpose registers and two single precision
866 * floating point registers
868 if (!vfp_access_check(s
)) {
874 tmp
= tcg_temp_new_i32();
875 neon_load_reg32(tmp
, a
->vm
);
876 store_reg(s
, a
->rt
, tmp
);
877 tmp
= tcg_temp_new_i32();
878 neon_load_reg32(tmp
, a
->vm
+ 1);
879 store_reg(s
, a
->rt2
, tmp
);
882 tmp
= load_reg(s
, a
->rt
);
883 neon_store_reg32(tmp
, a
->vm
);
884 tcg_temp_free_i32(tmp
);
885 tmp
= load_reg(s
, a
->rt2
);
886 neon_store_reg32(tmp
, a
->vm
+ 1);
887 tcg_temp_free_i32(tmp
);
893 static bool trans_VMOV_64_dp(DisasContext
*s
, arg_VMOV_64_dp
*a
)
898 * VMOV between two general-purpose registers and one double precision
899 * floating point register
902 /* UNDEF accesses to D16-D31 if they don't exist */
903 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
907 if (!vfp_access_check(s
)) {
913 tmp
= tcg_temp_new_i32();
914 neon_load_reg32(tmp
, a
->vm
* 2);
915 store_reg(s
, a
->rt
, tmp
);
916 tmp
= tcg_temp_new_i32();
917 neon_load_reg32(tmp
, a
->vm
* 2 + 1);
918 store_reg(s
, a
->rt2
, tmp
);
921 tmp
= load_reg(s
, a
->rt
);
922 neon_store_reg32(tmp
, a
->vm
* 2);
923 tcg_temp_free_i32(tmp
);
924 tmp
= load_reg(s
, a
->rt2
);
925 neon_store_reg32(tmp
, a
->vm
* 2 + 1);
926 tcg_temp_free_i32(tmp
);
932 static bool trans_VLDR_VSTR_sp(DisasContext
*s
, arg_VLDR_VSTR_sp
*a
)
937 if (!vfp_access_check(s
)) {
941 offset
= a
->imm
<< 2;
946 /* For thumb, use of PC is UNPREDICTABLE. */
947 addr
= add_reg_for_lit(s
, a
->rn
, offset
);
948 tmp
= tcg_temp_new_i32();
950 gen_aa32_ld32u(s
, tmp
, addr
, get_mem_index(s
));
951 neon_store_reg32(tmp
, a
->vd
);
953 neon_load_reg32(tmp
, a
->vd
);
954 gen_aa32_st32(s
, tmp
, addr
, get_mem_index(s
));
956 tcg_temp_free_i32(tmp
);
957 tcg_temp_free_i32(addr
);
962 static bool trans_VLDR_VSTR_dp(DisasContext
*s
, arg_VLDR_VSTR_dp
*a
)
968 /* UNDEF accesses to D16-D31 if they don't exist */
969 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
& 0x10)) {
973 if (!vfp_access_check(s
)) {
977 offset
= a
->imm
<< 2;
982 /* For thumb, use of PC is UNPREDICTABLE. */
983 addr
= add_reg_for_lit(s
, a
->rn
, offset
);
984 tmp
= tcg_temp_new_i64();
986 gen_aa32_ld64(s
, tmp
, addr
, get_mem_index(s
));
987 neon_store_reg64(tmp
, a
->vd
);
989 neon_load_reg64(tmp
, a
->vd
);
990 gen_aa32_st64(s
, tmp
, addr
, get_mem_index(s
));
992 tcg_temp_free_i64(tmp
);
993 tcg_temp_free_i32(addr
);
998 static bool trans_VLDM_VSTM_sp(DisasContext
*s
, arg_VLDM_VSTM_sp
*a
)
1006 if (n
== 0 || (a
->vd
+ n
) > 32) {
1008 * UNPREDICTABLE cases for bad immediates: we choose to
1009 * UNDEF to avoid generating huge numbers of TCG ops
1013 if (a
->rn
== 15 && a
->w
) {
1014 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1018 if (!vfp_access_check(s
)) {
1022 /* For thumb, use of PC is UNPREDICTABLE. */
1023 addr
= add_reg_for_lit(s
, a
->rn
, 0);
1026 tcg_gen_addi_i32(addr
, addr
, -(a
->imm
<< 2));
1029 if (s
->v8m_stackcheck
&& a
->rn
== 13 && a
->w
) {
1031 * Here 'addr' is the lowest address we will store to,
1032 * and is either the old SP (if post-increment) or
1033 * the new SP (if pre-decrement). For post-increment
1034 * where the old value is below the limit and the new
1035 * value is above, it is UNKNOWN whether the limit check
1036 * triggers; we choose to trigger.
1038 gen_helper_v8m_stackcheck(cpu_env
, addr
);
1042 tmp
= tcg_temp_new_i32();
1043 for (i
= 0; i
< n
; i
++) {
1046 gen_aa32_ld32u(s
, tmp
, addr
, get_mem_index(s
));
1047 neon_store_reg32(tmp
, a
->vd
+ i
);
1050 neon_load_reg32(tmp
, a
->vd
+ i
);
1051 gen_aa32_st32(s
, tmp
, addr
, get_mem_index(s
));
1053 tcg_gen_addi_i32(addr
, addr
, offset
);
1055 tcg_temp_free_i32(tmp
);
1059 offset
= -offset
* n
;
1060 tcg_gen_addi_i32(addr
, addr
, offset
);
1062 store_reg(s
, a
->rn
, addr
);
1064 tcg_temp_free_i32(addr
);
1070 static bool trans_VLDM_VSTM_dp(DisasContext
*s
, arg_VLDM_VSTM_dp
*a
)
1079 if (n
== 0 || (a
->vd
+ n
) > 32 || n
> 16) {
1081 * UNPREDICTABLE cases for bad immediates: we choose to
1082 * UNDEF to avoid generating huge numbers of TCG ops
1086 if (a
->rn
== 15 && a
->w
) {
1087 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1091 /* UNDEF accesses to D16-D31 if they don't exist */
1092 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
+ n
) > 16) {
1096 if (!vfp_access_check(s
)) {
1100 /* For thumb, use of PC is UNPREDICTABLE. */
1101 addr
= add_reg_for_lit(s
, a
->rn
, 0);
1104 tcg_gen_addi_i32(addr
, addr
, -(a
->imm
<< 2));
1107 if (s
->v8m_stackcheck
&& a
->rn
== 13 && a
->w
) {
1109 * Here 'addr' is the lowest address we will store to,
1110 * and is either the old SP (if post-increment) or
1111 * the new SP (if pre-decrement). For post-increment
1112 * where the old value is below the limit and the new
1113 * value is above, it is UNKNOWN whether the limit check
1114 * triggers; we choose to trigger.
1116 gen_helper_v8m_stackcheck(cpu_env
, addr
);
1120 tmp
= tcg_temp_new_i64();
1121 for (i
= 0; i
< n
; i
++) {
1124 gen_aa32_ld64(s
, tmp
, addr
, get_mem_index(s
));
1125 neon_store_reg64(tmp
, a
->vd
+ i
);
1128 neon_load_reg64(tmp
, a
->vd
+ i
);
1129 gen_aa32_st64(s
, tmp
, addr
, get_mem_index(s
));
1131 tcg_gen_addi_i32(addr
, addr
, offset
);
1133 tcg_temp_free_i64(tmp
);
1137 offset
= -offset
* n
;
1138 } else if (a
->imm
& 1) {
1145 tcg_gen_addi_i32(addr
, addr
, offset
);
1147 store_reg(s
, a
->rn
, addr
);
1149 tcg_temp_free_i32(addr
);
1156 * Types for callbacks for do_vfp_3op_sp() and do_vfp_3op_dp().
1157 * The callback should emit code to write a value to vd. If
1158 * do_vfp_3op_{sp,dp}() was passed reads_vd then the TCGv vd
1159 * will contain the old value of the relevant VFP register;
1160 * otherwise it must be written to only.
1162 typedef void VFPGen3OpSPFn(TCGv_i32 vd
,
1163 TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
);
1164 typedef void VFPGen3OpDPFn(TCGv_i64 vd
,
1165 TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
);
1168 * Types for callbacks for do_vfp_2op_sp() and do_vfp_2op_dp().
1169 * The callback should emit code to write a value to vd (which
1170 * should be written to only).
1172 typedef void VFPGen2OpSPFn(TCGv_i32 vd
, TCGv_i32 vm
);
1173 typedef void VFPGen2OpDPFn(TCGv_i64 vd
, TCGv_i64 vm
);
1176 * Return true if the specified S reg is in a scalar bank
1177 * (ie if it is s0..s7)
1179 static inline bool vfp_sreg_is_scalar(int reg
)
1181 return (reg
& 0x18) == 0;
1185 * Return true if the specified D reg is in a scalar bank
1186 * (ie if it is d0..d3 or d16..d19)
1188 static inline bool vfp_dreg_is_scalar(int reg
)
1190 return (reg
& 0xc) == 0;
1194 * Advance the S reg number forwards by delta within its bank
1195 * (ie increment the low 3 bits but leave the rest the same)
1197 static inline int vfp_advance_sreg(int reg
, int delta
)
1199 return ((reg
+ delta
) & 0x7) | (reg
& ~0x7);
1203 * Advance the D reg number forwards by delta within its bank
1204 * (ie increment the low 2 bits but leave the rest the same)
1206 static inline int vfp_advance_dreg(int reg
, int delta
)
1208 return ((reg
+ delta
) & 0x3) | (reg
& ~0x3);
1212 * Perform a 3-operand VFP data processing instruction. fn is the
1213 * callback to do the actual operation; this function deals with the
1214 * code to handle looping around for VFP vector processing.
1216 static bool do_vfp_3op_sp(DisasContext
*s
, VFPGen3OpSPFn
*fn
,
1217 int vd
, int vn
, int vm
, bool reads_vd
)
1219 uint32_t delta_m
= 0;
1220 uint32_t delta_d
= 0;
1221 int veclen
= s
->vec_len
;
1222 TCGv_i32 f0
, f1
, fd
;
1225 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1226 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1230 if (!vfp_access_check(s
)) {
1235 /* Figure out what type of vector operation this is. */
1236 if (vfp_sreg_is_scalar(vd
)) {
1240 delta_d
= s
->vec_stride
+ 1;
1242 if (vfp_sreg_is_scalar(vm
)) {
1243 /* mixed scalar/vector */
1252 f0
= tcg_temp_new_i32();
1253 f1
= tcg_temp_new_i32();
1254 fd
= tcg_temp_new_i32();
1255 fpst
= get_fpstatus_ptr(0);
1257 neon_load_reg32(f0
, vn
);
1258 neon_load_reg32(f1
, vm
);
1262 neon_load_reg32(fd
, vd
);
1264 fn(fd
, f0
, f1
, fpst
);
1265 neon_store_reg32(fd
, vd
);
1271 /* Set up the operands for the next iteration */
1273 vd
= vfp_advance_sreg(vd
, delta_d
);
1274 vn
= vfp_advance_sreg(vn
, delta_d
);
1275 neon_load_reg32(f0
, vn
);
1277 vm
= vfp_advance_sreg(vm
, delta_m
);
1278 neon_load_reg32(f1
, vm
);
1282 tcg_temp_free_i32(f0
);
1283 tcg_temp_free_i32(f1
);
1284 tcg_temp_free_i32(fd
);
1285 tcg_temp_free_ptr(fpst
);
1290 static bool do_vfp_3op_dp(DisasContext
*s
, VFPGen3OpDPFn
*fn
,
1291 int vd
, int vn
, int vm
, bool reads_vd
)
1293 uint32_t delta_m
= 0;
1294 uint32_t delta_d
= 0;
1295 int veclen
= s
->vec_len
;
1296 TCGv_i64 f0
, f1
, fd
;
1299 /* UNDEF accesses to D16-D31 if they don't exist */
1300 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((vd
| vn
| vm
) & 0x10)) {
1304 if (!dc_isar_feature(aa32_fpdp
, s
)) {
1308 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1309 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1313 if (!vfp_access_check(s
)) {
1318 /* Figure out what type of vector operation this is. */
1319 if (vfp_dreg_is_scalar(vd
)) {
1323 delta_d
= (s
->vec_stride
>> 1) + 1;
1325 if (vfp_dreg_is_scalar(vm
)) {
1326 /* mixed scalar/vector */
1335 f0
= tcg_temp_new_i64();
1336 f1
= tcg_temp_new_i64();
1337 fd
= tcg_temp_new_i64();
1338 fpst
= get_fpstatus_ptr(0);
1340 neon_load_reg64(f0
, vn
);
1341 neon_load_reg64(f1
, vm
);
1345 neon_load_reg64(fd
, vd
);
1347 fn(fd
, f0
, f1
, fpst
);
1348 neon_store_reg64(fd
, vd
);
1353 /* Set up the operands for the next iteration */
1355 vd
= vfp_advance_dreg(vd
, delta_d
);
1356 vn
= vfp_advance_dreg(vn
, delta_d
);
1357 neon_load_reg64(f0
, vn
);
1359 vm
= vfp_advance_dreg(vm
, delta_m
);
1360 neon_load_reg64(f1
, vm
);
1364 tcg_temp_free_i64(f0
);
1365 tcg_temp_free_i64(f1
);
1366 tcg_temp_free_i64(fd
);
1367 tcg_temp_free_ptr(fpst
);
1372 static bool do_vfp_2op_sp(DisasContext
*s
, VFPGen2OpSPFn
*fn
, int vd
, int vm
)
1374 uint32_t delta_m
= 0;
1375 uint32_t delta_d
= 0;
1376 int veclen
= s
->vec_len
;
1379 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1380 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1384 if (!vfp_access_check(s
)) {
1389 /* Figure out what type of vector operation this is. */
1390 if (vfp_sreg_is_scalar(vd
)) {
1394 delta_d
= s
->vec_stride
+ 1;
1396 if (vfp_sreg_is_scalar(vm
)) {
1397 /* mixed scalar/vector */
1406 f0
= tcg_temp_new_i32();
1407 fd
= tcg_temp_new_i32();
1409 neon_load_reg32(f0
, vm
);
1413 neon_store_reg32(fd
, vd
);
1420 /* single source one-many */
1422 vd
= vfp_advance_sreg(vd
, delta_d
);
1423 neon_store_reg32(fd
, vd
);
1428 /* Set up the operands for the next iteration */
1430 vd
= vfp_advance_sreg(vd
, delta_d
);
1431 vm
= vfp_advance_sreg(vm
, delta_m
);
1432 neon_load_reg32(f0
, vm
);
1435 tcg_temp_free_i32(f0
);
1436 tcg_temp_free_i32(fd
);
1441 static bool do_vfp_2op_dp(DisasContext
*s
, VFPGen2OpDPFn
*fn
, int vd
, int vm
)
1443 uint32_t delta_m
= 0;
1444 uint32_t delta_d
= 0;
1445 int veclen
= s
->vec_len
;
1448 /* UNDEF accesses to D16-D31 if they don't exist */
1449 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((vd
| vm
) & 0x10)) {
1453 if (!dc_isar_feature(aa32_fpdp
, s
)) {
1457 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1458 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1462 if (!vfp_access_check(s
)) {
1467 /* Figure out what type of vector operation this is. */
1468 if (vfp_dreg_is_scalar(vd
)) {
1472 delta_d
= (s
->vec_stride
>> 1) + 1;
1474 if (vfp_dreg_is_scalar(vm
)) {
1475 /* mixed scalar/vector */
1484 f0
= tcg_temp_new_i64();
1485 fd
= tcg_temp_new_i64();
1487 neon_load_reg64(f0
, vm
);
1491 neon_store_reg64(fd
, vd
);
1498 /* single source one-many */
1500 vd
= vfp_advance_dreg(vd
, delta_d
);
1501 neon_store_reg64(fd
, vd
);
1506 /* Set up the operands for the next iteration */
1508 vd
= vfp_advance_dreg(vd
, delta_d
);
1509 vd
= vfp_advance_dreg(vm
, delta_m
);
1510 neon_load_reg64(f0
, vm
);
1513 tcg_temp_free_i64(f0
);
1514 tcg_temp_free_i64(fd
);
1519 static void gen_VMLA_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1521 /* Note that order of inputs to the add matters for NaNs */
1522 TCGv_i32 tmp
= tcg_temp_new_i32();
1524 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1525 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1526 tcg_temp_free_i32(tmp
);
1529 static bool trans_VMLA_sp(DisasContext
*s
, arg_VMLA_sp
*a
)
1531 return do_vfp_3op_sp(s
, gen_VMLA_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1534 static void gen_VMLA_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1536 /* Note that order of inputs to the add matters for NaNs */
1537 TCGv_i64 tmp
= tcg_temp_new_i64();
1539 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1540 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1541 tcg_temp_free_i64(tmp
);
1544 static bool trans_VMLA_dp(DisasContext
*s
, arg_VMLA_dp
*a
)
1546 return do_vfp_3op_dp(s
, gen_VMLA_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1549 static void gen_VMLS_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1552 * VMLS: vd = vd + -(vn * vm)
1553 * Note that order of inputs to the add matters for NaNs.
1555 TCGv_i32 tmp
= tcg_temp_new_i32();
1557 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1558 gen_helper_vfp_negs(tmp
, tmp
);
1559 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1560 tcg_temp_free_i32(tmp
);
1563 static bool trans_VMLS_sp(DisasContext
*s
, arg_VMLS_sp
*a
)
1565 return do_vfp_3op_sp(s
, gen_VMLS_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1568 static void gen_VMLS_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1571 * VMLS: vd = vd + -(vn * vm)
1572 * Note that order of inputs to the add matters for NaNs.
1574 TCGv_i64 tmp
= tcg_temp_new_i64();
1576 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1577 gen_helper_vfp_negd(tmp
, tmp
);
1578 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1579 tcg_temp_free_i64(tmp
);
1582 static bool trans_VMLS_dp(DisasContext
*s
, arg_VMLS_dp
*a
)
1584 return do_vfp_3op_dp(s
, gen_VMLS_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1587 static void gen_VNMLS_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1590 * VNMLS: -fd + (fn * fm)
1591 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1592 * plausible looking simplifications because this will give wrong results
1595 TCGv_i32 tmp
= tcg_temp_new_i32();
1597 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1598 gen_helper_vfp_negs(vd
, vd
);
1599 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1600 tcg_temp_free_i32(tmp
);
1603 static bool trans_VNMLS_sp(DisasContext
*s
, arg_VNMLS_sp
*a
)
1605 return do_vfp_3op_sp(s
, gen_VNMLS_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1608 static void gen_VNMLS_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1611 * VNMLS: -fd + (fn * fm)
1612 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1613 * plausible looking simplifications because this will give wrong results
1616 TCGv_i64 tmp
= tcg_temp_new_i64();
1618 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1619 gen_helper_vfp_negd(vd
, vd
);
1620 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1621 tcg_temp_free_i64(tmp
);
1624 static bool trans_VNMLS_dp(DisasContext
*s
, arg_VNMLS_dp
*a
)
1626 return do_vfp_3op_dp(s
, gen_VNMLS_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1629 static void gen_VNMLA_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1631 /* VNMLA: -fd + -(fn * fm) */
1632 TCGv_i32 tmp
= tcg_temp_new_i32();
1634 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1635 gen_helper_vfp_negs(tmp
, tmp
);
1636 gen_helper_vfp_negs(vd
, vd
);
1637 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1638 tcg_temp_free_i32(tmp
);
1641 static bool trans_VNMLA_sp(DisasContext
*s
, arg_VNMLA_sp
*a
)
1643 return do_vfp_3op_sp(s
, gen_VNMLA_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1646 static void gen_VNMLA_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1648 /* VNMLA: -fd + (fn * fm) */
1649 TCGv_i64 tmp
= tcg_temp_new_i64();
1651 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1652 gen_helper_vfp_negd(tmp
, tmp
);
1653 gen_helper_vfp_negd(vd
, vd
);
1654 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1655 tcg_temp_free_i64(tmp
);
1658 static bool trans_VNMLA_dp(DisasContext
*s
, arg_VNMLA_dp
*a
)
1660 return do_vfp_3op_dp(s
, gen_VNMLA_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1663 static bool trans_VMUL_sp(DisasContext
*s
, arg_VMUL_sp
*a
)
1665 return do_vfp_3op_sp(s
, gen_helper_vfp_muls
, a
->vd
, a
->vn
, a
->vm
, false);
1668 static bool trans_VMUL_dp(DisasContext
*s
, arg_VMUL_dp
*a
)
1670 return do_vfp_3op_dp(s
, gen_helper_vfp_muld
, a
->vd
, a
->vn
, a
->vm
, false);
1673 static void gen_VNMUL_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1675 /* VNMUL: -(fn * fm) */
1676 gen_helper_vfp_muls(vd
, vn
, vm
, fpst
);
1677 gen_helper_vfp_negs(vd
, vd
);
1680 static bool trans_VNMUL_sp(DisasContext
*s
, arg_VNMUL_sp
*a
)
1682 return do_vfp_3op_sp(s
, gen_VNMUL_sp
, a
->vd
, a
->vn
, a
->vm
, false);
1685 static void gen_VNMUL_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1687 /* VNMUL: -(fn * fm) */
1688 gen_helper_vfp_muld(vd
, vn
, vm
, fpst
);
1689 gen_helper_vfp_negd(vd
, vd
);
1692 static bool trans_VNMUL_dp(DisasContext
*s
, arg_VNMUL_dp
*a
)
1694 return do_vfp_3op_dp(s
, gen_VNMUL_dp
, a
->vd
, a
->vn
, a
->vm
, false);
1697 static bool trans_VADD_sp(DisasContext
*s
, arg_VADD_sp
*a
)
1699 return do_vfp_3op_sp(s
, gen_helper_vfp_adds
, a
->vd
, a
->vn
, a
->vm
, false);
1702 static bool trans_VADD_dp(DisasContext
*s
, arg_VADD_dp
*a
)
1704 return do_vfp_3op_dp(s
, gen_helper_vfp_addd
, a
->vd
, a
->vn
, a
->vm
, false);
1707 static bool trans_VSUB_sp(DisasContext
*s
, arg_VSUB_sp
*a
)
1709 return do_vfp_3op_sp(s
, gen_helper_vfp_subs
, a
->vd
, a
->vn
, a
->vm
, false);
1712 static bool trans_VSUB_dp(DisasContext
*s
, arg_VSUB_dp
*a
)
1714 return do_vfp_3op_dp(s
, gen_helper_vfp_subd
, a
->vd
, a
->vn
, a
->vm
, false);
1717 static bool trans_VDIV_sp(DisasContext
*s
, arg_VDIV_sp
*a
)
1719 return do_vfp_3op_sp(s
, gen_helper_vfp_divs
, a
->vd
, a
->vn
, a
->vm
, false);
1722 static bool trans_VDIV_dp(DisasContext
*s
, arg_VDIV_dp
*a
)
1724 return do_vfp_3op_dp(s
, gen_helper_vfp_divd
, a
->vd
, a
->vn
, a
->vm
, false);
1727 static bool trans_VFM_sp(DisasContext
*s
, arg_VFM_sp
*a
)
1730 * VFNMA : fd = muladd(-fd, fn, fm)
1731 * VFNMS : fd = muladd(-fd, -fn, fm)
1732 * VFMA : fd = muladd( fd, fn, fm)
1733 * VFMS : fd = muladd( fd, -fn, fm)
1735 * These are fused multiply-add, and must be done as one floating
1736 * point operation with no rounding between the multiplication and
1737 * addition steps. NB that doing the negations here as separate
1738 * steps is correct : an input NaN should come out with its sign
1739 * bit flipped if it is a negated-input.
1742 TCGv_i32 vn
, vm
, vd
;
1745 * Present in VFPv4 only.
1746 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
1747 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
1749 if (!arm_dc_feature(s
, ARM_FEATURE_VFP4
) ||
1750 (s
->vec_len
!= 0 || s
->vec_stride
!= 0)) {
1754 if (!vfp_access_check(s
)) {
1758 vn
= tcg_temp_new_i32();
1759 vm
= tcg_temp_new_i32();
1760 vd
= tcg_temp_new_i32();
1762 neon_load_reg32(vn
, a
->vn
);
1763 neon_load_reg32(vm
, a
->vm
);
1766 gen_helper_vfp_negs(vn
, vn
);
1768 neon_load_reg32(vd
, a
->vd
);
1771 gen_helper_vfp_negs(vd
, vd
);
1773 fpst
= get_fpstatus_ptr(0);
1774 gen_helper_vfp_muladds(vd
, vn
, vm
, vd
, fpst
);
1775 neon_store_reg32(vd
, a
->vd
);
1777 tcg_temp_free_ptr(fpst
);
1778 tcg_temp_free_i32(vn
);
1779 tcg_temp_free_i32(vm
);
1780 tcg_temp_free_i32(vd
);
1785 static bool trans_VFM_dp(DisasContext
*s
, arg_VFM_dp
*a
)
1788 * VFNMA : fd = muladd(-fd, fn, fm)
1789 * VFNMS : fd = muladd(-fd, -fn, fm)
1790 * VFMA : fd = muladd( fd, fn, fm)
1791 * VFMS : fd = muladd( fd, -fn, fm)
1793 * These are fused multiply-add, and must be done as one floating
1794 * point operation with no rounding between the multiplication and
1795 * addition steps. NB that doing the negations here as separate
1796 * steps is correct : an input NaN should come out with its sign
1797 * bit flipped if it is a negated-input.
1800 TCGv_i64 vn
, vm
, vd
;
1803 * Present in VFPv4 only.
1804 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
1805 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
1807 if (!arm_dc_feature(s
, ARM_FEATURE_VFP4
) ||
1808 (s
->vec_len
!= 0 || s
->vec_stride
!= 0)) {
1812 /* UNDEF accesses to D16-D31 if they don't exist. */
1813 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((a
->vd
| a
->vn
| a
->vm
) & 0x10)) {
1817 if (!dc_isar_feature(aa32_fpdp
, s
)) {
1821 if (!vfp_access_check(s
)) {
1825 vn
= tcg_temp_new_i64();
1826 vm
= tcg_temp_new_i64();
1827 vd
= tcg_temp_new_i64();
1829 neon_load_reg64(vn
, a
->vn
);
1830 neon_load_reg64(vm
, a
->vm
);
1833 gen_helper_vfp_negd(vn
, vn
);
1835 neon_load_reg64(vd
, a
->vd
);
1838 gen_helper_vfp_negd(vd
, vd
);
1840 fpst
= get_fpstatus_ptr(0);
1841 gen_helper_vfp_muladdd(vd
, vn
, vm
, vd
, fpst
);
1842 neon_store_reg64(vd
, a
->vd
);
1844 tcg_temp_free_ptr(fpst
);
1845 tcg_temp_free_i64(vn
);
1846 tcg_temp_free_i64(vm
);
1847 tcg_temp_free_i64(vd
);
1852 static bool trans_VMOV_imm_sp(DisasContext
*s
, arg_VMOV_imm_sp
*a
)
1854 uint32_t delta_d
= 0;
1855 int veclen
= s
->vec_len
;
1861 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1862 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1866 if (!arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
1870 if (!vfp_access_check(s
)) {
1875 /* Figure out what type of vector operation this is. */
1876 if (vfp_sreg_is_scalar(vd
)) {
1880 delta_d
= s
->vec_stride
+ 1;
1884 fd
= tcg_const_i32(vfp_expand_imm(MO_32
, a
->imm
));
1887 neon_store_reg32(fd
, vd
);
1893 /* Set up the operands for the next iteration */
1895 vd
= vfp_advance_sreg(vd
, delta_d
);
1898 tcg_temp_free_i32(fd
);
1902 static bool trans_VMOV_imm_dp(DisasContext
*s
, arg_VMOV_imm_dp
*a
)
1904 uint32_t delta_d
= 0;
1905 int veclen
= s
->vec_len
;
1911 /* UNDEF accesses to D16-D31 if they don't exist. */
1912 if (!dc_isar_feature(aa32_fp_d32
, s
) && (vd
& 0x10)) {
1916 if (!dc_isar_feature(aa32_fpdp
, s
)) {
1920 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1921 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1925 if (!arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
1929 if (!vfp_access_check(s
)) {
1934 /* Figure out what type of vector operation this is. */
1935 if (vfp_dreg_is_scalar(vd
)) {
1939 delta_d
= (s
->vec_stride
>> 1) + 1;
1943 fd
= tcg_const_i64(vfp_expand_imm(MO_64
, a
->imm
));
1946 neon_store_reg64(fd
, vd
);
1952 /* Set up the operands for the next iteration */
1954 vd
= vfp_advance_dreg(vd
, delta_d
);
1957 tcg_temp_free_i64(fd
);
1961 static bool trans_VMOV_reg_sp(DisasContext
*s
, arg_VMOV_reg_sp
*a
)
1963 return do_vfp_2op_sp(s
, tcg_gen_mov_i32
, a
->vd
, a
->vm
);
1966 static bool trans_VMOV_reg_dp(DisasContext
*s
, arg_VMOV_reg_dp
*a
)
1968 return do_vfp_2op_dp(s
, tcg_gen_mov_i64
, a
->vd
, a
->vm
);
1971 static bool trans_VABS_sp(DisasContext
*s
, arg_VABS_sp
*a
)
1973 return do_vfp_2op_sp(s
, gen_helper_vfp_abss
, a
->vd
, a
->vm
);
1976 static bool trans_VABS_dp(DisasContext
*s
, arg_VABS_dp
*a
)
1978 return do_vfp_2op_dp(s
, gen_helper_vfp_absd
, a
->vd
, a
->vm
);
1981 static bool trans_VNEG_sp(DisasContext
*s
, arg_VNEG_sp
*a
)
1983 return do_vfp_2op_sp(s
, gen_helper_vfp_negs
, a
->vd
, a
->vm
);
1986 static bool trans_VNEG_dp(DisasContext
*s
, arg_VNEG_dp
*a
)
1988 return do_vfp_2op_dp(s
, gen_helper_vfp_negd
, a
->vd
, a
->vm
);
1991 static void gen_VSQRT_sp(TCGv_i32 vd
, TCGv_i32 vm
)
1993 gen_helper_vfp_sqrts(vd
, vm
, cpu_env
);
1996 static bool trans_VSQRT_sp(DisasContext
*s
, arg_VSQRT_sp
*a
)
1998 return do_vfp_2op_sp(s
, gen_VSQRT_sp
, a
->vd
, a
->vm
);
2001 static void gen_VSQRT_dp(TCGv_i64 vd
, TCGv_i64 vm
)
2003 gen_helper_vfp_sqrtd(vd
, vm
, cpu_env
);
2006 static bool trans_VSQRT_dp(DisasContext
*s
, arg_VSQRT_dp
*a
)
2008 return do_vfp_2op_dp(s
, gen_VSQRT_dp
, a
->vd
, a
->vm
);
2011 static bool trans_VCMP_sp(DisasContext
*s
, arg_VCMP_sp
*a
)
2015 /* Vm/M bits must be zero for the Z variant */
2016 if (a
->z
&& a
->vm
!= 0) {
2020 if (!vfp_access_check(s
)) {
2024 vd
= tcg_temp_new_i32();
2025 vm
= tcg_temp_new_i32();
2027 neon_load_reg32(vd
, a
->vd
);
2029 tcg_gen_movi_i32(vm
, 0);
2031 neon_load_reg32(vm
, a
->vm
);
2035 gen_helper_vfp_cmpes(vd
, vm
, cpu_env
);
2037 gen_helper_vfp_cmps(vd
, vm
, cpu_env
);
2040 tcg_temp_free_i32(vd
);
2041 tcg_temp_free_i32(vm
);
2046 static bool trans_VCMP_dp(DisasContext
*s
, arg_VCMP_dp
*a
)
2050 /* Vm/M bits must be zero for the Z variant */
2051 if (a
->z
&& a
->vm
!= 0) {
2055 /* UNDEF accesses to D16-D31 if they don't exist. */
2056 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2060 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2064 if (!vfp_access_check(s
)) {
2068 vd
= tcg_temp_new_i64();
2069 vm
= tcg_temp_new_i64();
2071 neon_load_reg64(vd
, a
->vd
);
2073 tcg_gen_movi_i64(vm
, 0);
2075 neon_load_reg64(vm
, a
->vm
);
2079 gen_helper_vfp_cmped(vd
, vm
, cpu_env
);
2081 gen_helper_vfp_cmpd(vd
, vm
, cpu_env
);
2084 tcg_temp_free_i64(vd
);
2085 tcg_temp_free_i64(vm
);
2090 static bool trans_VCVT_f32_f16(DisasContext
*s
, arg_VCVT_f32_f16
*a
)
2096 if (!dc_isar_feature(aa32_fp16_spconv
, s
)) {
2100 if (!vfp_access_check(s
)) {
2104 fpst
= get_fpstatus_ptr(false);
2105 ahp_mode
= get_ahp_flag();
2106 tmp
= tcg_temp_new_i32();
2107 /* The T bit tells us if we want the low or high 16 bits of Vm */
2108 tcg_gen_ld16u_i32(tmp
, cpu_env
, vfp_f16_offset(a
->vm
, a
->t
));
2109 gen_helper_vfp_fcvt_f16_to_f32(tmp
, tmp
, fpst
, ahp_mode
);
2110 neon_store_reg32(tmp
, a
->vd
);
2111 tcg_temp_free_i32(ahp_mode
);
2112 tcg_temp_free_ptr(fpst
);
2113 tcg_temp_free_i32(tmp
);
2117 static bool trans_VCVT_f64_f16(DisasContext
*s
, arg_VCVT_f64_f16
*a
)
2124 if (!dc_isar_feature(aa32_fp16_dpconv
, s
)) {
2128 /* UNDEF accesses to D16-D31 if they don't exist. */
2129 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
& 0x10)) {
2133 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2137 if (!vfp_access_check(s
)) {
2141 fpst
= get_fpstatus_ptr(false);
2142 ahp_mode
= get_ahp_flag();
2143 tmp
= tcg_temp_new_i32();
2144 /* The T bit tells us if we want the low or high 16 bits of Vm */
2145 tcg_gen_ld16u_i32(tmp
, cpu_env
, vfp_f16_offset(a
->vm
, a
->t
));
2146 vd
= tcg_temp_new_i64();
2147 gen_helper_vfp_fcvt_f16_to_f64(vd
, tmp
, fpst
, ahp_mode
);
2148 neon_store_reg64(vd
, a
->vd
);
2149 tcg_temp_free_i32(ahp_mode
);
2150 tcg_temp_free_ptr(fpst
);
2151 tcg_temp_free_i32(tmp
);
2152 tcg_temp_free_i64(vd
);
2156 static bool trans_VCVT_f16_f32(DisasContext
*s
, arg_VCVT_f16_f32
*a
)
2162 if (!dc_isar_feature(aa32_fp16_spconv
, s
)) {
2166 if (!vfp_access_check(s
)) {
2170 fpst
= get_fpstatus_ptr(false);
2171 ahp_mode
= get_ahp_flag();
2172 tmp
= tcg_temp_new_i32();
2174 neon_load_reg32(tmp
, a
->vm
);
2175 gen_helper_vfp_fcvt_f32_to_f16(tmp
, tmp
, fpst
, ahp_mode
);
2176 tcg_gen_st16_i32(tmp
, cpu_env
, vfp_f16_offset(a
->vd
, a
->t
));
2177 tcg_temp_free_i32(ahp_mode
);
2178 tcg_temp_free_ptr(fpst
);
2179 tcg_temp_free_i32(tmp
);
2183 static bool trans_VCVT_f16_f64(DisasContext
*s
, arg_VCVT_f16_f64
*a
)
2190 if (!dc_isar_feature(aa32_fp16_dpconv
, s
)) {
2194 /* UNDEF accesses to D16-D31 if they don't exist. */
2195 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
2199 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2203 if (!vfp_access_check(s
)) {
2207 fpst
= get_fpstatus_ptr(false);
2208 ahp_mode
= get_ahp_flag();
2209 tmp
= tcg_temp_new_i32();
2210 vm
= tcg_temp_new_i64();
2212 neon_load_reg64(vm
, a
->vm
);
2213 gen_helper_vfp_fcvt_f64_to_f16(tmp
, vm
, fpst
, ahp_mode
);
2214 tcg_temp_free_i64(vm
);
2215 tcg_gen_st16_i32(tmp
, cpu_env
, vfp_f16_offset(a
->vd
, a
->t
));
2216 tcg_temp_free_i32(ahp_mode
);
2217 tcg_temp_free_ptr(fpst
);
2218 tcg_temp_free_i32(tmp
);
2222 static bool trans_VRINTR_sp(DisasContext
*s
, arg_VRINTR_sp
*a
)
2227 if (!dc_isar_feature(aa32_vrint
, s
)) {
2231 if (!vfp_access_check(s
)) {
2235 tmp
= tcg_temp_new_i32();
2236 neon_load_reg32(tmp
, a
->vm
);
2237 fpst
= get_fpstatus_ptr(false);
2238 gen_helper_rints(tmp
, tmp
, fpst
);
2239 neon_store_reg32(tmp
, a
->vd
);
2240 tcg_temp_free_ptr(fpst
);
2241 tcg_temp_free_i32(tmp
);
2245 static bool trans_VRINTR_dp(DisasContext
*s
, arg_VRINTR_dp
*a
)
2250 if (!dc_isar_feature(aa32_vrint
, s
)) {
2254 /* UNDEF accesses to D16-D31 if they don't exist. */
2255 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2259 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2263 if (!vfp_access_check(s
)) {
2267 tmp
= tcg_temp_new_i64();
2268 neon_load_reg64(tmp
, a
->vm
);
2269 fpst
= get_fpstatus_ptr(false);
2270 gen_helper_rintd(tmp
, tmp
, fpst
);
2271 neon_store_reg64(tmp
, a
->vd
);
2272 tcg_temp_free_ptr(fpst
);
2273 tcg_temp_free_i64(tmp
);
2277 static bool trans_VRINTZ_sp(DisasContext
*s
, arg_VRINTZ_sp
*a
)
2283 if (!dc_isar_feature(aa32_vrint
, s
)) {
2287 if (!vfp_access_check(s
)) {
2291 tmp
= tcg_temp_new_i32();
2292 neon_load_reg32(tmp
, a
->vm
);
2293 fpst
= get_fpstatus_ptr(false);
2294 tcg_rmode
= tcg_const_i32(float_round_to_zero
);
2295 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
2296 gen_helper_rints(tmp
, tmp
, fpst
);
2297 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
2298 neon_store_reg32(tmp
, a
->vd
);
2299 tcg_temp_free_ptr(fpst
);
2300 tcg_temp_free_i32(tcg_rmode
);
2301 tcg_temp_free_i32(tmp
);
2305 static bool trans_VRINTZ_dp(DisasContext
*s
, arg_VRINTZ_dp
*a
)
2311 if (!dc_isar_feature(aa32_vrint
, s
)) {
2315 /* UNDEF accesses to D16-D31 if they don't exist. */
2316 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2320 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2324 if (!vfp_access_check(s
)) {
2328 tmp
= tcg_temp_new_i64();
2329 neon_load_reg64(tmp
, a
->vm
);
2330 fpst
= get_fpstatus_ptr(false);
2331 tcg_rmode
= tcg_const_i32(float_round_to_zero
);
2332 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
2333 gen_helper_rintd(tmp
, tmp
, fpst
);
2334 gen_helper_set_rmode(tcg_rmode
, tcg_rmode
, fpst
);
2335 neon_store_reg64(tmp
, a
->vd
);
2336 tcg_temp_free_ptr(fpst
);
2337 tcg_temp_free_i64(tmp
);
2338 tcg_temp_free_i32(tcg_rmode
);
2342 static bool trans_VRINTX_sp(DisasContext
*s
, arg_VRINTX_sp
*a
)
2347 if (!dc_isar_feature(aa32_vrint
, s
)) {
2351 if (!vfp_access_check(s
)) {
2355 tmp
= tcg_temp_new_i32();
2356 neon_load_reg32(tmp
, a
->vm
);
2357 fpst
= get_fpstatus_ptr(false);
2358 gen_helper_rints_exact(tmp
, tmp
, fpst
);
2359 neon_store_reg32(tmp
, a
->vd
);
2360 tcg_temp_free_ptr(fpst
);
2361 tcg_temp_free_i32(tmp
);
2365 static bool trans_VRINTX_dp(DisasContext
*s
, arg_VRINTX_dp
*a
)
2370 if (!dc_isar_feature(aa32_vrint
, s
)) {
2374 /* UNDEF accesses to D16-D31 if they don't exist. */
2375 if (!dc_isar_feature(aa32_fp_d32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2379 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2383 if (!vfp_access_check(s
)) {
2387 tmp
= tcg_temp_new_i64();
2388 neon_load_reg64(tmp
, a
->vm
);
2389 fpst
= get_fpstatus_ptr(false);
2390 gen_helper_rintd_exact(tmp
, tmp
, fpst
);
2391 neon_store_reg64(tmp
, a
->vd
);
2392 tcg_temp_free_ptr(fpst
);
2393 tcg_temp_free_i64(tmp
);
2397 static bool trans_VCVT_sp(DisasContext
*s
, arg_VCVT_sp
*a
)
2402 /* UNDEF accesses to D16-D31 if they don't exist. */
2403 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
& 0x10)) {
2407 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2411 if (!vfp_access_check(s
)) {
2415 vm
= tcg_temp_new_i32();
2416 vd
= tcg_temp_new_i64();
2417 neon_load_reg32(vm
, a
->vm
);
2418 gen_helper_vfp_fcvtds(vd
, vm
, cpu_env
);
2419 neon_store_reg64(vd
, a
->vd
);
2420 tcg_temp_free_i32(vm
);
2421 tcg_temp_free_i64(vd
);
2425 static bool trans_VCVT_dp(DisasContext
*s
, arg_VCVT_dp
*a
)
2430 /* UNDEF accesses to D16-D31 if they don't exist. */
2431 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
2435 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2439 if (!vfp_access_check(s
)) {
2443 vd
= tcg_temp_new_i32();
2444 vm
= tcg_temp_new_i64();
2445 neon_load_reg64(vm
, a
->vm
);
2446 gen_helper_vfp_fcvtsd(vd
, vm
, cpu_env
);
2447 neon_store_reg32(vd
, a
->vd
);
2448 tcg_temp_free_i32(vd
);
2449 tcg_temp_free_i64(vm
);
2453 static bool trans_VCVT_int_sp(DisasContext
*s
, arg_VCVT_int_sp
*a
)
2458 if (!vfp_access_check(s
)) {
2462 vm
= tcg_temp_new_i32();
2463 neon_load_reg32(vm
, a
->vm
);
2464 fpst
= get_fpstatus_ptr(false);
2467 gen_helper_vfp_sitos(vm
, vm
, fpst
);
2470 gen_helper_vfp_uitos(vm
, vm
, fpst
);
2472 neon_store_reg32(vm
, a
->vd
);
2473 tcg_temp_free_i32(vm
);
2474 tcg_temp_free_ptr(fpst
);
2478 static bool trans_VCVT_int_dp(DisasContext
*s
, arg_VCVT_int_dp
*a
)
2484 /* UNDEF accesses to D16-D31 if they don't exist. */
2485 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
& 0x10)) {
2489 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2493 if (!vfp_access_check(s
)) {
2497 vm
= tcg_temp_new_i32();
2498 vd
= tcg_temp_new_i64();
2499 neon_load_reg32(vm
, a
->vm
);
2500 fpst
= get_fpstatus_ptr(false);
2503 gen_helper_vfp_sitod(vd
, vm
, fpst
);
2506 gen_helper_vfp_uitod(vd
, vm
, fpst
);
2508 neon_store_reg64(vd
, a
->vd
);
2509 tcg_temp_free_i32(vm
);
2510 tcg_temp_free_i64(vd
);
2511 tcg_temp_free_ptr(fpst
);
2515 static bool trans_VJCVT(DisasContext
*s
, arg_VJCVT
*a
)
2520 if (!dc_isar_feature(aa32_jscvt
, s
)) {
2524 /* UNDEF accesses to D16-D31 if they don't exist. */
2525 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
2529 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2533 if (!vfp_access_check(s
)) {
2537 vm
= tcg_temp_new_i64();
2538 vd
= tcg_temp_new_i32();
2539 neon_load_reg64(vm
, a
->vm
);
2540 gen_helper_vjcvt(vd
, vm
, cpu_env
);
2541 neon_store_reg32(vd
, a
->vd
);
2542 tcg_temp_free_i64(vm
);
2543 tcg_temp_free_i32(vd
);
2547 static bool trans_VCVT_fix_sp(DisasContext
*s
, arg_VCVT_fix_sp
*a
)
2553 if (!arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
2557 if (!vfp_access_check(s
)) {
2561 frac_bits
= (a
->opc
& 1) ? (32 - a
->imm
) : (16 - a
->imm
);
2563 vd
= tcg_temp_new_i32();
2564 neon_load_reg32(vd
, a
->vd
);
2566 fpst
= get_fpstatus_ptr(false);
2567 shift
= tcg_const_i32(frac_bits
);
2569 /* Switch on op:U:sx bits */
2572 gen_helper_vfp_shtos(vd
, vd
, shift
, fpst
);
2575 gen_helper_vfp_sltos(vd
, vd
, shift
, fpst
);
2578 gen_helper_vfp_uhtos(vd
, vd
, shift
, fpst
);
2581 gen_helper_vfp_ultos(vd
, vd
, shift
, fpst
);
2584 gen_helper_vfp_toshs_round_to_zero(vd
, vd
, shift
, fpst
);
2587 gen_helper_vfp_tosls_round_to_zero(vd
, vd
, shift
, fpst
);
2590 gen_helper_vfp_touhs_round_to_zero(vd
, vd
, shift
, fpst
);
2593 gen_helper_vfp_touls_round_to_zero(vd
, vd
, shift
, fpst
);
2596 g_assert_not_reached();
2599 neon_store_reg32(vd
, a
->vd
);
2600 tcg_temp_free_i32(vd
);
2601 tcg_temp_free_i32(shift
);
2602 tcg_temp_free_ptr(fpst
);
2606 static bool trans_VCVT_fix_dp(DisasContext
*s
, arg_VCVT_fix_dp
*a
)
2613 if (!arm_dc_feature(s
, ARM_FEATURE_VFP3
)) {
2617 /* UNDEF accesses to D16-D31 if they don't exist. */
2618 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vd
& 0x10)) {
2622 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2626 if (!vfp_access_check(s
)) {
2630 frac_bits
= (a
->opc
& 1) ? (32 - a
->imm
) : (16 - a
->imm
);
2632 vd
= tcg_temp_new_i64();
2633 neon_load_reg64(vd
, a
->vd
);
2635 fpst
= get_fpstatus_ptr(false);
2636 shift
= tcg_const_i32(frac_bits
);
2638 /* Switch on op:U:sx bits */
2641 gen_helper_vfp_shtod(vd
, vd
, shift
, fpst
);
2644 gen_helper_vfp_sltod(vd
, vd
, shift
, fpst
);
2647 gen_helper_vfp_uhtod(vd
, vd
, shift
, fpst
);
2650 gen_helper_vfp_ultod(vd
, vd
, shift
, fpst
);
2653 gen_helper_vfp_toshd_round_to_zero(vd
, vd
, shift
, fpst
);
2656 gen_helper_vfp_tosld_round_to_zero(vd
, vd
, shift
, fpst
);
2659 gen_helper_vfp_touhd_round_to_zero(vd
, vd
, shift
, fpst
);
2662 gen_helper_vfp_tould_round_to_zero(vd
, vd
, shift
, fpst
);
2665 g_assert_not_reached();
2668 neon_store_reg64(vd
, a
->vd
);
2669 tcg_temp_free_i64(vd
);
2670 tcg_temp_free_i32(shift
);
2671 tcg_temp_free_ptr(fpst
);
2675 static bool trans_VCVT_sp_int(DisasContext
*s
, arg_VCVT_sp_int
*a
)
2680 if (!vfp_access_check(s
)) {
2684 fpst
= get_fpstatus_ptr(false);
2685 vm
= tcg_temp_new_i32();
2686 neon_load_reg32(vm
, a
->vm
);
2690 gen_helper_vfp_tosizs(vm
, vm
, fpst
);
2692 gen_helper_vfp_tosis(vm
, vm
, fpst
);
2696 gen_helper_vfp_touizs(vm
, vm
, fpst
);
2698 gen_helper_vfp_touis(vm
, vm
, fpst
);
2701 neon_store_reg32(vm
, a
->vd
);
2702 tcg_temp_free_i32(vm
);
2703 tcg_temp_free_ptr(fpst
);
2707 static bool trans_VCVT_dp_int(DisasContext
*s
, arg_VCVT_dp_int
*a
)
2713 /* UNDEF accesses to D16-D31 if they don't exist. */
2714 if (!dc_isar_feature(aa32_fp_d32
, s
) && (a
->vm
& 0x10)) {
2718 if (!dc_isar_feature(aa32_fpdp
, s
)) {
2722 if (!vfp_access_check(s
)) {
2726 fpst
= get_fpstatus_ptr(false);
2727 vm
= tcg_temp_new_i64();
2728 vd
= tcg_temp_new_i32();
2729 neon_load_reg64(vm
, a
->vm
);
2733 gen_helper_vfp_tosizd(vd
, vm
, fpst
);
2735 gen_helper_vfp_tosid(vd
, vm
, fpst
);
2739 gen_helper_vfp_touizd(vd
, vm
, fpst
);
2741 gen_helper_vfp_touid(vd
, vm
, fpst
);
2744 neon_store_reg32(vd
, a
->vd
);
2745 tcg_temp_free_i32(vd
);
2746 tcg_temp_free_i64(vm
);
2747 tcg_temp_free_ptr(fpst
);