target-sh4: fix 64-bit fmov to/from memory
PATCH 1/2 target-sh4: fix 64-bit fmov to/from memory
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
--- target-sh4/translate.c | 63 ++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 31 deletions(-)
target-sh4/translate.c +32 -31
@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );
@@ -1023,16 +1027,13 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); -tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); -tcg_temp_free (addr); -tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 ); +tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx); +tcg_temp_free (addr); }else {TCGv addr; addr =tcg_temp_new_i32 ();
@@ -1047,10 +1048,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }
@@ -1062,10 +1063,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }
Signature · 1 line
1.6.0.4
PATCH 2/2 target-sh4: implement ftrv instruction
This partially implements the ftrv instruction. It gives correct results under normal conditions. FPU exceptions are not correctly generated.
--- target-sh4/translate.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
target-sh4/translate.c +40 -0
@@ -1694,6 +1694,46 @@ static void _decode_opc(DisasContext * ctx)tcg_temp_free_i64 (fp); }return ; +case 0xf0fd :/* ftrv XMTRX,FVn */ +if ((ctx->opcode &0x300 ) !=0x100 ) +break ; +if (!(ctx->fpscr &FPSCR_PR )) { +TCGv fv[4 ]; +TCGv fp; +int n =B11_8 &0xc ; +int i; + +/* +* NOTE: The values calculated here are likely to differ +* from hardware since the hardware sacrifices accuracy +* for speed in this instruction. +* +* FIXME: FPU exceptions are not correctly raised here. +*/ + + fp =tcg_temp_new (); + +for (i =0 ; i <4 ; i++) { + fv[i] =tcg_temp_new (); +tcg_gen_mov_i32 (fv[i], cpu_fregs[n+i]); + } + +for (i =0 ; i <4 ; i++) { +gen_helper_fmul_FT (cpu_fregs[n+i], cpu_fregs[16 +i], fv[0 ]); +gen_helper_fmul_FT (fp, cpu_fregs[20 +i], fv[1 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); +gen_helper_fmul_FT (fp, cpu_fregs[24 +i], fv[2 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); +gen_helper_fmul_FT (fp, cpu_fregs[28 +i], fv[3 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); + } + +for (i =0 ; i <4 ; i++) +tcg_temp_free (fv[i]); +tcg_temp_free (fp); +return ; + } +break ; } fprintf(stderr, "unknown instruction 0x%04x at pc 0x%08x\n",
Signature · 1 line
1.6.0.4
Re: [Qemu-devel] [PATCH 2/2] target-sh4: implement ftrv instruction
Quoted 50 lines · Mans Rullgard
This partially implements the ftrv instruction. It gives correct results under normal conditions. FPU exceptions are not correctly generated.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)target-sh4/translate.c +33
-0@@ -1694,6 +1694,46 @@ static void _decode_opc(DisasContext * ctx)tcg_temp_free_i64 (fp); }return ; +case 0xf0fd :/* ftrv XMTRX,FVn */ +if ((ctx->opcode &0x300 ) !=0x100 ) +break ; +if (!(ctx->fpscr &FPSCR_PR )) { +TCGv fv[4 ]; +TCGv fp; +int n =B11_8 &0xc ; +int i; + +/* +* NOTE: The values calculated here are likely to differ +* from hardware since the hardware sacrifices accuracy +* for speed in this instruction. +* +* FIXME: FPU exceptions are not correctly raised here. +*/ + + fp =tcg_temp_new (); + +for (i =0 ; i <4 ; i++) { + fv[i] =tcg_temp_new (); +tcg_gen_mov_i32 (fv[i], cpu_fregs[n+i]); + } + +for (i =0 ; i <4 ; i++) { +gen_helper_fmul_FT (cpu_fregs[n+i], cpu_fregs[16 +i], fv[0 ]); +gen_helper_fmul_FT (fp, cpu_fregs[20 +i], fv[1 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); +gen_helper_fmul_FT (fp, cpu_fregs[24 +i], fv[2 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); +gen_helper_fmul_FT (fp, cpu_fregs[28 +i], fv[3 ]); +gen_helper_fadd_FT (cpu_fregs[n+i], cpu_fregs[n+i], fp); + }
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1739
Quoted 10 lines
target-sh4/translate.c +7
-0+ +for (i =0 ; i <4 ; i++) +tcg_temp_free (fv[i]); +tcg_temp_free (fp); +return ; + } +break ; } fprintf(stderr, "unknown instruction 0x%04x at pc 0x%08x\n",
While this code probably produce the correct result, I am not sure it is the best way to do it. It calls 28 times an helper, and uses 5 temp variable. IMHO the ftrv should be implemented in an helper, called from translate.c.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 17 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 63 ++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 31 deletions(-)target-sh4/translate.c +0
-0@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) {
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 999
Quoted 10 lines
target-sh4/translate.c +6
-4-TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi);
You are totally breaking the indendation. Care to resend this patch with a proper indentation?
Quoted 95 lines
target-sh4/translate.c +26
-27}else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );@@ -1023,16 +1027,13 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); -tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); -tcg_temp_free (addr); -tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 ); +tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx); +tcg_temp_free (addr); }else {TCGv addr; addr =tcg_temp_new_i32 ();@@ -1047,10 +1048,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }@@ -1062,10 +1063,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }Signature · 1 line
1.6.0.4
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
Quoted 23 lines · Aurelien Jarno
Quoted 22 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 63 ++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 31 deletions(-)target-sh4/translate.c +1
-4@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new ();
Quoted 8 lines
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 999
Quoted 5 lines
target-sh4/translate.c +5
-0+int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi);You are totally breaking the indendation. Care to resend this patch with a proper indentation?
I was told to use spaces for indentation even if surrounding code uses tabs. I'll be happy to convert it to tabs if that's what you want.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 34 lines · Måns Rullgård
Quoted 23 lines · Aurelien Jarno
Quoted 22 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 63 ++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 31 deletions(-)target-sh4/translate.c +1
-4@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new ();Quoted 8 lines
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 999
Quoted 5 lines
target-sh4/translate.c +5
-0+int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi);You are totally breaking the indendation. Care to resend this patch with a proper indentation?
Quoted 3 lines
I was told to use spaces for indentation even if surrounding code uses tabs. I'll be happy to convert it to tabs if that's what you want.
The current file use tabs. While it is not consistent with other qemu files, I think mixed indentation is even worse.
Please use tabs in your patch, and if you really like to you can send a patch to convert the indentation of the whole file to spaces, but please do it in a separate patch.
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 1/1 target-sh4: fix 64-bit fmov to/from memory
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
--- target-sh4/translate.c | 61 ++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 30 deletions(-)
target-sh4/translate.c +31 -30
@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );
@@ -1023,16 +1027,13 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); -tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); -tcg_temp_free (addr); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 );tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx); +tcg_temp_free (addr); }else {TCGv addr; addr =tcg_temp_new_i32 ();
@@ -1047,10 +1048,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }
@@ -1062,10 +1063,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }
Signature · 1 line
1.6.0.4
Quoted 49 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 61 ++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 30 deletions(-)target-sh4/translate.c +12
-8@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) {
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1022
Quoted 10 lines
target-sh4/translate.c +5
-5-TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );
This is wrong, the address register should only be incremented after the last load instruction, so that it has the correct value in case of exception.
Quoted 12 lines
target-sh4/translate.c +0
-5}else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );@@ -1023,16 +1027,13 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); -tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 ();
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1035
Quoted 10 lines
target-sh4/translate.c +5
-4-gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); -tcg_temp_free (addr); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 );tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx);
Same here.
Quoted 24 lines
target-sh4/translate.c +5
-5+tcg_temp_free (addr); }else {TCGv addr; addr =tcg_temp_new_i32 ();@@ -1047,10 +1048,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }@@ -1062,10 +1063,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 ();
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1072
Quoted 10 lines
target-sh4/translate.c +4
-3-gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }
Otherwise looks ok.
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
Quoted 56 lines · Aurelien Jarno
Quoted 55 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 61 ++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 30 deletions(-)target-sh4/translate.c +13
-13@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 );
Quoted 8 lines
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1022
Quoted 4 lines
target-sh4/translate.c +4
-0+tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );This is wrong, the address register should only be incremented after the last load instruction, so that it has the correct value in case of exception.
You're quite right. In fact, shouldn't the 32-bit values be loaded into a temporary locations (at least the first to be loaded) in case the second load generates an exception? The manual doesn't seem to allow a partial load in such a situation, so I'd assume it's not safe.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 67 lines · Måns Rullgård
Quoted 56 lines · Aurelien Jarno
Quoted 55 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 61 ++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 30 deletions(-)target-sh4/translate.c +13
-13@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +int fr =XREG (B11_8 );Quoted 8 lines
target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 1022
Quoted 4 lines
target-sh4/translate.c +4
-0+tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ],REG (B7_4 ), ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );This is wrong, the address register should only be incremented after the last load instruction, so that it has the correct value in case of exception.
Quoted 5 lines
You're quite right. In fact, shouldn't the 32-bit values be loaded into a temporary locations (at least the first to be loaded) in case the second load generates an exception? The manual doesn't seem to allow a partial load in such a situation, so I'd assume it's not safe.
There is nothing in the manual, but on most CPUs the value in the register is then defined as unpredictable. I don't think it is important to preserve the register value at this point. Preserving the address value is important so that the instruction could be re-executed after an exception, like a TLB miss for example.
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 1/1 target-sh4: fix 64-bit fmov to/from memory
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
--- target-sh4/translate.c | 62 +++++++++++++++++++++++++---------------------- 1 files changed, 33 insertions(+), 29 deletions(-)
target-sh4/translate.c +33 -29
@@ -991,31 +991,37 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );
@@ -1023,16 +1029,14 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx);tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +tcg_gen_qemu_st32 (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_mov_i32 (REG (B11_8 ), addr);tcg_temp_free (addr); -tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); }else {TCGv addr; addr =tcg_temp_new_i32 ();
@@ -1047,10 +1051,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }
@@ -1062,10 +1066,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }
Signature · 1 line
1.6.0.4
Aurelien Jarno
AppliedQuoted 3 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Thanks, applied.
Quoted 119 lines
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 62 +++++++++++++++++++++++++---------------------- 1 files changed, 33 insertions(+), 29 deletions(-)target-sh4/translate.c +33
-29@@ -991,31 +991,37 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )],REG (B11_8 ), ctx->memidx); }return ;case 0xf008 :/* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx); }return ;case 0xf009 :/* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp,REG (B7_4 ), ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); -tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B11_8 ); +tcg_gen_addi_i32 (addr_hi,REG (B7_4 ),4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ],REG (B7_4 ), ctx->memidx); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),8 ); +tcg_temp_free (addr_hi); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )],REG (B7_4 ), ctx->memidx);tcg_gen_addi_i32 (REG (B7_4 ),REG (B7_4 ),4 );@@ -1023,16 +1029,14 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00b :/* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) { -TCGv addr; -TCGv_i64 fp; - addr =tcg_temp_new (); +TCGv addr =tcg_temp_new_i32 (); +int fr =XREG (B7_4 ); +tcg_gen_subi_i32 (addr,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr, ctx->memidx);tcg_gen_subi_i32 (addr,REG (B11_8 ),8 ); - fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +tcg_gen_qemu_st32 (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_mov_i32 (REG (B11_8 ), addr);tcg_temp_free (addr); -tcg_gen_subi_i32 (REG (B11_8 ),REG (B11_8 ),8 ); }else {TCGv addr; addr =tcg_temp_new_i32 ();@@ -1047,10 +1051,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new_i32 ();tcg_gen_add_i32 (addr,REG (B7_4 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (fp, addr, ctx->memidx); -gen_store_fpr64 (fp,XREG (B11_8 )); -tcg_temp_free_i64 (fp); +int fr =XREG (B11_8 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_ld32u (cpu_fregs[FREG (B11_8 )], addr, ctx->memidx); }@@ -1062,10 +1066,10 @@ static void _decode_opc(DisasContext * ctx)TCGv addr =tcg_temp_new ();tcg_gen_add_i32 (addr,REG (B11_8 ),REG (0 ));if (ctx->fpscr &FPSCR_SZ ) { -TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp, addr, ctx->memidx); -tcg_temp_free_i64 (fp); +int fr =XREG (B7_4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr ], addr, ctx->memidx); +tcg_gen_addi_i32 (addr, addr,4 ); +tcg_gen_qemu_ld32u (cpu_fregs[fr+1 ], addr, ctx->memidx); }else {tcg_gen_qemu_st32 (cpu_fregs[FREG (B7_4 )], addr, ctx->memidx); }Signature · 1 line
1.6.0.4
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
Quoted 35 lines · Aurelien Jarno
Quoted 34 lines · Måns Rullgård
Quoted 31 lines · Aurelien Jarno
Quoted 17 lines · Mans Rullgard
When loading/storing a register pair, the even-numbered register always maps to the low 32 bits of memory independently of target endian configuration.
Signed-off-by Mans Rullgard <[email protected]>--- target-sh4/translate.c | 63 ++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 31 deletions(-)target-sh4/translate.c +0
-0@@ -991,31 +991,35 @@ static void _decode_opc(DisasContext * ctx)return ;case 0xf00a :/* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ if (ctx->fpscr &FPSCR_SZ ) {target-sh4/translate.c static void _decode_opc(DisasContext * ctx) · line 999
Quoted 10 lines
target-sh4/translate.c +6
-4-TCGv_i64 fp =tcg_temp_new_i64 (); -gen_load_fpr64 (fp,XREG (B7_4 )); -tcg_gen_qemu_st64 (fp,REG (B11_8 ), ctx->memidx); -tcg_temp_free_i64 (fp); +TCGv addr_hi =tcg_temp_new (); +int fr =XREG (B7_4 ); +tcg_gen_addi_i32 (addr_hi,REG (B11_8 ),4 ); +tcg_gen_qemu_st32 (cpu_fregs[fr ],REG (B11_8 ), ctx->memidx); +tcg_gen_qemu_st32 (cpu_fregs[fr+1 ], addr_hi, ctx->memidx); +tcg_temp_free (addr_hi);You are totally breaking the indendation. Care to resend this patch with a proper indentation?
Quoted 5 lines
Quoted 2 lines
I was told to use spaces for indentation even if surrounding code uses tabs. I'll be happy to convert it to tabs if that's what you want.
The current file use tabs. While it is not consistent with other qemu files, I think mixed indentation is even worse.
I can agree with that. New patch sent.
Signature · 2 lines
Måns Rullgård [email protected]