target/i386: extract common bits of gen_repz/gen_repz_nz
PATCH 1/1 target/i386: extract common bits of gen_repz/gen_repz_nz
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from gen_repz and gen_repz_nz.
Based-on: <[email protected]>
---
This was requested in the review of "target/i386: optimize string operations"
target/i386/tcg/translate.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-)
target/i386/tcg/translate.c +14 -20
@@ -688,14 +688,6 @@ static inline void gen_string_movl_A0_EDI(DisasContext *s)gen_lea_v_seg (s, cpu_regs[R_EDI ],R_ES ,-1 ); } -static inline TCGv gen_compute_Dshift (DisasContext *s,MemOp ot) -{ -TCGv dshift =tcg_temp_new (); -tcg_gen_ld32s_tl (dshift, tcg_env, offsetof(CPUX86State , df)); -tcg_gen_shli_tl (dshift, dshift, ot); -return dshift; -}; -static TCGv gen_ext_tl (TCGv dst,TCGv src,MemOp size,bool sign) {if (size ==MO_TL ) {
@@ -1446,29 +1438,31 @@ static void do_gen_rep(DisasContext *s, MemOp ot, TCGv dshift,gen_jmp_rel_csize (s,0 ,1 ); } -static void gen_repz (DisasContext *s,MemOp ot, -void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) - +static void do_gen_string (DisasContext *s,MemOp ot, +void (*fn)(DisasContext *s,MemOp ot,TCGv dshift), +bool is_repz_nz) { -TCGv dshift =gen_compute_Dshift (s, ot); +TCGv dshift =tcg_temp_new (); +tcg_gen_ld32s_tl (dshift, tcg_env, offsetof(CPUX86State , df)); +tcg_gen_shli_tl (dshift, dshift, ot);if (s->prefix & (PREFIX_REPZ |PREFIX_REPNZ )) { -do_gen_rep (s, ot, dshift, fn, false); +do_gen_rep (s, ot, dshift, fn, is_repz_nz); }else {fn (s, ot, dshift); } } +static void gen_repz (DisasContext *s,MemOp ot, +void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) +{ +do_gen_string (s, ot, fn, false); +} +static void gen_repz_nz (DisasContext *s,MemOp ot,void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) { -TCGv dshift =gen_compute_Dshift (s, ot); - -if (s->prefix & (PREFIX_REPZ |PREFIX_REPNZ )) { -do_gen_rep (s, ot, dshift, fn, true); - }else { -fn (s, ot, dshift); - } +do_gen_string (s, ot, fn, true); }static void gen_helper_fp_arith_ST0_FT0 (int op)
Signature · 1 line
2.47.1
PATCH 1/1 target/i386: extract common bits of gen_repz/gen_repz_nz
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from gen_repz and gen_repz_nz.
--- target/i386/tcg/translate.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-)
target/i386/tcg/translate.c +14 -20
@@ -695,14 +695,6 @@ static inline void gen_string_movl_A0_EDI(DisasContext *s)gen_lea_v_seg (s, cpu_regs[R_EDI ],R_ES ,-1 ); } -static inline TCGv gen_compute_Dshift (DisasContext *s,MemOp ot) -{ -TCGv dshift =tcg_temp_new (); -tcg_gen_ld32s_tl (dshift, tcg_env, offsetof(CPUX86State , df)); -tcg_gen_shli_tl (dshift, dshift, ot); -return dshift; -}; -static TCGv gen_ext_tl (TCGv dst,TCGv src,MemOp size,bool sign) {if (size ==MO_TL ) {
@@ -1453,29 +1445,31 @@ static void do_gen_rep(DisasContext *s, MemOp ot, TCGv dshift,gen_jmp_rel_csize (s,0 ,1 ); } -static void gen_repz (DisasContext *s,MemOp ot, -void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) - +static void do_gen_string (DisasContext *s,MemOp ot, +void (*fn)(DisasContext *s,MemOp ot,TCGv dshift), +bool is_repz_nz) { -TCGv dshift =gen_compute_Dshift (s, ot); +TCGv dshift =tcg_temp_new (); +tcg_gen_ld32s_tl (dshift, tcg_env, offsetof(CPUX86State , df)); +tcg_gen_shli_tl (dshift, dshift, ot);if (s->prefix & (PREFIX_REPZ |PREFIX_REPNZ )) { -do_gen_rep (s, ot, dshift, fn, false); +do_gen_rep (s, ot, dshift, fn, is_repz_nz); }else {fn (s, ot, dshift); } } +static void gen_repz (DisasContext *s,MemOp ot, +void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) +{ +do_gen_string (s, ot, fn, false); +} +static void gen_repz_nz (DisasContext *s,MemOp ot,void (*fn)(DisasContext *s,MemOp ot,TCGv dshift)) { -TCGv dshift =gen_compute_Dshift (s, ot); - -if (s->prefix & (PREFIX_REPZ |PREFIX_REPNZ )) { -do_gen_rep (s, ot, dshift, fn, true); - }else { -fn (s, ot, dshift); - } +do_gen_string (s, ot, fn, true); }static void gen_helper_fp_arith_ST0_FT0 (int op)
Signature · 1 line
2.47.1
Quoted 11 lines · Paolo Bonzini
Now that everything has been cleaned up, look at DF and prefixes in a single function, and call that one from
gen_repzandgen_repz_nz.Based-on:<[email protected]>
Suggested-by Richard Henderson<[email protected]>Signed-off-by Paolo Bonzini<[email protected]>---
This was requested in the review of "target/i386: optimize string operations"target/i386/tcg/translate.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-)
r~