target-s390x: fix CC computation for LOAD POSITIVE instructions
PATCH 1/3 target-s390x: fix CC computation for LOAD POSITIVE instructions
LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following condition code:
0: Result zero; no overflow
1: --
2: Result greater than zero; no overflow
3: Overflow
The current code wrongly returns 1 instead of 2 in case of a result greater than 0. This patches fixes that. This fixes the marshalling of the value '0L' in Python.
--- target-s390x/cc_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-s390x/cc_helper.c +2 -2
@@ -195,7 +195,7 @@ static uint32_t cc_calc_abs_64(int64_t dst)if ((uint64_t )dst ==0x8000000000000000ULL ) {return 3 ; }else if (dst) { -return 1 ; +return 2 ; }else {return 0 ; }
@@ -296,7 +296,7 @@ static uint32_t cc_calc_abs_32(int32_t dst)if ((uint32_t )dst ==0x80000000UL ) {return 3 ; }else if (dst) { -return 1 ; +return 2 ; }else {return 0 ; }
Signature · 1 line
2.1.4
PATCH 2/3 target-s390x: optimize (negative-) abs computation
Now that movcond exists, it's easy to write (negative-) absolute value using TCG code instead of an helper.
--- target-s390x/helper.h | 2 -- target-s390x/int_helper.c | 22 ---------------------- target-s390x/translate.c | 16 ++++++++++++++-- 3 files changed, 14 insertions(+), 26 deletions(-)
target-s390x/helper.h +0 -2
@@ -17,8 +17,6 @@ DEF_HELPER_4(mvst, i64, env, i64, i64, i64) DEF_HELPER_5(ex, i32, env, i32, i64, i64, i64) DEF_HELPER_FLAGS_1(abs_i32, TCG_CALL_NO_RWG_SE, i32, s32) DEF_HELPER_FLAGS_1(nabs_i32, TCG_CALL_NO_RWG_SE, s32, s32) -DEF_HELPER_FLAGS_1(abs_i64, TCG_CALL_NO_RWG_SE, i64, s64) -DEF_HELPER_FLAGS_1(nabs_i64, TCG_CALL_NO_RWG_SE, s64, s64) DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32)DEF_HELPER_4 (mvcle, i32, env, i32, i64, i32)
target-s390x/int_helper.c +0 -22
@@ -135,28 +135,6 @@ int32_t HELPER(nabs_i32)(int32_t val) } } -/* absolute value 64-bit */ -uint64_t HELPER (abs_i64 )(int64_t val) -{ -HELPER_LOG ("%s: val 0x%" PRIx64"\n" , __func__, val); - -if (val <0 ) { -return -val; - }else { -return val; - } -} - -/* negative absolute value 64-bit */ -int64_t HELPER (nabs_i64 )(int64_t val) -{ -if (val <0 ) { -return val; - }else { -return -val; - } -} -/* count leading zeros, for find leftmost one */ uint64_t HELPER (clz )(uint64_t v) {
target-s390x/translate.c +14 -2
@@ -1304,7 +1304,13 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,static ExitStatus op_abs (DisasContext *s,DisasOps *o) { -gen_helper_abs_i64 (o->out, o->in2); +TCGv_i64 z, n; + z =tcg_const_i64 (0 ); + n =tcg_temp_new_i64 (); +tcg_gen_neg_i64 (n, o->in2); +tcg_gen_movcond_i64 (TCG_COND_LT , o->out, o->in2, z, n, o->in2); +tcg_temp_free_i64 (n); +tcg_temp_free_i64 (z);return NO_EXIT ; }
@@ -2675,7 +2681,13 @@ static ExitStatus op_msdb(DisasContext *s, DisasOps *o)static ExitStatus op_nabs (DisasContext *s,DisasOps *o) { -gen_helper_nabs_i64 (o->out, o->in2); +TCGv_i64 z, n; + z =tcg_const_i64 (0 ); + n =tcg_temp_new_i64 (); +tcg_gen_neg_i64 (n, o->in2); +tcg_gen_movcond_i64 (TCG_COND_GE , o->out, o->in2, z, n, o->in2); +tcg_temp_free_i64 (n); +tcg_temp_free_i64 (z);return NO_EXIT ; }
Signature · 1 line
2.1.4
PATCH 3/3 target-s390x: remove unused helpers
In reply to Aurelien Jarno--- target-s390x/helper.h | 2 -- target-s390x/int_helper.c | 20 -------------------- 2 files changed, 22 deletions(-)
target-s390x/helper.h +0 -2
@@ -15,8 +15,6 @@ DEF_HELPER_4(clst, i64, env, i64, i64, i64) DEF_HELPER_4(mvpg, void, env, i64, i64, i64) DEF_HELPER_4(mvst, i64, env, i64, i64, i64) DEF_HELPER_5(ex, i32, env, i32, i64, i64, i64) -DEF_HELPER_FLAGS_1(abs_i32, TCG_CALL_NO_RWG_SE, i32, s32) -DEF_HELPER_FLAGS_1(nabs_i32, TCG_CALL_NO_RWG_SE, s32, s32) DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32)DEF_HELPER_4 (mvcle, i32, env, i32, i64, i32)
target-s390x/int_helper.c +0 -20
@@ -115,26 +115,6 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al,return ret; } -/* absolute value 32-bit */ -uint32_t HELPER (abs_i32 )(int32_t val) -{ -if (val <0 ) { -return -val; - }else { -return val; - } -} - -/* negative absolute value 32-bit */ -int32_t HELPER (nabs_i32 )(int32_t val) -{ -if (val <0 ) { -return val; - }else { -return -val; - } -} -/* count leading zeros, for find leftmost one */ uint64_t HELPER (clz )(uint64_t v) {
Signature · 1 line
2.1.4
Quoted 11 lines · Aurelien Jarno
LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following condition code:
0: Result zero; no overflow
1: --
2: Result greater than zero; no overflow
3: OverflowThe current code wrongly returns 1 instead of 2 in case of a result greater than 0. This patches fixes that. This fixes the marshalling of the value '0L' in Python.
Quoted 6 lines
Cc Richard Henderson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-s390x/cc_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
Re: [Qemu-devel] [PATCH 2/3] target-s390x: optimize (negative-) abs computation
In reply to Aurelien JarnoQuoted 11 lines · Aurelien Jarno
Now that movcond exists, it's easy to write (negative-) absolute value using TCG code instead of an helper.
Cc Richard Henderson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-s390x/helper.h | 2 -- target-s390x/int_helper.c | 22 ---------------------- target-s390x/translate.c | 16 ++++++++++++++-- 3 files changed, 14 insertions(+), 26 deletions(-)
r~
Re: [Qemu-devel] [PATCH 3/3] target-s390x: remove unused helpers
In reply to Aurelien JarnoQuoted 7 lines · Aurelien Jarno
Cc Richard Henderson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-s390x/helper.h | 2 -- target-s390x/int_helper.c | 20 -------------------- 2 files changed, 22 deletions(-)
r~
Alexander Graf
AppliedQuoted 7 lines · Aurelien Jarno
LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following condition code:
0: Result zero; no overflow
1: --
2: Result greater than zero; no overflow
3: Overflow
Quoted 7 lines
The current code wrongly returns 1 instead of 2 in case of a result greater than 0. This patches fixes that. This fixes the marshalling of the value '0L' in Python.
Cc Richard Henderson <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
Thanks, applied all to s390-next.
Alex