target/s390x: pc-relative translation blocks
cover target/s390x: pc-relative translation blocks
This is the S390 specific changes required to reduce the amount of translation for address space randomization.
Begin with some generic cleanups, then prepare by using displacements instead of addresses when possible, then add some tcg infrastructure to avoid a code gen ugly, then finalize the conversion.
r~
Richard Henderson (26):
target/s390x: Use tcg_constant_* in local contexts target/s390x: Use tcg_constant_* for DisasCompare target/s390x: Use tcg_constant_i32 for fpinst_extract_m34 target/s390x: Use tcg_constant_* in translate_vx.c.inc target/s390x: Change help_goto_direct to work on displacements target/s390x: Introduce gen_psw_addr_disp target/s390x: Remove pc argument to pc_to_link_into target/s390x: Use gen_psw_addr_disp in pc_to_link_info target/s390x: Use gen_psw_addr_disp in save_link_info target/s390x: Use gen_psw_addr_disp in op_sam target/s390x: Use ilen instead in branches target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state target/s390x: Add disp argument to update_psw_addr target/s390x: Don't set gbea for user-only target/s390x: Introduce per_enabled
target/s390x: Disable conditional branch-to-next for PER target/s390x: Introduce help_goto_indirect target/s390x: Split per_branch
target/s390x: Simplify help_branch
target/s390x: Split per_breaking_event from per_branch_* target/s390x: Remove PER check from use_goto_tb target/s390x: Pass original r2 register to BCR
tcg: Pass TCGTempKind to tcg_temp_new_internal
tcg: Introduce tcg_temp_ebb_new_*
tcg: Introduce tcg_temp_is_normal_*
target/s390x: Enable TARGET_TB_PCREL
include/tcg/tcg-op.h | 4 + include/tcg/tcg.h | 49 +- target/s390x/cpu-param.h | 1 + target/s390x/cpu.h | 13 +- target/s390x/cpu.c | 12 + target/s390x/tcg/translate.c | 858 ++++++++++++---------------- tcg/tcg.c | 14 +- target/s390x/tcg/translate_vx.c.inc | 45 +- target/s390x/tcg/insn-data.def | 2 +- 9 files changed, 461 insertions(+), 537 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/26 target/s390x: Use tcg_constant_* in local contexts
Replace tcg_const_* with tcg_constant_* in contexts where the free to remove is nearby.
--- target/s390x/tcg/translate.c | 408 +++++++++++++---------------------- 1 file changed, 145 insertions(+), 263 deletions(-)
target/s390x/tcg/translate.c +145 -263
@@ -171,8 +171,6 @@ static uint64_t inline_branch_miss[CC_OP_MAX];static void pc_to_link_info (TCGv_i64 out,DisasContext *s,uint64_t pc) { -TCGv_i64 tmp; -if (s->base.tb->flags &FLAG_MASK_32 ) {if (s->base.tb->flags &FLAG_MASK_64 ) {tcg_gen_movi_i64 (out, pc);
@@ -181,9 +179,7 @@ static void pc_to_link_info(TCGv_i64 out, DisasContext *s, uint64_t pc) pc |=0x80000000 ; }assert (!(s->base.tb->flags &FLAG_MASK_64 )); - tmp =tcg_const_i64 (pc); -tcg_gen_deposit_i64 (out, out, tmp,0 ,32 ); -tcg_temp_free_i64 (tmp); +tcg_gen_deposit_i64 (out, out,tcg_constant_i64 (pc),0 ,32 ); }static TCGv_i64 psw_addr;
@@ -348,11 +344,8 @@ static void per_branch(DisasContext *s, bool to_next)tcg_gen_movi_i64 (gbea, s->base.pc_next);if (s->base.tb->flags &FLAG_MASK_PER ) { -TCGv_i64 next_pc = to_next ?tcg_const_i64 (s->pc_tmp) : psw_addr; +TCGv_i64 next_pc = to_next ?tcg_constant_i64 (s->pc_tmp) : psw_addr;gen_helper_per_branch (cpu_env, gbea, next_pc); -if (to_next) { -tcg_temp_free_i64 (next_pc); - } }#endif }
@@ -370,9 +363,8 @@ static void per_branch_cond(DisasContext *s, TCGCond cond, gen_set_label(lab); }else { -TCGv_i64 pc =tcg_const_i64 (s->base.pc_next); +TCGv_i64 pc =tcg_constant_i64 (s->base.pc_next);tcg_gen_movcond_i64 (cond, gbea, arg1, arg2, gbea, pc); -tcg_temp_free_i64 (pc); }#endif }
@@ -426,23 +418,17 @@ static int get_mem_index(DisasContext *s)static void gen_exception (int excp) { -TCGv_i32 tmp =tcg_const_i32 (excp); -gen_helper_exception (cpu_env, tmp); -tcg_temp_free_i32 (tmp); +gen_helper_exception (cpu_env,tcg_constant_i32 (excp)); }static void gen_program_exception (DisasContext *s,int code) { -TCGv_i32 tmp; -/* Remember what pgm exeption this was. */ - tmp =tcg_const_i32 (code); -tcg_gen_st_i32 (tmp, cpu_env, offsetof(CPUS390XState , int_pgm_code)); -tcg_temp_free_i32 (tmp); +tcg_gen_st_i32 (tcg_constant_i32 (code), cpu_env, + offsetof(CPUS390XState , int_pgm_code)); - tmp =tcg_const_i32 (s->ilen); -tcg_gen_st_i32 (tmp, cpu_env, offsetof(CPUS390XState , int_pgm_ilen)); -tcg_temp_free_i32 (tmp); +tcg_gen_st_i32 (tcg_constant_i32 (s->ilen), cpu_env, + offsetof(CPUS390XState , int_pgm_ilen));/* update the psw */ update_psw_addr (s);
@@ -461,9 +447,7 @@ static inline void gen_illegal_opcode(DisasContext *s)static inline void gen_data_exception (uint8_t dxc) { -TCGv_i32 tmp =tcg_const_i32 (dxc); -gen_helper_data_exception (cpu_env, tmp); -tcg_temp_free_i32 (tmp); +gen_helper_data_exception (cpu_env,tcg_constant_i32 (dxc)); }static inline void gen_trap (DisasContext *s)
@@ -584,13 +568,13 @@ static void gen_op_calc_cc(DisasContext *s)switch (s->cc_op) {default : - dummy =tcg_const_i64 (0 ); + dummy =tcg_constant_i64 (0 );/* FALLTHRU */ case CC_OP_ADD_64 :case CC_OP_SUB_64 :case CC_OP_ADD_32 :case CC_OP_SUB_32 : - local_cc_op =tcg_const_i32 (s->cc_op); + local_cc_op =tcg_constant_i32 (s->cc_op);break ;case CC_OP_CONST0 :case CC_OP_CONST1 :
@@ -660,13 +644,6 @@ static void gen_op_calc_cc(DisasContext *s)tcg_abort (); } -if (local_cc_op) { -tcg_temp_free_i32 (local_cc_op); - } -if (dummy) { -tcg_temp_free_i64 (dummy); - } -/* We now have cc in cc_op as constant */ set_cc_static (s); }
@@ -1284,9 +1261,9 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,Most commonly we're single-stepping or some other condition that disables all use of goto_tb. Just update the PC and exit. */ -TCGv_i64 next =tcg_const_i64 (s->pc_tmp); +TCGv_i64 next =tcg_constant_i64 (s->pc_tmp);if (is_imm) { - cdest =tcg_const_i64 (dest); + cdest =tcg_constant_i64 (dest); }if (c->is_64) {
@@ -1296,21 +1273,15 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, }else {TCGv_i32 t0 =tcg_temp_new_i32 ();TCGv_i64 t1 =tcg_temp_new_i64 (); -TCGv_i64 z =tcg_const_i64 (0 ); +TCGv_i64 z =tcg_constant_i64 (0 );tcg_gen_setcond_i32 (c->cond, t0, c->u.s32.a, c->u.s32.b);tcg_gen_extu_i32_i64 (t1, t0);tcg_temp_free_i32 (t0);tcg_gen_movcond_i64 (TCG_COND_NE , psw_addr, t1, z, cdest, next);per_branch_cond (s,TCG_COND_NE , t1, z);tcg_temp_free_i64 (t1); -tcg_temp_free_i64 (z); } -if (is_imm) { -tcg_temp_free_i64 (cdest); - } -tcg_temp_free_i64 (next); - ret =DISAS_PC_UPDATED ; }
@@ -1394,10 +1365,9 @@ static DisasJumpType op_addc64(DisasContext *s, DisasOps *o) {compute_carry (s); -TCGv_i64 zero =tcg_const_i64 (0 ); +TCGv_i64 zero =tcg_constant_i64 (0 );tcg_gen_add2_i64 (o->out, cc_src, o->in1, zero, cc_src, zero);tcg_gen_add2_i64 (o->out, cc_src, o->out, cc_src, o->in2, zero); -tcg_temp_free_i64 (zero);return DISAS_NEXT ; }
@@ -2077,9 +2047,8 @@ static DisasJumpType op_clc(DisasContext *s, DisasOps *o)tcg_gen_qemu_ld64 (cc_dst, o->in2,get_mem_index (s));break ;default : - vl =tcg_const_i32 (l); + vl =tcg_constant_i32 (l);gen_helper_clc (cc_op, cpu_env, vl, o->addr1, o->in2); -tcg_temp_free_i32 (vl);set_cc_static (s);return DISAS_NEXT ; }
@@ -2099,11 +2068,9 @@ static DisasJumpType op_clcl(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t2 =tcg_const_i32 (r2); + t1 =tcg_constant_i32 (r1); + t2 =tcg_constant_i32 (r2);gen_helper_clcl (cc_op, cpu_env, t1, t2); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t2);set_cc_static (s);return DISAS_NEXT ; }
@@ -2120,11 +2087,9 @@ static DisasJumpType op_clcle(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t3 =tcg_const_i32 (r3); + t1 =tcg_constant_i32 (r1); + t3 =tcg_constant_i32 (r3);gen_helper_clcle (cc_op, cpu_env, t1, o->in2, t3); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t3);set_cc_static (s);return DISAS_NEXT ; }
@@ -2141,24 +2106,22 @@ static DisasJumpType op_clclu(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t3 =tcg_const_i32 (r3); + t1 =tcg_constant_i32 (r1); + t3 =tcg_constant_i32 (r3);gen_helper_clclu (cc_op, cpu_env, t1, o->in2, t3); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t3);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_clm (DisasContext *s,DisasOps *o) { -TCGv_i32 m3 =tcg_const_i32 (get_field (s, m3)); +TCGv_i32 m3 =tcg_constant_i32 (get_field (s, m3));TCGv_i32 t1 =tcg_temp_new_i32 (); +tcg_gen_extrl_i64_i32 (t1, o->in1);gen_helper_clm (cc_op, cpu_env, t1, m3, o->in2);set_cc_static (s);tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (m3);return DISAS_NEXT ; }
@@ -2217,8 +2180,8 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o)/* Note that R1:R1+1 = expected value and R3:R3+1 = new value. */ addr =get_address (s,0 , b2, d2); - t_r1 =tcg_const_i32 (r1); - t_r3 =tcg_const_i32 (r3); + t_r1 =tcg_constant_i32 (r1); + t_r3 =tcg_constant_i32 (r3);if (!(tb_cflags (s->base.tb) &CF_PARALLEL )) {gen_helper_cdsg (cpu_env, addr, t_r1, t_r3); }else if (HAVE_CMPXCHG128 ) {
@@ -2228,8 +2191,6 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) ret =DISAS_NORETURN ; }tcg_temp_free_i64 (addr); -tcg_temp_free_i32 (t_r1); -tcg_temp_free_i32 (t_r3);set_cc_static (s);return ret;
@@ -2238,14 +2199,13 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o)static DisasJumpType op_csst (DisasContext *s,DisasOps *o) {int r3 =get_field (s, r3); -TCGv_i32 t_r3 =tcg_const_i32 (r3); +TCGv_i32 t_r3 =tcg_constant_i32 (r3);if (tb_cflags (s->base.tb) &CF_PARALLEL ) {gen_helper_csst_parallel (cc_op, cpu_env, t_r3, o->addr1, o->in2); }else {gen_helper_csst (cc_op, cpu_env, t_r3, o->addr1, o->in2); } -tcg_temp_free_i32 (t_r3);set_cc_static (s);return DISAS_NEXT ;
@@ -2343,9 +2303,9 @@ static DisasJumpType op_cuXX(DisasContext *s, DisasOps *o) m3 =0 ; } - tr1 =tcg_const_i32 (r1); - tr2 =tcg_const_i32 (r2); - chk =tcg_const_i32 (m3); + tr1 =tcg_constant_i32 (r1); + tr2 =tcg_constant_i32 (r2); + chk =tcg_constant_i32 (m3);switch (s->insn->data) {case 12 :
@@ -2370,9 +2330,6 @@ static DisasJumpType op_cuXX(DisasContext *s, DisasOps *o)g_assert_not_reached (); } -tcg_temp_free_i32 (tr1); -tcg_temp_free_i32 (tr2); -tcg_temp_free_i32 (chk);set_cc_static (s);return DISAS_NEXT ; }
@@ -2380,15 +2337,11 @@ static DisasJumpType op_cuXX(DisasContext *s, DisasOps *o)#ifndef CONFIG_USER_ONLY static DisasJumpType op_diag (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); -TCGv_i32 func_code =tcg_const_i32 (get_field (s, i2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +TCGv_i32 func_code =tcg_constant_i32 (get_field (s, i2));gen_helper_diag (cpu_env, r1, r3, func_code); - -tcg_temp_free_i32 (func_code); -tcg_temp_free_i32 (r3); -tcg_temp_free_i32 (r1);return DISAS_NEXT ; }#endif
@@ -2494,18 +2447,13 @@ static DisasJumpType op_ex(DisasContext *s, DisasOps *o)update_cc_op (s);if (r1 ==0 ) { - v1 =tcg_const_i64 (0 ); + v1 =tcg_constant_i64 (0 ); }else { v1 = regs[r1]; } - ilen =tcg_const_i32 (s->ilen); + ilen =tcg_constant_i32 (s->ilen);gen_helper_ex (cpu_env, ilen, v1, o->in2); -tcg_temp_free_i32 (ilen); - -if (r1 ==0 ) { -tcg_temp_free_i64 (v1); - }return DISAS_PC_CC_UPDATED ; }
@@ -2657,12 +2605,11 @@ static DisasJumpType op_idte(DisasContext *s, DisasOps *o)TCGv_i32 m4;if (s390_has_feat (S390_FEAT_LOCAL_TLB_CLEARING )) { - m4 =tcg_const_i32 (get_field (s, m4)); + m4 =tcg_constant_i32 (get_field (s, m4)); }else { - m4 =tcg_const_i32 (0 ); + m4 =tcg_constant_i32 (0 ); }gen_helper_idte (cpu_env, o->in1, o->in2, m4); -tcg_temp_free_i32 (m4);return DISAS_NEXT ; }
@@ -2671,12 +2618,11 @@ static DisasJumpType op_ipte(DisasContext *s, DisasOps *o)TCGv_i32 m4;if (s390_has_feat (S390_FEAT_LOCAL_TLB_CLEARING )) { - m4 =tcg_const_i32 (get_field (s, m4)); + m4 =tcg_constant_i32 (get_field (s, m4)); }else { - m4 =tcg_const_i32 (0 ); + m4 =tcg_constant_i32 (0 ); }gen_helper_ipte (cpu_env, o->in1, o->in2, m4); -tcg_temp_free_i32 (m4);return DISAS_NEXT ; }
@@ -2732,16 +2678,12 @@ static DisasJumpType op_msa(DisasContext *s, DisasOps *o)g_assert_not_reached (); }; - t_r1 =tcg_const_i32 (r1); - t_r2 =tcg_const_i32 (r2); - t_r3 =tcg_const_i32 (r3); - type =tcg_const_i32 (s->insn->data); + t_r1 =tcg_constant_i32 (r1); + t_r2 =tcg_constant_i32 (r2); + t_r3 =tcg_constant_i32 (r3); + type =tcg_constant_i32 (s->insn->data);gen_helper_msa (cc_op, cpu_env, t_r1, t_r2, t_r3, type);set_cc_static (s); -tcg_temp_free_i32 (t_r1); -tcg_temp_free_i32 (t_r2); -tcg_temp_free_i32 (t_r3); -tcg_temp_free_i32 (type);return DISAS_NEXT ; }
@@ -3002,10 +2944,9 @@ static DisasJumpType op_loc(DisasContext *s, DisasOps *o)tcg_gen_extu_i32_i64 (t, t32);tcg_temp_free_i32 (t32); - z =tcg_const_i64 (0 ); + z =tcg_constant_i64 (0 );tcg_gen_movcond_i64 (TCG_COND_NE , o->out, t, z, o->in2, o->in1);tcg_temp_free_i64 (t); -tcg_temp_free_i64 (z); }return DISAS_NEXT ;
@@ -3014,11 +2955,10 @@ static DisasJumpType op_loc(DisasContext *s, DisasOps *o)#ifndef CONFIG_USER_ONLY static DisasJumpType op_lctl (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_lctl (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);/* Exit to main loop to reevaluate s390_cpu_exec_interrupt. */ s->exit_to_mainloop = true;return DISAS_TOO_MANY ;
@@ -3026,11 +2966,10 @@ static DisasJumpType op_lctl(DisasContext *s, DisasOps *o)static DisasJumpType op_lctlg (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_lctlg (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);/* Exit to main loop to reevaluate s390_cpu_exec_interrupt. */ s->exit_to_mainloop = true;return DISAS_TOO_MANY ;
@@ -3090,11 +3029,10 @@ static DisasJumpType op_lpswe(DisasContext *s, DisasOps *o)static DisasJumpType op_lam (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_lam (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);return DISAS_NEXT ; }
@@ -3304,9 +3242,6 @@ static DisasJumpType op_lcbb(DisasContext *s, DisasOps *o)static DisasJumpType op_mc (DisasContext *s,DisasOps *o) { -#if !defined(CONFIG_USER_ONLY ) -TCGv_i32 i2; -#endif const uint16_t monitor_class =get_field (s, i2);if (monitor_class &0xff00 ) {
@@ -3315,9 +3250,8 @@ static DisasJumpType op_mc(DisasContext *s, DisasOps *o) }#if !defined(CONFIG_USER_ONLY ) - i2 =tcg_const_i32 (monitor_class); -gen_helper_monitor_call (cpu_env, o->addr1, i2); -tcg_temp_free_i32 (i2); +gen_helper_monitor_call (cpu_env, o->addr1, +tcg_constant_i32 (monitor_class));#endif /* Defaults to a NOP. */ return DISAS_NEXT ;
@@ -3381,9 +3315,9 @@ static DisasJumpType op_movx(DisasContext *s, DisasOps *o)static DisasJumpType op_mvc (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_mvc (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -3395,9 +3329,9 @@ static DisasJumpType op_mvcrl(DisasContext *s, DisasOps *o)static DisasJumpType op_mvcin (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_mvcin (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -3413,11 +3347,9 @@ static DisasJumpType op_mvcl(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t2 =tcg_const_i32 (r2); + t1 =tcg_constant_i32 (r1); + t2 =tcg_constant_i32 (r2);gen_helper_mvcl (cc_op, cpu_env, t1, t2); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t2);set_cc_static (s);return DISAS_NEXT ; }
@@ -3434,11 +3366,9 @@ static DisasJumpType op_mvcle(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t3 =tcg_const_i32 (r3); + t1 =tcg_constant_i32 (r1); + t3 =tcg_constant_i32 (r3);gen_helper_mvcle (cc_op, cpu_env, t1, o->in2, t3); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t3);set_cc_static (s);return DISAS_NEXT ; }
@@ -3455,11 +3385,9 @@ static DisasJumpType op_mvclu(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } - t1 =tcg_const_i32 (r1); - t3 =tcg_const_i32 (r3); + t1 =tcg_constant_i32 (r1); + t3 =tcg_constant_i32 (r3);gen_helper_mvclu (cc_op, cpu_env, t1, o->in2, t3); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t3);set_cc_static (s);return DISAS_NEXT ; }
@@ -3492,49 +3420,45 @@ static DisasJumpType op_mvcs(DisasContext *s, DisasOps *o)static DisasJumpType op_mvn (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_mvn (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }static DisasJumpType op_mvo (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_mvo (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }static DisasJumpType op_mvpg (DisasContext *s,DisasOps *o) { -TCGv_i32 t1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 t2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 t1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 t2 =tcg_constant_i32 (get_field (s, r2));gen_helper_mvpg (cc_op, cpu_env, regs[0 ], t1, t2); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_mvst (DisasContext *s,DisasOps *o) { -TCGv_i32 t1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 t2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 t1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 t2 =tcg_constant_i32 (get_field (s, r2));gen_helper_mvst (cc_op, cpu_env, t1, t2); -tcg_temp_free_i32 (t1); -tcg_temp_free_i32 (t2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_mvz (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_mvz (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -3622,13 +3546,12 @@ static DisasJumpType op_msdb(DisasContext *s, DisasOps *o)static DisasJumpType op_nabs (DisasContext *s,DisasOps *o) { -TCGv_i64 z, n; - z =tcg_const_i64 (0 ); - n =tcg_temp_new_i64 (); +TCGv_i64 z =tcg_constant_i64 (0 ); +TCGv_i64 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 DISAS_NEXT ; }
@@ -3653,9 +3576,9 @@ static DisasJumpType op_nabsf128(DisasContext *s, DisasOps *o)static DisasJumpType op_nc (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_nc (cc_op, cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }
@@ -3687,9 +3610,9 @@ static DisasJumpType op_negf128(DisasContext *s, DisasOps *o)static DisasJumpType op_oc (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_oc (cc_op, cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }
@@ -3739,9 +3662,9 @@ static DisasJumpType op_oi(DisasContext *s, DisasOps *o)static DisasJumpType op_pack (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_pack (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -3755,9 +3678,8 @@ static DisasJumpType op_pka(DisasContext *s, DisasOps *o)gen_program_exception (s,PGM_SPECIFICATION );return DISAS_NORETURN ; } - l =tcg_const_i32 (l2); + l =tcg_constant_i32 (l2);gen_helper_pka (cpu_env, o->addr1, o->in2, l); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -3771,9 +3693,8 @@ static DisasJumpType op_pku(DisasContext *s, DisasOps *o)gen_program_exception (s,PGM_SPECIFICATION );return DISAS_NORETURN ; } - l =tcg_const_i32 (l2); + l =tcg_constant_i32 (l2);gen_helper_pku (cpu_env, o->addr1, o->in2, l); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -4020,9 +3941,8 @@ static DisasJumpType op_sam(DisasContext *s, DisasOps *o) } s->pc_tmp &= mask; - tsam =tcg_const_i64 (sam); + tsam =tcg_constant_i64 (sam);tcg_gen_deposit_i64 (psw_mask, psw_mask, tsam,31 ,2 ); -tcg_temp_free_i64 (tsam);/* Always exit the TB, since we (may have) changed execution mode. */ return DISAS_TOO_MANY ;
@@ -4083,12 +4003,11 @@ static DisasJumpType op_servc(DisasContext *s, DisasOps *o)static DisasJumpType op_sigp (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_sigp (cc_op, cpu_env, o->in2, r1, r3);set_cc_static (s); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);return DISAS_NEXT ; }#endif
@@ -4357,21 +4276,19 @@ static DisasJumpType op_stckc(DisasContext *s, DisasOps *o)static DisasJumpType op_stctg (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_stctg (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);return DISAS_NEXT ; }static DisasJumpType op_stctl (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_stctl (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);return DISAS_NEXT ; }
@@ -4598,11 +4515,10 @@ static DisasJumpType op_st64(DisasContext *s, DisasOps *o)static DisasJumpType op_stam (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +gen_helper_stam (cpu_env, r1, o->in2, r3); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);return DISAS_NEXT ; }
@@ -4660,7 +4576,7 @@ static DisasJumpType op_stm(DisasContext *s, DisasOps *o)int r1 =get_field (s, r1);int r3 =get_field (s, r3);int size = s->insn->data; -TCGv_i64 tsize =tcg_const_i64 (size); +TCGv_i64 tsize =tcg_constant_i64 (size);while (1 ) {if (size ==8 ) {
@@ -4675,7 +4591,6 @@ static DisasJumpType op_stm(DisasContext *s, DisasOps *o) r1 = (r1 +1 ) &15 ; } -tcg_temp_free_i64 (tsize);return DISAS_NEXT ; }
@@ -4684,8 +4599,8 @@ static DisasJumpType op_stmh(DisasContext *s, DisasOps *o)int r1 =get_field (s, r1);int r3 =get_field (s, r3);TCGv_i64 t =tcg_temp_new_i64 (); -TCGv_i64 t4 =tcg_const_i64 (4 ); -TCGv_i64 t32 =tcg_const_i64 (32 ); +TCGv_i64 t4 =tcg_constant_i64 (4 ); +TCGv_i64 t32 =tcg_constant_i64 (32 );while (1 ) {tcg_gen_shl_i64 (t, regs[r1], t32);
@@ -4698,8 +4613,6 @@ static DisasJumpType op_stmh(DisasContext *s, DisasOps *o) }tcg_temp_free_i64 (t); -tcg_temp_free_i64 (t4); -tcg_temp_free_i64 (t32);return DISAS_NEXT ; }
@@ -4718,26 +4631,20 @@ static DisasJumpType op_stpq(DisasContext *s, DisasOps *o)static DisasJumpType op_srst (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_srst (cpu_env, r1, r2); - -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_srstu (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_srstu (cpu_env, r1, r2); - -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }
@@ -4795,10 +4702,9 @@ static DisasJumpType op_subb64(DisasContext *s, DisasOps *o)* Borrow is {0, -1}, so add to subtract; replicate the * borrow input to produce 128-bit -1 for the addition. */ -TCGv_i64 zero =tcg_const_i64 (0 ); +TCGv_i64 zero =tcg_constant_i64 (0 );tcg_gen_add2_i64 (o->out, cc_src, o->in1, zero, cc_src, cc_src);tcg_gen_sub2_i64 (o->out, cc_src, o->out, cc_src, o->in2, zero); -tcg_temp_free_i64 (zero);return DISAS_NEXT ; }
@@ -4810,13 +4716,11 @@ static DisasJumpType op_svc(DisasContext *s, DisasOps *o)update_psw_addr (s);update_cc_op (s); - t =tcg_const_i32 (get_field (s, i1) &0xff ); + t =tcg_constant_i32 (get_field (s, i1) &0xff );tcg_gen_st_i32 (t, cpu_env, offsetof(CPUS390XState , int_svc_code)); -tcg_temp_free_i32 (t); - t =tcg_const_i32 (s->ilen); + t =tcg_constant_i32 (s->ilen);tcg_gen_st_i32 (t, cpu_env, offsetof(CPUS390XState , int_svc_ilen)); -tcg_temp_free_i32 (t);gen_exception (EXCP_SVC );return DISAS_NORETURN ;
@@ -4873,18 +4777,18 @@ static DisasJumpType op_tprot(DisasContext *s, DisasOps *o)static DisasJumpType op_tp (DisasContext *s,DisasOps *o) { -TCGv_i32 l1 =tcg_const_i32 (get_field (s, l1) +1 ); +TCGv_i32 l1 =tcg_constant_i32 (get_field (s, l1) +1 ); +gen_helper_tp (cc_op, cpu_env, o->addr1, l1); -tcg_temp_free_i32 (l1);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_tr (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_tr (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }
@@ -4899,27 +4803,27 @@ static DisasJumpType op_tre(DisasContext *s, DisasOps *o)static DisasJumpType op_trt (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_trt (cc_op, cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_trtr (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_trtr (cc_op, cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_trXX (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); -TCGv_i32 sizes =tcg_const_i32 (s->insn->opc &3 ); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2)); +TCGv_i32 sizes =tcg_constant_i32 (s->insn->opc &3 );TCGv_i32 tst =tcg_temp_new_i32 ();int m3 =get_field (s, m3);
@@ -4938,9 +4842,6 @@ static DisasJumpType op_trXX(DisasContext *s, DisasOps *o) }gen_helper_trXX (cc_op, cpu_env, r1, r2, tst, sizes); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2); -tcg_temp_free_i32 (sizes);tcg_temp_free_i32 (tst);set_cc_static (s);return DISAS_NEXT ;
@@ -4948,19 +4849,19 @@ static DisasJumpType op_trXX(DisasContext *s, DisasOps *o)static DisasJumpType op_ts (DisasContext *s,DisasOps *o) { -TCGv_i32 t1 =tcg_const_i32 (0xff ); +TCGv_i32 t1 =tcg_constant_i32 (0xff ); +tcg_gen_atomic_xchg_i32 (t1, o->in2, t1,get_mem_index (s),MO_UB );tcg_gen_extract_i32 (cc_op, t1,7 ,1 ); -tcg_temp_free_i32 (t1);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_unpk (DisasContext *s,DisasOps *o) { -TCGv_i32 l =tcg_const_i32 (get_field (s, l1)); +TCGv_i32 l =tcg_constant_i32 (get_field (s, l1)); +gen_helper_unpk (cpu_env, l, o->addr1, o->in2); -tcg_temp_free_i32 (l);return DISAS_NEXT ; }
@@ -4974,9 +4875,8 @@ static DisasJumpType op_unpka(DisasContext *s, DisasOps *o)gen_program_exception (s,PGM_SPECIFICATION );return DISAS_NORETURN ; } - l =tcg_const_i32 (l1); + l =tcg_constant_i32 (l1);gen_helper_unpka (cc_op, cpu_env, o->addr1, l, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }
@@ -4991,9 +4891,8 @@ static DisasJumpType op_unpku(DisasContext *s, DisasOps *o)gen_program_exception (s,PGM_SPECIFICATION );return DISAS_NORETURN ; } - l =tcg_const_i32 (l1); + l =tcg_constant_i32 (l1);gen_helper_unpku (cc_op, cpu_env, o->addr1, l, o->in2); -tcg_temp_free_i32 (l);set_cc_static (s);return DISAS_NEXT ; }
@@ -5012,7 +4911,7 @@ static DisasJumpType op_xc(DisasContext *s, DisasOps *o)/* If the addresses are identical, this is a store/memset of zero. */ if (b1 == b2 && d1 == d2 && (l +1 ) <=32 ) { - o->in2 =tcg_const_i64 (0 ); + o->in2 =tcg_constant_i64 (0 ); l++;while (l >=8 ) {
@@ -5045,9 +4944,8 @@ static DisasJumpType op_xc(DisasContext *s, DisasOps *o)/* But in general we'll defer to a helper. */ o->in2 =get_address (s,0 , b2, d2); - t32 =tcg_const_i32 (l); + t32 =tcg_constant_i32 (l);gen_helper_xc (cc_op, cpu_env, t32, o->addr1, o->in2); -tcg_temp_free_i32 (t32);set_cc_static (s);return DISAS_NEXT ; }
@@ -5112,46 +5010,39 @@ static DisasJumpType op_zero2(DisasContext *s, DisasOps *o)#ifndef CONFIG_USER_ONLY static DisasJumpType op_clp (DisasContext *s,DisasOps *o) { -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_clp (cpu_env, r2); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_pcilg (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_pcilg (cpu_env, r1, r2); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_pcistg (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_pcistg (cpu_env, r1, r2); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_stpcifc (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 ar =tcg_const_i32 (get_field (s, b2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 ar =tcg_constant_i32 (get_field (s, b2));gen_helper_stpcifc (cpu_env, r1, o->addr1, ar); -tcg_temp_free_i32 (ar); -tcg_temp_free_i32 (r1);set_cc_static (s);return DISAS_NEXT ; }
@@ -5164,38 +5055,31 @@ static DisasJumpType op_sic(DisasContext *s, DisasOps *o)static DisasJumpType op_rpcit (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r2 =tcg_const_i32 (get_field (s, r2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r2 =tcg_constant_i32 (get_field (s, r2));gen_helper_rpcit (cpu_env, r1, r2); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r2);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_pcistb (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 r3 =tcg_const_i32 (get_field (s, r3)); -TCGv_i32 ar =tcg_const_i32 (get_field (s, b2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 r3 =tcg_constant_i32 (get_field (s, r3)); +TCGv_i32 ar =tcg_constant_i32 (get_field (s, b2));gen_helper_pcistb (cpu_env, r1, r3, o->addr1, ar); -tcg_temp_free_i32 (ar); -tcg_temp_free_i32 (r1); -tcg_temp_free_i32 (r3);set_cc_static (s);return DISAS_NEXT ; }static DisasJumpType op_mpcifc (DisasContext *s,DisasOps *o) { -TCGv_i32 r1 =tcg_const_i32 (get_field (s, r1)); -TCGv_i32 ar =tcg_const_i32 (get_field (s, b2)); +TCGv_i32 r1 =tcg_constant_i32 (get_field (s, r1)); +TCGv_i32 ar =tcg_constant_i32 (get_field (s, b2));gen_helper_mpcifc (cpu_env, r1, o->addr1, ar); -tcg_temp_free_i32 (ar); -tcg_temp_free_i32 (r1);set_cc_static (s);return DISAS_NEXT ; }
@@ -6316,9 +6200,8 @@ static const DisasInsn *extract_insn(CPUS390XState *env, DisasContext *s)if (unlikely (s->ex_value)) {/* Drop the EX data now, so that it's clear on exception paths. */ -TCGv_i64 zero =tcg_const_i64 (0 ); -tcg_gen_st_i64 (zero, cpu_env, offsetof(CPUS390XState , ex_value)); -tcg_temp_free_i64 (zero); +tcg_gen_st_i64 (tcg_constant_i64 (0 ), cpu_env, + offsetof(CPUS390XState , ex_value));/* Extract the values saved by EXECUTE. */ insn = s->ex_value &0xffffffffffff0000ull ;
@@ -6444,9 +6327,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)#ifndef CONFIG_USER_ONLY if (s->base.tb->flags &FLAG_MASK_PER ) { -TCGv_i64 addr =tcg_const_i64 (s->base.pc_next); +TCGv_i64 addr =tcg_constant_i64 (s->base.pc_next);gen_helper_per_ifetch (cpu_env, addr); -tcg_temp_free_i64 (addr); }#endif
Signature · 1 line
2.34.1
Re: [PATCH 01/26] target/s390x: Use tcg_constant_* in local contexts
Quoted 8 lines · Richard Henderson
Replace tcg_const_* with tcg_constant_* in contexts where the free to remove is nearby.
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 408 +++++++++++++---------------------- 1 file changed, 145 insertions(+), 263 deletions(-)
PATCH 2/26 target/s390x: Use tcg_constant_* for DisasCompare
In reply to Richard HendersonThe a and b fields are not modified by the consumer, and while we need not free a constant, tcg will quietly ignore such frees, so free_compare need not be changed.
--- target/s390x/tcg/translate.c | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-)
target/s390x/tcg/translate.c +22 -22
@@ -830,7 +830,7 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) c->is_64 = false; c->u.s32.a =tcg_temp_new_i32 ();tcg_gen_extrl_i64_i32 (c->u.s32.a, cc_dst); - c->u.s32.b =tcg_const_i32 (0 ); + c->u.s32.b =tcg_constant_i32 (0 );break ;case CC_OP_LTGT_32 :case CC_OP_LTUGTU_32 :
@@ -845,7 +845,7 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask)case CC_OP_NZ :case CC_OP_FLOGR : c->u.s64.a = cc_dst; - c->u.s64.b =tcg_const_i64 (0 ); + c->u.s64.b =tcg_constant_i64 (0 ); c->g1 = true;break ;case CC_OP_LTGT_64 :
@@ -859,14 +859,14 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask)case CC_OP_TM_64 :case CC_OP_ICM : c->u.s64.a =tcg_temp_new_i64 (); - c->u.s64.b =tcg_const_i64 (0 ); + c->u.s64.b =tcg_constant_i64 (0 );tcg_gen_and_i64 (c->u.s64.a, cc_src, cc_dst);break ;case CC_OP_ADDU :case CC_OP_SUBU : c->is_64 = true; - c->u.s64.b =tcg_const_i64 (0 ); + c->u.s64.b =tcg_constant_i64 (0 ); c->g1 = true;switch (mask) {case 8 |2 :
@@ -889,65 +889,65 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask)switch (mask) {case 0x8 |0x4 |0x2 :/* cc != 3 */ cond =TCG_COND_NE ; - c->u.s32.b =tcg_const_i32 (3 ); + c->u.s32.b =tcg_constant_i32 (3 );break ;case 0x8 |0x4 |0x1 :/* cc != 2 */ cond =TCG_COND_NE ; - c->u.s32.b =tcg_const_i32 (2 ); + c->u.s32.b =tcg_constant_i32 (2 );break ;case 0x8 |0x2 |0x1 :/* cc != 1 */ cond =TCG_COND_NE ; - c->u.s32.b =tcg_const_i32 (1 ); + c->u.s32.b =tcg_constant_i32 (1 );break ;case 0x8 |0x2 :/* cc == 0 || cc == 2 => (cc & 1) == 0 */ cond =TCG_COND_EQ ; c->g1 = false; c->u.s32.a =tcg_temp_new_i32 (); - c->u.s32.b =tcg_const_i32 (0 ); + c->u.s32.b =tcg_constant_i32 (0 );tcg_gen_andi_i32 (c->u.s32.a, cc_op,1 );break ;case 0x8 |0x4 :/* cc < 2 */ cond =TCG_COND_LTU ; - c->u.s32.b =tcg_const_i32 (2 ); + c->u.s32.b =tcg_constant_i32 (2 );break ;case 0x8 :/* cc == 0 */ cond =TCG_COND_EQ ; - c->u.s32.b =tcg_const_i32 (0 ); + c->u.s32.b =tcg_constant_i32 (0 );break ;case 0x4 |0x2 |0x1 :/* cc != 0 */ cond =TCG_COND_NE ; - c->u.s32.b =tcg_const_i32 (0 ); + c->u.s32.b =tcg_constant_i32 (0 );break ;case 0x4 |0x1 :/* cc == 1 || cc == 3 => (cc & 1) != 0 */ cond =TCG_COND_NE ; c->g1 = false; c->u.s32.a =tcg_temp_new_i32 (); - c->u.s32.b =tcg_const_i32 (0 ); + c->u.s32.b =tcg_constant_i32 (0 );tcg_gen_andi_i32 (c->u.s32.a, cc_op,1 );break ;case 0x4 :/* cc == 1 */ cond =TCG_COND_EQ ; - c->u.s32.b =tcg_const_i32 (1 ); + c->u.s32.b =tcg_constant_i32 (1 );break ;case 0x2 |0x1 :/* cc > 1 */ cond =TCG_COND_GTU ; - c->u.s32.b =tcg_const_i32 (1 ); + c->u.s32.b =tcg_constant_i32 (1 );break ;case 0x2 :/* cc == 2 */ cond =TCG_COND_EQ ; - c->u.s32.b =tcg_const_i32 (2 ); + c->u.s32.b =tcg_constant_i32 (2 );break ;case 0x1 :/* cc == 3 */ cond =TCG_COND_EQ ; - c->u.s32.b =tcg_const_i32 (3 ); + c->u.s32.b =tcg_constant_i32 (3 );break ;default :/* CC is masked by something else: (8 >> cc) & mask. */ cond =TCG_COND_NE ; c->g1 = false; - c->u.s32.a =tcg_const_i32 (8 ); - c->u.s32.b =tcg_const_i32 (0 ); -tcg_gen_shr_i32 (c->u.s32.a, c->u.s32.a, cc_op); + c->u.s32.a =tcg_temp_new_i32 (); + c->u.s32.b =tcg_constant_i32 (0 ); +tcg_gen_shr_i32 (c->u.s32.a,tcg_constant_i32 (8 ), cc_op);tcg_gen_andi_i32 (c->u.s32.a, c->u.s32.a, mask);break ; }
@@ -1604,7 +1604,7 @@ static DisasJumpType op_bct32(DisasContext *s, DisasOps *o)tcg_gen_subi_i64 (t, regs[r1],1 );store_reg32_i64 (r1, t); c.u.s32.a =tcg_temp_new_i32 (); - c.u.s32.b =tcg_const_i32 (0 ); + c.u.s32.b =tcg_constant_i32 (0 );tcg_gen_extrl_i64_i32 (c.u.s32.a, t);tcg_temp_free_i64 (t);
@@ -1628,7 +1628,7 @@ static DisasJumpType op_bcth(DisasContext *s, DisasOps *o)tcg_gen_subi_i64 (t, t,1 );store_reg32h_i64 (r1, t); c.u.s32.a =tcg_temp_new_i32 (); - c.u.s32.b =tcg_const_i32 (0 ); + c.u.s32.b =tcg_constant_i32 (0 );tcg_gen_extrl_i64_i32 (c.u.s32.a, t);tcg_temp_free_i64 (t);
@@ -1649,7 +1649,7 @@ static DisasJumpType op_bct64(DisasContext *s, DisasOps *o)tcg_gen_subi_i64 (regs[r1], regs[r1],1 ); c.u.s64.a = regs[r1]; - c.u.s64.b =tcg_const_i64 (0 ); + c.u.s64.b =tcg_constant_i64 (0 );return help_branch (s, &c, is_imm, imm, o->in2); }
Signature · 1 line
2.34.1
Re: [PATCH 02/26] target/s390x: Use tcg_constant_* for DisasCompare
Quoted 8 lines · Richard Henderson
The a and b fields are not modified by the consumer, and while we need not free a constant, tcg will quietly ignore such frees, so
free_compareneed not be changed.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-)
I did not check all the code paths in the consumer, but if there is a bug and a or b ends up being modified, one of the temp_readonly() assertions will catch it.
PATCH 3/26 target/s390x: Use tcg_constant_i32 for fpinst_extract_m34
In reply to Richard HendersonReturn a constant or NULL, which means the free may be removed from all callers of fpinst_extract_m34.
--- target/s390x/tcg/translate.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-)
target/s390x/tcg/translate.c +1 -25
@@ -1775,7 +1775,7 @@ static TCGv_i32 fpinst_extract_m34(DisasContext *s, bool m3_with_fpe,return NULL ; } -return tcg_const_i32 (deposit32 (m3,4 ,4 , m4)); +return tcg_constant_i32 (deposit32 (m3,4 ,4 , m4)); }static DisasJumpType op_cfeb (DisasContext *s,DisasOps *o)
@@ -1786,7 +1786,6 @@ static DisasJumpType op_cfeb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cfeb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1799,7 +1798,6 @@ static DisasJumpType op_cfdb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cfdb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1812,7 +1810,6 @@ static DisasJumpType op_cfxb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cfxb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1825,7 +1822,6 @@ static DisasJumpType op_cgeb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cgeb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1838,7 +1834,6 @@ static DisasJumpType op_cgdb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cgdb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1851,7 +1846,6 @@ static DisasJumpType op_cgxb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cgxb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1864,7 +1858,6 @@ static DisasJumpType op_clfeb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clfeb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1877,7 +1870,6 @@ static DisasJumpType op_clfdb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clfdb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1890,7 +1882,6 @@ static DisasJumpType op_clfxb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clfxb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1903,7 +1894,6 @@ static DisasJumpType op_clgeb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clgeb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1916,7 +1906,6 @@ static DisasJumpType op_clgdb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clgdb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1929,7 +1918,6 @@ static DisasJumpType op_clgxb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_clgxb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);set_cc_static (s);return DISAS_NEXT ; }
@@ -1942,7 +1930,6 @@ static DisasJumpType op_cegb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cegb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -1954,7 +1941,6 @@ static DisasJumpType op_cdgb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cdgb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -1966,7 +1952,6 @@ static DisasJumpType op_cxgb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cxgb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return_low128 (o->out2);return DISAS_NEXT ; }
@@ -1979,7 +1964,6 @@ static DisasJumpType op_celgb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_celgb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -1991,7 +1975,6 @@ static DisasJumpType op_cdlgb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cdlgb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2003,7 +1986,6 @@ static DisasJumpType op_cxlgb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_cxlgb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return_low128 (o->out2);return DISAS_NEXT ; }
@@ -2466,7 +2448,6 @@ static DisasJumpType op_fieb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_fieb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2478,7 +2459,6 @@ static DisasJumpType op_fidb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_fidb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2491,7 +2471,6 @@ static DisasJumpType op_fixb(DisasContext *s, DisasOps *o) }gen_helper_fixb (o->out, cpu_env, o->in1, o->in2, m34);return_low128 (o->out2); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2766,7 +2745,6 @@ static DisasJumpType op_ledb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_ledb (o->out, cpu_env, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2778,7 +2756,6 @@ static DisasJumpType op_ldxb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_ldxb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
@@ -2790,7 +2767,6 @@ static DisasJumpType op_lexb(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; }gen_helper_lexb (o->out, cpu_env, o->in1, o->in2, m34); -tcg_temp_free_i32 (m34);return DISAS_NEXT ; }
Signature · 1 line
2.34.1
Re: [PATCH 03/26] target/s390x: Use tcg_constant_i32 for fpinst_extract_m34
Quoted 7 lines · Richard Henderson
Return a constant or NULL, which means the free may be removed from all callers of
fpinst_extract_m34.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-)
PATCH 4/26 target/s390x: Use tcg_constant_* in translate_vx.c.inc
In reply to Richard HendersonIn most cases, this is a simple local allocate and free replaced by tcg_constant_*. In three cases, a variable temp was initialized with a constant value -- reorg to localize the constant.
--- target/s390x/tcg/translate_vx.c.inc | 45 +++++++++++++---------------- 1 file changed, 20 insertions(+), 25 deletions(-)
target/s390x/tcg/translate_vx.c.inc +20 -25
@@ -319,12 +319,10 @@ static void gen_gvec128_4_i64(gen_gvec128_4_i64_fn fn, uint8_t d, uint8_t a, static void gen_addi2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, TCGv_i64 ah, uint64_t b) { - TCGv_i64 bl = tcg_const_i64(b); - TCGv_i64 bh = tcg_const_i64(0); + TCGv_i64 bl = tcg_constant_i64(b); + TCGv_i64 bh = tcg_constant_i64(0); tcg_gen_add2_i64(dl, dh, al, ah, bl, bh); - tcg_temp_free_i64(bl); - tcg_temp_free_i64(bh); } static DisasJumpType op_vbperm(DisasContext *s, DisasOps *o)
@@ -609,9 +607,8 @@ static DisasJumpType op_vlei(DisasContext *s, DisasOps *o) return DISAS_NORETURN; } - tmp = tcg_const_i64((int16_t)get_field(s, i2)); + tmp = tcg_constant_i64((int16_t)get_field(s, i2)); write_vec_element_i64(tmp, get_field(s, v1), enr, es); - tcg_temp_free_i64(tmp); return DISAS_NEXT; }
@@ -1107,11 +1104,13 @@ static DisasJumpType op_vseg(DisasContext *s, DisasOps *o) static DisasJumpType op_vst(DisasContext *s, DisasOps *o) { - TCGv_i64 tmp = tcg_const_i64(16); + TCGv_i64 tmp; /* Probe write access before actually modifying memory */ - gen_helper_probe_write_access(cpu_env, o->addr1, tmp); + gen_helper_probe_write_access(cpu_env, o->addr1, + tcg_constant_i64(16)); + tmp = tcg_temp_new_i64(); read_vec_element_i64(tmp, get_field(s, v1), 0, ES_64); tcg_gen_qemu_st_i64(tmp, o->addr1, get_mem_index(s), MO_TEUQ); gen_addi_and_wrap_i64(s, o->addr1, o->addr1, 8);
@@ -1270,9 +1269,10 @@ static DisasJumpType op_vstm(DisasContext *s, DisasOps *o) } /* Probe write access before actually modifying memory */ - tmp = tcg_const_i64((v3 - v1 + 1) * 16); - gen_helper_probe_write_access(cpu_env, o->addr1, tmp); + gen_helper_probe_write_access(cpu_env, o->addr1, + tcg_constant_i64((v3 - v1 + 1) * 16)); + tmp = tcg_temp_new_i64(); for (;; v1++) { read_vec_element_i64(tmp, v1, 0, ES_64); tcg_gen_qemu_st_i64(tmp, o->addr1, get_mem_index(s), MO_TEUQ);
@@ -1359,7 +1359,7 @@ static DisasJumpType op_va(DisasContext *s, DisasOps *o) static void gen_acc(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b, uint8_t es) { const uint8_t msb_bit_nr = NUM_VEC_ELEMENT_BITS(es) - 1; - TCGv_i64 msb_mask = tcg_const_i64(dup_const(es, 1ull << msb_bit_nr)); + TCGv_i64 msb_mask = tcg_constant_i64(dup_const(es, 1ull << msb_bit_nr)); TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_temp_new_i64(); TCGv_i64 t3 = tcg_temp_new_i64();
@@ -1416,7 +1416,7 @@ static void gen_acc2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, { TCGv_i64 th = tcg_temp_new_i64(); TCGv_i64 tl = tcg_temp_new_i64(); - TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 zero = tcg_constant_i64(0); tcg_gen_add2_i64(tl, th, al, zero, bl, zero); tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
@@ -1425,7 +1425,6 @@ static void gen_acc2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, tcg_temp_free_i64(th); tcg_temp_free_i64(tl); - tcg_temp_free_i64(zero); } static DisasJumpType op_vacc(DisasContext *s, DisasOps *o)
@@ -1455,15 +1454,14 @@ static void gen_ac2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh, TCGv_i64 cl, TCGv_i64 ch) { TCGv_i64 tl = tcg_temp_new_i64(); - TCGv_i64 th = tcg_const_i64(0); + TCGv_i64 zero = tcg_constant_i64(0); /* extract the carry only */ tcg_gen_extract_i64(tl, cl, 0, 1); tcg_gen_add2_i64(dl, dh, al, ah, bl, bh); - tcg_gen_add2_i64(dl, dh, dl, dh, tl, th); + tcg_gen_add2_i64(dl, dh, dl, dh, tl, zero); tcg_temp_free_i64(tl); - tcg_temp_free_i64(th); } static DisasJumpType op_vac(DisasContext *s, DisasOps *o)
@@ -1484,7 +1482,7 @@ static void gen_accc2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, TCGv_i64 ah, { TCGv_i64 tl = tcg_temp_new_i64(); TCGv_i64 th = tcg_temp_new_i64(); - TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 zero = tcg_constant_i64(0); tcg_gen_andi_i64(tl, cl, 1); tcg_gen_add2_i64(tl, th, tl, zero, al, zero);
@@ -1495,7 +1493,6 @@ static void gen_accc2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, TCGv_i64 ah, tcg_temp_free_i64(tl); tcg_temp_free_i64(th); - tcg_temp_free_i64(zero); } static DisasJumpType op_vaccc(DisasContext *s, DisasOps *o)
@@ -1597,14 +1594,13 @@ static void gen_avgl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) static void gen_avgl_i64(TCGv_i64 dl, TCGv_i64 al, TCGv_i64 bl) { TCGv_i64 dh = tcg_temp_new_i64(); - TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 zero = tcg_constant_i64(0); tcg_gen_add2_i64(dl, dh, al, zero, bl, zero); gen_addi2_i64(dl, dh, dl, dh, 1); tcg_gen_extract2_i64(dl, dl, dh, 1); tcg_temp_free_i64(dh); - tcg_temp_free_i64(zero); } static DisasJumpType op_vavgl(DisasContext *s, DisasOps *o)
@@ -2440,7 +2436,7 @@ static void gen_scbi2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, { TCGv_i64 th = tcg_temp_new_i64(); TCGv_i64 tl = tcg_temp_new_i64(); - TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 zero = tcg_constant_i64(0); tcg_gen_sub2_i64(tl, th, al, zero, bl, zero); tcg_gen_andi_i64(th, th, 1);
@@ -2452,7 +2448,6 @@ static void gen_scbi2_i64(TCGv_i64 dl, TCGv_i64 dh, TCGv_i64 al, tcg_temp_free_i64(th); tcg_temp_free_i64(tl); - tcg_temp_free_i64(zero); } static DisasJumpType op_vscbi(DisasContext *s, DisasOps *o)
@@ -2572,11 +2567,12 @@ static DisasJumpType op_vsumq(DisasContext *s, DisasOps *o) return DISAS_NORETURN; } - sumh = tcg_const_i64(0); + sumh = tcg_temp_new_i64(); suml = tcg_temp_new_i64(); - zero = tcg_const_i64(0); + zero = tcg_constant_i64(0); tmpl = tcg_temp_new_i64(); + tcg_gen_mov_i64(sumh, zero); read_vec_element_i64(suml, get_field(s, v3), max_idx, es); for (idx = 0; idx <= max_idx; idx++) { read_vec_element_i64(tmpl, get_field(s, v2), idx, es);
@@ -2587,7 +2583,6 @@ static DisasJumpType op_vsumq(DisasContext *s, DisasOps *o) tcg_temp_free_i64(sumh); tcg_temp_free_i64(suml); - tcg_temp_free_i64(zero); tcg_temp_free_i64(tmpl); return DISAS_NEXT; }
Signature · 1 line
2.34.1
Re: [PATCH 04/26] target/s390x: Use tcg_constant_* in translate_vx.c.inc
Quoted 9 lines · Richard Henderson
In most cases, this is a simple local allocate and free replaced by tcg_constant_*. In three cases, a variable temp was initialized with a constant value -- reorg to localize the constant.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate_vx.c.inc | 45 +++++++++++++---------------- 1 file changed, 20 insertions(+), 25 deletions(-)
...
target/s390x/tcg/translate_vx.c.inc static DisasJumpType op_va(DisasContext *s, DisasOps *o) · line 1365
Quoted 9 lines
target/s390x/tcg/translate_vx.c.inc +1
-1@@ -1359,7 +1359,7 @@ static DisasJumpType op_va(DisasContext *s, DisasOps *o) static void gen_acc(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b, uint8_t es) { const uint8_t msb_bit_nr = NUM_VEC_ELEMENT_BITS(es) - 1; - TCGv_i64 msb_mask = tcg_const_i64(dup_const(es, 1ull << msb_bit_nr)); + TCGv_i64 msb_mask = tcg_constant_i64(dup_const(es, 1ull << msb_bit_nr)); TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_temp_new_i64(); TCGv_i64 t3 = tcg_temp_new_i64();
This also fixes a leak, right?
...
Re: [PATCH 04/26] target/s390x: Use tcg_constant_* in translate_vx.c.inc
Quoted 13 lines · Ilya Leoshkevich
Quoted 9 lines · Richard Henderson
In most cases, this is a simple local allocate and free replaced by tcg_constant_*. In three cases, a variable temp was initialized with a constant value -- reorg to localize the constant.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate_vx.c.inc | 45 +++++++++++++---------------- 1 file changed, 20 insertions(+), 25 deletions(-)...
Quoted 11 lines
target/s390x/tcg/translate_vx.c.inc static DisasJumpType op_va(DisasContext *s, DisasOps *o) · line 1365
Quoted 9 lines
target/s390x/tcg/translate_vx.c.inc +1
-1@@ -1359,7 +1359,7 @@ static DisasJumpType op_va(DisasContext *s, DisasOps *o) static void gen_acc(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b, uint8_t es) { const uint8_t msb_bit_nr = NUM_VEC_ELEMENT_BITS(es) - 1; - TCGv_i64 msb_mask = tcg_const_i64(dup_const(es, 1ull << msb_bit_nr)); + TCGv_i64 msb_mask = tcg_constant_i64(dup_const(es, 1ull << msb_bit_nr)); TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_temp_new_i64(); TCGv_i64 t3 = tcg_temp_new_i64();This also fixes a leak, right?
Yes.
r~
PATCH 5/26 target/s390x: Change help_goto_direct to work on displacements
In reply to Richard HendersonIn preparation for TARGET_TB_PCREL, reduce reliance on absolute values.
--- target/s390x/tcg/translate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
target/s390x/tcg/translate.c +7 -4
@@ -1145,8 +1145,10 @@ struct DisasInsn {/* ====================================================================== */ /* Miscellaneous helpers, used by several operations. */ -static DisasJumpType help_goto_direct (DisasContext *s,uint64_t dest) +static DisasJumpType help_goto_direct (DisasContext *s,int64_t disp) { +uint64_t dest = s->base.pc_next + disp; +if (dest == s->pc_tmp) {per_branch (s, true);return DISAS_NEXT ;
@@ -1169,7 +1171,8 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, bool is_imm, int imm, TCGv_i64 cdest) { DisasJumpType ret; -uint64_t dest = s->base.pc_next + (int64_t )imm *2 ; +int64_t disp = (int64_t )imm *2 ; +uint64_t dest = s->base.pc_next + disp;TCGLabel *lab;/* Take care of the special cases first. */
@@ -1185,7 +1188,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, goto egress; }if (c->cond ==TCG_COND_ALWAYS ) { - ret =help_goto_direct (s, dest); + ret =help_goto_direct (s, disp); goto egress; } }else {
@@ -1558,7 +1561,7 @@ static DisasJumpType op_bal(DisasContext *s, DisasOps *o)static DisasJumpType op_basi (DisasContext *s,DisasOps *o) {pc_to_link_info (o->out, s, s->pc_tmp); -return help_goto_direct (s, s->base.pc_next + (int64_t )get_field (s, i2) *2 ); +return help_goto_direct (s, (int64_t )get_field (s, i2) *2 ); }static DisasJumpType op_bc (DisasContext *s,DisasOps *o)
Signature · 1 line
2.34.1
Re: [PATCH 05/26] target/s390x: Change help_goto_direct to work on displacements
Quoted 6 lines · Richard Henderson
In preparation for
TARGET_TB_PCREL, reduce reliance on absolute values.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
PATCH 6/26 target/s390x: Introduce gen_psw_addr_disp
In reply to Richard HendersonIn preparation for TARGET_TB_PCREL, reduce reliance on absolute values.
--- target/s390x/tcg/translate.c | 69 ++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 23 deletions(-)
target/s390x/tcg/translate.c +46 -23
@@ -169,6 +169,11 @@ static uint64_t inline_branch_hit[CC_OP_MAX];static uint64_t inline_branch_miss[CC_OP_MAX ];#endif +static void gen_psw_addr_disp (DisasContext *s,TCGv_i64 dest,int64_t disp) +{ +tcg_gen_movi_i64 (dest, s->base.pc_next + disp); +} +static void pc_to_link_info (TCGv_i64 out,DisasContext *s,uint64_t pc) {if (s->base.tb->flags &FLAG_MASK_32 ) {
@@ -334,18 +339,24 @@ static void return_low128(TCGv_i64 dest)static void update_psw_addr (DisasContext *s) { -/* psw.addr */ -tcg_gen_movi_i64 (psw_addr, s->base.pc_next); +gen_psw_addr_disp (s, psw_addr,0 ); }static void per_branch (DisasContext *s,bool to_next) {#ifndef CONFIG_USER_ONLY -tcg_gen_movi_i64 (gbea, s->base.pc_next); +gen_psw_addr_disp (s, gbea,0 );if (s->base.tb->flags &FLAG_MASK_PER ) { -TCGv_i64 next_pc = to_next ?tcg_constant_i64 (s->pc_tmp) : psw_addr; -gen_helper_per_branch (cpu_env, gbea, next_pc); +if (to_next) { +TCGv_i64 next_pc =tcg_temp_new_i64 (); + +gen_psw_addr_disp (s, next_pc, s->ilen); +gen_helper_per_branch (cpu_env, gbea, next_pc); +tcg_temp_free_i64 (next_pc); + }else { +gen_helper_per_branch (cpu_env, gbea, psw_addr); + } }#endif }
@@ -358,20 +369,23 @@ static void per_branch_cond(DisasContext *s, TCGCond cond,TCGLabel *lab =gen_new_label ();tcg_gen_brcond_i64 (tcg_invert_cond (cond), arg1, arg2, lab); -tcg_gen_movi_i64 (gbea, s->base.pc_next); +gen_psw_addr_disp (s, gbea,0 );gen_helper_per_branch (cpu_env, gbea, psw_addr); gen_set_label(lab); }else { -TCGv_i64 pc =tcg_constant_i64 (s->base.pc_next); +TCGv_i64 pc =tcg_temp_new_i64 (); + +gen_psw_addr_disp (s, pc,0 );tcg_gen_movcond_i64 (cond, gbea, arg1, arg2, gbea, pc); +tcg_temp_free_i64 (pc); }#endif }static void per_breaking_event (DisasContext *s) { -tcg_gen_movi_i64 (gbea, s->base.pc_next); +gen_psw_addr_disp (s, gbea,0 ); }static void update_cc_op (DisasContext *s)
@@ -1147,21 +1161,19 @@ struct DisasInsn {static DisasJumpType help_goto_direct (DisasContext *s,int64_t disp) { -uint64_t dest = s->base.pc_next + disp; - -if (dest == s->pc_tmp) { +if (disp == s->ilen) {per_branch (s, true);return DISAS_NEXT ; } -if (use_goto_tb (s, dest)) { +if (use_goto_tb (s, s->base.pc_next + disp)) {update_cc_op (s);per_breaking_event (s);tcg_gen_goto_tb (0 ); -tcg_gen_movi_i64 (psw_addr, dest); +gen_psw_addr_disp (s, psw_addr, disp);tcg_gen_exit_tb (s->base.tb,0 );return DISAS_NORETURN ; }else { -tcg_gen_movi_i64 (psw_addr, dest); +gen_psw_addr_disp (s, psw_addr, disp);per_branch (s, false);return DISAS_PC_UPDATED ; }
@@ -1219,14 +1231,14 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,/* Branch not taken. */ tcg_gen_goto_tb (0 ); -tcg_gen_movi_i64 (psw_addr, s->pc_tmp); +gen_psw_addr_disp (s, psw_addr, s->ilen);tcg_gen_exit_tb (s->base.tb,0 );/* Branch taken. */ gen_set_label (lab);per_breaking_event (s);tcg_gen_goto_tb (1 ); -tcg_gen_movi_i64 (psw_addr, dest); +gen_psw_addr_disp (s, psw_addr, disp);tcg_gen_exit_tb (s->base.tb,1 ); ret =DISAS_NORETURN ;
@@ -1249,12 +1261,12 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,/* Branch not taken. */ update_cc_op (s);tcg_gen_goto_tb (0 ); -tcg_gen_movi_i64 (psw_addr, s->pc_tmp); +gen_psw_addr_disp (s, psw_addr, s->ilen);tcg_gen_exit_tb (s->base.tb,0 );gen_set_label (lab);if (is_imm) { -tcg_gen_movi_i64 (psw_addr, dest); +gen_psw_addr_disp (s, psw_addr, disp); }per_breaking_event (s); ret =DISAS_PC_UPDATED ;
@@ -1264,9 +1276,12 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,Most commonly we're single-stepping or some other condition that disables all use of goto_tb. Just update the PC and exit. */ -TCGv_i64 next =tcg_constant_i64 (s->pc_tmp); +TCGv_i64 next =tcg_temp_new_i64 (); + +gen_psw_addr_disp (s, next, s->ilen);if (is_imm) { - cdest =tcg_constant_i64 (dest); + cdest =tcg_temp_new_i64 (); +gen_psw_addr_disp (s, cdest, disp); }if (c->is_64) {
@@ -1285,6 +1300,10 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,tcg_temp_free_i64 (t1); } +tcg_temp_free_i64 (next); +if (is_imm) { +tcg_temp_free_i64 (cdest); + } ret =DISAS_PC_UPDATED ; }
@@ -5827,7 +5846,8 @@ static void in2_a2(DisasContext *s, DisasOps *o)static void in2_ri2 (DisasContext *s,DisasOps *o) { - o->in2 =tcg_const_i64 (s->base.pc_next + (int64_t )get_field (s, i2) *2 ); + o->in2 =tcg_temp_new_i64 (); +gen_psw_addr_disp (s, o->in2, (int64_t )get_field (s, i2) *2 ); }#define SPEC_in2_ri2 0
@@ -6306,8 +6326,11 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)#ifndef CONFIG_USER_ONLY if (s->base.tb->flags &FLAG_MASK_PER ) { -TCGv_i64 addr =tcg_constant_i64 (s->base.pc_next); +TCGv_i64 addr =tcg_temp_new_i64 (); + +gen_psw_addr_disp (s, addr,0 );gen_helper_per_ifetch (cpu_env, addr); +tcg_temp_free_i64 (addr); }#endif
@@ -6428,7 +6451,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)if (s->base.tb->flags &FLAG_MASK_PER ) {/* An exception might be triggered, save PSW if not already done. */ if (ret ==DISAS_NEXT || ret ==DISAS_TOO_MANY ) { -tcg_gen_movi_i64 (psw_addr, s->pc_tmp); +gen_psw_addr_disp (s, psw_addr, s->ilen); }/* Call the helper to check for a possible PER exception. */
Signature · 1 line
2.34.1
Re: [PATCH 06/26] target/s390x: Introduce gen_psw_addr_disp
Quoted 6 lines · Richard Henderson
In preparation for
TARGET_TB_PCREL, reduce reliance on absolute values.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 69 ++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 23 deletions(-)
PATCH 7/26 target/s390x: Remove pc argument to pc_to_link_into
In reply to Richard HendersonAll callers pass s->pc_tmp.
--- target/s390x/tcg/translate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
target/s390x/tcg/translate.c +6 -4
@@ -174,8 +174,10 @@ static void gen_psw_addr_disp(DisasContext *s, TCGv_i64 dest, int64_t disp)tcg_gen_movi_i64 (dest, s->base.pc_next + disp); } -static void pc_to_link_info (TCGv_i64 out,DisasContext *s,uint64_t pc) +static void pc_to_link_info (TCGv_i64 out,DisasContext *s) { +uint64_t pc = s->pc_tmp; +if (s->base.tb->flags &FLAG_MASK_32 ) {if (s->base.tb->flags &FLAG_MASK_64 ) {tcg_gen_movi_i64 (out, pc);
@@ -1534,7 +1536,7 @@ static DisasJumpType op_ni(DisasContext *s, DisasOps *o)static DisasJumpType op_bas (DisasContext *s,DisasOps *o) { -pc_to_link_info (o->out, s, s->pc_tmp); +pc_to_link_info (o->out, s);if (o->in2) {tcg_gen_mov_i64 (psw_addr, o->in2);per_branch (s, false);
@@ -1549,7 +1551,7 @@ static void save_link_info(DisasContext *s, DisasOps *o)TCGv_i64 t;if (s->base.tb->flags & (FLAG_MASK_32 |FLAG_MASK_64 )) { -pc_to_link_info (o->out, s, s->pc_tmp); +pc_to_link_info (o->out, s);return ; }gen_op_calc_cc (s);
@@ -1579,7 +1581,7 @@ static DisasJumpType op_bal(DisasContext *s, DisasOps *o)static DisasJumpType op_basi (DisasContext *s,DisasOps *o) { -pc_to_link_info (o->out, s, s->pc_tmp); +pc_to_link_info (o->out, s);return help_goto_direct (s, (int64_t )get_field (s, i2) *2 ); }
Signature · 1 line
2.34.1
Re: [PATCH 07/26] target/s390x: Remove pc argument to pc_to_link_into
Quoted 7 lines · Richard Henderson
All callers pass
s->pc_tmp.Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
PATCH 8/26 target/s390x: Use gen_psw_addr_disp in pc_to_link_info
In reply to Richard HendersonThis is slightly more complicated that a straight displacement for 31 and 24-bit modes. Dont bother with a cant-happen assert.
--- target/s390x/tcg/translate.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
target/s390x/tcg/translate.c +12 -9
@@ -176,17 +176,20 @@ static void gen_psw_addr_disp(DisasContext *s, TCGv_i64 dest, int64_t disp)static void pc_to_link_info (TCGv_i64 out,DisasContext *s) { -uint64_t pc = s->pc_tmp; +TCGv_i64 tmp; -if (s->base.tb->flags &FLAG_MASK_32 ) { -if (s->base.tb->flags &FLAG_MASK_64 ) { -tcg_gen_movi_i64 (out, pc); -return ; - } - pc |=0x80000000 ; +if (s->base.tb->flags &FLAG_MASK_64 ) { +gen_psw_addr_disp (s, out, s->ilen); +return ; } -assert (!(s->base.tb->flags &FLAG_MASK_64 )); -tcg_gen_deposit_i64 (out, out,tcg_constant_i64 (pc),0 ,32 ); + + tmp =tcg_temp_new_i64 (); +gen_psw_addr_disp (s, tmp, s->ilen); +if (s->base.tb->flags &FLAG_MASK_32 ) { +tcg_gen_ori_i64 (tmp, tmp,0x80000000 ); + } +tcg_gen_deposit_i64 (out, out, tmp,0 ,32 ); +tcg_temp_free_i64 (tmp); }static TCGv_i64 psw_addr;
Signature · 1 line
2.34.1
Re: [PATCH 08/26] target/s390x: Use gen_psw_addr_disp in pc_to_link_info
Quoted 7 lines · Richard Henderson
This is slightly more complicated that a straight displacement for 31 and 24-bit modes. Dont bother with a cant-happen assert.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
PATCH 9/26 target/s390x: Use gen_psw_addr_disp in save_link_info
In reply to Richard HendersonTrivial but non-mechanical conversion away from pc_tmp.
--- target/s390x/tcg/translate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/s390x/tcg/translate.c +4 -2
@@ -1558,9 +1558,11 @@ static void save_link_info(DisasContext *s, DisasOps *o)return ; }gen_op_calc_cc (s); -tcg_gen_andi_i64 (o->out, o->out,0xffffffff00000000ull ); -tcg_gen_ori_i64 (o->out, o->out, ((s->ilen /2 ) <<30 ) | s->pc_tmp); t =tcg_temp_new_i64 (); +tcg_gen_andi_i64 (o->out, o->out,0xffffffff00000000ull ); +gen_psw_addr_disp (s, t, s->ilen); +tcg_gen_or_i64 (o->out, o->out, t); +tcg_gen_ori_i64 (o->out, o->out, (s->ilen /2 ) <<30 );tcg_gen_shri_i64 (t, psw_mask,16 );tcg_gen_andi_i64 (t, t,0x0f000000 );tcg_gen_or_i64 (o->out, o->out, t);
Signature · 1 line
2.34.1
Re: [PATCH 09/26] target/s390x: Use gen_psw_addr_disp in save_link_info
Quoted 7 lines · Richard Henderson
Trivial but non-mechanical conversion away from
pc_tmp.Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
I was a bit worried about this sequence and wrote a regression test. It did not find any issues, but I will post it here, might prove useful some day.
PATCH 1/1 tests/tcg/s390x: Add bal.S
Add a small test to prevent regressions.
--- tests/tcg/s390x/Makefile.softmmu-target | 1 + tests/tcg/s390x/bal.S | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/tcg/s390x/bal.S
tests/tcg/s390x/Makefile.softmmu-target +1 -0
@@ -7,3 +7,4 @@ QEMU_OPTS=-action panic=exit-failure -kernel -Wl,--build-id=none $< -o $@ TESTS += unaligned-lowcore +TESTS += bal
tests/tcg/s390x/bal.S new file +24 -0
@@ -0,0 +1,24 @@ + .org 0x200 /* lowcore padding */ + .globl _start +_start: + lpswe start24_psw +_start24: + lgrl %r0,initial_r0 + lgrl %r1,expected_r0 + bal %r0,0f +0: + cgrjne %r0,%r1,1f + lpswe success_psw +1: + lpswe failure_psw + .align 8 +start24_psw: + .quad 0x160000000000,_start24 /* 24-bit mode, cc = 1, pm = 6 */ +initial_r0: + .quad 0x1234567887654321 +expected_r0: + .quad 0x1234567896000000 + 0b /* ilc = 2, cc = 1, pm = 6 */ +success_psw: + .quad 0x2000000000000,0xfff /* see is_special_wait_psw() */ +failure_psw: + .quad 0x2000000000000,0 /* disabled wait */
Signature · 1 line
2.37.2
PATCH 10/26 target/s390x: Use gen_psw_addr_disp in op_sam
In reply to Richard HendersonComplicated because we may now require a runtime jump.
--- target/s390x/tcg/translate.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-)
target/s390x/tcg/translate.c +28 -12
@@ -3922,7 +3922,7 @@ static DisasJumpType op_sacf(DisasContext *s, DisasOps *o)static DisasJumpType op_sam (DisasContext *s,DisasOps *o) {int sam = s->insn->data; -TCGv_i64 tsam; +TCGLabel *fault =NULL ;uint64_t mask;switch (sam) {
@@ -3937,20 +3937,36 @@ static DisasJumpType op_sam(DisasContext *s, DisasOps *o)break ; } -/* Bizarre but true, we check the address of the current insn for the -specification exception, not the next to be executed. Thus the PoO -documents that Bad Things Happen two bytes before the end. */ -if (s->base.pc_next & ~mask) { -gen_program_exception (s,PGM_SPECIFICATION ); -return DISAS_NORETURN ; - } - s->pc_tmp &= mask; +/* +* Bizarre but true, we check the address of the current insn for the +* specification exception, not the next to be executed. Thus the PoO +* documents that Bad Things Happen two bytes before the end. +*/ +if (mask !=-1 ) { +TCGv_i64 t =tcg_temp_new_i64 (); + fault =gen_new_label (); - tsam =tcg_constant_i64 (sam); -tcg_gen_deposit_i64 (psw_mask, psw_mask, tsam,31 ,2 ); +gen_psw_addr_disp (s, t,0 ); +tcg_gen_andi_i64 (t, t, ~mask); +tcg_gen_brcondi_i64 (TCG_COND_NE , t,0 , fault); +tcg_temp_free_i64 (t); + } + +update_cc_op (s); + +tcg_gen_deposit_i64 (psw_mask, psw_mask,tcg_constant_i64 (sam),31 ,2 ); + +gen_psw_addr_disp (s, psw_addr, s->ilen); +tcg_gen_andi_i64 (psw_addr, psw_addr, mask);/* Always exit the TB, since we (may have) changed execution mode. */ -return DISAS_TOO_MANY ; +tcg_gen_lookup_and_goto_ptr (); + +if (mask !=-1 ) { +gen_set_label (fault); +gen_program_exception (s,PGM_SPECIFICATION ); + } +return DISAS_NORETURN ; }static DisasJumpType op_sar (DisasContext *s,DisasOps *o)
Signature · 1 line
2.34.1
Re: [PATCH 10/26] target/s390x: Use gen_psw_addr_disp in op_sam
Quoted 6 lines · Richard Henderson
Complicated because we may now require a runtime jump.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-)
PATCH 11/26 target/s390x: Use ilen instead in branches
In reply to Richard HendersonRemove the remaining uses of pc_tmp, and remove the variable.
--- target/s390x/tcg/translate.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
target/s390x/tcg/translate.c +3 -10
@@ -141,12 +141,6 @@ struct DisasContext {TCGOp *insn_start;DisasFields fields;uint64_t ex_value; -/* -* During translate_one(), pc_tmp is used to determine the instruction -* to be executed after base.pc_next - e.g. next sequential instruction -* or a branch target. -*/ -uint64_t pc_tmp;uint32_t ilen;enum cc_op cc_op;bool exit_to_mainloop;
@@ -1198,7 +1192,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, goto egress; }if (is_imm) { -if (dest == s->pc_tmp) { +if (disp == s->ilen) {/* Branch to next. */ per_branch (s, true); ret =DISAS_NEXT ;
@@ -1222,7 +1216,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, } } -if (use_goto_tb (s, s->pc_tmp)) { +if (use_goto_tb (s, s->base.pc_next + s->ilen)) {if (is_imm &&use_goto_tb (s, dest)) {/* Both exits can use goto_tb. */ update_cc_op (s);
@@ -6247,7 +6241,6 @@ static const DisasInsn *extract_insn(CPUS390XState *env, DisasContext *s)g_assert_not_reached (); } } - s->pc_tmp = s->base.pc_next + ilen; s->ilen = ilen;/* We can't actually determine the insn format until we've looked up
@@ -6484,7 +6477,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) out:/* Advance to the next instruction. */ - s->base.pc_next = s->pc_tmp; + s->base.pc_next += s->ilen;return ret; }
Signature · 1 line
2.34.1
Re: [PATCH 11/26] target/s390x: Use ilen instead in branches
Quoted 6 lines · Richard Henderson
Remove the remaining uses of
pc_tmp, and remove the variable.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
PATCH 12/26 target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state
In reply to Richard HendersonMasking after the fact in s390x_tr_init_disas_context provides incorrect information to tb_lookup.
--- target/s390x/cpu.h | 13 +++++++------ target/s390x/tcg/translate.c | 6 ------ 2 files changed, 7 insertions(+), 12 deletions(-)
target/s390x/cpu.h +7 -6
@@ -379,17 +379,18 @@ static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch) }static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc, -target_ulong *cs_base,uint32_t *flags) +target_ulong *cs_base,uint32_t *pflags) { - *pc = env->psw.addr; - *cs_base = env->ex_value; - *flags = (env->psw.mask >>FLAG_MASK_PSW_SHIFT ) &FLAG_MASK_PSW ; +int flags = (env->psw.mask >>FLAG_MASK_PSW_SHIFT ) &FLAG_MASK_PSW ;if (env->cregs[0 ] &CR0_AFP ) { - *flags |=FLAG_MASK_AFP ; + flags |=FLAG_MASK_AFP ; }if (env->cregs[0 ] &CR0_VECTOR ) { - *flags |=FLAG_MASK_VECTOR ; + flags |=FLAG_MASK_VECTOR ; } + *pflags = flags; + *cs_base = env->ex_value; + *pc = (flags &FLAG_MASK_64 ? env->psw.addr : env->psw.addr &0x7fffffff ); }/* PER bits from control register 9 */
target/s390x/tcg/translate.c +0 -6
@@ -6485,12 +6485,6 @@ static void s390x_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) {DisasContext *dc =container_of (dcbase, DisasContext, base); -/* 31-bit mode */ -if (!(dc->base.tb->flags &FLAG_MASK_64 )) { - dc->base.pc_first &=0x7fffffff ; - dc->base.pc_next = dc->base.pc_first; - } - dc->cc_op =CC_OP_DYNAMIC ; dc->ex_value = dc->base.tb->cs_base; dc->exit_to_mainloop = (dc->base.tb->flags &FLAG_MASK_PER ) || dc->ex_value;
Signature · 1 line
2.34.1
Re: [PATCH 12/26] target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state
Quoted 8 lines · Richard Henderson
Masking after the fact in
s390x_tr_init_disas_contextprovides incorrect information totb_lookup.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/cpu.h | 13 +++++++------ target/s390x/tcg/translate.c | 6 ------ 2 files changed, 7 insertions(+), 12 deletions(-)
How can we end up in a situation where this matters? E.g. if we are in 64-bit mode and execute
0xa12345678: sam31
we will get a specification exception, and cpu_get_tb_cpu_state() will not run. And for valid 31-bit addresses masking should be a no-op.
Re: [PATCH 12/26] target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state
Quoted 10 lines · Ilya Leoshkevich
Quoted 8 lines · Richard Henderson
Masking after the fact in
s390x_tr_init_disas_contextprovides incorrect information totb_lookup.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/cpu.h | 13 +++++++------ target/s390x/tcg/translate.c | 6 ------ 2 files changed, 7 insertions(+), 12 deletions(-)
Quoted 7 lines
How can we end up in a situation where this matters? E.g. if we are in 64-bit mode and execute
0xa12345678: sam31we will get a specification exception, and
cpu_get_tb_cpu_state()will not run. And for valid 31-bit addresses masking should be a no-op.
Ah, true. I was mislead by the presence of the code in s390x_tr_init_disas_context. Perhaps a tcg_debug_assert or just a comment?
r~
Re: [PATCH 12/26] target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state
Quoted 14 lines · Richard Henderson
Quoted 13 lines · Ilya Leoshkevich
Quoted 8 lines · Richard Henderson
Masking after the fact in
s390x_tr_init_disas_contextprovides incorrect information totb_lookup.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/cpu.h | 13 +++++++------ target/s390x/tcg/translate.c | 6 ------ 2 files changed, 7 insertions(+), 12 deletions(-)How can we end up in a situation where this matters? E.g. if we are in 64-bit mode and execute
Quoted 7 lines
Quoted 4 lines
0xa12345678: sam31we will get a specification exception, and
cpu_get_tb_cpu_state()will not run. And for valid 31-bit addresses masking should be a no-op.Ah, true. I was mislead by the presence of the code in
s390x_tr_init_disas_context. Perhaps atcg_debug_assertor just a comment?
An assert sounds good to me.
I tried the following diff with the attached test and it worked:
target/s390x/cpu.h +6 -1
@@ -390,7 +390,12 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc, } *pflags = flags; *cs_base = env->ex_value; - *pc = (flags &FLAG_MASK_64 ? env->psw.addr : env->psw.addr &0x7fffffff ); +if (!(flags &FLAG_MASK_32 )) { +g_assert (env->psw.addr <=0xffffff ); + }else if (!(flags &FLAG_MASK_64 )) { +g_assert (env->psw.addr <=0x7fffffff ); + } + *pc = env->psw.addr; }/* PER bits from control register 9 */
target/s390x/tcg/translate.c +6 -0
@@ -6464,6 +6464,12 @@ static void s390x_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) {DisasContext *dc =container_of (dcbase, DisasContext, base); +if (!(dc->base.tb->flags &FLAG_MASK_32 )) { +tcg_debug_assert (dc->base.pc_first <=0xffffff ); + }else if (!(dc->base.tb->flags &FLAG_MASK_64 )) { +tcg_debug_assert (dc->base.pc_first <=0x7fffffff ); + } + dc->pc_save = dc->base.pc_first; dc->cc_op =CC_OP_DYNAMIC ; dc->ex_value = dc->base.tb->cs_base;
PATCH 1/1 tests/tcg/s390x: Add sam.S
Add a small test to prevent regressions.
--- tests/tcg/s390x/Makefile.softmmu-target | 1 + tests/tcg/s390x/sam.S | 67 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tests/tcg/s390x/sam.S
tests/tcg/s390x/Makefile.softmmu-target +1 -0
@@ -7,3 +7,4 @@ QEMU_OPTS=-action panic=exit-failure -kernel -Wl,--build-id=none $< -o $@ TESTS += unaligned-lowcore +TESTS += sam
tests/tcg/s390x/sam.S new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.38.1
PATCH 13/26 target/s390x: Add disp argument to update_psw_addr
In reply to Richard HendersonRename to update_psw_addr_disp at the same time.
--- target/s390x/tcg/translate.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
target/s390x/tcg/translate.c +11 -11
@@ -336,9 +336,9 @@ static void return_low128(TCGv_i64 dest)tcg_gen_ld_i64 (dest, cpu_env, offsetof(CPUS390XState , retxl)); } -static void update_psw_addr (DisasContext *s) +static void update_psw_addr_disp (DisasContext *s,int64_t disp) { -gen_psw_addr_disp (s, psw_addr,0 ); +gen_psw_addr_disp (s, psw_addr, disp); }static void per_branch (DisasContext *s,bool to_next)
@@ -444,7 +444,7 @@ static void gen_program_exception(DisasContext *s, int code) offsetof(CPUS390XState, int_pgm_ilen));/* update the psw */ -update_psw_addr (s); +update_psw_addr_disp (s,0 );/* Save off cc. */ update_cc_op (s);
@@ -1168,11 +1168,11 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)update_cc_op (s);per_breaking_event (s);tcg_gen_goto_tb (0 ); -gen_psw_addr_disp (s, psw_addr, disp); +update_psw_addr_disp (s, disp);tcg_gen_exit_tb (s->base.tb,0 );return DISAS_NORETURN ; }else { -gen_psw_addr_disp (s, psw_addr, disp); +update_psw_addr_disp (s, disp);per_branch (s, false);return DISAS_PC_UPDATED ; }
@@ -2448,7 +2448,7 @@ static DisasJumpType op_ex(DisasContext *s, DisasOps *o)return DISAS_NORETURN ; } -update_psw_addr (s); +update_psw_addr_disp (s,0 );update_cc_op (s);if (r1 ==0 ) {
@@ -3175,7 +3175,7 @@ static DisasJumpType op_lpd(DisasContext *s, DisasOps *o)/* In a parallel context, stop the world and single step. */ if (tb_cflags (s->base.tb) &CF_PARALLEL ) { -update_psw_addr (s); +update_psw_addr_disp (s,0 );update_cc_op (s);gen_exception (EXCP_ATOMIC );return DISAS_NORETURN ;
@@ -4490,7 +4490,7 @@ static DisasJumpType op_stura(DisasContext *s, DisasOps *o)tcg_gen_qemu_st_tl (o->in1, o->in2,MMU_REAL_IDX , s->insn->data);if (s->base.tb->flags &FLAG_MASK_PER ) { -update_psw_addr (s); +update_psw_addr_disp (s,0 );gen_helper_per_store_real (cpu_env); }return DISAS_NEXT ;
@@ -4728,7 +4728,7 @@ static DisasJumpType op_svc(DisasContext *s, DisasOps *o) {TCGv_i32 t; -update_psw_addr (s); +update_psw_addr_disp (s,0 );update_cc_op (s); t =tcg_constant_i32 (get_field (s, i1) &0xff );
@@ -6467,7 +6467,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)if (s->base.tb->flags &FLAG_MASK_PER ) {/* An exception might be triggered, save PSW if not already done. */ if (ret ==DISAS_NEXT || ret ==DISAS_TOO_MANY ) { -gen_psw_addr_disp (s, psw_addr, s->ilen); +update_psw_addr_disp (s, s->ilen); }/* Call the helper to check for a possible PER exception. */
@@ -6534,7 +6534,7 @@ static void s390x_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)case DISAS_NORETURN :break ;case DISAS_TOO_MANY : -update_psw_addr (dc); +update_psw_addr_disp (dc,0 );/* FALLTHRU */ case DISAS_PC_UPDATED :/* Next TB starts off with CC_OP_DYNAMIC, so make sure the
Signature · 1 line
2.34.1
Re: [PATCH 13/26] target/s390x: Add disp argument to update_psw_addr
Quoted 6 lines · Richard Henderson
Rename to
update_psw_addr_dispat the same time.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
PATCH 14/26 target/s390x: Don't set gbea for user-only
In reply to Richard HendersonThe rest of the per_* functions have this ifdef;
this one seemed to be missing.
--- target/s390x/tcg/translate.c | 2 ++ 1 file changed, 2 insertions(+)
target/s390x/tcg/translate.c +2 -0
@@ -384,7 +384,9 @@ static void per_branch_cond(DisasContext *s, TCGCond cond,static void per_breaking_event (DisasContext *s) { +#ifndef CONFIG_USER_ONLY gen_psw_addr_disp (s, gbea,0 ); +#endif }static void update_cc_op (DisasContext *s)
Signature · 1 line
2.34.1
Re: [PATCH 14/26] target/s390x: Don't set gbea for user-only
Quoted 4 lines · Richard Henderson
The rest of the per_* functions have this ifdef;
this one seemed to be missing.Signed-off-by Richard Henderson <[email protected]>
PATCH 15/26 target/s390x: Introduce per_enabled
In reply to Richard HendersonHoist the test of FLAG_MASK_PER to a helper.
--- target/s390x/tcg/translate.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
target/s390x/tcg/translate.c +16 -7
@@ -341,12 +341,21 @@ static void update_psw_addr_disp(DisasContext *s, int64_t disp)gen_psw_addr_disp (s, psw_addr, disp); } +static inline bool per_enabled (DisasContext *s) +{ +#ifdef CONFIG_USER_ONLY +return false; +#else +return unlikely (s->base.tb->flags &FLAG_MASK_PER ); +#endif +} +static void per_branch (DisasContext *s,bool to_next) {#ifndef CONFIG_USER_ONLY gen_psw_addr_disp (s, gbea,0 ); -if (s->base.tb->flags &FLAG_MASK_PER ) { +if (per_enabled (s)) {if (to_next) {TCGv_i64 next_pc =tcg_temp_new_i64 ();
@@ -364,7 +373,7 @@ static void per_branch_cond(DisasContext *s, TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2) {#ifndef CONFIG_USER_ONLY -if (s->base.tb->flags &FLAG_MASK_PER ) { +if (per_enabled (s)) {TCGLabel *lab =gen_new_label ();tcg_gen_brcond_i64 (tcg_invert_cond (cond), arg1, arg2, lab);
@@ -665,7 +674,7 @@ static void gen_op_calc_cc(DisasContext *s)static bool use_goto_tb (DisasContext *s,uint64_t dest) { -if (unlikely (s->base.tb->flags &FLAG_MASK_PER )) { +if (per_enabled (s)) {return false; }return translator_use_goto_tb (&s->base, dest);
@@ -4491,7 +4500,7 @@ static DisasJumpType op_stura(DisasContext *s, DisasOps *o) {tcg_gen_qemu_st_tl (o->in1, o->in2,MMU_REAL_IDX , s->insn->data); -if (s->base.tb->flags &FLAG_MASK_PER ) { +if (per_enabled (s)) {update_psw_addr_disp (s,0 );gen_helper_per_store_real (cpu_env); }
@@ -6343,7 +6352,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) }#ifndef CONFIG_USER_ONLY -if (s->base.tb->flags &FLAG_MASK_PER ) { +if (per_enabled (s)) {TCGv_i64 addr =tcg_temp_new_i64 ();gen_psw_addr_disp (s, addr,0 );
@@ -6466,7 +6475,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) }#ifndef CONFIG_USER_ONLY -if (s->base.tb->flags &FLAG_MASK_PER ) { +if (per_enabled (s)) {/* An exception might be triggered, save PSW if not already done. */ if (ret ==DISAS_NEXT || ret ==DISAS_TOO_MANY ) {update_psw_addr_disp (s, s->ilen);
@@ -6489,7 +6498,7 @@ static void s390x_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) dc->cc_op =CC_OP_DYNAMIC ; dc->ex_value = dc->base.tb->cs_base; - dc->exit_to_mainloop = (dc->base.tb->flags &FLAG_MASK_PER ) || dc->ex_value; + dc->exit_to_mainloop =per_enabled (dc) || dc->ex_value; }static void s390x_tr_tb_start (DisasContextBase *db,CPUState *cs)
Signature · 1 line
2.34.1
Re: [PATCH 15/26] target/s390x: Introduce per_enabled
Quoted 6 lines · Richard Henderson
Hoist the test of
FLAG_MASK_PERto a helper.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
PATCH 16/26 target/s390x: Disable conditional branch-to-next for PER
In reply to Richard HendersonFor PER, we require a conditional call to helper_per_branch for the conditional branch. Fold the remaining optimization into a call to helper_goto_direct, which will take care of the remaining gbea adjustment.
--- target/s390x/tcg/translate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
target/s390x/tcg/translate.c +6 -7
@@ -1203,13 +1203,12 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, goto egress; }if (is_imm) { -if (disp == s->ilen) { -/* Branch to next. */ -per_branch (s, true); - ret =DISAS_NEXT ; - goto egress; - } -if (c->cond ==TCG_COND_ALWAYS ) { +/* +* Do not optimize a conditional branch if PER enabled, because we +* still need a conditional call to helper_per_branch. +*/ +if (c->cond ==TCG_COND_ALWAYS + || (disp == s->ilen && !per_enabled (s))) { ret =help_goto_direct (s, disp); goto egress; }
Signature · 1 line
2.34.1
Re: [PATCH 16/26] target/s390x: Disable conditional branch-to-next for PER
Quoted 9 lines · Richard Henderson
For PER, we require a conditional call to
helper_per_branchfor the conditional branch. Fold the remaining optimization into a call tohelper_goto_direct, which will take care of the remaining gbea adjustment.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
PATCH 17/26 target/s390x: Introduce help_goto_indirect
In reply to Richard HendersonAdd a small helper to handle unconditional indirect jumps.
--- target/s390x/tcg/translate.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
target/s390x/tcg/translate.c +10 -9
@@ -1189,6 +1189,13 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp) } } +static DisasJumpType help_goto_indirect (DisasContext *s,TCGv_i64 dest) +{ +tcg_gen_mov_i64 (psw_addr, dest); +per_branch (s, false); +return DISAS_PC_UPDATED ; +} +static DisasJumpType help_branch (DisasContext *s,DisasCompare *c,bool is_imm,int imm,TCGv_i64 cdest) {
@@ -1219,9 +1226,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, goto egress; }if (c->cond ==TCG_COND_ALWAYS ) { -tcg_gen_mov_i64 (psw_addr, cdest); -per_branch (s, false); - ret =DISAS_PC_UPDATED ; + ret =help_goto_indirect (s, cdest); goto egress; } }
@@ -1545,9 +1550,7 @@ static DisasJumpType op_bas(DisasContext *s, DisasOps *o) {pc_to_link_info (o->out, s);if (o->in2) { -tcg_gen_mov_i64 (psw_addr, o->in2); -per_branch (s, false); -return DISAS_PC_UPDATED ; +return help_goto_indirect (s, o->in2); }else {return DISAS_NEXT ; }
@@ -1580,9 +1583,7 @@ static DisasJumpType op_bal(DisasContext *s, DisasOps *o) {save_link_info (s, o);if (o->in2) { -tcg_gen_mov_i64 (psw_addr, o->in2); -per_branch (s, false); -return DISAS_PC_UPDATED ; +return help_goto_indirect (s, o->in2); }else {return DISAS_NEXT ; }
Signature · 1 line
2.34.1
Re: [PATCH 17/26] target/s390x: Introduce help_goto_indirect
Quoted 6 lines · Richard Henderson
Add a small helper to handle unconditional indirect jumps.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
PATCH 18/26 target/s390x: Split per_branch
In reply to Richard HendersonSplit into per_branch_dest and per_branch_disp, which can be used for direct and indirect. In preperation for TARGET_TB_PCREL, call per_branch_* before indirect branches.
--- target/s390x/tcg/translate.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)
target/s390x/tcg/translate.c +18 -14
@@ -350,21 +350,25 @@ static inline bool per_enabled(DisasContext *s)#endif } -static void per_branch (DisasContext *s,bool to_next) +static void per_branch_dest (DisasContext *s,TCGv_i64 dest) {#ifndef CONFIG_USER_ONLY gen_psw_addr_disp (s, gbea,0 ); +if (s->base.tb->flags &FLAG_MASK_PER ) { +gen_helper_per_branch (cpu_env, gbea, dest); + } +#endif +} -if (per_enabled (s)) { -if (to_next) { -TCGv_i64 next_pc =tcg_temp_new_i64 (); - -gen_psw_addr_disp (s, next_pc, s->ilen); -gen_helper_per_branch (cpu_env, gbea, next_pc); -tcg_temp_free_i64 (next_pc); - }else { -gen_helper_per_branch (cpu_env, gbea, psw_addr); - } +static void per_branch_disp (DisasContext *s,int64_t disp) +{ +#ifndef CONFIG_USER_ONLY +gen_psw_addr_disp (s, gbea,0 ); +if (s->base.tb->flags &FLAG_MASK_PER ) { +TCGv_i64 dest =tcg_temp_new_i64 (); +gen_psw_addr_disp (s, dest, disp); +gen_helper_per_branch (cpu_env, gbea, dest); +tcg_temp_free_i64 (dest); }#endif }
@@ -1172,7 +1176,7 @@ struct DisasInsn {static DisasJumpType help_goto_direct (DisasContext *s,int64_t disp) {if (disp == s->ilen) { -per_branch (s, true); +per_branch_disp (s, disp);return DISAS_NEXT ; }if (use_goto_tb (s, s->base.pc_next + disp)) {
@@ -1184,7 +1188,7 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)return DISAS_NORETURN ; }else {update_psw_addr_disp (s, disp); -per_branch (s, false); +per_branch_dest (s, psw_addr);return DISAS_PC_UPDATED ; } }
@@ -1192,7 +1196,7 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)static DisasJumpType help_goto_indirect (DisasContext *s,TCGv_i64 dest) {tcg_gen_mov_i64 (psw_addr, dest); -per_branch (s, false); +per_branch_dest (s, psw_addr);return DISAS_PC_UPDATED ; }
Signature · 1 line
2.34.1
Re: [PATCH 18/26] target/s390x: Split per_branch
Quoted 40 lines · Richard Henderson
Split into
per_branch_destandper_branch_disp, which can be used for direct and indirect. In preperation forTARGET_TB_PCREL, call per_branch_* before indirect branches.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)target/s390x/tcg/translate.c +8
-11@@ -350,21 +350,25 @@ static inline bool per_enabled(DisasContext *s)#endif } -static void per_branch (DisasContext *s,bool to_next) +static void per_branch_dest (DisasContext *s,TCGv_i64 dest) {#ifndef CONFIG_USER_ONLY gen_psw_addr_disp (s, gbea,0 ); +if (s->base.tb->flags &FLAG_MASK_PER ) { +gen_helper_per_branch (cpu_env, gbea, dest); + } +#endif +} -if (per_enabled (s)) { -if (to_next) { -TCGv_i64 next_pc =tcg_temp_new_i64 (); - -gen_psw_addr_disp (s, next_pc, s->ilen); -gen_helper_per_branch (cpu_env, gbea, next_pc); -tcg_temp_free_i64 (next_pc); - }else { -gen_helper_per_branch (cpu_env, gbea, psw_addr); - } +static void per_branch_disp (DisasContext *s,int64_t disp) +{
target/s390x/tcg/translate.c static inline bool per_enabled(DisasContext *s) · line 374
Quoted 10 lines
target/s390x/tcg/translate.c +7
-0+#ifndef CONFIG_USER_ONLY +gen_psw_addr_disp (s, gbea,0 ); +if (s->base.tb->flags &FLAG_MASK_PER ) { +TCGv_i64 dest =tcg_temp_new_i64 (); +gen_psw_addr_disp (s, dest, disp); +gen_helper_per_branch (cpu_env, gbea, dest); +tcg_temp_free_i64 (dest); }#endif }
...
Nit: maybe use per_enabled(s) instead of testing the mask manually?
PATCH 19/26 target/s390x: Simplify help_branch
In reply to Richard HendersonAlways use a tcg branch, instead of movcond. The movcond was not a bad idea before PER was added, but since then we have either 2 or 3 actions to perform on each leg of the branch, and multiple movcond is inefficient.
Reorder the taken branch to be fallthrough of the tcg branch. This will be helpful later with TARGET_TB_PCREL.
--- target/s390x/tcg/translate.c | 154 ++++++++++------------------------- 1 file changed, 44 insertions(+), 110 deletions(-)
target/s390x/tcg/translate.c +44 -110
@@ -373,28 +373,6 @@ static void per_branch_disp(DisasContext *s, int64_t disp)#endif } -static void per_branch_cond (DisasContext *s,TCGCond cond, -TCGv_i64 arg1,TCGv_i64 arg2) -{ -#ifndef CONFIG_USER_ONLY -if (per_enabled (s)) { -TCGLabel *lab =gen_new_label (); -tcg_gen_brcond_i64 (tcg_invert_cond (cond), arg1, arg2, lab); - -gen_psw_addr_disp (s, gbea,0 ); -gen_helper_per_branch (cpu_env, gbea, psw_addr); - -gen_set_label (lab); - }else { -TCGv_i64 pc =tcg_temp_new_i64 (); - -gen_psw_addr_disp (s, pc,0 ); -tcg_gen_movcond_i64 (cond, gbea, arg1, arg2, gbea, pc); -tcg_temp_free_i64 (pc); - } -#endif -} -static void per_breaking_event (DisasContext *s) {#ifndef CONFIG_USER_ONLY
@@ -1205,7 +1183,6 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, {DisasJumpType ret;int64_t disp = (int64_t )imm *2 ; -uint64_t dest = s->base.pc_next + disp;TCGLabel *lab;/* Take care of the special cases first. */
@@ -1235,96 +1212,53 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, } } -if (use_goto_tb (s, s->base.pc_next + s->ilen)) { -if (is_imm &&use_goto_tb (s, dest)) { -/* Both exits can use goto_tb. */ -update_cc_op (s); +update_cc_op (s); - lab =gen_new_label (); -if (c->is_64) { -tcg_gen_brcond_i64 (c->cond, c->u.s64.a, c->u.s64.b, lab); - }else { -tcg_gen_brcond_i32 (c->cond, c->u.s32.a, c->u.s32.b, lab); - } - -/* Branch not taken. */ -tcg_gen_goto_tb (0 ); -gen_psw_addr_disp (s, psw_addr, s->ilen); -tcg_gen_exit_tb (s->base.tb,0 ); - -/* Branch taken. */ -gen_set_label (lab); -per_breaking_event (s); -tcg_gen_goto_tb (1 ); -gen_psw_addr_disp (s, psw_addr, disp); -tcg_gen_exit_tb (s->base.tb,1 ); - - ret =DISAS_NORETURN ; - }else { -/* Fallthru can use goto_tb, but taken branch cannot. */ -/* Store taken branch destination before the brcond. This -avoids having to allocate a new local temp to hold it. -We'll overwrite this in the not taken case anyway. */ -if (!is_imm) { -tcg_gen_mov_i64 (psw_addr, cdest); - } - - lab =gen_new_label (); -if (c->is_64) { -tcg_gen_brcond_i64 (c->cond, c->u.s64.a, c->u.s64.b, lab); - }else { -tcg_gen_brcond_i32 (c->cond, c->u.s32.a, c->u.s32.b, lab); - } - -/* Branch not taken. */ -update_cc_op (s); -tcg_gen_goto_tb (0 ); -gen_psw_addr_disp (s, psw_addr, s->ilen); -tcg_gen_exit_tb (s->base.tb,0 ); - -gen_set_label (lab); -if (is_imm) { -gen_psw_addr_disp (s, psw_addr, disp); - } -per_breaking_event (s); - ret =DISAS_PC_UPDATED ; - } - }else { -/* Fallthru cannot use goto_tb. This by itself is vanishingly rare. -Most commonly we're single-stepping or some other condition that -disables all use of goto_tb. Just update the PC and exit. */ - -TCGv_i64 next =tcg_temp_new_i64 (); - -gen_psw_addr_disp (s, next, s->ilen); -if (is_imm) { - cdest =tcg_temp_new_i64 (); -gen_psw_addr_disp (s, cdest, disp); - } - -if (c->is_64) { -tcg_gen_movcond_i64 (c->cond, psw_addr, c->u.s64.a, c->u.s64.b, - cdest, next); -per_branch_cond (s, c->cond, c->u.s64.a, c->u.s64.b); - }else { -TCGv_i32 t0 =tcg_temp_new_i32 (); -TCGv_i64 t1 =tcg_temp_new_i64 (); -TCGv_i64 z =tcg_constant_i64 (0 ); -tcg_gen_setcond_i32 (c->cond, t0, c->u.s32.a, c->u.s32.b); -tcg_gen_extu_i32_i64 (t1, t0); -tcg_temp_free_i32 (t0); -tcg_gen_movcond_i64 (TCG_COND_NE , psw_addr, t1, z, cdest, next); -per_branch_cond (s,TCG_COND_NE , t1, z); -tcg_temp_free_i64 (t1); - } - -tcg_temp_free_i64 (next); -if (is_imm) { -tcg_temp_free_i64 (cdest); - } - ret =DISAS_PC_UPDATED ; +/* +* Store taken branch destination before the brcond. This +* avoids having to allocate a new local temp to hold it. +* We'll overwrite this in the not taken case anyway. +*/ +if (!is_imm) { +tcg_gen_mov_i64 (psw_addr, cdest); } + lab =gen_new_label (); +if (c->is_64) { +tcg_gen_brcond_i64 (tcg_invert_cond (c->cond), + c->u.s64.a, c->u.s64.b, lab); + }else { +tcg_gen_brcond_i32 (tcg_invert_cond (c->cond), + c->u.s32.a, c->u.s32.b, lab); + } + +/* Branch taken. */ +if (is_imm) { +gen_psw_addr_disp (s, psw_addr, disp); + } +per_branch_dest (s, psw_addr); + +if (is_imm &&use_goto_tb (s, s->base.pc_next + disp)) { +tcg_gen_goto_tb (0 ); +tcg_gen_exit_tb (s->base.tb,0 ); + }else { +tcg_gen_lookup_and_goto_ptr (); + } + +gen_set_label (lab); + +/* Branch not taken. */ +if (use_goto_tb (s, s->base.pc_next + s->ilen)) { +tcg_gen_goto_tb (1 ); +gen_psw_addr_disp (s, psw_addr, s->ilen); +tcg_gen_exit_tb (s->base.tb,1 ); + }else { +gen_psw_addr_disp (s, psw_addr, s->ilen); +tcg_gen_lookup_and_goto_ptr (); + } + + ret =DISAS_NORETURN ; + egress:free_compare (c);return ret;
Signature · 1 line
2.34.1
Re: [PATCH 19/26] target/s390x: Simplify help_branch
Quoted 5 lines · Richard Henderson
Always use a tcg branch, instead of movcond. The movcond was not a bad idea before PER was added, but since then we have either 2 or 3 actions to perform on each leg of the branch, and multiple movcond is inefficient.
Quoted 7 lines
Reorder the taken branch to be fallthrough of the tcg branch. This will be helpful later with
TARGET_TB_PCREL.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 154 ++++++++++------------------------- 1 file changed, 44 insertions(+), 110 deletions(-)
PATCH 20/26 target/s390x: Split per_breaking_event from per_branch_*
In reply to Richard HendersonThis allows us to update gbea before other updates to psw_addr, which will be important for TARGET_TB_PCREL.
--- target/s390x/tcg/translate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
target/s390x/tcg/translate.c +4 -3
@@ -353,7 +353,6 @@ static inline bool per_enabled(DisasContext *s)static void per_branch_dest (DisasContext *s,TCGv_i64 dest) {#ifndef CONFIG_USER_ONLY -gen_psw_addr_disp (s, gbea,0 );if (s->base.tb->flags &FLAG_MASK_PER ) {gen_helper_per_branch (cpu_env, gbea, dest); }
@@ -363,7 +362,6 @@ static void per_branch_dest(DisasContext *s, TCGv_i64 dest)static void per_branch_disp (DisasContext *s,int64_t disp) {#ifndef CONFIG_USER_ONLY -gen_psw_addr_disp (s, gbea,0 );if (s->base.tb->flags &FLAG_MASK_PER ) {TCGv_i64 dest =tcg_temp_new_i64 ();gen_psw_addr_disp (s, dest, disp);
@@ -1153,13 +1151,14 @@ struct DisasInsn {static DisasJumpType help_goto_direct (DisasContext *s,int64_t disp) { +per_breaking_event (s); +if (disp == s->ilen) {per_branch_disp (s, disp);return DISAS_NEXT ; }if (use_goto_tb (s, s->base.pc_next + disp)) {update_cc_op (s); -per_breaking_event (s);tcg_gen_goto_tb (0 );update_psw_addr_disp (s, disp);tcg_gen_exit_tb (s->base.tb,0 );
@@ -1173,6 +1172,7 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)static DisasJumpType help_goto_indirect (DisasContext *s,TCGv_i64 dest) { +per_breaking_event (s);tcg_gen_mov_i64 (psw_addr, dest);per_branch_dest (s, psw_addr);return DISAS_PC_UPDATED ;
@@ -1233,6 +1233,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, }/* Branch taken. */ +per_breaking_event (s);if (is_imm) {gen_psw_addr_disp (s, psw_addr, disp); }
Signature · 1 line
2.34.1
Re: [PATCH 20/26] target/s390x: Split per_breaking_event from per_branch_*
Quoted 7 lines · Richard Henderson
This allows us to update gbea before other updates to
psw_addr, which will be important forTARGET_TB_PCREL.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
PATCH 21/26 target/s390x: Remove PER check from use_goto_tb
In reply to Richard HendersonWhile it is common for the PC update to happen in the shadow of a goto_tb, it is not required to be there. By moving it before the goto_tb, we can also place the call to helper_per_branch there, and then afterward chain to the next tb.
--- target/s390x/tcg/translate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
target/s390x/tcg/translate.c +4 -6
@@ -654,9 +654,6 @@ static void gen_op_calc_cc(DisasContext *s)static bool use_goto_tb (DisasContext *s,uint64_t dest) { -if (per_enabled (s)) { -return false; - }return translator_use_goto_tb (&s->base, dest); }
@@ -1157,15 +1154,16 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)per_branch_disp (s, disp);return DISAS_NEXT ; } + +update_psw_addr_disp (s, disp); +per_branch_dest (s, psw_addr); +if (use_goto_tb (s, s->base.pc_next + disp)) {update_cc_op (s);tcg_gen_goto_tb (0 ); -update_psw_addr_disp (s, disp);tcg_gen_exit_tb (s->base.tb,0 );return DISAS_NORETURN ; }else { -update_psw_addr_disp (s, disp); -per_branch_dest (s, psw_addr);return DISAS_PC_UPDATED ; } }
Signature · 1 line
2.34.1
Re: [PATCH 21/26] target/s390x: Remove PER check from use_goto_tb
Quoted 47 lines · Richard Henderson
While it is common for the PC update to happen in the shadow of a
goto_tb, it is not required to be there. By moving it before thegoto_tb, we can also place the call tohelper_per_branchthere, and then afterward chain to the next tb.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)target/s390x/tcg/translate.c +4
-6@@ -654,9 +654,6 @@ static void gen_op_calc_cc(DisasContext *s)static bool use_goto_tb (DisasContext *s,uint64_t dest) { -if (per_enabled (s)) { -return false; - }return translator_use_goto_tb (&s->base, dest); }@@ -1157,15 +1154,16 @@ static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)per_branch_disp (s, disp);return DISAS_NEXT ; } + +update_psw_addr_disp (s, disp); +per_branch_dest (s, psw_addr); +if (use_goto_tb (s, s->base.pc_next + disp)) {update_cc_op (s);tcg_gen_goto_tb (0 ); -update_psw_addr_disp (s, disp);tcg_gen_exit_tb (s->base.tb,0 );return DISAS_NORETURN ; }else { -update_psw_addr_disp (s, disp); -per_branch_dest (s, psw_addr);return DISAS_PC_UPDATED ; } }Signature · 1 line
2.34.1
While looking at this, I had a hard time convincing myself that successful-branch PER events work at all. The code does set per_perc_atmid, but afterwards it does goto_tb/exit_tb, and does not reach per_check_exception() added by translate_one().
I wrote a small test for this theory by turning on PER for successful-branch events and looping 10 times. It passes in KVM, but fails in TCG. Here is the relevant IR fragment:
IN:0x00000212: a706 0000 brct %r0, 0x212
OP:
ld_i32 tmp0,env,$0xfffffffffffffff0
brcond_i32 tmp0,$0x0,lt,$L0
---- 0000000000000212 0000000000000004 0000000000000004 mov_i64 tmp2,psw_addr
call per_ifetch,$0x1,$0,env,tmp2
sub_i64 tmp2,r0,$0x1
extract2_i64 r0,r0,tmp2,$0x20
rotl_i64 r0,r0,$0x20
mov_i32 tmp0,tmp2
brcond_i32 tmp0,$0x0,eq,$L1
/* branch taken: set per_perc_atmid and exit */ mov_i64 gbea,psw_addr
call per_branch,$0x1,$0,env,gbea,psw_addr goto_tb $0x0
exit_tb $0x7f73fc000400
set_label $L1
add_i64 psw_addr,psw_addr,$0x4
goto_tb $0x1
exit_tb $0x7f73fc000401
/* check per_perc_atmid */
call per_check_exception,$0x0,$0,env
set_label $L0
exit_tb $0x7f73fc000403
I will post the proposed fix and the test itself shortly.
That said, the patch makes sense to me and does not make things worse, so:
PATCH 1/2 target/s390x: Fix successful-branch PER events
The branching code sets per_perc_atmid, but afterwards it does goto_tb/exit_tb, so per_check_exception() added by translate_one() is not reached.
Fix by raising PER exception in per_branch().
--- target/s390x/tcg/misc_helper.c | 1 + 1 file changed, 1 insertion(+)
target/s390x/tcg/misc_helper.c +1 -0
@@ -619,6 +619,7 @@ void HELPER(per_branch)(CPUS390XState *env, uint64_t from, uint64_t to) || get_per_in_range(env, to)) { env->per_address = from; env->per_perc_atmid =PER_CODE_EVENT_BRANCH |get_per_atmid (env); +tcg_s390_program_interrupt (env,PGM_PER ,GETPC ()); } } }
Signature · 1 line
2.38.1
PATCH 2/2 tests/tcg/s390x: Add per.S
Add a small test to avoid regressions.
--- tests/tcg/s390x/Makefile.softmmu-target | 1 + tests/tcg/s390x/per.S | 55 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/tcg/s390x/per.S
tests/tcg/s390x/Makefile.softmmu-target +1 -0
@@ -7,3 +7,4 @@ QEMU_OPTS=-action panic=exit-failure -kernel -Wl,--build-id=none $< -o $@ TESTS += unaligned-lowcore +TESTS += per
tests/tcg/s390x/per.S new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.38.1
PATCH 22/26 target/s390x: Pass original r2 register to BCR
In reply to Richard HendersonWe do not modify any general-purpose registers in BCR, which means that we may be able to avoid saving the value across a branch.
--- target/s390x/tcg/translate.c | 10 ++++++++++ target/s390x/tcg/insn-data.def | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
target/s390x/tcg/translate.c +10 -0
@@ -5704,6 +5704,16 @@ static void in2_r2_nz(DisasContext *s, DisasOps *o) }#define SPEC_in2_r2_nz 0 +static void in2_r2_o_nz (DisasContext *s,DisasOps *o) +{ +int r2 =get_field (s, r2); +if (r2 !=0 ) { + o->in2 = regs[r2]; + o->g_in2 = true; + } +} +#define SPEC_in2_r2_o_nz 0 +static void in2_r2_8s (DisasContext *s,DisasOps *o) { o->in2 =tcg_temp_new_i64 ();
target/s390x/tcg/insn-data.def +1 -1
@@ -121,7 +121,7 @@ /* BRANCH INDIRECT ON CONDITION */ C(0xe347, BIC, RXY_b, MIE2,0, m2_64w, 0, 0, bc, 0) /* BRANCH ON CONDITION */ - C(0x0700, BCR, RR_b, Z, 0, r2_nz, 0, 0, bc, 0) + C(0x0700, BCR, RR_b, Z, 0, r2_o_nz, 0, 0, bc, 0) C(0x4700, BC, RX_b, Z, 0, a2, 0, 0, bc, 0) /* BRANCH RELATIVE ON CONDITION */ C(0xa704, BRC, RI_c, Z, 0, 0, 0, 0, bc, 0)
Signature · 1 line
2.34.1
Re: [PATCH 22/26] target/s390x: Pass original r2 register to BCR
Quoted 9 lines · Richard Henderson
We do not modify any general-purpose registers in BCR, which means that we may be able to avoid saving the value across a branch.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg/translate.c | 10 ++++++++++ target/s390x/tcg/insn-data.def | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
PATCH 23/26 tcg: Pass TCGTempKind to tcg_temp_new_internal
In reply to Richard Henderson--- include/tcg/tcg.h | 14 +++++++------- tcg/tcg.c | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-)
include/tcg/tcg.h +7 -7
@@ -846,7 +846,7 @@ void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size);TCGTemp *tcg_global_mem_new_internal (TCGType ,TCGv_ptr ,intptr_t ,const char *); -TCGTemp *tcg_temp_new_internal (TCGType ,bool ); +TCGTemp *tcg_temp_new_internal (TCGType ,TCGTempKind kind);void tcg_temp_free_internal (TCGTemp *);TCGv_vec tcg_temp_new_vec (TCGType type);TCGv_vec tcg_temp_new_vec_matching (TCGv_vec match);
@@ -880,13 +880,13 @@ static inline TCGv_i32 tcg_global_mem_new_i32(TCGv_ptr reg, intptr_t offset,static inline TCGv_i32 tcg_temp_new_i32 (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 , false); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 ,TEMP_NORMAL );return temp_tcgv_i32 (t); }static inline TCGv_i32 tcg_temp_local_new_i32 (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 , true); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 ,TEMP_LOCAL );return temp_tcgv_i32 (t); }
@@ -899,13 +899,13 @@ static inline TCGv_i64 tcg_global_mem_new_i64(TCGv_ptr reg, intptr_t offset,static inline TCGv_i64 tcg_temp_new_i64 (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 , false); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 ,TEMP_NORMAL );return temp_tcgv_i64 (t); }static inline TCGv_i64 tcg_temp_local_new_i64 (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 , true); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 ,TEMP_LOCAL );return temp_tcgv_i64 (t); }
@@ -918,13 +918,13 @@ static inline TCGv_ptr tcg_global_mem_new_ptr(TCGv_ptr reg, intptr_t offset,static inline TCGv_ptr tcg_temp_new_ptr (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR , false); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR ,TEMP_NORMAL );return temp_tcgv_ptr (t); }static inline TCGv_ptr tcg_temp_local_new_ptr (void ) { -TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR , true); +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR ,TEMP_LOCAL );return temp_tcgv_ptr (t); }
tcg/tcg.c +15 -5
@@ -942,14 +942,24 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base,return ts; } -TCGTemp *tcg_temp_new_internal (TCGType type,bool temp_local) +TCGTemp *tcg_temp_new_internal (TCGType type,TCGTempKind kind) {TCGContext *s = tcg_ctx; -TCGTempKind kind = temp_local ?TEMP_LOCAL :TEMP_NORMAL ;TCGTemp *ts;int idx, k; - k = type + (temp_local ?TCG_TYPE_COUNT :0 ); +switch (kind) { +case TEMP_NORMAL : + k =0 ; +break ; +case TEMP_LOCAL : + k =TCG_TYPE_COUNT ; +break ; +default : +g_assert_not_reached (); + } + k += type; + idx =find_first_bit (s->free_temps[k].l,TCG_MAX_TEMPS );if (idx <TCG_MAX_TEMPS ) {/* There is already an available temp with the right type. */
@@ -1008,7 +1018,7 @@ TCGv_vec tcg_temp_new_vec(TCGType type) }#endif - t =tcg_temp_new_internal (type,0 ); + t =tcg_temp_new_internal (type,TEMP_NORMAL );return temp_tcgv_vec (t); }
@@ -1019,7 +1029,7 @@ TCGv_vec tcg_temp_new_vec_matching(TCGv_vec match)tcg_debug_assert (t->temp_allocated !=0 ); - t =tcg_temp_new_internal (t->base_type,0 ); + t =tcg_temp_new_internal (t->base_type,TEMP_NORMAL );return temp_tcgv_vec (t); }
Signature · 1 line
2.34.1
Re: [PATCH 23/26] tcg: Pass TCGTempKind to tcg_temp_new_internal
Quoted 6 lines · Richard Henderson
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- include/tcg/tcg.h | 14 +++++++------- tcg/tcg.c | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-)
PATCH 24/26 tcg: Introduce tcg_temp_ebb_new_*
In reply to Richard HendersonAllow targets to allocate extended-basic-block temps.
--- include/tcg/tcg-op.h | 2 ++ include/tcg/tcg.h | 20 +++++++++++++++++++- tcg/tcg.c | 16 ++++------------ 3 files changed, 25 insertions(+), 13 deletions(-)
include/tcg/tcg-op.h +2 -0
@@ -848,6 +848,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_new () tcg_temp_new_i32()#define tcg_global_mem_new tcg_global_mem_new_i32#define tcg_temp_local_new () tcg_temp_local_new_i32() +#define tcg_temp_ebb_new () tcg_temp_ebb_new_i32()#define tcg_temp_free tcg_temp_free_i32#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i32#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32
@@ -855,6 +856,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_new () tcg_temp_new_i64()#define tcg_global_mem_new tcg_global_mem_new_i64#define tcg_temp_local_new () tcg_temp_local_new_i64() +#define tcg_temp_ebb_new () tcg_temp_ebb_new_i64()#define tcg_temp_free tcg_temp_free_i64#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i64#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i64
include/tcg/tcg.h +19 -1
@@ -609,7 +609,7 @@ struct TCGContext {#endif GHashTable *const_table[TCG_TYPE_COUNT ]; -TCGTempSet free_temps[TCG_TYPE_COUNT *2 ]; +TCGTempSet free_temps[TCG_TYPE_COUNT *3 ];TCGTemp temps[TCG_MAX_TEMPS ];/* globals first, temps after */ QTAILQ_HEAD(, TCGOp) ops, free_ops;
@@ -890,6 +890,12 @@ static inline TCGv_i32 tcg_temp_local_new_i32(void)return temp_tcgv_i32 (t); } +static inline TCGv_i32 tcg_temp_ebb_new_i32 (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 ,TEMP_EBB ); +return temp_tcgv_i32 (t); +} +static inline TCGv_i64 tcg_global_mem_new_i64 (TCGv_ptr reg,intptr_t offset,const char *name) {
@@ -909,6 +915,12 @@ static inline TCGv_i64 tcg_temp_local_new_i64(void)return temp_tcgv_i64 (t); } +static inline TCGv_i64 tcg_temp_ebb_new_i64 (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 ,TEMP_EBB ); +return temp_tcgv_i64 (t); +} +static inline TCGv_ptr tcg_global_mem_new_ptr (TCGv_ptr reg,intptr_t offset,const char *name) {
@@ -928,6 +940,12 @@ static inline TCGv_ptr tcg_temp_local_new_ptr(void)return temp_tcgv_ptr (t); } +static inline TCGv_ptr tcg_temp_ebb_new_ptr (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR ,TEMP_EBB ); +return temp_tcgv_ptr (t); +} +#if defined(CONFIG_DEBUG_TCG )/* If you call tcg_clear_temp_count() at the start of a section of * code which is not supposed to leak any TCG temporaries, then
tcg/tcg.c +4 -12
@@ -948,17 +948,8 @@ TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind)TCGTemp *ts;int idx, k; -switch (kind) { -case TEMP_NORMAL : - k =0 ; -break ; -case TEMP_LOCAL : - k =TCG_TYPE_COUNT ; -break ; -default : -g_assert_not_reached (); - } - k += type; +assert (kind >=TEMP_NORMAL && kind <=TEMP_LOCAL ); + k =TCG_TYPE_COUNT * kind + type; idx =find_first_bit (s->free_temps[k].l,TCG_MAX_TEMPS );if (idx <TCG_MAX_TEMPS ) {
@@ -1046,6 +1037,7 @@ void tcg_temp_free_internal(TCGTemp *ts)*/ return ;case TEMP_NORMAL : +case TEMP_EBB :case TEMP_LOCAL :break ;default :
@@ -1063,7 +1055,7 @@ void tcg_temp_free_internal(TCGTemp *ts) ts->temp_allocated =0 ; idx =temp_idx (ts); - k = ts->base_type + (ts->kind ==TEMP_NORMAL ?0 :TCG_TYPE_COUNT ); + k = ts->base_type + ts->kind *TCG_TYPE_COUNT ;set_bit (idx, s->free_temps[k].l); }
Signature · 1 line
2.34.1
Re: [PATCH 24/26] tcg: Introduce tcg_temp_ebb_new_*
Quoted 91 lines · Richard Henderson
Allow targets to allocate extended-basic-block temps.
Signed-off-by Richard Henderson <[email protected]>--- include/tcg/tcg-op.h | 2 ++ include/tcg/tcg.h | 20 +++++++++++++++++++- tcg/tcg.c | 16 ++++------------ 3 files changed, 25 insertions(+), 13 deletions(-)include/tcg/tcg-op.h +2
-0@@ -848,6 +848,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_new () tcg_temp_new_i32()#define tcg_global_mem_new tcg_global_mem_new_i32#define tcg_temp_local_new () tcg_temp_local_new_i32() +#define tcg_temp_ebb_new () tcg_temp_ebb_new_i32()#define tcg_temp_free tcg_temp_free_i32#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i32#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32@@ -855,6 +856,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_new () tcg_temp_new_i64()#define tcg_global_mem_new tcg_global_mem_new_i64#define tcg_temp_local_new () tcg_temp_local_new_i64() +#define tcg_temp_ebb_new () tcg_temp_ebb_new_i64()#define tcg_temp_free tcg_temp_free_i64#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i64#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i64include/tcg/tcg.h +19
-1@@ -609,7 +609,7 @@ struct TCGContext {#endif GHashTable *const_table[TCG_TYPE_COUNT ]; -TCGTempSet free_temps[TCG_TYPE_COUNT *2 ]; +TCGTempSet free_temps[TCG_TYPE_COUNT *3 ];TCGTemp temps[TCG_MAX_TEMPS ];/* globals first, temps after */ QTAILQ_HEAD(, TCGOp) ops, free_ops;@@ -890,6 +890,12 @@ static inline TCGv_i32 tcg_temp_local_new_i32(void)return temp_tcgv_i32 (t); } +static inline TCGv_i32 tcg_temp_ebb_new_i32 (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I32 ,TEMP_EBB ); +return temp_tcgv_i32 (t); +} +static inline TCGv_i64 tcg_global_mem_new_i64 (TCGv_ptr reg,intptr_t offset,const char *name) {@@ -909,6 +915,12 @@ static inline TCGv_i64 tcg_temp_local_new_i64(void)return temp_tcgv_i64 (t); } +static inline TCGv_i64 tcg_temp_ebb_new_i64 (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_I64 ,TEMP_EBB ); +return temp_tcgv_i64 (t); +} +static inline TCGv_ptr tcg_global_mem_new_ptr (TCGv_ptr reg,intptr_t offset,const char *name) {@@ -928,6 +940,12 @@ static inline TCGv_ptr tcg_temp_local_new_ptr(void)return temp_tcgv_ptr (t); } +static inline TCGv_ptr tcg_temp_ebb_new_ptr (void ) +{ +TCGTemp *t =tcg_temp_new_internal (TCG_TYPE_PTR ,TEMP_EBB ); +return temp_tcgv_ptr (t); +} +#if defined(CONFIG_DEBUG_TCG )/* If you call tcg_clear_temp_count() at the start of a section of * code which is not supposed to leak any TCG temporaries, then tcg/tcg.c +0
-2@@ -948,17 +948,8 @@ TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind)TCGTemp *ts;int idx, k; -switch (kind) { -case TEMP_NORMAL :
tcg/tcg.c TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) · line 951
Quoted 10 lines
tcg/tcg.c +1
-9- k =0 ; -break ; -case TEMP_LOCAL : - k =TCG_TYPE_COUNT ; -break ; -default : -g_assert_not_reached (); - } - k += type; +assert (kind >=TEMP_NORMAL && kind <=TEMP_LOCAL );
Nit: maybe also add QEMU_BUILD_BUG_ON(TEMP_NORMAL != 0) and QEMU_BUILD_BUG_ON(TEMP_LOCAL != 2), since we are using this for 0-based array indexing here? Alternatively, subtract TEMP_NORMAL from kind.
Quoted 25 lines
tcg/tcg.c +3
-1+ k =TCG_TYPE_COUNT * kind + type; idx =find_first_bit (s->free_temps[k].l,TCG_MAX_TEMPS );if (idx <TCG_MAX_TEMPS ) {@@ -1046,6 +1037,7 @@ void tcg_temp_free_internal(TCGTemp *ts)*/ return ;case TEMP_NORMAL : +case TEMP_EBB :case TEMP_LOCAL :break ;default :@@ -1063,7 +1055,7 @@ void tcg_temp_free_internal(TCGTemp *ts) ts->temp_allocated =0 ; idx =temp_idx (ts); - k = ts->base_type + (ts->kind ==TEMP_NORMAL ?0 :TCG_TYPE_COUNT ); + k = ts->base_type + ts->kind *TCG_TYPE_COUNT ;set_bit (idx, s->free_temps[k].l); }Signature · 1 line
2.34.1
While not directly related to this patch, it would be good to update tcg/README with all the new kinds of temporaries. E.g. the EBB ones are not mentioned there:
TCG instructions operate on variables which are temporaries, local temporaries or globals.
Re: [PATCH 24/26] tcg: Introduce tcg_temp_ebb_new_*
Quoted 8 lines · Ilya Leoshkevich
Reviewed-by Ilya Leoshkevich <[email protected]>While not directly related to this patch, it would be good to update tcg/README with all the new kinds of temporaries. E.g. the EBB ones are not mentioned there:
TCG instructions operate on variables which are temporaries, local temporaries or globals.
Thanks for the review on this.
I'm not sure I want to take this anymore. It's confusing to use. I really think what I should do instead is improve the TCG register allocator.
r~
Re: [PATCH 24/26] tcg: Introduce tcg_temp_ebb_new_*
Quoted 9 lines · Richard Henderson
Quoted 7 lines · Ilya Leoshkevich
Reviewed-by Ilya Leoshkevich <[email protected]>While not directly related to this patch, it would be good to update tcg/README with all the new kinds of temporaries. E.g. the EBB ones are not mentioned there:
TCG instructions operate on variables which are temporaries,
local
temporaries or globals.
Quoted 5 lines
Thanks for the review on this.
I'm not sure I want to take this anymore. It's confusing to use. I really think what I should do instead is improve the TCG register allocator.
Whats the ultimate aim for the rewrite? Hold values in target registers over the extended block? What about avoid spills between potential fault points?
Quoted 3 lines
r~
Signature · 1 line
Alex Bennée
Re: [PATCH 24/26] tcg: Introduce tcg_temp_ebb_new_*
Quoted 7 lines · Alex Bennée
Quoted 3 lines
I'm not sure I want to take this anymore. It's confusing to use. I really think what I should do instead is improve the TCG register allocator.
Whats the ultimate aim for the rewrite? Hold values in target registers over the extended block? What about avoid spills between potential fault points?
Primary goal is to handle register allocation across basic blocks without front end translators needing to consider "local" vs "temporary". Which would also allow any use of branches in the middle-end, where we currently have to worry about accidentally killing temporaries held by the front end. That's where this patch fails, in that it makes the current situation even more complicated.
Secondary goal would be proper register allocation across basic blocks.
Tertiary goal would be single-assignment form, to allow better optimizations.
I'll have to do some research before committing to do anything in this area.
r~
PATCH 25/26 tcg: Introduce tcg_temp_is_normal_*
In reply to Richard HendersonAllow targets to determine if a given temp will die across a branch.
--- include/tcg/tcg-op.h | 2 ++ include/tcg/tcg.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+)
include/tcg/tcg-op.h +2 -0
@@ -850,6 +850,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_local_new () tcg_temp_local_new_i32()#define tcg_temp_ebb_new () tcg_temp_ebb_new_i32()#define tcg_temp_free tcg_temp_free_i32 +#define tcg_temp_is_normal tcg_temp_is_normal_i32#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i32#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32#else
@@ -858,6 +859,7 @@ static inline void tcg_gen_plugin_cb_end(void)#define tcg_temp_local_new () tcg_temp_local_new_i64()#define tcg_temp_ebb_new () tcg_temp_ebb_new_i64()#define tcg_temp_free tcg_temp_free_i64 +#define tcg_temp_is_normal tcg_temp_is_normal_i64#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i64#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i64#endif
include/tcg/tcg.h +15 -0
@@ -871,6 +871,21 @@ static inline void tcg_temp_free_vec(TCGv_vec arg)tcg_temp_free_internal (tcgv_vec_temp (arg)); } +static inline bool tcg_temp_is_normal_i32 (TCGv_i32 arg) +{ +return tcgv_i32_temp (arg)->kind ==TEMP_NORMAL ; +} + +static inline bool tcg_temp_is_normal_i64 (TCGv_i64 arg) +{ +return tcgv_i64_temp (arg)->kind ==TEMP_NORMAL ; +} + +static inline bool tcg_temp_is_normal_ptr (TCGv_ptr arg) +{ +return tcgv_ptr_temp (arg)->kind ==TEMP_NORMAL ; +} +static inline TCGv_i32 tcg_global_mem_new_i32 (TCGv_ptr reg,intptr_t offset,const char *name) {
Signature · 1 line
2.34.1
Re: [PATCH 25/26] tcg: Introduce tcg_temp_is_normal_*
Quoted 8 lines · Richard Henderson
Allow targets to determine if a given temp will die across a branch.
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- include/tcg/tcg-op.h | 2 ++ include/tcg/tcg.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+)
PATCH 26/26 target/s390x: Enable TARGET_TB_PCREL
In reply to Richard Henderson--- target/s390x/cpu-param.h | 1 + target/s390x/cpu.c | 12 +++++ target/s390x/tcg/translate.c | 88 +++++++++++++++++++++++------------- 3 files changed, 69 insertions(+), 32 deletions(-)
target/s390x/cpu-param.h +1 -0
@@ -13,5 +13,6 @@#define TARGET_PHYS_ADDR_SPACE_BITS 64#define TARGET_VIRT_ADDR_SPACE_BITS 64#define NB_MMU_MODES 4 +#define TARGET_TB_PCREL 1#endif
target/s390x/cpu.c +12 -0
@@ -35,6 +35,7 @@#include "fpu/softfloat-helpers.h" #include "disas/capstone.h" #include "sysemu/tcg.h" +#include "exec/exec-all.h" #define CR0_RESET 0xE0UL#define CR14_RESET 0xC2000000UL;
@@ -81,6 +82,16 @@ uint64_t s390_cpu_get_psw_mask(CPUS390XState *env)return r; } +static void s390_cpu_synchronize_from_tb (CPUState *cs, +const TranslationBlock *tb) +{ +/* The program counter is always up to date with TARGET_TB_PCREL. */ +if (!TARGET_TB_PCREL ) { +S390CPU *cpu =S390_CPU (cs); + cpu->env.psw.addr =tb_pc (tb); + } +} +static void s390_cpu_set_pc (CPUState *cs,vaddr value) {S390CPU *cpu =S390_CPU (cs);
@@ -272,6 +283,7 @@ static void s390_cpu_reset_full(DeviceState *dev)static const struct TCGCPUOps s390_tcg_ops = { .initialize = s390x_translate_init, + .synchronize_from_tb = s390_cpu_synchronize_from_tb, #ifdef CONFIG_USER_ONLY .record_sigsegv = s390_cpu_record_sigsegv,
target/s390x/tcg/translate.c +56 -32
167 lines not on this page · raw message
Signature · 1 line
2.34.1
Ping.
Quoted 51 lines · Richard Henderson
This is the S390 specific changes required to reduce the amount of translation for address space randomization.
Begin with some generic cleanups, then prepare by using displacements instead of addresses when possible, then add some tcg infrastructure to avoid a code gen ugly, then finalize the conversion.
r~
Richard Henderson (26):
target/s390x: Use tcg_constant_* in local contexts target/s390x: Use tcg_constant_* for DisasCompare target/s390x: Use tcg_constant_i32 for fpinst_extract_m34 target/s390x: Use tcg_constant_* in translate_vx.c.inc target/s390x: Change help_goto_direct to work on displacements target/s390x: Introduce gen_psw_addr_disp target/s390x: Remove pc argument to pc_to_link_into target/s390x: Use gen_psw_addr_disp in pc_to_link_info target/s390x: Use gen_psw_addr_disp in save_link_info target/s390x: Use gen_psw_addr_disp in op_sam target/s390x: Use ilen instead in branches target/s390x: Move masking of psw.addr to cpu_get_tb_cpu_state target/s390x: Add disp argument to update_psw_addr target/s390x: Don't set gbea for user-only target/s390x: Introduce per_enabled target/s390x: Disable conditional branch-to-next for PER target/s390x: Introduce help_goto_indirect target/s390x: Split per_branch target/s390x: Simplify help_branch target/s390x: Split per_breaking_event from per_branch_* target/s390x: Remove PER check from use_goto_tb target/s390x: Pass original r2 register to BCR tcg: Pass TCGTempKind to tcg_temp_new_internal tcg: Introduce tcg_temp_ebb_new_* tcg: Introduce tcg_temp_is_normal_* target/s390x: Enable TARGET_TB_PCRELinclude/tcg/tcg-op.h | 4 + include/tcg/tcg.h | 49 +- target/s390x/cpu-param.h | 1 + target/s390x/cpu.h | 13 +- target/s390x/cpu.c | 12 + target/s390x/tcg/translate.c | 858 ++++++++++++---------------- tcg/tcg.c | 14 +- target/s390x/tcg/translate_vx.c.inc | 45 +- target/s390x/tcg/insn-data.def | 2 +- 9 files changed, 461 insertions(+), 537 deletions(-)