* [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count @ 2012-09-12 20:44 Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil ` (3 more replies) 0 siblings, 4 replies; 11+ messages in thread From: Stefan Weil @ 2012-09-12 20:44 UTC (permalink / raw) To: Blue Swirl; +Cc: Alexander Graf, qemu-devel, Aurelien Jarno, Richard Henderson Function tcg_target_get_call_iarg_regs_count was wrong for w64 hosts and can be simplified for all TCG targets: [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments [PATCH 2/4] tcg/i386: Remove unused registers from [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c [PATCH 4/4] tcg: Remove unused parameter from The first patch is also needed for stable-1.2. It was already sent today as a single patch. Regards, Stefan Weil ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments 2012-09-12 20:44 [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil @ 2012-09-12 20:44 ` Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs Stefan Weil ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Stefan Weil @ 2012-09-12 20:44 UTC (permalink / raw) To: Blue Swirl Cc: Stefan Weil, Alexander Graf, qemu-devel, Aurelien Jarno, Richard Henderson TCG uses 6 registers for function arguments on 64 bit Linux hosts, but only 4 registers on W64 hosts. Commit 2999a0b20074a7e4a58f56572bb1436749368f59 increased the number of arguments for some important helper functions from 4 to 5 which triggered a bug for W64 hosts: QEMU aborts when executing helper_lcall_real in the guest's BIOS because function tcg_target_get_call_iarg_regs_count always returned 6. As W64 has only 4 registers for arguments, the 5th argument must be passed on the stack using a correct stack offset. Signed-off-by: Stefan Weil <sw@weilnetz.de> --- tcg/i386/tcg-target.c | 2 +- tcg/i386/tcg-target.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index da17bba..43b5572 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -118,7 +118,7 @@ static void patch_reloc(uint8_t *code_ptr, int type, static inline int tcg_target_get_call_iarg_regs_count(int flags) { if (TCG_TARGET_REG_BITS == 64) { - return 6; + return ARRAY_SIZE(tcg_target_call_iarg_regs); } return 0; diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index c3cfe05..87417d0 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -67,7 +67,11 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_ESP #define TCG_TARGET_STACK_ALIGN 16 +#if defined(_WIN64) +#define TCG_TARGET_CALL_STACK_OFFSET 32 +#else #define TCG_TARGET_CALL_STACK_OFFSET 0 +#endif /* optional instructions */ #define TCG_TARGET_HAS_div2_i32 1 -- 1.7.10 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs 2012-09-12 20:44 [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil @ 2012-09-12 20:44 ` Stefan Weil 2012-09-12 21:18 ` Peter Maydell 2012-09-12 20:44 ` [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 4/4] tcg: Remove unused parameter from tcg_target_get_call_iarg_regs_count Stefan Weil 3 siblings, 1 reply; 11+ messages in thread From: Stefan Weil @ 2012-09-12 20:44 UTC (permalink / raw) To: Blue Swirl Cc: Stefan Weil, Alexander Graf, qemu-devel, Aurelien Jarno, Richard Henderson 32 bit x86 hosts don't need registers for helper function arguments because they use the default stack based calling convention. Removing the registers allows simpler code for function tcg_target_get_call_iarg_regs_count. Signed-off-by: Stefan Weil <sw@weilnetz.de> --- tcg/i386/tcg-target.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 43b5572..d60bab8 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -75,9 +75,7 @@ static const int tcg_target_call_iarg_regs[] = { TCG_REG_R8, TCG_REG_R9, #else - TCG_REG_EAX, - TCG_REG_EDX, - TCG_REG_ECX + /* 32 bit mode uses stack based calling convention (GCC default). */ #endif }; @@ -117,11 +115,7 @@ static void patch_reloc(uint8_t *code_ptr, int type, /* maximum number of register used for input function arguments */ static inline int tcg_target_get_call_iarg_regs_count(int flags) { - if (TCG_TARGET_REG_BITS == 64) { - return ARRAY_SIZE(tcg_target_call_iarg_regs); - } - - return 0; + return ARRAY_SIZE(tcg_target_call_iarg_regs); } /* parse target specific constraints */ -- 1.7.10 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs 2012-09-12 20:44 ` [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs Stefan Weil @ 2012-09-12 21:18 ` Peter Maydell 2012-09-13 5:50 ` Stefan Weil 0 siblings, 1 reply; 11+ messages in thread From: Peter Maydell @ 2012-09-12 21:18 UTC (permalink / raw) To: Stefan Weil Cc: Blue Swirl, Richard Henderson, Alexander Graf, Aurelien Jarno, qemu-devel On 12 September 2012 21:44, Stefan Weil <sw@weilnetz.de> wrote: > --- a/tcg/i386/tcg-target.c > +++ b/tcg/i386/tcg-target.c > @@ -75,9 +75,7 @@ static const int tcg_target_call_iarg_regs[] = { > TCG_REG_R8, > TCG_REG_R9, > #else > - TCG_REG_EAX, > - TCG_REG_EDX, > - TCG_REG_ECX > + /* 32 bit mode uses stack based calling convention (GCC default). */ > #endif > }; This makes the array zero-length for 32 bit targets, but functions like tcg_out_tlb_load() and tcg_out_qemu_ld() still unconditionally access elements in it... -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs 2012-09-12 21:18 ` Peter Maydell @ 2012-09-13 5:50 ` Stefan Weil 2012-09-13 14:19 ` Richard Henderson 2012-09-13 14:31 ` Peter Maydell 0 siblings, 2 replies; 11+ messages in thread From: Stefan Weil @ 2012-09-13 5:50 UTC (permalink / raw) To: Peter Maydell Cc: Blue Swirl, Richard Henderson, Alexander Graf, Aurelien Jarno, qemu-devel Am 12.09.2012 23:18, schrieb Peter Maydell: > On 12 September 2012 21:44, Stefan Weil <sw@weilnetz.de> wrote: >> --- a/tcg/i386/tcg-target.c >> +++ b/tcg/i386/tcg-target.c >> @@ -75,9 +75,7 @@ static const int tcg_target_call_iarg_regs[] = { >> TCG_REG_R8, >> TCG_REG_R9, >> #else >> - TCG_REG_EAX, >> - TCG_REG_EDX, >> - TCG_REG_ECX >> + /* 32 bit mode uses stack based calling convention (GCC default). */ >> #endif >> }; > This makes the array zero-length for 32 bit targets, but functions > like tcg_out_tlb_load() and tcg_out_qemu_ld() still unconditionally > access elements in it... > > -- PMM Thanks for the hint. I'm afraid there are a lot more functions of that kind in i386/tcg-target.c. I could use conditional compilation for those accesses, but first I'd like to understand why this works at all. - sw ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs 2012-09-13 5:50 ` Stefan Weil @ 2012-09-13 14:19 ` Richard Henderson 2012-09-13 14:31 ` Peter Maydell 1 sibling, 0 replies; 11+ messages in thread From: Richard Henderson @ 2012-09-13 14:19 UTC (permalink / raw) To: Stefan Weil Cc: Blue Swirl, Peter Maydell, Alexander Graf, Aurelien Jarno, qemu-devel On 09/12/2012 10:50 PM, Stefan Weil wrote: > I could use conditional compilation for those accesses, > but first I'd like to understand why this works at all. Before your patch you mean? Because those are the registers reserved by the "L" constraint. r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs 2012-09-13 5:50 ` Stefan Weil 2012-09-13 14:19 ` Richard Henderson @ 2012-09-13 14:31 ` Peter Maydell 1 sibling, 0 replies; 11+ messages in thread From: Peter Maydell @ 2012-09-13 14:31 UTC (permalink / raw) To: Stefan Weil Cc: Blue Swirl, Richard Henderson, Alexander Graf, Aurelien Jarno, qemu-devel On 13 September 2012 06:50, Stefan Weil <sw@weilnetz.de> wrote: > Am 12.09.2012 23:18, schrieb Peter Maydell: >> This makes the array zero-length for 32 bit targets, but functions >> like tcg_out_tlb_load() and tcg_out_qemu_ld() still unconditionally >> access elements in it... > Thanks for the hint. I'm afraid there are a lot more functions > of that kind in i386/tcg-target.c. > > I could use conditional compilation for those accesses, > but first I'd like to understand why this works at all. The functions in question are generating code that needs to use some temporary registers. (As RTH says, this lines up with the L constraint marking those registers as not usable for the relevant TCG operands.) To avoid unnecessary register copies in the old pre-commit-6a18ae2d register-based calling convention, they are forcing those temporary registers to be the same as some of the registers that were used for function arguments. Now we no longer use a register-based calling convention it doesn't matter which registers we use as long as the functions and the constraint definitions match up. The only tricky bit will be that the 64-bit-target cases do still care about using the same registers as are used for function inputs. -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c 2012-09-12 20:44 [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs Stefan Weil @ 2012-09-12 20:44 ` Stefan Weil 2012-09-12 20:59 ` Aurelien Jarno 2012-09-12 20:44 ` [Qemu-devel] [PATCH 4/4] tcg: Remove unused parameter from tcg_target_get_call_iarg_regs_count Stefan Weil 3 siblings, 1 reply; 11+ messages in thread From: Stefan Weil @ 2012-09-12 20:44 UTC (permalink / raw) To: Blue Swirl Cc: Stefan Weil, Alexander Graf, qemu-devel, Aurelien Jarno, Richard Henderson The TCG targets no longer need individual implementations. Signed-off-by: Stefan Weil <sw@weilnetz.de> --- tcg/arm/tcg-target.c | 6 ------ tcg/hppa/tcg-target.c | 6 ------ tcg/i386/tcg-target.c | 6 ------ tcg/ia64/tcg-target.c | 6 ------ tcg/mips/tcg-target.c | 6 ------ tcg/ppc/tcg-target.c | 6 ------ tcg/ppc64/tcg-target.c | 6 ------ tcg/s390/tcg-target.c | 5 ----- tcg/sparc/tcg-target.c | 6 ------ tcg/tcg.c | 7 ++++++- tcg/tci/tcg-target.c | 6 ------ 11 files changed, 6 insertions(+), 60 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index cf0ca3d..38e2057 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -145,12 +145,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return 4; -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c index 4f17928..985476a 100644 --- a/tcg/hppa/tcg-target.c +++ b/tcg/hppa/tcg-target.c @@ -175,12 +175,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, *insn_ptr = insn; } -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return 4; -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index d60bab8..3c25acc 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -112,12 +112,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return ARRAY_SIZE(tcg_target_call_iarg_regs); -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c index dc588db..7f31876 100644 --- a/tcg/ia64/tcg-target.c +++ b/tcg/ia64/tcg-target.c @@ -176,12 +176,6 @@ static const int tcg_target_call_oarg_regs[] = { TCG_REG_R8 }; -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return 8; -} - /* * opcode formation */ diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 1006e28..aad590c 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -185,12 +185,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return 4; -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c index 0cff181..b889e34 100644 --- a/tcg/ppc/tcg-target.c +++ b/tcg/ppc/tcg-target.c @@ -221,12 +221,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static int tcg_target_get_call_iarg_regs_count(int flags) -{ - return ARRAY_SIZE (tcg_target_call_iarg_regs); -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 27a0ae8..08c5c0f 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -208,12 +208,6 @@ static void patch_reloc (uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static int tcg_target_get_call_iarg_regs_count (int flags) -{ - return ARRAY_SIZE (tcg_target_call_iarg_regs); -} - /* parse target specific constraints */ static int target_parse_constraint (TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 99b5339..287f010 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -376,11 +376,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -static int tcg_target_get_call_iarg_regs_count(int flags) -{ - return sizeof(tcg_target_call_iarg_regs) / sizeof(int); -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index 247a278..3b6c108 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -137,12 +137,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, } } -/* maximum number of register used for input function arguments */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) -{ - return 6; -} - /* parse target specific constraints */ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) { diff --git a/tcg/tcg.c b/tcg/tcg.c index a4e7f42..53316f6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -89,7 +89,6 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, tcg_target_long arg2); static int tcg_target_const_match(tcg_target_long val, const TCGArgConstraint *arg_ct); -static int tcg_target_get_call_iarg_regs_count(int flags); TCGOpDef tcg_op_defs[] = { #define DEF(s, oargs, iargs, cargs, flags) { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags }, @@ -182,6 +181,12 @@ int gen_new_label(void) #include "tcg-target.c" +/* Maximum number of register used for input function arguments. */ +static inline int tcg_target_get_call_iarg_regs_count(int flags) +{ + return ARRAY_SIZE(tcg_target_call_iarg_regs); +} + /* pool based memory allocation */ void *tcg_malloc_internal(TCGContext *s, int size) { diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c index 7124b15..7d43132 100644 --- a/tcg/tci/tcg-target.c +++ b/tcg/tci/tcg-target.c @@ -891,12 +891,6 @@ static int tcg_target_const_match(tcg_target_long val, return arg_ct->ct & TCG_CT_CONST; } -/* Maximum number of register used for input function arguments. */ -static int tcg_target_get_call_iarg_regs_count(int flags) -{ - return ARRAY_SIZE(tcg_target_call_iarg_regs); -} - static void tcg_target_init(TCGContext *s) { #if defined(CONFIG_DEBUG_TCG_INTERPRETER) -- 1.7.10 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c 2012-09-12 20:44 ` [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c Stefan Weil @ 2012-09-12 20:59 ` Aurelien Jarno 2012-09-13 5:31 ` Stefan Weil 0 siblings, 1 reply; 11+ messages in thread From: Aurelien Jarno @ 2012-09-12 20:59 UTC (permalink / raw) To: Stefan Weil; +Cc: Alexander Graf, qemu-devel, Blue Swirl, Richard Henderson On Wed, Sep 12, 2012 at 10:44:37PM +0200, Stefan Weil wrote: > The TCG targets no longer need individual implementations. > > Signed-off-by: Stefan Weil <sw@weilnetz.de> > --- > tcg/arm/tcg-target.c | 6 ------ > tcg/hppa/tcg-target.c | 6 ------ > tcg/i386/tcg-target.c | 6 ------ > tcg/ia64/tcg-target.c | 6 ------ > tcg/mips/tcg-target.c | 6 ------ > tcg/ppc/tcg-target.c | 6 ------ > tcg/ppc64/tcg-target.c | 6 ------ > tcg/s390/tcg-target.c | 5 ----- > tcg/sparc/tcg-target.c | 6 ------ > tcg/tcg.c | 7 ++++++- > tcg/tci/tcg-target.c | 6 ------ > 11 files changed, 6 insertions(+), 60 deletions(-) > > diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c > index cf0ca3d..38e2057 100644 > --- a/tcg/arm/tcg-target.c > +++ b/tcg/arm/tcg-target.c > @@ -145,12 +145,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return 4; > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c > index 4f17928..985476a 100644 > --- a/tcg/hppa/tcg-target.c > +++ b/tcg/hppa/tcg-target.c > @@ -175,12 +175,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > *insn_ptr = insn; > } > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return 4; > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c > index d60bab8..3c25acc 100644 > --- a/tcg/i386/tcg-target.c > +++ b/tcg/i386/tcg-target.c > @@ -112,12 +112,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return ARRAY_SIZE(tcg_target_call_iarg_regs); > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c > index dc588db..7f31876 100644 > --- a/tcg/ia64/tcg-target.c > +++ b/tcg/ia64/tcg-target.c > @@ -176,12 +176,6 @@ static const int tcg_target_call_oarg_regs[] = { > TCG_REG_R8 > }; > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return 8; > -} > - > /* > * opcode formation > */ > diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c > index 1006e28..aad590c 100644 > --- a/tcg/mips/tcg-target.c > +++ b/tcg/mips/tcg-target.c > @@ -185,12 +185,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return 4; > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c > index 0cff181..b889e34 100644 > --- a/tcg/ppc/tcg-target.c > +++ b/tcg/ppc/tcg-target.c > @@ -221,12 +221,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return ARRAY_SIZE (tcg_target_call_iarg_regs); > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c > index 27a0ae8..08c5c0f 100644 > --- a/tcg/ppc64/tcg-target.c > +++ b/tcg/ppc64/tcg-target.c > @@ -208,12 +208,6 @@ static void patch_reloc (uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static int tcg_target_get_call_iarg_regs_count (int flags) > -{ > - return ARRAY_SIZE (tcg_target_call_iarg_regs); > -} > - > /* parse target specific constraints */ > static int target_parse_constraint (TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c > index 99b5339..287f010 100644 > --- a/tcg/s390/tcg-target.c > +++ b/tcg/s390/tcg-target.c > @@ -376,11 +376,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -static int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return sizeof(tcg_target_call_iarg_regs) / sizeof(int); > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c > index 247a278..3b6c108 100644 > --- a/tcg/sparc/tcg-target.c > +++ b/tcg/sparc/tcg-target.c > @@ -137,12 +137,6 @@ static void patch_reloc(uint8_t *code_ptr, int type, > } > } > > -/* maximum number of register used for input function arguments */ > -static inline int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return 6; > -} > - > /* parse target specific constraints */ > static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) > { > diff --git a/tcg/tcg.c b/tcg/tcg.c > index a4e7f42..53316f6 100644 > --- a/tcg/tcg.c > +++ b/tcg/tcg.c > @@ -89,7 +89,6 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, > tcg_target_long arg2); > static int tcg_target_const_match(tcg_target_long val, > const TCGArgConstraint *arg_ct); > -static int tcg_target_get_call_iarg_regs_count(int flags); > > TCGOpDef tcg_op_defs[] = { > #define DEF(s, oargs, iargs, cargs, flags) { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags }, > @@ -182,6 +181,12 @@ int gen_new_label(void) > > #include "tcg-target.c" > > +/* Maximum number of register used for input function arguments. */ > +static inline int tcg_target_get_call_iarg_regs_count(int flags) > +{ > + return ARRAY_SIZE(tcg_target_call_iarg_regs); > +} > + Do we really need a function for that, given that it has only one caller? For me ARRAY_SIZE(tcg_target_call_iarg_regs) is even more understandable than tcg_target_get_call_iarg_regs_count(). > /* pool based memory allocation */ > void *tcg_malloc_internal(TCGContext *s, int size) > { > diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c > index 7124b15..7d43132 100644 > --- a/tcg/tci/tcg-target.c > +++ b/tcg/tci/tcg-target.c > @@ -891,12 +891,6 @@ static int tcg_target_const_match(tcg_target_long val, > return arg_ct->ct & TCG_CT_CONST; > } > > -/* Maximum number of register used for input function arguments. */ > -static int tcg_target_get_call_iarg_regs_count(int flags) > -{ > - return ARRAY_SIZE(tcg_target_call_iarg_regs); > -} > - > static void tcg_target_init(TCGContext *s) > { > #if defined(CONFIG_DEBUG_TCG_INTERPRETER) > -- > 1.7.10 > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c 2012-09-12 20:59 ` Aurelien Jarno @ 2012-09-13 5:31 ` Stefan Weil 0 siblings, 0 replies; 11+ messages in thread From: Stefan Weil @ 2012-09-13 5:31 UTC (permalink / raw) To: Aurelien Jarno Cc: Blue Swirl, Peter Maydell, Richard Henderson, Alexander Graf, qemu-devel Am 12.09.2012 22:59, schrieb Aurelien Jarno: > On Wed, Sep 12, 2012 at 10:44:37PM +0200, Stefan Weil wrote: >> The TCG targets no longer need individual implementations. >> >> Signed-off-by: Stefan Weil <sw@weilnetz.de> >> --- >> tcg/arm/tcg-target.c | 6 ------ >> tcg/hppa/tcg-target.c | 6 ------ >> tcg/i386/tcg-target.c | 6 ------ >> tcg/ia64/tcg-target.c | 6 ------ >> tcg/mips/tcg-target.c | 6 ------ >> tcg/ppc/tcg-target.c | 6 ------ >> tcg/ppc64/tcg-target.c | 6 ------ >> tcg/s390/tcg-target.c | 5 ----- >> tcg/sparc/tcg-target.c | 6 ------ >> tcg/tcg.c | 7 ++++++- >> tcg/tci/tcg-target.c | 6 ------ >> 11 files changed, 6 insertions(+), 60 deletions(-) >> >> [...] >> diff --git a/tcg/tcg.c b/tcg/tcg.c >> index a4e7f42..53316f6 100644 >> --- a/tcg/tcg.c >> +++ b/tcg/tcg.c >> @@ -89,7 +89,6 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, >> tcg_target_long arg2); >> static int tcg_target_const_match(tcg_target_long val, >> const TCGArgConstraint *arg_ct); >> -static int tcg_target_get_call_iarg_regs_count(int flags); >> >> TCGOpDef tcg_op_defs[] = { >> #define DEF(s, oargs, iargs, cargs, flags) { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags }, >> @@ -182,6 +181,12 @@ int gen_new_label(void) >> >> #include "tcg-target.c" >> >> +/* Maximum number of register used for input function arguments. */ >> +static inline int tcg_target_get_call_iarg_regs_count(int flags) >> +{ >> + return ARRAY_SIZE(tcg_target_call_iarg_regs); >> +} >> + > Do we really need a function for that, given that it has only one > caller? > > For me ARRAY_SIZE(tcg_target_call_iarg_regs) is even more understandable > than tcg_target_get_call_iarg_regs_count(). > I agree. tcg_target_get_call_iarg_regs_count can be removed completely, but only if we find a solution for the problem which Peter Maydell found: some code accesses tcg_target_call_iarg_regs unconditionally even for x86 32 bit, so for the moment, we cannot reduce its size to 0. Stefan ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 4/4] tcg: Remove unused parameter from tcg_target_get_call_iarg_regs_count 2012-09-12 20:44 [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil ` (2 preceding siblings ...) 2012-09-12 20:44 ` [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c Stefan Weil @ 2012-09-12 20:44 ` Stefan Weil 3 siblings, 0 replies; 11+ messages in thread From: Stefan Weil @ 2012-09-12 20:44 UTC (permalink / raw) To: Blue Swirl Cc: Stefan Weil, Alexander Graf, qemu-devel, Aurelien Jarno, Richard Henderson Since commit 6a18ae2d2947532d5c26439548afa0481c4529f9, 'flags' is no longer used in tcg_target_get_call_iarg_regs_count. Signed-off-by: Stefan Weil <sw@weilnetz.de> --- tcg/tcg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 53316f6..0f0a8d0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -182,7 +182,7 @@ int gen_new_label(void) #include "tcg-target.c" /* Maximum number of register used for input function arguments. */ -static inline int tcg_target_get_call_iarg_regs_count(int flags) +static inline int tcg_target_get_call_iarg_regs_count(void) { return ARRAY_SIZE(tcg_target_call_iarg_regs); } @@ -1871,7 +1871,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, flags = args[nb_oargs + nb_iargs]; - nb_regs = tcg_target_get_call_iarg_regs_count(flags); + nb_regs = tcg_target_get_call_iarg_regs_count(); if (nb_regs > nb_params) nb_regs = nb_params; -- 1.7.10 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-09-13 14:31 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-09-12 20:44 [Qemu-devel] [PATCH 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 2/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs Stefan Weil 2012-09-12 21:18 ` Peter Maydell 2012-09-13 5:50 ` Stefan Weil 2012-09-13 14:19 ` Richard Henderson 2012-09-13 14:31 ` Peter Maydell 2012-09-12 20:44 ` [Qemu-devel] [PATCH 3/4] tcg: Move tcg_target_get_call_iarg_regs_count to tcg.c Stefan Weil 2012-09-12 20:59 ` Aurelien Jarno 2012-09-13 5:31 ` Stefan Weil 2012-09-12 20:44 ` [Qemu-devel] [PATCH 4/4] tcg: Remove unused parameter from tcg_target_get_call_iarg_regs_count Stefan Weil
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).