target-arm: Fix VQMOV(U)N
cover target-arm: Fix VQMOV(U)N
This patchset fixes the VQMOV(U)N instructions (saturating narrowing conversions). Tested by random generation of instructions for VQMOVN, VQMOVUN, VMOVN.
Patch 1/2 is the same as the one Christophe sent recently but I have corrected the authorship (this patch is from the meego tree).
Juha Riihimäki (1):
target-arm: Fix VQMOVUN Neon instruction.
Peter Maydell (1):
target-arm: Fix 32 bit signed saturating narrow
target-arm/helpers.h | 3 ++ target-arm/neon_helper.c | 65 +++++++++++++++++++++++++++++++++++++++++++++- target-arm/translate.c | 28 +++++++++++++++---- 3 files changed, 89 insertions(+), 7 deletions(-)
PATCH 1/2 target-arm: Fix VQMOVUN Neon instruction.
From: Juha Riihimäki <[email protected]>
VQMOVUN does a signed-to-unsigned saturating conversion. This is different from both the signed-to-signed and unsigned-to-unsigned conversions already implemented, so we need a new set of helper functions (neon_unarrow_sat*).
--- target-arm/helpers.h | 3 ++ target-arm/neon_helper.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate.c | 28 ++++++++++++++++---- 3 files changed, 88 insertions(+), 6 deletions(-)
target-arm/helpers.h +3 -0
@@ -299,10 +299,13 @@ DEF_HELPER_3(neon_qrdmulh_s32, i32, env, i32, i32) DEF_HELPER_1(neon_narrow_u8, i32, i64) DEF_HELPER_1(neon_narrow_u16, i32, i64) +DEF_HELPER_2(neon_unarrow_sat8, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u8, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s8, i32, env, i64) +DEF_HELPER_2(neon_unarrow_sat16, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u16, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s16, i32, env, i64) +DEF_HELPER_2(neon_unarrow_sat32, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u32, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s32, i32, env, i64)DEF_HELPER_1 (neon_narrow_high_u8, i32, i64)
target-arm/neon_helper.c +63 -0
81 lines not on this page · raw message
target-arm/translate.c +22 -6
@@ -4065,6 +4065,16 @@ static inline void gen_neon_narrow_satu(int size, TCGv dest, TCGv_i64 src) } } +static inline void gen_neon_unarrow_sats (int size,TCGv dest,TCGv_i64 src) +{ +switch (size) { +case 0 :gen_helper_neon_unarrow_sat8 (dest, cpu_env, src);break ; +case 1 :gen_helper_neon_unarrow_sat16 (dest, cpu_env, src);break ; +case 2 :gen_helper_neon_unarrow_sat32 (dest, cpu_env, src);break ; +default :abort (); + } +} +static inline void gen_neon_shift_narrow (int size,TCGv var,TCGv shift,int q,int u) {
@@ -5461,12 +5471,18 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)for (pass =0 ; pass <2 ; pass++) {neon_load_reg64 (cpu_V0, rm + pass); tmp =new_tmp (); -if (op ==36 && q ==0 ) { -gen_neon_narrow (size, tmp, cpu_V0); - }else if (q) { -gen_neon_narrow_satu (size, tmp, cpu_V0); - }else { -gen_neon_narrow_sats (size, tmp, cpu_V0); +if (op ==36 ) { +if (q) {/* VQMOVUN */ +gen_neon_unarrow_sats (size, tmp, cpu_V0); + }else {/* VMOVN */ +gen_neon_narrow (size, tmp, cpu_V0); + } + }else {/* VQMOVN */ +if (q) { +gen_neon_narrow_satu (size, tmp, cpu_V0); + }else { +gen_neon_narrow_sats (size, tmp, cpu_V0); + } }if (pass ==0 ) { tmp2 = tmp;
Signature · 1 line
1.7.1
PATCH 2/2 target-arm: Fix 32 bit signed saturating narrow
In reply to Peter MaydellThe returned value when doing saturating signed 64->32 bit conversion of a negative number was incorrect due to a missing cast.
--- target-arm/neon_helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-arm/neon_helper.c +1 -1
@@ -1209,7 +1209,7 @@ uint32_t HELPER(neon_narrow_sat_s32)(CPUState *env, uint64_t x) {if ((int64_t )x != (int32_t )x) {SET_QC (); -return (x >>63 ) ^0x7fffffff ; +return ((int64_t )x >>63 ) ^0x7fffffff ; }return x; }
Signature · 1 line
1.7.1
Quoted 10 lines · Peter Maydell
This patchset fixes the VQMOV(U)N instructions (saturating narrowing conversions). Tested by random generation of instructions for VQMOVN, VQMOVUN, VMOVN.
Patch 1/2 is the same as the one Christophe sent recently but I have corrected the authorship (this patch is from the meego tree).
Juha Riihimäki (1):
target-arm: Fix VQMOVUN Neon instruction.
Quoted 9 lines
Peter Maydell (1):
target-arm: Fix 32 bit signed saturating narrowtarget-arm/helpers.h | 3 ++ target-arm/neon_helper.c | 65 +++++++++++++++++++++++++++++++++++++++++++++- target-arm/translate.c | 28 +++++++++++++++---- 3 files changed, 89 insertions(+), 7 deletions(-)
Thanks, both applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net