target/arm: Introduce neon_full_reg_offset
This function makes it clear that we're talking about the whole register, and not the 32-bit piece at index 0. This fixes a bug when running on a big-endian host. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20201030022618.785675-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
b149dea55c
commit
015ee81a4c
@ -76,7 +76,7 @@ neon_element_offset(int reg, int element, MemOp size)
|
|||||||
ofs ^= 8 - element_size;
|
ofs ^= 8 - element_size;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return neon_reg_offset(reg, 0) + ofs;
|
return neon_full_reg_offset(reg) + ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop)
|
static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop)
|
||||||
@ -585,12 +585,12 @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
|
|||||||
* We cannot write 16 bytes at once because the
|
* We cannot write 16 bytes at once because the
|
||||||
* destination is unaligned.
|
* destination is unaligned.
|
||||||
*/
|
*/
|
||||||
tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
|
tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd),
|
||||||
8, 8, tmp);
|
8, 8, tmp);
|
||||||
tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0),
|
tcg_gen_gvec_mov(0, neon_full_reg_offset(vd + 1),
|
||||||
neon_reg_offset(vd, 0), 8, 8);
|
neon_full_reg_offset(vd), 8, 8);
|
||||||
} else {
|
} else {
|
||||||
tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
|
tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd),
|
||||||
vec_size, vec_size, tmp);
|
vec_size, vec_size, tmp);
|
||||||
}
|
}
|
||||||
tcg_gen_addi_i32(addr, addr, 1 << size);
|
tcg_gen_addi_i32(addr, addr, 1 << size);
|
||||||
@ -691,9 +691,9 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
|
|||||||
static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
|
static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
|
||||||
{
|
{
|
||||||
int vec_size = a->q ? 16 : 8;
|
int vec_size = a->q ? 16 : 8;
|
||||||
int rd_ofs = neon_reg_offset(a->vd, 0);
|
int rd_ofs = neon_full_reg_offset(a->vd);
|
||||||
int rn_ofs = neon_reg_offset(a->vn, 0);
|
int rn_ofs = neon_full_reg_offset(a->vn);
|
||||||
int rm_ofs = neon_reg_offset(a->vm, 0);
|
int rm_ofs = neon_full_reg_offset(a->vm);
|
||||||
|
|
||||||
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1177,8 +1177,8 @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn)
|
|||||||
{
|
{
|
||||||
/* Handle a 2-reg-shift insn which can be vectorized. */
|
/* Handle a 2-reg-shift insn which can be vectorized. */
|
||||||
int vec_size = a->q ? 16 : 8;
|
int vec_size = a->q ? 16 : 8;
|
||||||
int rd_ofs = neon_reg_offset(a->vd, 0);
|
int rd_ofs = neon_full_reg_offset(a->vd);
|
||||||
int rm_ofs = neon_reg_offset(a->vm, 0);
|
int rm_ofs = neon_full_reg_offset(a->vm);
|
||||||
|
|
||||||
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1620,8 +1620,8 @@ static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a,
|
|||||||
{
|
{
|
||||||
/* FP operations in 2-reg-and-shift group */
|
/* FP operations in 2-reg-and-shift group */
|
||||||
int vec_size = a->q ? 16 : 8;
|
int vec_size = a->q ? 16 : 8;
|
||||||
int rd_ofs = neon_reg_offset(a->vd, 0);
|
int rd_ofs = neon_full_reg_offset(a->vd);
|
||||||
int rm_ofs = neon_reg_offset(a->vm, 0);
|
int rm_ofs = neon_full_reg_offset(a->vm);
|
||||||
TCGv_ptr fpst;
|
TCGv_ptr fpst;
|
||||||
|
|
||||||
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
||||||
@ -1756,7 +1756,7 @@ static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_ofs = neon_reg_offset(a->vd, 0);
|
reg_ofs = neon_full_reg_offset(a->vd);
|
||||||
vec_size = a->q ? 16 : 8;
|
vec_size = a->q ? 16 : 8;
|
||||||
imm = asimd_imm_const(a->imm, a->cmode, a->op);
|
imm = asimd_imm_const(a->imm, a->cmode, a->op);
|
||||||
|
|
||||||
@ -2300,9 +2300,9 @@ static bool trans_VMULL_P_3d(DisasContext *s, arg_3diff *a)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcg_gen_gvec_3_ool(neon_reg_offset(a->vd, 0),
|
tcg_gen_gvec_3_ool(neon_full_reg_offset(a->vd),
|
||||||
neon_reg_offset(a->vn, 0),
|
neon_full_reg_offset(a->vn),
|
||||||
neon_reg_offset(a->vm, 0),
|
neon_full_reg_offset(a->vm),
|
||||||
16, 16, 0, fn_gvec);
|
16, 16, 0, fn_gvec);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2445,8 +2445,8 @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a,
|
|||||||
{
|
{
|
||||||
/* Two registers and a scalar, using gvec */
|
/* Two registers and a scalar, using gvec */
|
||||||
int vec_size = a->q ? 16 : 8;
|
int vec_size = a->q ? 16 : 8;
|
||||||
int rd_ofs = neon_reg_offset(a->vd, 0);
|
int rd_ofs = neon_full_reg_offset(a->vd);
|
||||||
int rn_ofs = neon_reg_offset(a->vn, 0);
|
int rn_ofs = neon_full_reg_offset(a->vn);
|
||||||
int rm_ofs;
|
int rm_ofs;
|
||||||
int idx;
|
int idx;
|
||||||
TCGv_ptr fpstatus;
|
TCGv_ptr fpstatus;
|
||||||
@ -2477,7 +2477,7 @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a,
|
|||||||
/* a->vm is M:Vm, which encodes both register and index */
|
/* a->vm is M:Vm, which encodes both register and index */
|
||||||
idx = extract32(a->vm, a->size + 2, 2);
|
idx = extract32(a->vm, a->size + 2, 2);
|
||||||
a->vm = extract32(a->vm, 0, a->size + 2);
|
a->vm = extract32(a->vm, 0, a->size + 2);
|
||||||
rm_ofs = neon_reg_offset(a->vm, 0);
|
rm_ofs = neon_full_reg_offset(a->vm);
|
||||||
|
|
||||||
fpstatus = fpstatus_ptr(a->size == 1 ? FPST_STD_F16 : FPST_STD);
|
fpstatus = fpstatus_ptr(a->size == 1 ? FPST_STD_F16 : FPST_STD);
|
||||||
tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, fpstatus,
|
tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, fpstatus,
|
||||||
@ -2923,7 +2923,7 @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcg_gen_gvec_dup_mem(a->size, neon_reg_offset(a->vd, 0),
|
tcg_gen_gvec_dup_mem(a->size, neon_full_reg_offset(a->vd),
|
||||||
neon_element_offset(a->vm, a->index, a->size),
|
neon_element_offset(a->vm, a->index, a->size),
|
||||||
a->q ? 16 : 8, a->q ? 16 : 8);
|
a->q ? 16 : 8, a->q ? 16 : 8);
|
||||||
return true;
|
return true;
|
||||||
@ -3412,8 +3412,8 @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a)
|
|||||||
static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn)
|
static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn)
|
||||||
{
|
{
|
||||||
int vec_size = a->q ? 16 : 8;
|
int vec_size = a->q ? 16 : 8;
|
||||||
int rd_ofs = neon_reg_offset(a->vd, 0);
|
int rd_ofs = neon_full_reg_offset(a->vd);
|
||||||
int rm_ofs = neon_reg_offset(a->vm, 0);
|
int rm_ofs = neon_full_reg_offset(a->vm);
|
||||||
|
|
||||||
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -653,7 +653,7 @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmp = load_reg(s, a->rt);
|
tmp = load_reg(s, a->rt);
|
||||||
tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0),
|
tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(a->vn),
|
||||||
vec_size, vec_size, tmp);
|
vec_size, vec_size, tmp);
|
||||||
tcg_temp_free_i32(tmp);
|
tcg_temp_free_i32(tmp);
|
||||||
|
|
||||||
|
@ -1094,6 +1094,14 @@ static inline void gen_hlt(DisasContext *s, int imm)
|
|||||||
unallocated_encoding(s);
|
unallocated_encoding(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the offset of a "full" NEON Dreg.
|
||||||
|
*/
|
||||||
|
static long neon_full_reg_offset(unsigned reg)
|
||||||
|
{
|
||||||
|
return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]);
|
||||||
|
}
|
||||||
|
|
||||||
static inline long vfp_reg_offset(bool dp, unsigned reg)
|
static inline long vfp_reg_offset(bool dp, unsigned reg)
|
||||||
{
|
{
|
||||||
if (dp) {
|
if (dp) {
|
||||||
|
Loading…
Reference in New Issue
Block a user