Subject: Re: RETURN_IN_MEMORY
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: Richard Earnshaw <rearnsha@arm.com>
List: port-arm
Date: 08/28/2002 10:27:28
> Our GCC 2.95.3 does:
> 
> /* We override the default here because the default is to follow the
>    APCS rules and we want to follow the (simpler) ATPCS rules. */
> #undef RETURN_IN_MEMORY
> #define RETURN_IN_MEMORY(TYPE) \
> 	(AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes (TYPE) > 4)
> 
> In GCC 3.x, int_size_in_bytes() returns -1 to indicate a variable-sized
> type, and you would think that we would want to handle that case as a
> return-in-memory, as well.  Therefore, I think we want to cast the return
> value of int_size_in_bytes() to (unsigned int) before the comparison.
> 
> Agree?  Disagree?  (This is the chunk I've added to my local copy of
> GCC 3.x's arm_return_in_memory()):
> 
>   if (TARGET_ATPCS)
>     {
>       /* ATPCS returns aggregate types in memory only if they are
>          larger than a word (or are variable size).  */
>       return (((unsigned int) int_size_in_bytes (type)) > UNITS_PER_WORD);
>     }

Agree, but write the test out explicitly as a check for <0 and a check for 
> UNITS_PER_WORD -- if you put int_size_in_bytes into a temporary gcc 
should do the above optimization for you.

    if (TARGET_ATPCS)
      {
	HOST_WIDE_INT size = int_size_in_bytes (type);

        /* ATPCS returns aggregate types in memory only if they are
           larger than a word (or are variable size).  */
	return (size < 0 || size > UNITS_PER_WORD);
      }

R.