This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [arm, patch] Remove redundant promotion of function arguments
On Thu, 2004-04-08 at 13:22, Paul Brook wrote:
> On Thursday 01 April 2004 17:22, Richard Earnshaw wrote:
> > > using -malignment-traps causes the sign-extension in r and s to become
> > > zero-extention confirming that PROMOTE_MODE is being exposed here.
> > >
> > > So the compiler isn't really promoting arguments according the the AAPCS
> > > (or ATPCS) rules, but is instead just doing a promotion that is supposed
> > > to be part of an optimization and then exposing that in the calling
> > > convention. That's clearly wrong.
>
> <snip>
>
> The attached patch splits PROMOTE_FUNCTION_MODE off from PROMOTE_MODE and
> removes PROMOTE_FOR_CALL_ONLY as described by Richard.
>
> This allows us to do abi compliant function argument/return value promotions
> on ARM, instead of setting TARGET_PROMOTE_PROTOTYPES. This eliminates the
> redundant extension of function arguments by the callee.
>
> These changes maintain abi compatibility with previous versions of gcc, and
> the atpcs and aapcs. Older standards (apcs) seem somewhat less clear, but I
> think they are compatible. The changes also make gcc mirror the behavior of
> armcc.
>
> Changes to other targets are simply renaming of macros and corresponding
> comments. There is not difference in the generated code for any target other
> than arm.
>
> Tested on sparc-sun-solaris2.8/-m64 and cross-compiler to arm-none-elf, and by
> manually inspecting the generated assembly for the examples given previously
> in this thread.
>
> Ok?
>
> Paul
>
> 2004-04-08 Paul Brook <paul@codesourcery.com>
>
> * explow.c (promote_mode): Use PROMOTE_FUNCTION_MODE instead of
> PROMOTE_FOR_CALL_ONLY.
> * config/arm/arm-protos.h (arm_function_value): Declare.
> * config/arm/arm.h (TARGET_PROMOTE_FUNCTION_ARGS): Define.
> (TARGET_PROMOTE_PROTOTYPES): Return false.
> (arm_function_value): New function.
> * config/arm/arm.h (PROMOTE_FUNCTION_MODE): Define.
> (FUNCTION_VALUE): Call arm_function_value.
> * config/cris/cris.h (PROMOTE_MODE): Rename ...
> (PROMOTE_FUNCTION_MODE): ... to this.
> (PROMOTE_FOR_CALL_ONLY): Remove.
> * config/mmix/mmix.h: Likewise.
> * config/s390/s390.h: Likewise.
> * config/sparc/sparc.h: Likewise.
> * config/sparc/sparc.c: Update comments about PROMOTE_MODE.
> * doc/tm.texi (PROMOTE_FUNCTION_MODE): Document.
> (TARGET_PROMOTE_FUNCTION_MODE, TARGET_PROMOTE_FUNCTION_RETURN): Update.
> (PROMOTE_FOR_CALL_ONLY): Remove.
There's a problem with the ARM implementation. Specifically, you've
changed the ABI for the 'ATPCS' and APCS. Previously those ABIs would
promote things somewhat randomly (varies depending on the -march value)
at the caller side, so you need TARGET_PROMOTE_PROTOTYPES to return TRUE
when the ABI is not AAPCS conformant.
You should also poison PROMOTE_FOR_CALL_ONLY.
R.