Fix struct ret in variadic fct with ARM hardfloat

The procedure calling standard for ARM architecture mandate the use of
the base standard for variadic function. Therefore, hgen float aggregate
must be returned via stack when greater than 4 bytes and via core
registers else in case of variadic function.

This patch improve gfunc_sret() to take into account whether the
function is variadic or not and make use of gfunc_sret() return value to
determine whether to pass a structure via stack in gfunc_prolog(). It
also take advantage of knowing if a function is variadic or not move
float result value from VFP register to core register in gfunc_epilog().
This commit is contained in:
Thomas Preud'homme
2014-01-06 22:27:39 +08:00
parent bcc1904f9c
commit 8efaa71190
7 changed files with 35 additions and 23 deletions

View File

@ -1881,7 +1881,7 @@ static void gcall_or_jmp(int is_jmp)
/* Return the number of registers needed to return the struct, or 0 if
returning via struct pointer. */
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align) {
*ret_align = 1; // Never have to re-align return values for x86-64
return 0;
}
@ -1971,6 +1971,7 @@ void gfunc_prolog(CType * func_type)
/* if the function returns a structure, then add an
implicit pointer parameter */
func_vt = sym->type;
func_var = (sym->c == FUNC_ELLIPSIS);
if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
func_vc = addr;
addr += 4;