tcg/ppc: AREG0 support and Darwin fixes
v3 cover tcg/ppc: AREG0 support and Darwin fixes
Hello Anthony,
Here's a cleaned up version of the series ack'ed by Alex for 1.1-rc1. Thanks for delaying.
Regards,
Andreas
v2 -> v3:
* Do not hard-assign ir = 4 for CONFIG_TCG_PASS_AREG0, instead use ir++ (Alex).
v1 -> v2:
* Drop _CALL_DARWIN fix that malc doesn't accept (_CALL_DARWIN being reserved).
* Fix a register clobbering issue with 64-bit loads in non-AREG0 path.
* Split register numbering and alignment adjustments off from AREG0 support.
* Address register clobbering for AREG0 aligned and unaligned paths.
Andreas Färber (4):
tcg/ppc: Do not overwrite lower address word on Darwin and AIX tcg/ppc: Don't hardcode register numbers
tcg/ppc: Clobber r5 for 64-bit qemu_ld
tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
tcg/ppc/tcg-target.c | 65 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 50 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.7
PATCH v3 1/4 tcg/ppc: Do not overwrite lower address word on Darwin and AIX
From: Andreas Färber <[email protected]>
For targets where TARGET_LONG_BITS != 32, i.e. 64-bit guests, addr_reg is moved to r4. For hosts without TCG_TARGET_CALL_ALIGN_ARGS either data_reg2 or data_reg or a masked version thereof would overwrite r4. Place it in r5 instead, matching TCG_TARGET_CALL_ALIGN_ARGS hosts.
This fixes immediate crashes of 64-bit guests observed on Darwin/ppc but not on Darwin/ppc64.
--- tcg/ppc/tcg-target.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
tcg/ppc/tcg-target.c +0 -4
@@ -816,11 +816,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)#else tcg_out_mov (s,TCG_TYPE_I32 ,3 , addr_reg2);tcg_out_mov (s,TCG_TYPE_I32 ,4 , addr_reg); -#ifdef TCG_TARGET_CALL_ALIGN_ARGS ir =5 ; -#else - ir =4 ; -#endif #endif switch (opc) {
Signature · 1 line
1.7.7
PATCH v3 2/4 tcg/ppc: Don't hardcode register numbers
In reply to Andreas FärberAlso assure i64 alignment where necessary.
Alignment code optimization suggested by malc.
--- tcg/ppc/tcg-target.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
tcg/ppc/tcg-target.c +17 -12
@@ -552,7 +552,7 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc) {int addr_reg, data_reg, data_reg2, r0, r1, rbase, bswap;#ifdef CONFIG_SOFTMMU -int mem_index, s_bits, r2; +int mem_index, s_bits, r2, ir;void *label1_ptr, *label2_ptr;#if TARGET_LONG_BITS ==64 int addr_reg2;
@@ -614,14 +614,17 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)#endif /* slow path */ + ir =3 ;#if TARGET_LONG_BITS ==32 -tcg_out_mov (s,TCG_TYPE_I32 ,3 , addr_reg); -tcg_out_movi (s,TCG_TYPE_I32 ,4 , mem_index); +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#else -tcg_out_mov (s,TCG_TYPE_I32 ,3 , addr_reg2); -tcg_out_mov (s,TCG_TYPE_I32 ,4 , addr_reg); -tcg_out_movi (s,TCG_TYPE_I32 ,5 , mem_index); +#ifdef TCG_TARGET_CALL_ALIGN_ARGS + ir |=1 ; +#endif +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg2); +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#endif +tcg_out_movi (s,TCG_TYPE_I32 , ir, mem_index);tcg_out_call (s, (tcg_target_long ) qemu_ld_helpers[s_bits],1 );switch (opc) {
@@ -810,13 +813,15 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)#endif /* slow path */ + ir =3 ;#if TARGET_LONG_BITS ==32 -tcg_out_mov (s,TCG_TYPE_I32 ,3 , addr_reg); - ir =4 ; +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#else -tcg_out_mov (s,TCG_TYPE_I32 ,3 , addr_reg2); -tcg_out_mov (s,TCG_TYPE_I32 ,4 , addr_reg); - ir =5 ; +#ifdef TCG_TARGET_CALL_ALIGN_ARGS + ir |=1 ; +#endif +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg2); +tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#endif switch (opc) {
@@ -841,7 +846,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)break ;case 3 :#ifdef TCG_TARGET_CALL_ALIGN_ARGS - ir =5 ; + ir |=1 ;#endif tcg_out_mov (s,TCG_TYPE_I32 , ir++, data_reg2);tcg_out_mov (s,TCG_TYPE_I32 , ir, data_reg);
Signature · 1 line
1.7.7
PATCH v3 3/4 tcg/ppc: Clobber r5 for 64-bit qemu_ld
In reply to Andreas FärberThis accounts for the additional addr_reg2 register.
--- tcg/ppc/tcg-target.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
tcg/ppc/tcg-target.c +3 -0
@@ -244,6 +244,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)tcg_regset_set32 (ct->u.regs,0 ,0xffffffff );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R3 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R4 ); +#if TARGET_LONG_BITS ==64 +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R5 ); +#endif break ;case 'K' :/* qemu_st[8..32] constraint */ ct->ct |=TCG_CT_REG ;
Signature · 1 line
1.7.7
PATCH v3 4/4 tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
In reply to Andreas FärberAdjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3, based on patches by malc.
Also adjust the registers clobbered, based on patch by Alex.
--- tcg/ppc/tcg-target.c | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-)
tcg/ppc/tcg-target.c +32 -1
@@ -244,9 +244,19 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)tcg_regset_set32 (ct->u.regs,0 ,0xffffffff );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R3 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R4 ); +#ifdef CONFIG_TCG_PASS_AREG0 +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R5 ); +#if TARGET_LONG_BITS ==64 +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R6 ); +#ifdef TCG_TARGET_CALL_ALIGN_ARGS +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R7 ); +#endif +#endif +#else /* !AREG0 */ #if TARGET_LONG_BITS ==64 tcg_regset_reset_reg (ct->u.regs,TCG_REG_R5 );#endif +#endif break ;case 'K' :/* qemu_st[8..32] constraint */ ct->ct |=TCG_CT_REG ;
@@ -254,9 +264,19 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)tcg_regset_reset_reg (ct->u.regs,TCG_REG_R3 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R4 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R5 ); +#ifdef CONFIG_TCG_PASS_AREG0 +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R6 ); +#if TARGET_LONG_BITS ==64 +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R7 ); +#ifdef TCG_TARGET_CALL_ALIGN_ARGS +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R8 ); +#endif +#endif +#else /* !AREG0 */ #if TARGET_LONG_BITS ==64 tcg_regset_reset_reg (ct->u.regs,TCG_REG_R6 );#endif +#endif break ;case 'M' :/* qemu_st64 constraint */ ct->ct |=TCG_CT_REG ;
@@ -266,6 +286,12 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)tcg_regset_reset_reg (ct->u.regs,TCG_REG_R5 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R6 );tcg_regset_reset_reg (ct->u.regs,TCG_REG_R7 ); +#if defined(CONFIG_TCG_PASS_AREG0 ) +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R8 ); +#ifdef TCG_TARGET_CALL_ALIGN_ARGS +tcg_regset_reset_reg (ct->u.regs,TCG_REG_R9 ); +#endif +#endif break ;#else case 'L' :
@@ -512,7 +538,6 @@ static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg)#include "../../softmmu_defs.h" #ifdef CONFIG_TCG_PASS_AREG0 -#error CONFIG_TCG_PASS_AREG0 is not supported/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ static const void * const qemu_ld_helpers[4] = {
@@ -618,6 +643,9 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)/* slow path */ ir =3 ; +#ifdef CONFIG_TCG_PASS_AREG0 +tcg_out_mov (s,TCG_TYPE_I32 , ir++,TCG_AREG0 ); +#endif #if TARGET_LONG_BITS ==32 tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#else
@@ -817,6 +845,9 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)/* slow path */ ir =3 ; +#ifdef CONFIG_TCG_PASS_AREG0 +tcg_out_mov (s,TCG_TYPE_I32 , ir++,TCG_AREG0 ); +#endif #if TARGET_LONG_BITS ==32 tcg_out_mov (s,TCG_TYPE_I32 , ir++, addr_reg);#else
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
Quoted 4 lines · Andreas F?rber
Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3, based on patches by malc.
Also adjust the registers clobbered, based on patch by Alex.
ppc64 is similarly broken in pass areg0 case.
[..snip..]
Signature · 1 line
mailto:[email protected]
Re: [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
Am 09.05.2012 19:53, schrieb malc:
Quoted 10 lines · Andreas F?rber
Quoted 5 lines
Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3, based on patches by malc.
Also adjust the registers clobbered, based on patch by Alex.
ppc64 is similarly broken in pass areg0 case.
[..snip..]
FWIW I plan to review that next. Please don't add any #error before rc1.
Note to Anthony: That's about tcg/ppc64. I'm positive we can fix any obvious issues there in time for rc2.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg