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.1 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/>.
23 #include "qemu/osdep.h"
24 #include "translate.h"
25 #include "translate-a32.h"
27 /* Include the generated VFP decoder */
28 #include "decode-vfp.c.inc"
29 #include "decode-vfp-uncond.c.inc"
31 static inline void vfp_load_reg64(TCGv_i64 var
, int reg
)
33 tcg_gen_ld_i64(var
, tcg_env
, vfp_reg_offset(true, reg
));
36 static inline void vfp_store_reg64(TCGv_i64 var
, int reg
)
38 tcg_gen_st_i64(var
, tcg_env
, vfp_reg_offset(true, reg
));
41 static inline void vfp_load_reg32(TCGv_i32 var
, int reg
)
43 tcg_gen_ld_i32(var
, tcg_env
, vfp_reg_offset(false, reg
));
46 static inline void vfp_store_reg32(TCGv_i32 var
, int reg
)
48 tcg_gen_st_i32(var
, tcg_env
, vfp_reg_offset(false, reg
));
51 static inline void vfp_load_reg16(TCGv_i32 var
, int reg
)
53 tcg_gen_ld16u_i32(var
, tcg_env
,
54 vfp_reg_offset(false, reg
) + HOST_BIG_ENDIAN
* 2);
58 * The imm8 encodes the sign bit, enough bits to represent an exponent in
59 * the range 01....1xx to 10....0xx, and the most significant 4 bits of
60 * the mantissa; see VFPExpandImm() in the v8 ARM ARM.
62 uint64_t vfp_expand_imm(int size
, uint8_t imm8
)
68 imm
= (extract32(imm8
, 7, 1) ? 0x8000 : 0) |
69 (extract32(imm8
, 6, 1) ? 0x3fc0 : 0x4000) |
70 extract32(imm8
, 0, 6);
74 imm
= (extract32(imm8
, 7, 1) ? 0x8000 : 0) |
75 (extract32(imm8
, 6, 1) ? 0x3e00 : 0x4000) |
76 (extract32(imm8
, 0, 6) << 3);
80 imm
= (extract32(imm8
, 7, 1) ? 0x8000 : 0) |
81 (extract32(imm8
, 6, 1) ? 0x3000 : 0x4000) |
82 (extract32(imm8
, 0, 6) << 6);
85 g_assert_not_reached();
91 * Return the offset of a 16-bit half of the specified VFP single-precision
92 * register. If top is true, returns the top 16 bits; otherwise the bottom
95 static inline long vfp_f16_offset(unsigned reg
, bool top
)
97 long offs
= vfp_reg_offset(false, reg
);
111 * Generate code for M-profile lazy FP state preservation if needed;
112 * this corresponds to the pseudocode PreserveFPState() function.
114 static void gen_preserve_fp_state(DisasContext
*s
, bool skip_context_update
)
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 (translator_io_start(&s
->base
)) {
123 s
->base
.is_jmp
= DISAS_UPDATE_EXIT
;
125 gen_helper_v7m_preserve_fp_state(tcg_env
);
127 * If the preserve_fp_state helper doesn't throw an exception
128 * then it will clear LSPACT; we don't need to repeat this for
129 * any further FP insns in this TB.
131 s
->v7m_lspact
= false;
133 * The helper might have zeroed VPR, so we do not know the
134 * correct value for the MVE_NO_PRED TB flag any more.
135 * If we're about to create a new fp context then that
136 * will precisely determine the MVE_NO_PRED value (see
137 * gen_update_fp_context()). Otherwise, we must:
138 * - set s->mve_no_pred to false, so this instruction
139 * is generated to use helper functions
140 * - end the TB now, without chaining to the next TB
142 if (skip_context_update
|| !s
->v7m_new_fp_ctxt_needed
) {
143 s
->mve_no_pred
= false;
144 s
->base
.is_jmp
= DISAS_UPDATE_NOCHAIN
;
150 * Generate code for M-profile FP context handling: update the
151 * ownership of the FP context, and create a new context if
152 * necessary. This corresponds to the parts of the pseudocode
153 * ExecuteFPCheck() after the initial PreserveFPState() call.
155 static void gen_update_fp_context(DisasContext
*s
)
157 /* Update ownership of FP context: set FPCCR.S to match current state */
158 if (s
->v8m_fpccr_s_wrong
) {
161 tmp
= load_cpu_field(v7m
.fpccr
[M_REG_S
]);
163 tcg_gen_ori_i32(tmp
, tmp
, R_V7M_FPCCR_S_MASK
);
165 tcg_gen_andi_i32(tmp
, tmp
, ~R_V7M_FPCCR_S_MASK
);
167 store_cpu_field(tmp
, v7m
.fpccr
[M_REG_S
]);
168 /* Don't need to do this for any further FP insns in this TB */
169 s
->v8m_fpccr_s_wrong
= false;
172 if (s
->v7m_new_fp_ctxt_needed
) {
174 * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA,
175 * the FPSCR, and VPR.
177 TCGv_i32 control
, fpscr
;
178 uint32_t bits
= R_V7M_CONTROL_FPCA_MASK
;
180 fpscr
= load_cpu_field(v7m
.fpdscr
[s
->v8m_secure
]);
181 gen_helper_vfp_set_fpscr(tcg_env
, fpscr
);
182 if (dc_isar_feature(aa32_mve
, s
)) {
183 store_cpu_field(tcg_constant_i32(0), v7m
.vpr
);
186 * We just updated the FPSCR and VPR. Some of this state is cached
187 * in the MVE_NO_PRED TB flag. We want to avoid having to end the
188 * TB here, which means we need the new value of the MVE_NO_PRED
189 * flag to be exactly known here and the same for all executions.
190 * Luckily FPDSCR.LTPSIZE is always constant 4 and the VPR is
191 * always set to 0, so the new MVE_NO_PRED flag is always 1
192 * if and only if we have MVE.
194 * (The other FPSCR state cached in TB flags is VECLEN and VECSTRIDE,
195 * but those do not exist for M-profile, so are not relevant here.)
197 s
->mve_no_pred
= dc_isar_feature(aa32_mve
, s
);
200 bits
|= R_V7M_CONTROL_SFPA_MASK
;
202 control
= load_cpu_field(v7m
.control
[M_REG_S
]);
203 tcg_gen_ori_i32(control
, control
, bits
);
204 store_cpu_field(control
, v7m
.control
[M_REG_S
]);
205 /* Don't need to do this for any further FP insns in this TB */
206 s
->v7m_new_fp_ctxt_needed
= false;
211 * Check that VFP access is enabled, A-profile specific version.
213 * If VFP is enabled, return true. If not, emit code to generate an
214 * appropriate exception and return false.
215 * The ignore_vfp_enabled argument specifies that we should ignore
216 * whether VFP is enabled via FPEXC.EN: this should be true for FMXR/FMRX
217 * accesses to FPSID, FPEXC, MVFR0, MVFR1, MVFR2, and false for all other insns.
219 static bool vfp_access_check_a(DisasContext
*s
, bool ignore_vfp_enabled
)
223 * The full syndrome is only used for HSR when HCPTR traps:
224 * For v8, when TA==0, coproc is RES0.
225 * For v7, any use of a Floating-point instruction or access
226 * to a Floating-point Extension register that is trapped to
227 * Hyp mode because of a trap configured in the HCPTR sets
230 int coproc
= arm_dc_feature(s
, ARM_FEATURE_V8
) ? 0 : 0xa;
231 uint32_t syn
= syn_fp_access_trap(1, 0xe, false, coproc
);
233 gen_exception_insn_el(s
, 0, EXCP_UDEF
, syn
, s
->fp_excp_el
);
238 * Note that rebuild_hflags_a32 has already accounted for being in EL0
239 * and the higher EL in A64 mode, etc. Unlike A64 mode, there do not
240 * appear to be any insns which touch VFP which are allowed.
242 if (s
->sme_trap_nonstreaming
) {
243 gen_exception_insn(s
, 0, EXCP_UDEF
,
244 syn_smetrap(SME_ET_Streaming
,
245 curr_insn_len(s
) == 2));
249 if (!s
->vfp_enabled
&& !ignore_vfp_enabled
) {
250 assert(!arm_dc_feature(s
, ARM_FEATURE_M
));
251 unallocated_encoding(s
);
258 * Check that VFP access is enabled, M-profile specific version.
260 * If VFP is enabled, do the necessary M-profile lazy-FP handling and then
261 * return true. If not, emit code to generate an appropriate exception and
263 * skip_context_update is true to skip the "update FP context" part of this.
265 bool vfp_access_check_m(DisasContext
*s
, bool skip_context_update
)
269 * M-profile mostly catches the "FPU disabled" case early, in
270 * disas_m_nocp(), but a few insns (eg LCTP, WLSTP, DLSTP)
271 * which do coprocessor-checks are outside the large ranges of
272 * the encoding space handled by the patterns in m-nocp.decode,
273 * and for them we may need to raise NOCP here.
275 gen_exception_insn_el(s
, 0, EXCP_NOCP
,
276 syn_uncategorized(), s
->fp_excp_el
);
280 /* Handle M-profile lazy FP state mechanics */
282 /* Trigger lazy-state preservation if necessary */
283 gen_preserve_fp_state(s
, skip_context_update
);
285 if (!skip_context_update
) {
286 /* Update ownership of FP context and create new FP context if needed */
287 gen_update_fp_context(s
);
294 * The most usual kind of VFP access check, for everything except
295 * FMXR/FMRX to the always-available special registers.
297 bool vfp_access_check(DisasContext
*s
)
299 if (arm_dc_feature(s
, ARM_FEATURE_M
)) {
300 return vfp_access_check_m(s
, false);
302 return vfp_access_check_a(s
, false);
306 static bool trans_VSEL(DisasContext
*s
, arg_VSEL
*a
)
311 if (!dc_isar_feature(aa32_vsel
, s
)) {
315 if (sz
== 3 && !dc_isar_feature(aa32_fpdp_v2
, s
)) {
319 if (sz
== 1 && !dc_isar_feature(aa32_fp16_arith
, s
)) {
323 /* UNDEF accesses to D16-D31 if they don't exist */
324 if (sz
== 3 && !dc_isar_feature(aa32_simd_r32
, s
) &&
325 ((a
->vm
| a
->vn
| a
->vd
) & 0x10)) {
333 if (!vfp_access_check(s
)) {
338 TCGv_i64 frn
, frm
, dest
;
339 TCGv_i64 tmp
, zero
, zf
, nf
, vf
;
341 zero
= tcg_constant_i64(0);
343 frn
= tcg_temp_new_i64();
344 frm
= tcg_temp_new_i64();
345 dest
= tcg_temp_new_i64();
347 zf
= tcg_temp_new_i64();
348 nf
= tcg_temp_new_i64();
349 vf
= tcg_temp_new_i64();
351 tcg_gen_extu_i32_i64(zf
, cpu_ZF
);
352 tcg_gen_ext_i32_i64(nf
, cpu_NF
);
353 tcg_gen_ext_i32_i64(vf
, cpu_VF
);
355 vfp_load_reg64(frn
, rn
);
356 vfp_load_reg64(frm
, rm
);
359 tcg_gen_movcond_i64(TCG_COND_EQ
, dest
, zf
, zero
, frn
, frm
);
362 tcg_gen_movcond_i64(TCG_COND_LT
, dest
, vf
, zero
, frn
, frm
);
364 case 2: /* ge: N == V -> N ^ V == 0 */
365 tmp
= tcg_temp_new_i64();
366 tcg_gen_xor_i64(tmp
, vf
, nf
);
367 tcg_gen_movcond_i64(TCG_COND_GE
, dest
, tmp
, zero
, frn
, frm
);
369 case 3: /* gt: !Z && N == V */
370 tcg_gen_movcond_i64(TCG_COND_NE
, dest
, zf
, zero
, frn
, frm
);
371 tmp
= tcg_temp_new_i64();
372 tcg_gen_xor_i64(tmp
, vf
, nf
);
373 tcg_gen_movcond_i64(TCG_COND_GE
, dest
, tmp
, zero
, dest
, frm
);
376 vfp_store_reg64(dest
, rd
);
378 TCGv_i32 frn
, frm
, dest
;
381 zero
= tcg_constant_i32(0);
383 frn
= tcg_temp_new_i32();
384 frm
= tcg_temp_new_i32();
385 dest
= tcg_temp_new_i32();
386 vfp_load_reg32(frn
, rn
);
387 vfp_load_reg32(frm
, rm
);
390 tcg_gen_movcond_i32(TCG_COND_EQ
, dest
, cpu_ZF
, zero
, frn
, frm
);
393 tcg_gen_movcond_i32(TCG_COND_LT
, dest
, cpu_VF
, zero
, frn
, frm
);
395 case 2: /* ge: N == V -> N ^ V == 0 */
396 tmp
= tcg_temp_new_i32();
397 tcg_gen_xor_i32(tmp
, cpu_VF
, cpu_NF
);
398 tcg_gen_movcond_i32(TCG_COND_GE
, dest
, tmp
, zero
, frn
, frm
);
400 case 3: /* gt: !Z && N == V */
401 tcg_gen_movcond_i32(TCG_COND_NE
, dest
, cpu_ZF
, zero
, frn
, frm
);
402 tmp
= tcg_temp_new_i32();
403 tcg_gen_xor_i32(tmp
, cpu_VF
, cpu_NF
);
404 tcg_gen_movcond_i32(TCG_COND_GE
, dest
, tmp
, zero
, dest
, frm
);
407 /* For fp16 the top half is always zeroes */
409 tcg_gen_andi_i32(dest
, dest
, 0xffff);
411 vfp_store_reg32(dest
, rd
);
418 * Table for converting the most common AArch32 encoding of
419 * rounding mode to arm_fprounding order (which matches the
420 * common AArch64 order); see ARM ARM pseudocode FPDecodeRM().
422 static const uint8_t fp_decode_rm
[] = {
429 static bool trans_VRINT(DisasContext
*s
, arg_VRINT
*a
)
435 int rounding
= fp_decode_rm
[a
->rm
];
437 if (!dc_isar_feature(aa32_vrint
, s
)) {
441 if (sz
== 3 && !dc_isar_feature(aa32_fpdp_v2
, s
)) {
445 if (sz
== 1 && !dc_isar_feature(aa32_fp16_arith
, s
)) {
449 /* UNDEF accesses to D16-D31 if they don't exist */
450 if (sz
== 3 && !dc_isar_feature(aa32_simd_r32
, s
) &&
451 ((a
->vm
| a
->vd
) & 0x10)) {
458 if (!vfp_access_check(s
)) {
463 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
465 fpst
= fpstatus_ptr(FPST_FPCR
);
468 tcg_rmode
= gen_set_rmode(rounding
, fpst
);
473 tcg_op
= tcg_temp_new_i64();
474 tcg_res
= tcg_temp_new_i64();
475 vfp_load_reg64(tcg_op
, rm
);
476 gen_helper_rintd(tcg_res
, tcg_op
, fpst
);
477 vfp_store_reg64(tcg_res
, rd
);
481 tcg_op
= tcg_temp_new_i32();
482 tcg_res
= tcg_temp_new_i32();
483 vfp_load_reg32(tcg_op
, rm
);
485 gen_helper_rinth(tcg_res
, tcg_op
, fpst
);
487 gen_helper_rints(tcg_res
, tcg_op
, fpst
);
489 vfp_store_reg32(tcg_res
, rd
);
492 gen_restore_rmode(tcg_rmode
, fpst
);
496 static bool trans_VCVT(DisasContext
*s
, arg_VCVT
*a
)
501 TCGv_i32 tcg_rmode
, tcg_shift
;
502 int rounding
= fp_decode_rm
[a
->rm
];
503 bool is_signed
= a
->op
;
505 if (!dc_isar_feature(aa32_vcvt_dr
, s
)) {
509 if (sz
== 3 && !dc_isar_feature(aa32_fpdp_v2
, s
)) {
513 if (sz
== 1 && !dc_isar_feature(aa32_fp16_arith
, s
)) {
517 /* UNDEF accesses to D16-D31 if they don't exist */
518 if (sz
== 3 && !dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
525 if (!vfp_access_check(s
)) {
530 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
532 fpst
= fpstatus_ptr(FPST_FPCR
);
535 tcg_shift
= tcg_constant_i32(0);
536 tcg_rmode
= gen_set_rmode(rounding
, fpst
);
539 TCGv_i64 tcg_double
, tcg_res
;
541 tcg_double
= tcg_temp_new_i64();
542 tcg_res
= tcg_temp_new_i64();
543 tcg_tmp
= tcg_temp_new_i32();
544 vfp_load_reg64(tcg_double
, rm
);
546 gen_helper_vfp_tosld(tcg_res
, tcg_double
, tcg_shift
, fpst
);
548 gen_helper_vfp_tould(tcg_res
, tcg_double
, tcg_shift
, fpst
);
550 tcg_gen_extrl_i64_i32(tcg_tmp
, tcg_res
);
551 vfp_store_reg32(tcg_tmp
, rd
);
553 TCGv_i32 tcg_single
, tcg_res
;
554 tcg_single
= tcg_temp_new_i32();
555 tcg_res
= tcg_temp_new_i32();
556 vfp_load_reg32(tcg_single
, rm
);
559 gen_helper_vfp_toslh(tcg_res
, tcg_single
, tcg_shift
, fpst
);
561 gen_helper_vfp_toulh(tcg_res
, tcg_single
, tcg_shift
, fpst
);
565 gen_helper_vfp_tosls(tcg_res
, tcg_single
, tcg_shift
, fpst
);
567 gen_helper_vfp_touls(tcg_res
, tcg_single
, tcg_shift
, fpst
);
570 vfp_store_reg32(tcg_res
, rd
);
573 gen_restore_rmode(tcg_rmode
, fpst
);
577 bool mve_skip_vmov(DisasContext
*s
, int vn
, int index
, int size
)
580 * In a CPU with MVE, the VMOV (vector lane to general-purpose register)
581 * and VMOV (general-purpose register to vector lane) insns are not
582 * predicated, but they are subject to beatwise execution if they are
583 * not in an IT block.
585 * Since our implementation always executes all 4 beats in one tick,
586 * this means only that if PSR.ECI says we should not be executing
587 * the beat corresponding to the lane of the vector register being
588 * accessed then we should skip performing the move, and that we need
589 * to do the usual check for bad ECI state and advance of ECI state.
591 * Note that if PSR.ECI is non-zero then we cannot be in an IT block.
593 * Return true if this VMOV scalar <-> gpreg should be skipped because
594 * the MVE PSR.ECI state says we skip the beat where the store happens.
597 /* Calculate the byte offset into Qn which we're going to access */
598 int ofs
= (index
<< size
) + ((vn
& 1) * 8);
600 if (!dc_isar_feature(aa32_mve
, s
)) {
615 g_assert_not_reached();
619 static bool trans_VMOV_to_gp(DisasContext
*s
, arg_VMOV_to_gp
*a
)
621 /* VMOV scalar to general purpose register */
625 * SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has
626 * all sizes, whether the CPU has fp or not.
628 if (!dc_isar_feature(aa32_mve
, s
)) {
630 ? !dc_isar_feature(aa32_fpsp_v2
, s
)
631 : !arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
636 /* UNDEF accesses to D16-D31 if they don't exist */
637 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vn
& 0x10)) {
641 if (dc_isar_feature(aa32_mve
, s
)) {
642 if (!mve_eci_check(s
)) {
647 if (!vfp_access_check(s
)) {
651 if (!mve_skip_vmov(s
, a
->vn
, a
->index
, a
->size
)) {
652 tmp
= tcg_temp_new_i32();
653 read_neon_element32(tmp
, a
->vn
, a
->index
,
654 a
->size
| (a
->u
? 0 : MO_SIGN
));
655 store_reg(s
, a
->rt
, tmp
);
658 if (dc_isar_feature(aa32_mve
, s
)) {
659 mve_update_and_store_eci(s
);
664 static bool trans_VMOV_from_gp(DisasContext
*s
, arg_VMOV_from_gp
*a
)
666 /* VMOV general purpose register to scalar */
670 * SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has
671 * all sizes, whether the CPU has fp or not.
673 if (!dc_isar_feature(aa32_mve
, s
)) {
675 ? !dc_isar_feature(aa32_fpsp_v2
, s
)
676 : !arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
681 /* UNDEF accesses to D16-D31 if they don't exist */
682 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vn
& 0x10)) {
686 if (dc_isar_feature(aa32_mve
, s
)) {
687 if (!mve_eci_check(s
)) {
692 if (!vfp_access_check(s
)) {
696 if (!mve_skip_vmov(s
, a
->vn
, a
->index
, a
->size
)) {
697 tmp
= load_reg(s
, a
->rt
);
698 write_neon_element32(tmp
, a
->vn
, a
->index
, a
->size
);
701 if (dc_isar_feature(aa32_mve
, s
)) {
702 mve_update_and_store_eci(s
);
707 static bool trans_VDUP(DisasContext
*s
, arg_VDUP
*a
)
709 /* VDUP (general purpose register) */
713 if (!arm_dc_feature(s
, ARM_FEATURE_NEON
)) {
717 /* UNDEF accesses to D16-D31 if they don't exist */
718 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vn
& 0x10)) {
726 if (a
->q
&& (a
->vn
& 1)) {
730 vec_size
= a
->q
? 16 : 8;
739 if (!vfp_access_check(s
)) {
743 tmp
= load_reg(s
, a
->rt
);
744 tcg_gen_gvec_dup_i32(size
, neon_full_reg_offset(a
->vn
),
745 vec_size
, vec_size
, tmp
);
749 static bool trans_VMSR_VMRS(DisasContext
*s
, arg_VMSR_VMRS
*a
)
752 bool ignore_vfp_enabled
= false;
754 if (arm_dc_feature(s
, ARM_FEATURE_M
)) {
755 /* M profile version was already handled in m-nocp.decode */
759 if (!dc_isar_feature(aa32_fpsp_v2
, s
)) {
766 * VFPv2 allows access to FPSID from userspace; VFPv3 restricts
767 * all ID registers to privileged access only.
769 if (IS_USER(s
) && dc_isar_feature(aa32_fpsp_v3
, s
)) {
772 ignore_vfp_enabled
= true;
776 if (IS_USER(s
) || !arm_dc_feature(s
, ARM_FEATURE_MVFR
)) {
779 ignore_vfp_enabled
= true;
782 if (IS_USER(s
) || !arm_dc_feature(s
, ARM_FEATURE_V8
)) {
785 ignore_vfp_enabled
= true;
793 ignore_vfp_enabled
= true;
796 case ARM_VFP_FPINST2
:
797 /* Not present in VFPv3 */
798 if (IS_USER(s
) || dc_isar_feature(aa32_fpsp_v3
, s
)) {
807 * Call vfp_access_check_a() directly, because we need to tell
808 * it to ignore FPEXC.EN for some register accesses.
810 if (!vfp_access_check_a(s
, ignore_vfp_enabled
)) {
815 /* VMRS, move VFP special register to gp register */
821 if (s
->current_el
== 1) {
824 gen_helper_check_hcr_el2_trap(tcg_env
,
825 tcg_constant_i32(a
->rt
),
826 tcg_constant_i32(a
->reg
));
831 case ARM_VFP_FPINST2
:
832 tmp
= load_cpu_field(vfp
.xregs
[a
->reg
]);
836 tmp
= load_cpu_field_low32(vfp
.fpsr
);
837 tcg_gen_andi_i32(tmp
, tmp
, FPSR_NZCV_MASK
);
839 tmp
= tcg_temp_new_i32();
840 gen_helper_vfp_get_fpscr(tmp
, tcg_env
);
844 g_assert_not_reached();
848 /* Set the 4 flag bits in the CPSR. */
851 store_reg(s
, a
->rt
, tmp
);
854 /* VMSR, move gp register to VFP special register */
860 /* Writes are ignored. */
863 tmp
= load_reg(s
, a
->rt
);
864 gen_helper_vfp_set_fpscr(tcg_env
, tmp
);
869 * TODO: VFP subarchitecture support.
870 * For now, keep the EN bit only
872 tmp
= load_reg(s
, a
->rt
);
873 tcg_gen_andi_i32(tmp
, tmp
, 1 << 30);
874 store_cpu_field(tmp
, vfp
.xregs
[a
->reg
]);
878 case ARM_VFP_FPINST2
:
879 tmp
= load_reg(s
, a
->rt
);
880 store_cpu_field(tmp
, vfp
.xregs
[a
->reg
]);
883 g_assert_not_reached();
891 static bool trans_VMOV_half(DisasContext
*s
, arg_VMOV_single
*a
)
895 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
900 /* UNPREDICTABLE; we choose to UNDEF */
904 if (!vfp_access_check(s
)) {
909 /* VFP to general purpose register */
910 tmp
= tcg_temp_new_i32();
911 vfp_load_reg16(tmp
, a
->vn
);
912 store_reg(s
, a
->rt
, tmp
);
914 /* general purpose register to VFP */
915 tmp
= load_reg(s
, a
->rt
);
916 tcg_gen_andi_i32(tmp
, tmp
, 0xffff);
917 vfp_store_reg32(tmp
, a
->vn
);
923 static bool trans_VMOV_single(DisasContext
*s
, arg_VMOV_single
*a
)
927 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
931 if (!vfp_access_check(s
)) {
936 /* VFP to general purpose register */
937 tmp
= tcg_temp_new_i32();
938 vfp_load_reg32(tmp
, a
->vn
);
940 /* Set the 4 flag bits in the CPSR. */
943 store_reg(s
, a
->rt
, tmp
);
946 /* general purpose register to VFP */
947 tmp
= load_reg(s
, a
->rt
);
948 vfp_store_reg32(tmp
, a
->vn
);
954 static bool trans_VMOV_64_sp(DisasContext
*s
, arg_VMOV_64_sp
*a
)
958 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
963 * VMOV between two general-purpose registers and two single precision
964 * floating point registers
966 if (!vfp_access_check(s
)) {
972 tmp
= tcg_temp_new_i32();
973 vfp_load_reg32(tmp
, a
->vm
);
974 store_reg(s
, a
->rt
, tmp
);
975 tmp
= tcg_temp_new_i32();
976 vfp_load_reg32(tmp
, a
->vm
+ 1);
977 store_reg(s
, a
->rt2
, tmp
);
980 tmp
= load_reg(s
, a
->rt
);
981 vfp_store_reg32(tmp
, a
->vm
);
982 tmp
= load_reg(s
, a
->rt2
);
983 vfp_store_reg32(tmp
, a
->vm
+ 1);
989 static bool trans_VMOV_64_dp(DisasContext
*s
, arg_VMOV_64_dp
*a
)
994 * VMOV between two general-purpose registers and one double precision
995 * floating point register. Note that this does not require support
996 * for double precision arithmetic.
998 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1002 /* UNDEF accesses to D16-D31 if they don't exist */
1003 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
1007 if (!vfp_access_check(s
)) {
1012 /* fpreg to gpreg */
1013 tmp
= tcg_temp_new_i32();
1014 vfp_load_reg32(tmp
, a
->vm
* 2);
1015 store_reg(s
, a
->rt
, tmp
);
1016 tmp
= tcg_temp_new_i32();
1017 vfp_load_reg32(tmp
, a
->vm
* 2 + 1);
1018 store_reg(s
, a
->rt2
, tmp
);
1020 /* gpreg to fpreg */
1021 tmp
= load_reg(s
, a
->rt
);
1022 vfp_store_reg32(tmp
, a
->vm
* 2);
1023 tmp
= load_reg(s
, a
->rt2
);
1024 vfp_store_reg32(tmp
, a
->vm
* 2 + 1);
1030 static bool trans_VLDR_VSTR_hp(DisasContext
*s
, arg_VLDR_VSTR_sp
*a
)
1035 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1039 if (!vfp_access_check(s
)) {
1043 /* imm8 field is offset/2 for fp16, unlike fp32 and fp64 */
1044 offset
= a
->imm
<< 1;
1049 /* For thumb, use of PC is UNPREDICTABLE. */
1050 addr
= add_reg_for_lit(s
, a
->rn
, offset
);
1051 tmp
= tcg_temp_new_i32();
1053 gen_aa32_ld_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UW
| MO_ALIGN
);
1054 vfp_store_reg32(tmp
, a
->vd
);
1056 vfp_load_reg32(tmp
, a
->vd
);
1057 gen_aa32_st_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UW
| MO_ALIGN
);
1062 static bool trans_VLDR_VSTR_sp(DisasContext
*s
, arg_VLDR_VSTR_sp
*a
)
1067 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1071 if (!vfp_access_check(s
)) {
1075 offset
= a
->imm
<< 2;
1080 /* For thumb, use of PC is UNPREDICTABLE. */
1081 addr
= add_reg_for_lit(s
, a
->rn
, offset
);
1082 tmp
= tcg_temp_new_i32();
1084 gen_aa32_ld_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UL
| MO_ALIGN
);
1085 vfp_store_reg32(tmp
, a
->vd
);
1087 vfp_load_reg32(tmp
, a
->vd
);
1088 gen_aa32_st_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UL
| MO_ALIGN
);
1093 static bool trans_VLDR_VSTR_dp(DisasContext
*s
, arg_VLDR_VSTR_dp
*a
)
1099 /* Note that this does not require support for double arithmetic. */
1100 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1104 /* UNDEF accesses to D16-D31 if they don't exist */
1105 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
& 0x10)) {
1109 if (!vfp_access_check(s
)) {
1113 offset
= a
->imm
<< 2;
1118 /* For thumb, use of PC is UNPREDICTABLE. */
1119 addr
= add_reg_for_lit(s
, a
->rn
, offset
);
1120 tmp
= tcg_temp_new_i64();
1122 gen_aa32_ld_i64(s
, tmp
, addr
, get_mem_index(s
), MO_UQ
| MO_ALIGN_4
);
1123 vfp_store_reg64(tmp
, a
->vd
);
1125 vfp_load_reg64(tmp
, a
->vd
);
1126 gen_aa32_st_i64(s
, tmp
, addr
, get_mem_index(s
), MO_UQ
| MO_ALIGN_4
);
1131 static bool trans_VLDM_VSTM_sp(DisasContext
*s
, arg_VLDM_VSTM_sp
*a
)
1137 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1143 if (n
== 0 || (a
->vd
+ n
) > 32) {
1145 * UNPREDICTABLE cases for bad immediates: we choose to
1146 * UNDEF to avoid generating huge numbers of TCG ops
1150 if (a
->rn
== 15 && a
->w
) {
1151 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1155 s
->eci_handled
= true;
1157 if (!vfp_access_check(s
)) {
1161 /* For thumb, use of PC is UNPREDICTABLE. */
1162 addr
= add_reg_for_lit(s
, a
->rn
, 0);
1165 tcg_gen_addi_i32(addr
, addr
, -(a
->imm
<< 2));
1168 if (s
->v8m_stackcheck
&& a
->rn
== 13 && a
->w
) {
1170 * Here 'addr' is the lowest address we will store to,
1171 * and is either the old SP (if post-increment) or
1172 * the new SP (if pre-decrement). For post-increment
1173 * where the old value is below the limit and the new
1174 * value is above, it is UNKNOWN whether the limit check
1175 * triggers; we choose to trigger.
1177 gen_helper_v8m_stackcheck(tcg_env
, addr
);
1181 tmp
= tcg_temp_new_i32();
1182 for (i
= 0; i
< n
; i
++) {
1185 gen_aa32_ld_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UL
| MO_ALIGN
);
1186 vfp_store_reg32(tmp
, a
->vd
+ i
);
1189 vfp_load_reg32(tmp
, a
->vd
+ i
);
1190 gen_aa32_st_i32(s
, tmp
, addr
, get_mem_index(s
), MO_UL
| MO_ALIGN
);
1192 tcg_gen_addi_i32(addr
, addr
, offset
);
1197 offset
= -offset
* n
;
1198 tcg_gen_addi_i32(addr
, addr
, offset
);
1200 store_reg(s
, a
->rn
, addr
);
1207 static bool trans_VLDM_VSTM_dp(DisasContext
*s
, arg_VLDM_VSTM_dp
*a
)
1214 /* Note that this does not require support for double arithmetic. */
1215 if (!dc_isar_feature(aa32_fpsp_v2
, s
) && !dc_isar_feature(aa32_mve
, s
)) {
1221 if (n
== 0 || (a
->vd
+ n
) > 32 || n
> 16) {
1223 * UNPREDICTABLE cases for bad immediates: we choose to
1224 * UNDEF to avoid generating huge numbers of TCG ops
1228 if (a
->rn
== 15 && a
->w
) {
1229 /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
1233 /* UNDEF accesses to D16-D31 if they don't exist */
1234 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
+ n
) > 16) {
1238 s
->eci_handled
= true;
1240 if (!vfp_access_check(s
)) {
1244 /* For thumb, use of PC is UNPREDICTABLE. */
1245 addr
= add_reg_for_lit(s
, a
->rn
, 0);
1248 tcg_gen_addi_i32(addr
, addr
, -(a
->imm
<< 2));
1251 if (s
->v8m_stackcheck
&& a
->rn
== 13 && a
->w
) {
1253 * Here 'addr' is the lowest address we will store to,
1254 * and is either the old SP (if post-increment) or
1255 * the new SP (if pre-decrement). For post-increment
1256 * where the old value is below the limit and the new
1257 * value is above, it is UNKNOWN whether the limit check
1258 * triggers; we choose to trigger.
1260 gen_helper_v8m_stackcheck(tcg_env
, addr
);
1264 tmp
= tcg_temp_new_i64();
1265 for (i
= 0; i
< n
; i
++) {
1268 gen_aa32_ld_i64(s
, tmp
, addr
, get_mem_index(s
), MO_UQ
| MO_ALIGN_4
);
1269 vfp_store_reg64(tmp
, a
->vd
+ i
);
1272 vfp_load_reg64(tmp
, a
->vd
+ i
);
1273 gen_aa32_st_i64(s
, tmp
, addr
, get_mem_index(s
), MO_UQ
| MO_ALIGN_4
);
1275 tcg_gen_addi_i32(addr
, addr
, offset
);
1280 offset
= -offset
* n
;
1281 } else if (a
->imm
& 1) {
1288 tcg_gen_addi_i32(addr
, addr
, offset
);
1290 store_reg(s
, a
->rn
, addr
);
1298 * Types for callbacks for do_vfp_3op_sp() and do_vfp_3op_dp().
1299 * The callback should emit code to write a value to vd. If
1300 * do_vfp_3op_{sp,dp}() was passed reads_vd then the TCGv vd
1301 * will contain the old value of the relevant VFP register;
1302 * otherwise it must be written to only.
1304 typedef void VFPGen3OpSPFn(TCGv_i32 vd
,
1305 TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
);
1306 typedef void VFPGen3OpDPFn(TCGv_i64 vd
,
1307 TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
);
1310 * Types for callbacks for do_vfp_2op_sp() and do_vfp_2op_dp().
1311 * The callback should emit code to write a value to vd (which
1312 * should be written to only).
1314 typedef void VFPGen2OpSPFn(TCGv_i32 vd
, TCGv_i32 vm
);
1315 typedef void VFPGen2OpDPFn(TCGv_i64 vd
, TCGv_i64 vm
);
1318 * Return true if the specified S reg is in a scalar bank
1319 * (ie if it is s0..s7)
1321 static inline bool vfp_sreg_is_scalar(int reg
)
1323 return (reg
& 0x18) == 0;
1327 * Return true if the specified D reg is in a scalar bank
1328 * (ie if it is d0..d3 or d16..d19)
1330 static inline bool vfp_dreg_is_scalar(int reg
)
1332 return (reg
& 0xc) == 0;
1336 * Advance the S reg number forwards by delta within its bank
1337 * (ie increment the low 3 bits but leave the rest the same)
1339 static inline int vfp_advance_sreg(int reg
, int delta
)
1341 return ((reg
+ delta
) & 0x7) | (reg
& ~0x7);
1345 * Advance the D reg number forwards by delta within its bank
1346 * (ie increment the low 2 bits but leave the rest the same)
1348 static inline int vfp_advance_dreg(int reg
, int delta
)
1350 return ((reg
+ delta
) & 0x3) | (reg
& ~0x3);
1354 * Perform a 3-operand VFP data processing instruction. fn is the
1355 * callback to do the actual operation; this function deals with the
1356 * code to handle looping around for VFP vector processing.
1358 static bool do_vfp_3op_sp(DisasContext
*s
, VFPGen3OpSPFn
*fn
,
1359 int vd
, int vn
, int vm
, bool reads_vd
)
1361 uint32_t delta_m
= 0;
1362 uint32_t delta_d
= 0;
1363 int veclen
= s
->vec_len
;
1364 TCGv_i32 f0
, f1
, fd
;
1367 if (!dc_isar_feature(aa32_fpsp_v2
, s
)) {
1371 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1372 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1376 if (!vfp_access_check(s
)) {
1381 /* Figure out what type of vector operation this is. */
1382 if (vfp_sreg_is_scalar(vd
)) {
1386 delta_d
= s
->vec_stride
+ 1;
1388 if (vfp_sreg_is_scalar(vm
)) {
1389 /* mixed scalar/vector */
1398 f0
= tcg_temp_new_i32();
1399 f1
= tcg_temp_new_i32();
1400 fd
= tcg_temp_new_i32();
1401 fpst
= fpstatus_ptr(FPST_FPCR
);
1403 vfp_load_reg32(f0
, vn
);
1404 vfp_load_reg32(f1
, vm
);
1408 vfp_load_reg32(fd
, vd
);
1410 fn(fd
, f0
, f1
, fpst
);
1411 vfp_store_reg32(fd
, vd
);
1417 /* Set up the operands for the next iteration */
1419 vd
= vfp_advance_sreg(vd
, delta_d
);
1420 vn
= vfp_advance_sreg(vn
, delta_d
);
1421 vfp_load_reg32(f0
, vn
);
1423 vm
= vfp_advance_sreg(vm
, delta_m
);
1424 vfp_load_reg32(f1
, vm
);
1430 static bool do_vfp_3op_hp(DisasContext
*s
, VFPGen3OpSPFn
*fn
,
1431 int vd
, int vn
, int vm
, bool reads_vd
)
1434 * Do a half-precision operation. Functionally this is
1435 * the same as do_vfp_3op_sp(), except:
1436 * - it uses the FPST_FPCR_F16
1437 * - it doesn't need the VFP vector handling (fp16 is a
1438 * v8 feature, and in v8 VFP vectors don't exist)
1439 * - it does the aa32_fp16_arith feature test
1441 TCGv_i32 f0
, f1
, fd
;
1444 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
1448 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
1452 if (!vfp_access_check(s
)) {
1456 f0
= tcg_temp_new_i32();
1457 f1
= tcg_temp_new_i32();
1458 fd
= tcg_temp_new_i32();
1459 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
1461 vfp_load_reg16(f0
, vn
);
1462 vfp_load_reg16(f1
, vm
);
1465 vfp_load_reg16(fd
, vd
);
1467 fn(fd
, f0
, f1
, fpst
);
1468 vfp_store_reg32(fd
, vd
);
1472 static bool do_vfp_3op_dp(DisasContext
*s
, VFPGen3OpDPFn
*fn
,
1473 int vd
, int vn
, int vm
, bool reads_vd
)
1475 uint32_t delta_m
= 0;
1476 uint32_t delta_d
= 0;
1477 int veclen
= s
->vec_len
;
1478 TCGv_i64 f0
, f1
, fd
;
1481 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
1485 /* UNDEF accesses to D16-D31 if they don't exist */
1486 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((vd
| vn
| vm
) & 0x10)) {
1490 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1491 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1495 if (!vfp_access_check(s
)) {
1500 /* Figure out what type of vector operation this is. */
1501 if (vfp_dreg_is_scalar(vd
)) {
1505 delta_d
= (s
->vec_stride
>> 1) + 1;
1507 if (vfp_dreg_is_scalar(vm
)) {
1508 /* mixed scalar/vector */
1517 f0
= tcg_temp_new_i64();
1518 f1
= tcg_temp_new_i64();
1519 fd
= tcg_temp_new_i64();
1520 fpst
= fpstatus_ptr(FPST_FPCR
);
1522 vfp_load_reg64(f0
, vn
);
1523 vfp_load_reg64(f1
, vm
);
1527 vfp_load_reg64(fd
, vd
);
1529 fn(fd
, f0
, f1
, fpst
);
1530 vfp_store_reg64(fd
, vd
);
1535 /* Set up the operands for the next iteration */
1537 vd
= vfp_advance_dreg(vd
, delta_d
);
1538 vn
= vfp_advance_dreg(vn
, delta_d
);
1539 vfp_load_reg64(f0
, vn
);
1541 vm
= vfp_advance_dreg(vm
, delta_m
);
1542 vfp_load_reg64(f1
, vm
);
1548 static bool do_vfp_2op_sp(DisasContext
*s
, VFPGen2OpSPFn
*fn
, int vd
, int vm
)
1550 uint32_t delta_m
= 0;
1551 uint32_t delta_d
= 0;
1552 int veclen
= s
->vec_len
;
1555 /* Note that the caller must check the aa32_fpsp_v2 feature. */
1557 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1558 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1562 if (!vfp_access_check(s
)) {
1567 /* Figure out what type of vector operation this is. */
1568 if (vfp_sreg_is_scalar(vd
)) {
1572 delta_d
= s
->vec_stride
+ 1;
1574 if (vfp_sreg_is_scalar(vm
)) {
1575 /* mixed scalar/vector */
1584 f0
= tcg_temp_new_i32();
1585 fd
= tcg_temp_new_i32();
1587 vfp_load_reg32(f0
, vm
);
1591 vfp_store_reg32(fd
, vd
);
1598 /* single source one-many */
1600 vd
= vfp_advance_sreg(vd
, delta_d
);
1601 vfp_store_reg32(fd
, vd
);
1606 /* Set up the operands for the next iteration */
1608 vd
= vfp_advance_sreg(vd
, delta_d
);
1609 vm
= vfp_advance_sreg(vm
, delta_m
);
1610 vfp_load_reg32(f0
, vm
);
1615 static bool do_vfp_2op_hp(DisasContext
*s
, VFPGen2OpSPFn
*fn
, int vd
, int vm
)
1618 * Do a half-precision operation. Functionally this is
1619 * the same as do_vfp_2op_sp(), except:
1620 * - it doesn't need the VFP vector handling (fp16 is a
1621 * v8 feature, and in v8 VFP vectors don't exist)
1622 * - it does the aa32_fp16_arith feature test
1626 /* Note that the caller must check the aa32_fp16_arith feature */
1628 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
1632 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
1636 if (!vfp_access_check(s
)) {
1640 f0
= tcg_temp_new_i32();
1641 vfp_load_reg16(f0
, vm
);
1643 vfp_store_reg32(f0
, vd
);
1648 static bool do_vfp_2op_dp(DisasContext
*s
, VFPGen2OpDPFn
*fn
, int vd
, int vm
)
1650 uint32_t delta_m
= 0;
1651 uint32_t delta_d
= 0;
1652 int veclen
= s
->vec_len
;
1655 /* Note that the caller must check the aa32_fpdp_v2 feature. */
1657 /* UNDEF accesses to D16-D31 if they don't exist */
1658 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((vd
| vm
) & 0x10)) {
1662 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
1663 (veclen
!= 0 || s
->vec_stride
!= 0)) {
1667 if (!vfp_access_check(s
)) {
1672 /* Figure out what type of vector operation this is. */
1673 if (vfp_dreg_is_scalar(vd
)) {
1677 delta_d
= (s
->vec_stride
>> 1) + 1;
1679 if (vfp_dreg_is_scalar(vm
)) {
1680 /* mixed scalar/vector */
1689 f0
= tcg_temp_new_i64();
1690 fd
= tcg_temp_new_i64();
1692 vfp_load_reg64(f0
, vm
);
1696 vfp_store_reg64(fd
, vd
);
1703 /* single source one-many */
1705 vd
= vfp_advance_dreg(vd
, delta_d
);
1706 vfp_store_reg64(fd
, vd
);
1711 /* Set up the operands for the next iteration */
1713 vd
= vfp_advance_dreg(vd
, delta_d
);
1714 vd
= vfp_advance_dreg(vm
, delta_m
);
1715 vfp_load_reg64(f0
, vm
);
1720 static void gen_VMLA_hp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1722 /* Note that order of inputs to the add matters for NaNs */
1723 TCGv_i32 tmp
= tcg_temp_new_i32();
1725 gen_helper_vfp_mulh(tmp
, vn
, vm
, fpst
);
1726 gen_helper_vfp_addh(vd
, vd
, tmp
, fpst
);
1729 static bool trans_VMLA_hp(DisasContext
*s
, arg_VMLA_sp
*a
)
1731 return do_vfp_3op_hp(s
, gen_VMLA_hp
, a
->vd
, a
->vn
, a
->vm
, true);
1734 static void gen_VMLA_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1736 /* Note that order of inputs to the add matters for NaNs */
1737 TCGv_i32 tmp
= tcg_temp_new_i32();
1739 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1740 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1743 static bool trans_VMLA_sp(DisasContext
*s
, arg_VMLA_sp
*a
)
1745 return do_vfp_3op_sp(s
, gen_VMLA_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1748 static void gen_VMLA_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1750 /* Note that order of inputs to the add matters for NaNs */
1751 TCGv_i64 tmp
= tcg_temp_new_i64();
1753 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1754 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1757 static bool trans_VMLA_dp(DisasContext
*s
, arg_VMLA_dp
*a
)
1759 return do_vfp_3op_dp(s
, gen_VMLA_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1762 static void gen_VMLS_hp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1765 * VMLS: vd = vd + -(vn * vm)
1766 * Note that order of inputs to the add matters for NaNs.
1768 TCGv_i32 tmp
= tcg_temp_new_i32();
1770 gen_helper_vfp_mulh(tmp
, vn
, vm
, fpst
);
1771 gen_vfp_negh(tmp
, tmp
);
1772 gen_helper_vfp_addh(vd
, vd
, tmp
, fpst
);
1775 static bool trans_VMLS_hp(DisasContext
*s
, arg_VMLS_sp
*a
)
1777 return do_vfp_3op_hp(s
, gen_VMLS_hp
, a
->vd
, a
->vn
, a
->vm
, true);
1780 static void gen_VMLS_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1783 * VMLS: vd = vd + -(vn * vm)
1784 * Note that order of inputs to the add matters for NaNs.
1786 TCGv_i32 tmp
= tcg_temp_new_i32();
1788 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1789 gen_vfp_negs(tmp
, tmp
);
1790 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1793 static bool trans_VMLS_sp(DisasContext
*s
, arg_VMLS_sp
*a
)
1795 return do_vfp_3op_sp(s
, gen_VMLS_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1798 static void gen_VMLS_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1801 * VMLS: vd = vd + -(vn * vm)
1802 * Note that order of inputs to the add matters for NaNs.
1804 TCGv_i64 tmp
= tcg_temp_new_i64();
1806 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1807 gen_vfp_negd(tmp
, tmp
);
1808 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1811 static bool trans_VMLS_dp(DisasContext
*s
, arg_VMLS_dp
*a
)
1813 return do_vfp_3op_dp(s
, gen_VMLS_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1816 static void gen_VNMLS_hp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1819 * VNMLS: -fd + (fn * fm)
1820 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1821 * plausible looking simplifications because this will give wrong results
1824 TCGv_i32 tmp
= tcg_temp_new_i32();
1826 gen_helper_vfp_mulh(tmp
, vn
, vm
, fpst
);
1827 gen_vfp_negh(vd
, vd
);
1828 gen_helper_vfp_addh(vd
, vd
, tmp
, fpst
);
1831 static bool trans_VNMLS_hp(DisasContext
*s
, arg_VNMLS_sp
*a
)
1833 return do_vfp_3op_hp(s
, gen_VNMLS_hp
, a
->vd
, a
->vn
, a
->vm
, true);
1836 static void gen_VNMLS_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1839 * VNMLS: -fd + (fn * fm)
1840 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1841 * plausible looking simplifications because this will give wrong results
1844 TCGv_i32 tmp
= tcg_temp_new_i32();
1846 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1847 gen_vfp_negs(vd
, vd
);
1848 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1851 static bool trans_VNMLS_sp(DisasContext
*s
, arg_VNMLS_sp
*a
)
1853 return do_vfp_3op_sp(s
, gen_VNMLS_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1856 static void gen_VNMLS_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1859 * VNMLS: -fd + (fn * fm)
1860 * Note that it isn't valid to replace (-A + B) with (B - A) or similar
1861 * plausible looking simplifications because this will give wrong results
1864 TCGv_i64 tmp
= tcg_temp_new_i64();
1866 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1867 gen_vfp_negd(vd
, vd
);
1868 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1871 static bool trans_VNMLS_dp(DisasContext
*s
, arg_VNMLS_dp
*a
)
1873 return do_vfp_3op_dp(s
, gen_VNMLS_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1876 static void gen_VNMLA_hp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1878 /* VNMLA: -fd + -(fn * fm) */
1879 TCGv_i32 tmp
= tcg_temp_new_i32();
1881 gen_helper_vfp_mulh(tmp
, vn
, vm
, fpst
);
1882 gen_vfp_negh(tmp
, tmp
);
1883 gen_vfp_negh(vd
, vd
);
1884 gen_helper_vfp_addh(vd
, vd
, tmp
, fpst
);
1887 static bool trans_VNMLA_hp(DisasContext
*s
, arg_VNMLA_sp
*a
)
1889 return do_vfp_3op_hp(s
, gen_VNMLA_hp
, a
->vd
, a
->vn
, a
->vm
, true);
1892 static void gen_VNMLA_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1894 /* VNMLA: -fd + -(fn * fm) */
1895 TCGv_i32 tmp
= tcg_temp_new_i32();
1897 gen_helper_vfp_muls(tmp
, vn
, vm
, fpst
);
1898 gen_vfp_negs(tmp
, tmp
);
1899 gen_vfp_negs(vd
, vd
);
1900 gen_helper_vfp_adds(vd
, vd
, tmp
, fpst
);
1903 static bool trans_VNMLA_sp(DisasContext
*s
, arg_VNMLA_sp
*a
)
1905 return do_vfp_3op_sp(s
, gen_VNMLA_sp
, a
->vd
, a
->vn
, a
->vm
, true);
1908 static void gen_VNMLA_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1910 /* VNMLA: -fd + (fn * fm) */
1911 TCGv_i64 tmp
= tcg_temp_new_i64();
1913 gen_helper_vfp_muld(tmp
, vn
, vm
, fpst
);
1914 gen_vfp_negd(tmp
, tmp
);
1915 gen_vfp_negd(vd
, vd
);
1916 gen_helper_vfp_addd(vd
, vd
, tmp
, fpst
);
1919 static bool trans_VNMLA_dp(DisasContext
*s
, arg_VNMLA_dp
*a
)
1921 return do_vfp_3op_dp(s
, gen_VNMLA_dp
, a
->vd
, a
->vn
, a
->vm
, true);
1924 static bool trans_VMUL_hp(DisasContext
*s
, arg_VMUL_sp
*a
)
1926 return do_vfp_3op_hp(s
, gen_helper_vfp_mulh
, a
->vd
, a
->vn
, a
->vm
, false);
1929 static bool trans_VMUL_sp(DisasContext
*s
, arg_VMUL_sp
*a
)
1931 return do_vfp_3op_sp(s
, gen_helper_vfp_muls
, a
->vd
, a
->vn
, a
->vm
, false);
1934 static bool trans_VMUL_dp(DisasContext
*s
, arg_VMUL_dp
*a
)
1936 return do_vfp_3op_dp(s
, gen_helper_vfp_muld
, a
->vd
, a
->vn
, a
->vm
, false);
1939 static void gen_VNMUL_hp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1941 /* VNMUL: -(fn * fm) */
1942 gen_helper_vfp_mulh(vd
, vn
, vm
, fpst
);
1943 gen_vfp_negh(vd
, vd
);
1946 static bool trans_VNMUL_hp(DisasContext
*s
, arg_VNMUL_sp
*a
)
1948 return do_vfp_3op_hp(s
, gen_VNMUL_hp
, a
->vd
, a
->vn
, a
->vm
, false);
1951 static void gen_VNMUL_sp(TCGv_i32 vd
, TCGv_i32 vn
, TCGv_i32 vm
, TCGv_ptr fpst
)
1953 /* VNMUL: -(fn * fm) */
1954 gen_helper_vfp_muls(vd
, vn
, vm
, fpst
);
1955 gen_vfp_negs(vd
, vd
);
1958 static bool trans_VNMUL_sp(DisasContext
*s
, arg_VNMUL_sp
*a
)
1960 return do_vfp_3op_sp(s
, gen_VNMUL_sp
, a
->vd
, a
->vn
, a
->vm
, false);
1963 static void gen_VNMUL_dp(TCGv_i64 vd
, TCGv_i64 vn
, TCGv_i64 vm
, TCGv_ptr fpst
)
1965 /* VNMUL: -(fn * fm) */
1966 gen_helper_vfp_muld(vd
, vn
, vm
, fpst
);
1967 gen_vfp_negd(vd
, vd
);
1970 static bool trans_VNMUL_dp(DisasContext
*s
, arg_VNMUL_dp
*a
)
1972 return do_vfp_3op_dp(s
, gen_VNMUL_dp
, a
->vd
, a
->vn
, a
->vm
, false);
1975 static bool trans_VADD_hp(DisasContext
*s
, arg_VADD_sp
*a
)
1977 return do_vfp_3op_hp(s
, gen_helper_vfp_addh
, a
->vd
, a
->vn
, a
->vm
, false);
1980 static bool trans_VADD_sp(DisasContext
*s
, arg_VADD_sp
*a
)
1982 return do_vfp_3op_sp(s
, gen_helper_vfp_adds
, a
->vd
, a
->vn
, a
->vm
, false);
1985 static bool trans_VADD_dp(DisasContext
*s
, arg_VADD_dp
*a
)
1987 return do_vfp_3op_dp(s
, gen_helper_vfp_addd
, a
->vd
, a
->vn
, a
->vm
, false);
1990 static bool trans_VSUB_hp(DisasContext
*s
, arg_VSUB_sp
*a
)
1992 return do_vfp_3op_hp(s
, gen_helper_vfp_subh
, a
->vd
, a
->vn
, a
->vm
, false);
1995 static bool trans_VSUB_sp(DisasContext
*s
, arg_VSUB_sp
*a
)
1997 return do_vfp_3op_sp(s
, gen_helper_vfp_subs
, a
->vd
, a
->vn
, a
->vm
, false);
2000 static bool trans_VSUB_dp(DisasContext
*s
, arg_VSUB_dp
*a
)
2002 return do_vfp_3op_dp(s
, gen_helper_vfp_subd
, a
->vd
, a
->vn
, a
->vm
, false);
2005 static bool trans_VDIV_hp(DisasContext
*s
, arg_VDIV_sp
*a
)
2007 return do_vfp_3op_hp(s
, gen_helper_vfp_divh
, a
->vd
, a
->vn
, a
->vm
, false);
2010 static bool trans_VDIV_sp(DisasContext
*s
, arg_VDIV_sp
*a
)
2012 return do_vfp_3op_sp(s
, gen_helper_vfp_divs
, a
->vd
, a
->vn
, a
->vm
, false);
2015 static bool trans_VDIV_dp(DisasContext
*s
, arg_VDIV_dp
*a
)
2017 return do_vfp_3op_dp(s
, gen_helper_vfp_divd
, a
->vd
, a
->vn
, a
->vm
, false);
2020 static bool trans_VMINNM_hp(DisasContext
*s
, arg_VMINNM_sp
*a
)
2022 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2025 return do_vfp_3op_hp(s
, gen_helper_vfp_minnumh
,
2026 a
->vd
, a
->vn
, a
->vm
, false);
2029 static bool trans_VMAXNM_hp(DisasContext
*s
, arg_VMAXNM_sp
*a
)
2031 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2034 return do_vfp_3op_hp(s
, gen_helper_vfp_maxnumh
,
2035 a
->vd
, a
->vn
, a
->vm
, false);
2038 static bool trans_VMINNM_sp(DisasContext
*s
, arg_VMINNM_sp
*a
)
2040 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2043 return do_vfp_3op_sp(s
, gen_helper_vfp_minnums
,
2044 a
->vd
, a
->vn
, a
->vm
, false);
2047 static bool trans_VMAXNM_sp(DisasContext
*s
, arg_VMAXNM_sp
*a
)
2049 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2052 return do_vfp_3op_sp(s
, gen_helper_vfp_maxnums
,
2053 a
->vd
, a
->vn
, a
->vm
, false);
2056 static bool trans_VMINNM_dp(DisasContext
*s
, arg_VMINNM_dp
*a
)
2058 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2061 return do_vfp_3op_dp(s
, gen_helper_vfp_minnumd
,
2062 a
->vd
, a
->vn
, a
->vm
, false);
2065 static bool trans_VMAXNM_dp(DisasContext
*s
, arg_VMAXNM_dp
*a
)
2067 if (!dc_isar_feature(aa32_vminmaxnm
, s
)) {
2070 return do_vfp_3op_dp(s
, gen_helper_vfp_maxnumd
,
2071 a
->vd
, a
->vn
, a
->vm
, false);
2074 static bool do_vfm_hp(DisasContext
*s
, arg_VFMA_sp
*a
, bool neg_n
, bool neg_d
)
2077 * VFNMA : fd = muladd(-fd, fn, fm)
2078 * VFNMS : fd = muladd(-fd, -fn, fm)
2079 * VFMA : fd = muladd( fd, fn, fm)
2080 * VFMS : fd = muladd( fd, -fn, fm)
2082 * These are fused multiply-add, and must be done as one floating
2083 * point operation with no rounding between the multiplication and
2084 * addition steps. NB that doing the negations here as separate
2085 * steps is correct : an input NaN should come out with its sign
2086 * bit flipped if it is a negated-input.
2089 TCGv_i32 vn
, vm
, vd
;
2092 * Present in VFPv4 only, and only with the FP16 extension.
2093 * Note that we can't rely on the SIMDFMAC check alone, because
2094 * in a Neon-no-VFP core that ID register field will be non-zero.
2096 if (!dc_isar_feature(aa32_fp16_arith
, s
) ||
2097 !dc_isar_feature(aa32_simdfmac
, s
) ||
2098 !dc_isar_feature(aa32_fpsp_v2
, s
)) {
2102 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
2106 if (!vfp_access_check(s
)) {
2110 vn
= tcg_temp_new_i32();
2111 vm
= tcg_temp_new_i32();
2112 vd
= tcg_temp_new_i32();
2114 vfp_load_reg16(vn
, a
->vn
);
2115 vfp_load_reg16(vm
, a
->vm
);
2118 gen_vfp_negh(vn
, vn
);
2120 vfp_load_reg16(vd
, a
->vd
);
2123 gen_vfp_negh(vd
, vd
);
2125 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
2126 gen_helper_vfp_muladdh(vd
, vn
, vm
, vd
, fpst
);
2127 vfp_store_reg32(vd
, a
->vd
);
2131 static bool do_vfm_sp(DisasContext
*s
, arg_VFMA_sp
*a
, bool neg_n
, bool neg_d
)
2134 * VFNMA : fd = muladd(-fd, fn, fm)
2135 * VFNMS : fd = muladd(-fd, -fn, fm)
2136 * VFMA : fd = muladd( fd, fn, fm)
2137 * VFMS : fd = muladd( fd, -fn, fm)
2139 * These are fused multiply-add, and must be done as one floating
2140 * point operation with no rounding between the multiplication and
2141 * addition steps. NB that doing the negations here as separate
2142 * steps is correct : an input NaN should come out with its sign
2143 * bit flipped if it is a negated-input.
2146 TCGv_i32 vn
, vm
, vd
;
2149 * Present in VFPv4 only.
2150 * Note that we can't rely on the SIMDFMAC check alone, because
2151 * in a Neon-no-VFP core that ID register field will be non-zero.
2153 if (!dc_isar_feature(aa32_simdfmac
, s
) ||
2154 !dc_isar_feature(aa32_fpsp_v2
, s
)) {
2158 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
2159 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
2161 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
2165 if (!vfp_access_check(s
)) {
2169 vn
= tcg_temp_new_i32();
2170 vm
= tcg_temp_new_i32();
2171 vd
= tcg_temp_new_i32();
2173 vfp_load_reg32(vn
, a
->vn
);
2174 vfp_load_reg32(vm
, a
->vm
);
2177 gen_vfp_negs(vn
, vn
);
2179 vfp_load_reg32(vd
, a
->vd
);
2182 gen_vfp_negs(vd
, vd
);
2184 fpst
= fpstatus_ptr(FPST_FPCR
);
2185 gen_helper_vfp_muladds(vd
, vn
, vm
, vd
, fpst
);
2186 vfp_store_reg32(vd
, a
->vd
);
2190 static bool do_vfm_dp(DisasContext
*s
, arg_VFMA_dp
*a
, bool neg_n
, bool neg_d
)
2193 * VFNMA : fd = muladd(-fd, -fn, fm)
2194 * VFNMS : fd = muladd(-fd, fn, fm)
2195 * VFMA : fd = muladd( fd, fn, fm)
2196 * VFMS : fd = muladd( fd, -fn, fm)
2198 * These are fused multiply-add, and must be done as one floating
2199 * point operation with no rounding between the multiplication and
2200 * addition steps. NB that doing the negations here as separate
2201 * steps is correct : an input NaN should come out with its sign
2202 * bit flipped if it is a negated-input.
2205 TCGv_i64 vn
, vm
, vd
;
2208 * Present in VFPv4 only.
2209 * Note that we can't rely on the SIMDFMAC check alone, because
2210 * in a Neon-no-VFP core that ID register field will be non-zero.
2212 if (!dc_isar_feature(aa32_simdfmac
, s
) ||
2213 !dc_isar_feature(aa32_fpdp_v2
, s
)) {
2217 * In v7A, UNPREDICTABLE with non-zero vector length/stride; from
2218 * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A.
2220 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
2224 /* UNDEF accesses to D16-D31 if they don't exist. */
2225 if (!dc_isar_feature(aa32_simd_r32
, s
) &&
2226 ((a
->vd
| a
->vn
| a
->vm
) & 0x10)) {
2230 if (!vfp_access_check(s
)) {
2234 vn
= tcg_temp_new_i64();
2235 vm
= tcg_temp_new_i64();
2236 vd
= tcg_temp_new_i64();
2238 vfp_load_reg64(vn
, a
->vn
);
2239 vfp_load_reg64(vm
, a
->vm
);
2242 gen_vfp_negd(vn
, vn
);
2244 vfp_load_reg64(vd
, a
->vd
);
2247 gen_vfp_negd(vd
, vd
);
2249 fpst
= fpstatus_ptr(FPST_FPCR
);
2250 gen_helper_vfp_muladdd(vd
, vn
, vm
, vd
, fpst
);
2251 vfp_store_reg64(vd
, a
->vd
);
2255 #define MAKE_ONE_VFM_TRANS_FN(INSN, PREC, NEGN, NEGD) \
2256 static bool trans_##INSN##_##PREC(DisasContext *s, \
2257 arg_##INSN##_##PREC *a) \
2259 return do_vfm_##PREC(s, a, NEGN, NEGD); \
2262 #define MAKE_VFM_TRANS_FNS(PREC) \
2263 MAKE_ONE_VFM_TRANS_FN(VFMA, PREC, false, false) \
2264 MAKE_ONE_VFM_TRANS_FN(VFMS, PREC, true, false) \
2265 MAKE_ONE_VFM_TRANS_FN(VFNMS, PREC, false, true) \
2266 MAKE_ONE_VFM_TRANS_FN(VFNMA, PREC, true, true)
2268 MAKE_VFM_TRANS_FNS(hp
)
2269 MAKE_VFM_TRANS_FNS(sp
)
2270 MAKE_VFM_TRANS_FNS(dp
)
2272 static bool trans_VMOV_imm_hp(DisasContext
*s
, arg_VMOV_imm_sp
*a
)
2274 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2278 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
2282 if (!vfp_access_check(s
)) {
2286 vfp_store_reg32(tcg_constant_i32(vfp_expand_imm(MO_16
, a
->imm
)), a
->vd
);
2290 static bool trans_VMOV_imm_sp(DisasContext
*s
, arg_VMOV_imm_sp
*a
)
2292 uint32_t delta_d
= 0;
2293 int veclen
= s
->vec_len
;
2299 if (!dc_isar_feature(aa32_fpsp_v3
, s
)) {
2303 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
2304 (veclen
!= 0 || s
->vec_stride
!= 0)) {
2308 if (!vfp_access_check(s
)) {
2313 /* Figure out what type of vector operation this is. */
2314 if (vfp_sreg_is_scalar(vd
)) {
2318 delta_d
= s
->vec_stride
+ 1;
2322 fd
= tcg_constant_i32(vfp_expand_imm(MO_32
, a
->imm
));
2325 vfp_store_reg32(fd
, vd
);
2331 /* Set up the operands for the next iteration */
2333 vd
= vfp_advance_sreg(vd
, delta_d
);
2339 static bool trans_VMOV_imm_dp(DisasContext
*s
, arg_VMOV_imm_dp
*a
)
2341 uint32_t delta_d
= 0;
2342 int veclen
= s
->vec_len
;
2348 if (!dc_isar_feature(aa32_fpdp_v3
, s
)) {
2352 /* UNDEF accesses to D16-D31 if they don't exist. */
2353 if (!dc_isar_feature(aa32_simd_r32
, s
) && (vd
& 0x10)) {
2357 if (!dc_isar_feature(aa32_fpshvec
, s
) &&
2358 (veclen
!= 0 || s
->vec_stride
!= 0)) {
2362 if (!vfp_access_check(s
)) {
2367 /* Figure out what type of vector operation this is. */
2368 if (vfp_dreg_is_scalar(vd
)) {
2372 delta_d
= (s
->vec_stride
>> 1) + 1;
2376 fd
= tcg_constant_i64(vfp_expand_imm(MO_64
, a
->imm
));
2379 vfp_store_reg64(fd
, vd
);
2385 /* Set up the operands for the next iteration */
2387 vd
= vfp_advance_dreg(vd
, delta_d
);
2393 #define DO_VFP_2OP(INSN, PREC, FN, CHECK) \
2394 static bool trans_##INSN##_##PREC(DisasContext *s, \
2395 arg_##INSN##_##PREC *a) \
2397 if (!dc_isar_feature(CHECK, s)) { \
2400 return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \
2403 #define DO_VFP_VMOV(INSN, PREC, FN) \
2404 static bool trans_##INSN##_##PREC(DisasContext *s, \
2405 arg_##INSN##_##PREC *a) \
2407 if (!dc_isar_feature(aa32_fp##PREC##_v2, s) && \
2408 !dc_isar_feature(aa32_mve, s)) { \
2411 return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \
2414 DO_VFP_VMOV(VMOV_reg
, sp
, tcg_gen_mov_i32
)
2415 DO_VFP_VMOV(VMOV_reg
, dp
, tcg_gen_mov_i64
)
2417 DO_VFP_2OP(VABS
, hp
, gen_vfp_absh
, aa32_fp16_arith
)
2418 DO_VFP_2OP(VABS
, sp
, gen_vfp_abss
, aa32_fpsp_v2
)
2419 DO_VFP_2OP(VABS
, dp
, gen_vfp_absd
, aa32_fpdp_v2
)
2421 DO_VFP_2OP(VNEG
, hp
, gen_vfp_negh
, aa32_fp16_arith
)
2422 DO_VFP_2OP(VNEG
, sp
, gen_vfp_negs
, aa32_fpsp_v2
)
2423 DO_VFP_2OP(VNEG
, dp
, gen_vfp_negd
, aa32_fpdp_v2
)
2425 static void gen_VSQRT_hp(TCGv_i32 vd
, TCGv_i32 vm
)
2427 gen_helper_vfp_sqrth(vd
, vm
, tcg_env
);
2430 static void gen_VSQRT_sp(TCGv_i32 vd
, TCGv_i32 vm
)
2432 gen_helper_vfp_sqrts(vd
, vm
, tcg_env
);
2435 static void gen_VSQRT_dp(TCGv_i64 vd
, TCGv_i64 vm
)
2437 gen_helper_vfp_sqrtd(vd
, vm
, tcg_env
);
2440 DO_VFP_2OP(VSQRT
, hp
, gen_VSQRT_hp
, aa32_fp16_arith
)
2441 DO_VFP_2OP(VSQRT
, sp
, gen_VSQRT_sp
, aa32_fpsp_v2
)
2442 DO_VFP_2OP(VSQRT
, dp
, gen_VSQRT_dp
, aa32_fpdp_v2
)
2444 static bool trans_VCMP_hp(DisasContext
*s
, arg_VCMP_sp
*a
)
2448 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2452 /* Vm/M bits must be zero for the Z variant */
2453 if (a
->z
&& a
->vm
!= 0) {
2457 if (!vfp_access_check(s
)) {
2461 vd
= tcg_temp_new_i32();
2462 vm
= tcg_temp_new_i32();
2464 vfp_load_reg16(vd
, a
->vd
);
2466 tcg_gen_movi_i32(vm
, 0);
2468 vfp_load_reg16(vm
, a
->vm
);
2472 gen_helper_vfp_cmpeh(vd
, vm
, tcg_env
);
2474 gen_helper_vfp_cmph(vd
, vm
, tcg_env
);
2479 static bool trans_VCMP_sp(DisasContext
*s
, arg_VCMP_sp
*a
)
2483 if (!dc_isar_feature(aa32_fpsp_v2
, s
)) {
2487 /* Vm/M bits must be zero for the Z variant */
2488 if (a
->z
&& a
->vm
!= 0) {
2492 if (!vfp_access_check(s
)) {
2496 vd
= tcg_temp_new_i32();
2497 vm
= tcg_temp_new_i32();
2499 vfp_load_reg32(vd
, a
->vd
);
2501 tcg_gen_movi_i32(vm
, 0);
2503 vfp_load_reg32(vm
, a
->vm
);
2507 gen_helper_vfp_cmpes(vd
, vm
, tcg_env
);
2509 gen_helper_vfp_cmps(vd
, vm
, tcg_env
);
2514 static bool trans_VCMP_dp(DisasContext
*s
, arg_VCMP_dp
*a
)
2518 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2522 /* Vm/M bits must be zero for the Z variant */
2523 if (a
->z
&& a
->vm
!= 0) {
2527 /* UNDEF accesses to D16-D31 if they don't exist. */
2528 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2532 if (!vfp_access_check(s
)) {
2536 vd
= tcg_temp_new_i64();
2537 vm
= tcg_temp_new_i64();
2539 vfp_load_reg64(vd
, a
->vd
);
2541 tcg_gen_movi_i64(vm
, 0);
2543 vfp_load_reg64(vm
, a
->vm
);
2547 gen_helper_vfp_cmped(vd
, vm
, tcg_env
);
2549 gen_helper_vfp_cmpd(vd
, vm
, tcg_env
);
2554 static bool trans_VCVT_f32_f16(DisasContext
*s
, arg_VCVT_f32_f16
*a
)
2560 if (!dc_isar_feature(aa32_fp16_spconv
, s
)) {
2564 if (!vfp_access_check(s
)) {
2568 fpst
= fpstatus_ptr(FPST_FPCR
);
2569 ahp_mode
= get_ahp_flag();
2570 tmp
= tcg_temp_new_i32();
2571 /* The T bit tells us if we want the low or high 16 bits of Vm */
2572 tcg_gen_ld16u_i32(tmp
, tcg_env
, vfp_f16_offset(a
->vm
, a
->t
));
2573 gen_helper_vfp_fcvt_f16_to_f32(tmp
, tmp
, fpst
, ahp_mode
);
2574 vfp_store_reg32(tmp
, a
->vd
);
2578 static bool trans_VCVT_f64_f16(DisasContext
*s
, arg_VCVT_f64_f16
*a
)
2585 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2589 if (!dc_isar_feature(aa32_fp16_dpconv
, s
)) {
2593 /* UNDEF accesses to D16-D31 if they don't exist. */
2594 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
& 0x10)) {
2598 if (!vfp_access_check(s
)) {
2602 fpst
= fpstatus_ptr(FPST_FPCR
);
2603 ahp_mode
= get_ahp_flag();
2604 tmp
= tcg_temp_new_i32();
2605 /* The T bit tells us if we want the low or high 16 bits of Vm */
2606 tcg_gen_ld16u_i32(tmp
, tcg_env
, vfp_f16_offset(a
->vm
, a
->t
));
2607 vd
= tcg_temp_new_i64();
2608 gen_helper_vfp_fcvt_f16_to_f64(vd
, tmp
, fpst
, ahp_mode
);
2609 vfp_store_reg64(vd
, a
->vd
);
2613 static bool trans_VCVT_b16_f32(DisasContext
*s
, arg_VCVT_b16_f32
*a
)
2618 if (!dc_isar_feature(aa32_bf16
, s
)) {
2622 if (!vfp_access_check(s
)) {
2626 fpst
= fpstatus_ptr(FPST_FPCR
);
2627 tmp
= tcg_temp_new_i32();
2629 vfp_load_reg32(tmp
, a
->vm
);
2630 gen_helper_bfcvt(tmp
, tmp
, fpst
);
2631 tcg_gen_st16_i32(tmp
, tcg_env
, vfp_f16_offset(a
->vd
, a
->t
));
2635 static bool trans_VCVT_f16_f32(DisasContext
*s
, arg_VCVT_f16_f32
*a
)
2641 if (!dc_isar_feature(aa32_fp16_spconv
, s
)) {
2645 if (!vfp_access_check(s
)) {
2649 fpst
= fpstatus_ptr(FPST_FPCR
);
2650 ahp_mode
= get_ahp_flag();
2651 tmp
= tcg_temp_new_i32();
2653 vfp_load_reg32(tmp
, a
->vm
);
2654 gen_helper_vfp_fcvt_f32_to_f16(tmp
, tmp
, fpst
, ahp_mode
);
2655 tcg_gen_st16_i32(tmp
, tcg_env
, vfp_f16_offset(a
->vd
, a
->t
));
2659 static bool trans_VCVT_f16_f64(DisasContext
*s
, arg_VCVT_f16_f64
*a
)
2666 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2670 if (!dc_isar_feature(aa32_fp16_dpconv
, s
)) {
2674 /* UNDEF accesses to D16-D31 if they don't exist. */
2675 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
2679 if (!vfp_access_check(s
)) {
2683 fpst
= fpstatus_ptr(FPST_FPCR
);
2684 ahp_mode
= get_ahp_flag();
2685 tmp
= tcg_temp_new_i32();
2686 vm
= tcg_temp_new_i64();
2688 vfp_load_reg64(vm
, a
->vm
);
2689 gen_helper_vfp_fcvt_f64_to_f16(tmp
, vm
, fpst
, ahp_mode
);
2690 tcg_gen_st16_i32(tmp
, tcg_env
, vfp_f16_offset(a
->vd
, a
->t
));
2694 static bool trans_VRINTR_hp(DisasContext
*s
, arg_VRINTR_sp
*a
)
2699 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2703 if (!vfp_access_check(s
)) {
2707 tmp
= tcg_temp_new_i32();
2708 vfp_load_reg16(tmp
, a
->vm
);
2709 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
2710 gen_helper_rinth(tmp
, tmp
, fpst
);
2711 vfp_store_reg32(tmp
, a
->vd
);
2715 static bool trans_VRINTR_sp(DisasContext
*s
, arg_VRINTR_sp
*a
)
2720 if (!dc_isar_feature(aa32_vrint
, s
)) {
2724 if (!vfp_access_check(s
)) {
2728 tmp
= tcg_temp_new_i32();
2729 vfp_load_reg32(tmp
, a
->vm
);
2730 fpst
= fpstatus_ptr(FPST_FPCR
);
2731 gen_helper_rints(tmp
, tmp
, fpst
);
2732 vfp_store_reg32(tmp
, a
->vd
);
2736 static bool trans_VRINTR_dp(DisasContext
*s
, arg_VRINTR_dp
*a
)
2741 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2745 if (!dc_isar_feature(aa32_vrint
, s
)) {
2749 /* UNDEF accesses to D16-D31 if they don't exist. */
2750 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2754 if (!vfp_access_check(s
)) {
2758 tmp
= tcg_temp_new_i64();
2759 vfp_load_reg64(tmp
, a
->vm
);
2760 fpst
= fpstatus_ptr(FPST_FPCR
);
2761 gen_helper_rintd(tmp
, tmp
, fpst
);
2762 vfp_store_reg64(tmp
, a
->vd
);
2766 static bool trans_VRINTZ_hp(DisasContext
*s
, arg_VRINTZ_sp
*a
)
2772 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2776 if (!vfp_access_check(s
)) {
2780 tmp
= tcg_temp_new_i32();
2781 vfp_load_reg16(tmp
, a
->vm
);
2782 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
2783 tcg_rmode
= gen_set_rmode(FPROUNDING_ZERO
, fpst
);
2784 gen_helper_rinth(tmp
, tmp
, fpst
);
2785 gen_restore_rmode(tcg_rmode
, fpst
);
2786 vfp_store_reg32(tmp
, a
->vd
);
2790 static bool trans_VRINTZ_sp(DisasContext
*s
, arg_VRINTZ_sp
*a
)
2796 if (!dc_isar_feature(aa32_vrint
, s
)) {
2800 if (!vfp_access_check(s
)) {
2804 tmp
= tcg_temp_new_i32();
2805 vfp_load_reg32(tmp
, a
->vm
);
2806 fpst
= fpstatus_ptr(FPST_FPCR
);
2807 tcg_rmode
= gen_set_rmode(FPROUNDING_ZERO
, fpst
);
2808 gen_helper_rints(tmp
, tmp
, fpst
);
2809 gen_restore_rmode(tcg_rmode
, fpst
);
2810 vfp_store_reg32(tmp
, a
->vd
);
2814 static bool trans_VRINTZ_dp(DisasContext
*s
, arg_VRINTZ_dp
*a
)
2820 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2824 if (!dc_isar_feature(aa32_vrint
, s
)) {
2828 /* UNDEF accesses to D16-D31 if they don't exist. */
2829 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2833 if (!vfp_access_check(s
)) {
2837 tmp
= tcg_temp_new_i64();
2838 vfp_load_reg64(tmp
, a
->vm
);
2839 fpst
= fpstatus_ptr(FPST_FPCR
);
2840 tcg_rmode
= gen_set_rmode(FPROUNDING_ZERO
, fpst
);
2841 gen_helper_rintd(tmp
, tmp
, fpst
);
2842 gen_restore_rmode(tcg_rmode
, fpst
);
2843 vfp_store_reg64(tmp
, a
->vd
);
2847 static bool trans_VRINTX_hp(DisasContext
*s
, arg_VRINTX_sp
*a
)
2852 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2856 if (!vfp_access_check(s
)) {
2860 tmp
= tcg_temp_new_i32();
2861 vfp_load_reg16(tmp
, a
->vm
);
2862 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
2863 gen_helper_rinth_exact(tmp
, tmp
, fpst
);
2864 vfp_store_reg32(tmp
, a
->vd
);
2868 static bool trans_VRINTX_sp(DisasContext
*s
, arg_VRINTX_sp
*a
)
2873 if (!dc_isar_feature(aa32_vrint
, s
)) {
2877 if (!vfp_access_check(s
)) {
2881 tmp
= tcg_temp_new_i32();
2882 vfp_load_reg32(tmp
, a
->vm
);
2883 fpst
= fpstatus_ptr(FPST_FPCR
);
2884 gen_helper_rints_exact(tmp
, tmp
, fpst
);
2885 vfp_store_reg32(tmp
, a
->vd
);
2889 static bool trans_VRINTX_dp(DisasContext
*s
, arg_VRINTX_dp
*a
)
2894 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2898 if (!dc_isar_feature(aa32_vrint
, s
)) {
2902 /* UNDEF accesses to D16-D31 if they don't exist. */
2903 if (!dc_isar_feature(aa32_simd_r32
, s
) && ((a
->vd
| a
->vm
) & 0x10)) {
2907 if (!vfp_access_check(s
)) {
2911 tmp
= tcg_temp_new_i64();
2912 vfp_load_reg64(tmp
, a
->vm
);
2913 fpst
= fpstatus_ptr(FPST_FPCR
);
2914 gen_helper_rintd_exact(tmp
, tmp
, fpst
);
2915 vfp_store_reg64(tmp
, a
->vd
);
2919 static bool trans_VCVT_sp(DisasContext
*s
, arg_VCVT_sp
*a
)
2924 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2928 /* UNDEF accesses to D16-D31 if they don't exist. */
2929 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
& 0x10)) {
2933 if (!vfp_access_check(s
)) {
2937 vm
= tcg_temp_new_i32();
2938 vd
= tcg_temp_new_i64();
2939 vfp_load_reg32(vm
, a
->vm
);
2940 gen_helper_vfp_fcvtds(vd
, vm
, tcg_env
);
2941 vfp_store_reg64(vd
, a
->vd
);
2945 static bool trans_VCVT_dp(DisasContext
*s
, arg_VCVT_dp
*a
)
2950 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
2954 /* UNDEF accesses to D16-D31 if they don't exist. */
2955 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
2959 if (!vfp_access_check(s
)) {
2963 vd
= tcg_temp_new_i32();
2964 vm
= tcg_temp_new_i64();
2965 vfp_load_reg64(vm
, a
->vm
);
2966 gen_helper_vfp_fcvtsd(vd
, vm
, tcg_env
);
2967 vfp_store_reg32(vd
, a
->vd
);
2971 static bool trans_VCVT_int_hp(DisasContext
*s
, arg_VCVT_int_sp
*a
)
2976 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
2980 if (!vfp_access_check(s
)) {
2984 vm
= tcg_temp_new_i32();
2985 vfp_load_reg32(vm
, a
->vm
);
2986 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
2989 gen_helper_vfp_sitoh(vm
, vm
, fpst
);
2992 gen_helper_vfp_uitoh(vm
, vm
, fpst
);
2994 vfp_store_reg32(vm
, a
->vd
);
2998 static bool trans_VCVT_int_sp(DisasContext
*s
, arg_VCVT_int_sp
*a
)
3003 if (!dc_isar_feature(aa32_fpsp_v2
, s
)) {
3007 if (!vfp_access_check(s
)) {
3011 vm
= tcg_temp_new_i32();
3012 vfp_load_reg32(vm
, a
->vm
);
3013 fpst
= fpstatus_ptr(FPST_FPCR
);
3016 gen_helper_vfp_sitos(vm
, vm
, fpst
);
3019 gen_helper_vfp_uitos(vm
, vm
, fpst
);
3021 vfp_store_reg32(vm
, a
->vd
);
3025 static bool trans_VCVT_int_dp(DisasContext
*s
, arg_VCVT_int_dp
*a
)
3031 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
3035 /* UNDEF accesses to D16-D31 if they don't exist. */
3036 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
& 0x10)) {
3040 if (!vfp_access_check(s
)) {
3044 vm
= tcg_temp_new_i32();
3045 vd
= tcg_temp_new_i64();
3046 vfp_load_reg32(vm
, a
->vm
);
3047 fpst
= fpstatus_ptr(FPST_FPCR
);
3050 gen_helper_vfp_sitod(vd
, vm
, fpst
);
3053 gen_helper_vfp_uitod(vd
, vm
, fpst
);
3055 vfp_store_reg64(vd
, a
->vd
);
3059 static bool trans_VJCVT(DisasContext
*s
, arg_VJCVT
*a
)
3064 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
3068 if (!dc_isar_feature(aa32_jscvt
, s
)) {
3072 /* UNDEF accesses to D16-D31 if they don't exist. */
3073 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
3077 if (!vfp_access_check(s
)) {
3081 vm
= tcg_temp_new_i64();
3082 vd
= tcg_temp_new_i32();
3083 vfp_load_reg64(vm
, a
->vm
);
3084 gen_helper_vjcvt(vd
, vm
, tcg_env
);
3085 vfp_store_reg32(vd
, a
->vd
);
3089 static bool trans_VCVT_fix_hp(DisasContext
*s
, arg_VCVT_fix_sp
*a
)
3095 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
3099 if (!vfp_access_check(s
)) {
3103 frac_bits
= (a
->opc
& 1) ? (32 - a
->imm
) : (16 - a
->imm
);
3105 vd
= tcg_temp_new_i32();
3106 vfp_load_reg32(vd
, a
->vd
);
3108 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
3109 shift
= tcg_constant_i32(frac_bits
);
3111 /* Switch on op:U:sx bits */
3114 gen_helper_vfp_shtoh_round_to_nearest(vd
, vd
, shift
, fpst
);
3117 gen_helper_vfp_sltoh_round_to_nearest(vd
, vd
, shift
, fpst
);
3120 gen_helper_vfp_uhtoh_round_to_nearest(vd
, vd
, shift
, fpst
);
3123 gen_helper_vfp_ultoh_round_to_nearest(vd
, vd
, shift
, fpst
);
3126 gen_helper_vfp_toshh_round_to_zero(vd
, vd
, shift
, fpst
);
3129 gen_helper_vfp_toslh_round_to_zero(vd
, vd
, shift
, fpst
);
3132 gen_helper_vfp_touhh_round_to_zero(vd
, vd
, shift
, fpst
);
3135 gen_helper_vfp_toulh_round_to_zero(vd
, vd
, shift
, fpst
);
3138 g_assert_not_reached();
3141 vfp_store_reg32(vd
, a
->vd
);
3145 static bool trans_VCVT_fix_sp(DisasContext
*s
, arg_VCVT_fix_sp
*a
)
3151 if (!dc_isar_feature(aa32_fpsp_v3
, s
)) {
3155 if (!vfp_access_check(s
)) {
3159 frac_bits
= (a
->opc
& 1) ? (32 - a
->imm
) : (16 - a
->imm
);
3161 vd
= tcg_temp_new_i32();
3162 vfp_load_reg32(vd
, a
->vd
);
3164 fpst
= fpstatus_ptr(FPST_FPCR
);
3165 shift
= tcg_constant_i32(frac_bits
);
3167 /* Switch on op:U:sx bits */
3170 gen_helper_vfp_shtos_round_to_nearest(vd
, vd
, shift
, fpst
);
3173 gen_helper_vfp_sltos_round_to_nearest(vd
, vd
, shift
, fpst
);
3176 gen_helper_vfp_uhtos_round_to_nearest(vd
, vd
, shift
, fpst
);
3179 gen_helper_vfp_ultos_round_to_nearest(vd
, vd
, shift
, fpst
);
3182 gen_helper_vfp_toshs_round_to_zero(vd
, vd
, shift
, fpst
);
3185 gen_helper_vfp_tosls_round_to_zero(vd
, vd
, shift
, fpst
);
3188 gen_helper_vfp_touhs_round_to_zero(vd
, vd
, shift
, fpst
);
3191 gen_helper_vfp_touls_round_to_zero(vd
, vd
, shift
, fpst
);
3194 g_assert_not_reached();
3197 vfp_store_reg32(vd
, a
->vd
);
3201 static bool trans_VCVT_fix_dp(DisasContext
*s
, arg_VCVT_fix_dp
*a
)
3208 if (!dc_isar_feature(aa32_fpdp_v3
, s
)) {
3212 /* UNDEF accesses to D16-D31 if they don't exist. */
3213 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vd
& 0x10)) {
3217 if (!vfp_access_check(s
)) {
3221 frac_bits
= (a
->opc
& 1) ? (32 - a
->imm
) : (16 - a
->imm
);
3223 vd
= tcg_temp_new_i64();
3224 vfp_load_reg64(vd
, a
->vd
);
3226 fpst
= fpstatus_ptr(FPST_FPCR
);
3227 shift
= tcg_constant_i32(frac_bits
);
3229 /* Switch on op:U:sx bits */
3232 gen_helper_vfp_shtod_round_to_nearest(vd
, vd
, shift
, fpst
);
3235 gen_helper_vfp_sltod_round_to_nearest(vd
, vd
, shift
, fpst
);
3238 gen_helper_vfp_uhtod_round_to_nearest(vd
, vd
, shift
, fpst
);
3241 gen_helper_vfp_ultod_round_to_nearest(vd
, vd
, shift
, fpst
);
3244 gen_helper_vfp_toshd_round_to_zero(vd
, vd
, shift
, fpst
);
3247 gen_helper_vfp_tosld_round_to_zero(vd
, vd
, shift
, fpst
);
3250 gen_helper_vfp_touhd_round_to_zero(vd
, vd
, shift
, fpst
);
3253 gen_helper_vfp_tould_round_to_zero(vd
, vd
, shift
, fpst
);
3256 g_assert_not_reached();
3259 vfp_store_reg64(vd
, a
->vd
);
3263 static bool trans_VCVT_hp_int(DisasContext
*s
, arg_VCVT_sp_int
*a
)
3268 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
3272 if (!vfp_access_check(s
)) {
3276 fpst
= fpstatus_ptr(FPST_FPCR_F16
);
3277 vm
= tcg_temp_new_i32();
3278 vfp_load_reg16(vm
, a
->vm
);
3282 gen_helper_vfp_tosizh(vm
, vm
, fpst
);
3284 gen_helper_vfp_tosih(vm
, vm
, fpst
);
3288 gen_helper_vfp_touizh(vm
, vm
, fpst
);
3290 gen_helper_vfp_touih(vm
, vm
, fpst
);
3293 vfp_store_reg32(vm
, a
->vd
);
3297 static bool trans_VCVT_sp_int(DisasContext
*s
, arg_VCVT_sp_int
*a
)
3302 if (!dc_isar_feature(aa32_fpsp_v2
, s
)) {
3306 if (!vfp_access_check(s
)) {
3310 fpst
= fpstatus_ptr(FPST_FPCR
);
3311 vm
= tcg_temp_new_i32();
3312 vfp_load_reg32(vm
, a
->vm
);
3316 gen_helper_vfp_tosizs(vm
, vm
, fpst
);
3318 gen_helper_vfp_tosis(vm
, vm
, fpst
);
3322 gen_helper_vfp_touizs(vm
, vm
, fpst
);
3324 gen_helper_vfp_touis(vm
, vm
, fpst
);
3327 vfp_store_reg32(vm
, a
->vd
);
3331 static bool trans_VCVT_dp_int(DisasContext
*s
, arg_VCVT_dp_int
*a
)
3337 if (!dc_isar_feature(aa32_fpdp_v2
, s
)) {
3341 /* UNDEF accesses to D16-D31 if they don't exist. */
3342 if (!dc_isar_feature(aa32_simd_r32
, s
) && (a
->vm
& 0x10)) {
3346 if (!vfp_access_check(s
)) {
3350 fpst
= fpstatus_ptr(FPST_FPCR
);
3351 vm
= tcg_temp_new_i64();
3352 vd
= tcg_temp_new_i32();
3353 vfp_load_reg64(vm
, a
->vm
);
3357 gen_helper_vfp_tosizd(vd
, vm
, fpst
);
3359 gen_helper_vfp_tosid(vd
, vm
, fpst
);
3363 gen_helper_vfp_touizd(vd
, vm
, fpst
);
3365 gen_helper_vfp_touid(vd
, vm
, fpst
);
3368 vfp_store_reg32(vd
, a
->vd
);
3372 static bool trans_VINS(DisasContext
*s
, arg_VINS
*a
)
3376 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
3380 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
3384 if (!vfp_access_check(s
)) {
3388 /* Insert low half of Vm into high half of Vd */
3389 rm
= tcg_temp_new_i32();
3390 rd
= tcg_temp_new_i32();
3391 vfp_load_reg16(rm
, a
->vm
);
3392 vfp_load_reg16(rd
, a
->vd
);
3393 tcg_gen_deposit_i32(rd
, rd
, rm
, 16, 16);
3394 vfp_store_reg32(rd
, a
->vd
);
3398 static bool trans_VMOVX(DisasContext
*s
, arg_VINS
*a
)
3402 if (!dc_isar_feature(aa32_fp16_arith
, s
)) {
3406 if (s
->vec_len
!= 0 || s
->vec_stride
!= 0) {
3410 if (!vfp_access_check(s
)) {
3414 /* Set Vd to high half of Vm */
3415 rm
= tcg_temp_new_i32();
3416 vfp_load_reg32(rm
, a
->vm
);
3417 tcg_gen_shri_i32(rm
, rm
, 16);
3418 vfp_store_reg32(rm
, a
->vd
);