target/arm: Make A32/T32 use new fpstatus_ptr() API

Make A32/T32 code use the new fpstatus_ptr() API:
get_fpstatus_ptr(0) -> fpstatus_ptr(FPST_FPCR)
get_fpstatus_ptr(1) -> fpstatus_ptr(FPST_STD)

Backports a84d1d1316726704edd2617b2c30c921d98a8137
This commit is contained in:
Peter Maydell 2021-02-26 11:55:52 -05:00 committed by Lioncash
parent 79359e3a69
commit b1b0a41507
3 changed files with 36 additions and 49 deletions

View file

@ -186,7 +186,7 @@ static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
}
opr_sz = (1 + a->q) * 8;
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
fn_gvec_ptr = a->size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
tcg_gen_gvec_3_ptr(tcg_ctx, vfp_reg_offset(1, a->vd),
vfp_reg_offset(1, a->vn),
@ -224,7 +224,7 @@ static bool trans_VCADD(DisasContext *s, arg_VCADD *a)
}
opr_sz = (1 + a->q) * 8;
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
fn_gvec_ptr = a->size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh;
tcg_gen_gvec_3_ptr(tcg_ctx, vfp_reg_offset(1, a->vd),
vfp_reg_offset(1, a->vn),
@ -331,7 +331,7 @@ static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a)
fn_gvec_ptr = (a->size ? gen_helper_gvec_fcmlas_idx
: gen_helper_gvec_fcmlah_idx);
opr_sz = (1 + a->q) * 8;
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
tcg_gen_gvec_3_ptr(tcg_ctx, vfp_reg_offset(1, a->vd),
vfp_reg_offset(1, a->vn),
vfp_reg_offset(1, a->vm),
@ -368,7 +368,7 @@ static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a)
fn_gvec = a->u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b;
opr_sz = (1 + a->q) * 8;
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
tcg_gen_gvec_3_ool(tcg_ctx, vfp_reg_offset(1, a->vd),
vfp_reg_offset(1, a->vn),
vfp_reg_offset(1, a->rm),
@ -1082,7 +1082,7 @@ static bool do_3same_fp(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn,
return true;
}
TCGv_ptr fpstatus = get_fpstatus_ptr(tcg_ctx, 1);
TCGv_ptr fpstatus = fpstatus_ptr(tcg_ctx, FPST_STD);
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
tmp = neon_load_reg(s, a->vn, pass);
tmp2 = neon_load_reg(s, a->vm, pass);
@ -1110,7 +1110,7 @@ static bool do_3same_fp(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn,
uint32_t rn_ofs, uint32_t rm_ofs, \
uint32_t oprsz, uint32_t maxsz) \
{ \
TCGv_ptr fpst = get_fpstatus_ptr(s, 1); \
TCGv_ptr fpst = fpstatus_ptr(s, FPST_STD); \
tcg_gen_gvec_3_ptr(s, rd_ofs, rn_ofs, rm_ofs, fpst, \
oprsz, maxsz, 0, FUNC); \
tcg_temp_free_ptr(s, fpst); \
@ -1307,7 +1307,7 @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn)
* early. Since Q is 0 there are always just two passes, so instead
* of a complicated loop over each pass we just unroll.
*/
fpstatus = get_fpstatus_ptr(tcg_ctx, 1);
fpstatus = fpstatus_ptr(tcg_ctx, FPST_STD);
tmp = neon_load_reg(s, a->vn, 0);
tmp2 = neon_load_reg(s, a->vn, 1);
fn(tcg_ctx, tmp, tmp, tmp2, fpstatus);
@ -1817,7 +1817,7 @@ static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a,
return true;
}
fpstatus = get_fpstatus_ptr(tcg_ctx, 1);
fpstatus = fpstatus_ptr(tcg_ctx, FPST_STD);
shiftv = tcg_const_i32(tcg_ctx, a->shift);
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
tmp = neon_load_reg(s, a->vm, pass);
@ -2625,7 +2625,7 @@ static bool trans_VMLS_2sc(DisasContext *s, arg_2scalar *a)
#define WRAP_FP_FN(WRAPNAME, FUNC) \
static void WRAPNAME(TCGContext *s, TCGv_i32 rd, TCGv_i32 rn, TCGv_i32 rm) \
{ \
TCGv_ptr fpstatus = get_fpstatus_ptr(s, 1); \
TCGv_ptr fpstatus = fpstatus_ptr(s, FPST_STD); \
FUNC(s, rd, rn, rm, fpstatus); \
tcg_temp_free_ptr(s, fpstatus); \
}
@ -3527,7 +3527,7 @@ static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, true);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
ahp = get_ahp_flag(s);
tmp = neon_load_reg(s, a->vm, 0);
gen_helper_vfp_fcvt_f32_to_f16(tcg_ctx, tmp, tmp, fpst, ahp);
@ -3576,7 +3576,7 @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, true);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
ahp = get_ahp_flag(s);
tmp3 = tcg_temp_new_i32(tcg_ctx);
tmp = neon_load_reg(s, a->vm, 0);
@ -3889,7 +3889,7 @@ static bool do_2misc_fp(DisasContext *s, arg_2misc *a,
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
TCGv_i32 tmp = neon_load_reg(s, a->vm, pass);
fn(tcg_ctx, tmp, tmp, fpst);
@ -3984,7 +3984,7 @@ static bool do_vrint(DisasContext *s, arg_2misc *a, int rmode)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
tcg_rmode = tcg_const_i32(tcg_ctx, arm_rmode_to_sf(rmode));
gen_helper_set_neon_rmode(tcg_ctx, tcg_rmode, tcg_rmode, tcg_ctx->cpu_env);
for (pass = 0; pass < (a->q ? 4 : 2); pass++) {
@ -4046,7 +4046,7 @@ static bool do_vcvt(DisasContext *s, arg_2misc *a, int rmode, bool is_signed)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, 1);
fpst = fpstatus_ptr(tcg_ctx, FPST_STD);
tcg_shift = tcg_const_i32(tcg_ctx, 0);
tcg_rmode = tcg_const_i32(tcg_ctx, arm_rmode_to_sf(rmode));
gen_helper_set_neon_rmode(tcg_ctx, tcg_rmode, tcg_rmode, tcg_ctx->cpu_env);

View file

@ -364,7 +364,7 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
tcg_rmode = tcg_const_i32(tcg_ctx, arm_rmode_to_sf(rounding));
gen_helper_set_rmode(tcg_ctx, tcg_rmode, tcg_rmode, fpst);
@ -428,7 +428,7 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
tcg_shift = tcg_const_i32(tcg_ctx, 0);
@ -1249,7 +1249,7 @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn,
f0 = tcg_temp_new_i32(tcg_ctx);
f1 = tcg_temp_new_i32(tcg_ctx);
fd = tcg_temp_new_i32(tcg_ctx);
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
neon_load_reg32(s, f0, vn);
neon_load_reg32(s, f1, vm);
@ -1333,7 +1333,7 @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn,
f0 = tcg_temp_new_i64(tcg_ctx);
f1 = tcg_temp_new_i64(tcg_ctx);
fd = tcg_temp_new_i64(tcg_ctx);
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
neon_load_reg64(s, f0, vn);
neon_load_reg64(s, f1, vm);
@ -1819,7 +1819,7 @@ static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d)
/* VFNMA, VFNMS */
gen_helper_vfp_negs(tcg_ctx, vd, vd);
}
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_vfp_muladds(tcg_ctx, vd, vn, vm, vd, fpst);
neon_store_reg32(s, vd, a->vd);
@ -1911,7 +1911,7 @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d)
/* VFNMA, VFNMS */
gen_helper_vfp_negd(tcg_ctx, vd, vd);
}
fpst = get_fpstatus_ptr(tcg_ctx, 0);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_vfp_muladdd(tcg_ctx, vd, vn, vm, vd, fpst);
neon_store_reg64(s, vd, a->vd);
@ -2200,7 +2200,7 @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
ahp_mode = get_ahp_flag(s);
tmp = tcg_temp_new_i32(tcg_ctx);
/* The T bit tells us if we want the low or high 16 bits of Vm */
@ -2239,7 +2239,7 @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
ahp_mode = get_ahp_flag(s);
tmp = tcg_temp_new_i32(tcg_ctx);
/* The T bit tells us if we want the low or high 16 bits of Vm */
@ -2269,7 +2269,7 @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
ahp_mode = get_ahp_flag(s);
tmp = tcg_temp_new_i32(tcg_ctx);
@ -2307,7 +2307,7 @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
ahp_mode = get_ahp_flag(s);
tmp = tcg_temp_new_i32(tcg_ctx);
vm = tcg_temp_new_i64(tcg_ctx);
@ -2338,7 +2338,7 @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a)
tmp = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_rints(tcg_ctx, tmp, tmp, fpst);
neon_store_reg32(s, tmp, a->vd);
tcg_temp_free_ptr(tcg_ctx, fpst);
@ -2371,7 +2371,7 @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a)
tmp = tcg_temp_new_i64(tcg_ctx);
neon_load_reg64(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_rintd(tcg_ctx, tmp, tmp, fpst);
neon_store_reg64(s, tmp, a->vd);
tcg_temp_free_ptr(tcg_ctx, fpst);
@ -2396,7 +2396,7 @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a)
tmp = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
tcg_rmode = tcg_const_i32(tcg_ctx, float_round_to_zero);
gen_helper_set_rmode(tcg_ctx, tcg_rmode, tcg_rmode, fpst);
gen_helper_rints(tcg_ctx, tmp, tmp, fpst);
@ -2434,7 +2434,7 @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a)
tmp = tcg_temp_new_i64(tcg_ctx);
neon_load_reg64(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
tcg_rmode = tcg_const_i32(tcg_ctx, float_round_to_zero);
gen_helper_set_rmode(tcg_ctx, tcg_rmode, tcg_rmode, fpst);
gen_helper_rintd(tcg_ctx, tmp, tmp, fpst);
@ -2462,7 +2462,7 @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a)
tmp = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_rints_exact(tcg_ctx, tmp, tmp, fpst);
neon_store_reg32(s, tmp, a->vd);
tcg_temp_free_ptr(tcg_ctx, fpst);
@ -2495,7 +2495,7 @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a)
tmp = tcg_temp_new_i64(tcg_ctx);
neon_load_reg64(s, tmp, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
gen_helper_rintd_exact(tcg_ctx, tmp, tmp, fpst);
neon_store_reg64(s, tmp, a->vd);
tcg_temp_free_ptr(tcg_ctx, fpst);
@ -2577,7 +2577,7 @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a)
vm = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, vm, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
if (a->s) {
/* i32 -> f32 */
gen_helper_vfp_sitos(tcg_ctx, vm, vm, fpst);
@ -2614,7 +2614,7 @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a)
vm = tcg_temp_new_i32(tcg_ctx);
vd = tcg_temp_new_i64(tcg_ctx);
neon_load_reg32(s, vm, a->vm);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
if (a->s) {
/* i32 -> f64 */
gen_helper_vfp_sitod(tcg_ctx, vd, vm, fpst);
@ -2682,7 +2682,7 @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a)
vd = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, vd, a->vd);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
shift = tcg_const_i32(tcg_ctx, frac_bits);
/* Switch on op:U:sx bits */
@ -2748,7 +2748,7 @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a)
vd = tcg_temp_new_i64(tcg_ctx);
neon_load_reg64(s, vd, a->vd);
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
shift = tcg_const_i32(tcg_ctx, frac_bits);
/* Switch on op:U:sx bits */
@ -2802,7 +2802,7 @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
vm = tcg_temp_new_i32(tcg_ctx);
neon_load_reg32(s, vm, a->vm);
@ -2845,7 +2845,7 @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a)
return true;
}
fpst = get_fpstatus_ptr(tcg_ctx, false);
fpst = fpstatus_ptr(tcg_ctx, FPST_FPCR);
vm = tcg_temp_new_i64(tcg_ctx);
vd = tcg_temp_new_i32(tcg_ctx);
neon_load_reg64(s, vm, a->vm);

View file

@ -1138,19 +1138,6 @@ static inline void gen_hlt(DisasContext *s, int imm)
unallocated_encoding(s);
}
static TCGv_ptr get_fpstatus_ptr(TCGContext *tcg_ctx, int neon)
{
TCGv_ptr statusptr = tcg_temp_new_ptr(tcg_ctx);
int offset;
if (neon) {
offset = offsetof(CPUARMState, vfp.standard_fp_status);
} else {
offset = offsetof(CPUARMState, vfp.fp_status);
}
tcg_gen_addi_ptr(tcg_ctx, statusptr, tcg_ctx->cpu_env, offset);
return statusptr;
}
static inline long vfp_reg_offset(bool dp, unsigned reg)
{
if (dp) {