target/hppa: Minor fix and improvement
cover target/hppa: Minor fix and improvement
The first patch is via inspection. Linux only uses priv levels 0 and 3, and I suspect that HP-UX is the same.
The second patch comes from examining traces.
r~
Richard Henderson (2):
target/hppa: Do not return freed temporary
target/hppa: Optimize blr r0,rn
target/hppa/translate.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.2
PATCH 1/2 target/hppa: Do not return freed temporary
For priv levels 1 & 2, we were doing so from do_ibranch_priv.
--- target/hppa/translate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
target/hppa/translate.c +2 -3
@@ -2007,16 +2007,15 @@ static TCGv_reg do_ibranch_priv(DisasContext *ctx, TCGv_reg offset)/* Privilege 0 is maximum and is allowed to decrease. */ return offset;case 3 : -/* Privilege 3 is minimum and is never allowed increase. */ +/* Privilege 3 is minimum and is never allowed to increase. */ dest =get_temp (ctx);tcg_gen_ori_reg (dest, offset,3 );break ;default : - dest =tcg_temp_new (); + dest =get_temp (ctx);tcg_gen_andi_reg (dest, offset,-4 );tcg_gen_ori_reg (dest, dest, ctx->privilege);tcg_gen_movcond_reg (TCG_COND_GTU , dest, dest, offset, dest, offset); -tcg_temp_free (dest);break ; }return dest;
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 1/2] target/hppa: Do not return freed temporary
Quoted 20 lines · Richard Henderson
For priv levels 1 & 2, we were doing so from
do_ibranch_priv.Signed-off-by Richard Henderson <[email protected]>--- target/hppa/translate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)target/hppa/translate.c +1
-1@@ -2007,16 +2007,15 @@ static TCGv_reg do_ibranch_priv(DisasContext *ctx, TCGv_reg offset)/* Privilege 0 is maximum and is allowed to decrease. */ return offset;case 3 : -/* Privilege 3 is minimum and is never allowed increase. */ +/* Privilege 3 is minimum and is never allowed to increase. */ dest =get_temp (ctx);tcg_gen_ori_reg (dest, offset,3 );break ;
target/hppa/translate.c static TCGv_reg do_ibranch_priv(DisasContext *ctx, TCGv_reg offset) · line 2021
Quoted 10 lines
target/hppa/translate.c +1
-2default : - dest =tcg_temp_new (); + dest =get_temp (ctx);tcg_gen_andi_reg (dest, offset,-4 );tcg_gen_ori_reg (dest, dest, ctx->privilege);tcg_gen_movcond_reg (TCG_COND_GTU , dest, dest, offset, dest, offset); -tcg_temp_free (dest);break ; }return dest;
Oops!
PATCH 2/2 target/hppa: Optimize blr r0,rn
In reply to Richard HendersonWe can eliminate an extra TB in this case, which merely loads a "return address" into rn.
--- target/hppa/translate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
target/hppa/translate.c +10 -6
@@ -3488,12 +3488,16 @@ static bool trans_b_gate(DisasContext *ctx, arg_b_gate *a)static bool trans_blr (DisasContext *ctx,arg_blr *a) { -TCGv_reg tmp =get_temp (ctx); - -tcg_gen_shli_reg (tmp,load_gpr (ctx, a->x),3 ); -tcg_gen_addi_reg (tmp, tmp, ctx->iaoq_f +8 ); -/* The computation here never changes privilege level. */ -return do_ibranch (ctx, tmp, a->l, a->n); +if (a->x) { +TCGv_reg tmp =get_temp (ctx); +tcg_gen_shli_reg (tmp,load_gpr (ctx, a->x),3 ); +tcg_gen_addi_reg (tmp, tmp, ctx->iaoq_f +8 ); +/* The computation here never changes privilege level. */ +return do_ibranch (ctx, tmp, a->l, a->n); + }else { +/* BLR R0,RX is a good way to load PC+8 into RX. */ +return do_dbranch (ctx, ctx->iaoq_f +8 , a->l, a->n); + } }static bool trans_bv (DisasContext *ctx,arg_bv *a)
Signature · 1 line
2.17.2