sparc64: fix wrpstate and wrtl on delay slot
PATCH 1/1 sparc64: fix wrpstate and wrtl on delay slot
Use TCG local to work around TCG register flush due to a branch.
Thanks to Artyom Tarasenko, Igor Kovalenko and Aurelien Jarno.
---
I analyzed the call tree in target-sparc/translate.c for brcond* usage. In the following lines, first level function uses brcond* directly, second level calls the first level etc.
gen_add_tv
Quoted 2 lines
gen_op_tadd_ccTVQuoted 1 line
taddcctv
gen_tag_tv
Quoted 4 lines
gen_op_tadd_ccTVQuoted 1 line
taddcctv
gen_op_tsub_ccTVQuoted 1 line
tsubcctv
gen_sub_tv
Quoted 2 lines
gen_op_tsub_ccTVQuoted 1 line
tsubcctv
gen_op_mulscc
Quoted 1 line
mulscc
gen_trap_ifdivzero_tl
Quoted 3 lines
gen_op_sdivxQuoted 1 line
sdivx
udivx
gen_op_sdivx
Quoted 1 line
sdivx
gen_branch2
Quoted 1 line
disas_sparc_insn
gen_branch_a
Quoted 8 lines
do_branchQuoted 2 lines
bpcc
bn+x
do_fbranchQuoted 2 lines
fbpcc
fbn+x
do_branch_regQuoted 1 line
bpr
gen_generic_branch
Quoted 58 lines
flush_condQuoted 8 lines
do_branchQuoted 2 lines
bpcc
bn+x
do_fbranchQuoted 2 lines
fbpcc
fbn+x
do_branch_regQuoted 1 line
bpr
save_npcQuoted 48 lines
save_stateQuoted 47 lines
gen_trap_ifnofpu
trap
flushw
FPU Operations
taddcctv
tsubcctv
wrfprs
wrpsr
wrpstate
wrtl
wrhpstate
return
save
restore
ldd
lda
lduba
lduha
ldda
ldsba
ldsha
ldstuba
swapa
ldswa
ldxa
ldfa
lddfa
ldqfa
ldf
ldfsr
lddqf
lddf
std
sta
stba
stha
stda
stxa
stf
stfsr
stqf
stdf
stfa
stqfa
stdfa
casa
casxa
Quoted 6 lines
Quoted 1 line
gen_intermediate_code_internal
gen_mov_pc_npcQuoted 4 lines
call
return
jmpl
rett
gen_cond_reg
Quoted 2 lines
do_branch_regQuoted 1 line
bpr
trap
fmovsr
fmovdr
fmovqr
fmovscc
fmovdcc
fmovqcc
movcc
movr
I only found wrtl in addition to wrpstate discovered earlier, other use cases looked OK.
target-sparc/translate.c | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-)
target-sparc/translate.c +18 -8
@@ -3505,16 +3505,28 @@ static void disas_sparc_insn(DisasContext * dc)tcg_gen_mov_tl (cpu_tbr, cpu_tmp0);break ;case 6 :// pstate -save_state (dc, cpu_cond); -gen_helper_wrpstate (cpu_tmp0); - dc->npc =DYNAMIC_PC ; + { +TCGv r_tmp =tcg_temp_local_new (); + +tcg_gen_mov_tl (r_tmp, cpu_tmp0); +save_state (dc, cpu_cond); +gen_helper_wrpstate (r_tmp); +tcg_temp_free (r_tmp); + dc->npc =DYNAMIC_PC ; + }break ;case 7 :// tl -save_state (dc, cpu_cond); -tcg_gen_trunc_tl_i32 (cpu_tmp32, cpu_tmp0); -tcg_gen_st_i32 (cpu_tmp32, cpu_env, - offsetof(CPUSPARCState , tl)); - dc->npc =DYNAMIC_PC ; + { +TCGv r_tmp =tcg_temp_local_new (); + +tcg_gen_mov_tl (r_tmp, cpu_tmp0); +save_state (dc, cpu_cond); +tcg_gen_trunc_tl_i32 (cpu_tmp32, r_tmp); +tcg_temp_free (r_tmp); + tcg_gen_st_i32(cpu_tmp32, cpu_env, +
offsetof(CPUSPARCState, tl));
+ dc->npc = DYNAMIC_PC;
+ }
break;
case 8: // pil
gen_helper_wrpil(cpu_tmp0);Signature · 1 line
1.6.2.4
Quoted 10 lines · Blue Swirl
Use TCG local to work around TCG register flush due to a branch.
Thanks to Artyom Tarasenko, Igor Kovalenko and Aurelien Jarno.
Signed-off-by Blue Swirl <[email protected]>---
I analyzed the call tree intarget-sparc/translate.cfor brcond* usage. In the following lines, first level function uses brcond* directly, second level calls the first level etc.
I want to be able to do exhaustive searches as well :) Have you used recently posted gcc save-temps method?
Signature · 2 lines
Kind regards, Igor V. Kovalenko
Just curious, is this for host or guest?
Quoted 20 lines · Igor Kovalenko
Quoted 10 lines · Blue Swirl
Use TCG local to work around TCG register flush due to a branch.
Thanks to Artyom Tarasenko, Igor Kovalenko and Aurelien Jarno.
Signed-off-by Blue Swirl <[email protected]>---
I analyzed the call tree intarget-sparc/translate.cfor brcond* usage. In the following lines, first level function uses brcond* directly, second level calls the first level etc.I want to be able to do exhaustive searches as well :) Have you used recently posted gcc save-temps method?
--
Kind regards,
Igor V. Kovalenko
Quoted 2 lines · Super Bisquit
Just curious, is this for host or guest?
Guest (aka target)
Quoted 24 lines
Quoted 20 lines · Igor Kovalenko
Quoted 10 lines · Blue Swirl
Use TCG local to work around TCG register flush due to a branch.
Thanks to Artyom Tarasenko, Igor Kovalenko and Aurelien Jarno.
Signed-off-by Blue Swirl <[email protected]>---
I analyzed the call tree intarget-sparc/translate.cfor brcond* usage. In the following lines, first level function uses brcond* directly, second level calls the first level etc.I want to be able to do exhaustive searches as well :) Have you used recently posted gcc save-temps method?
--
Kind regards,
Igor V. Kovalenko
Signature · 4 lines
Regards, Artyom Tarasenko solaris/sparc under qemu blog: http://tyom.blogspot.com/
Quoted 12 lines · Igor Kovalenko
Quoted 10 lines · Blue Swirl
Use TCG local to work around TCG register flush due to a branch.
Thanks to Artyom Tarasenko, Igor Kovalenko and Aurelien Jarno.
Signed-off-by Blue Swirl <[email protected]>---
I analyzed the call tree intarget-sparc/translate.cfor brcond* usage. In the following lines, first level function uses brcond* directly, second level calls the first level etc.
Quoted 2 lines
I want to be able to do exhaustive searches as well :) Have you used recently posted gcc save-temps method?
No, I just used the search facilities of the editor. First, search for brcond, examine the function for correctness and copy the function names to scratch buffer. Next, search for the function names just found, examine callers and copy their function names with prefix to scratch etc. About one hour's work.