Skip to contentSkip to conversation

sparc64: fix wrpstate and wrtl on delay slot

PATCH In review Blue Swirl 4 participants 5 messages Apr 30, 2011 – May 1, 2011

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

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_ccTV

Quoted 1 line

taddcctv

gen_tag_tv

Quoted 4 lines

gen_op_tadd_ccTV

Quoted 1 line

taddcctv

gen_op_tsub_ccTV

Quoted 1 line

tsubcctv

gen_sub_tv

Quoted 2 lines

gen_op_tsub_ccTV

Quoted 1 line

tsubcctv

gen_op_mulscc

Quoted 1 line

mulscc

gen_trap_ifdivzero_tl

Quoted 3 lines

gen_op_sdivx

Quoted 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_branch

Quoted 2 lines

bpcc
bn+x

do_fbranch

Quoted 2 lines

fbpcc
fbn+x

do_branch_reg

Quoted 1 line

bpr

gen_generic_branch

Quoted 58 lines

flush_cond

Quoted 8 lines

do_branch

Quoted 2 lines

bpcc
bn+x

do_fbranch

Quoted 2 lines

fbpcc
fbn+x

do_branch_reg

Quoted 1 line

bpr

save_npc

Quoted 48 lines

save_state

Quoted 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_npc

Quoted 4 lines

call
return
jmpl
rett

gen_cond_reg

Quoted 2 lines

do_branch_reg

Quoted 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
index 3c958b2..9222cde 100644
@@ -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
#1 lore raw
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.

---
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.

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
#2 lore raw

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.

---
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.

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

#3 lore raw
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.

---
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.

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/
author
#4 lore raw
In reply to Igor Kovalenko
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.

---
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.

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.