[arm, patch] Remove redundant promotion of function arguments

Paul Brook paul@codesourcery.com
Thu Apr 8 12:22:00 GMT 2004


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.extend
Type: text/x-diff
Size: 13597 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040408/45eec5e8/attachment.bin>


More information about the Gcc-patches mailing list