From patchwork Tue May 10 15:44:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 95013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6763C1007D5 for ; Wed, 11 May 2011 03:31:58 +1000 (EST) Received: (qmail 6335 invoked by alias); 10 May 2011 15:45:16 -0000 Received: (qmail 6322 invoked by uid 22791); 10 May 2011 15:45:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 15:45:00 +0000 Received: (qmail 3649 invoked from network); 10 May 2011 15:45:00 -0000 Received: from unknown (HELO ?84.152.158.68?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 15:45:00 -0000 Message-ID: <4DC95D5A.5020105@codesourcery.com> Date: Tue, 10 May 2011 17:44:26 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: GCC Patches Subject: C6X port 8/11: A new FUNCTION_ARG macro References: <4DC956D0.3040306@codesourcery.com> In-Reply-To: <4DC956D0.3040306@codesourcery.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On C6X, we have PARM_BOUNDARY == 8 (one byte), but some function argument slots still must be rounded to a larger value. As far as I could tell there's currently no way of telling gcc about this, hence a new target macro which controls this behaviour. Bernd * doc/tm.texi.in (FUNCTION_ARG_PADDING): Mention FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY. (FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY): Document. * function.c (locate_and_pad_parm): Take it into account. * doc/tm.texi: Regenerate. Index: doc/tm.texi =================================================================== --- doc/tm.texi.orig +++ doc/tm.texi @@ -4163,9 +4163,10 @@ to pad out an argument with extra space. @code{enum direction}: either @code{upward} to pad above the argument, @code{downward} to pad below, or @code{none} to inhibit padding. -The @emph{amount} of padding is always just enough to reach the next -multiple of @code{TARGET_FUNCTION_ARG_BOUNDARY}; this macro does not -control it. +The @emph{amount} of padding is not controlled by this macro. It is +always just enough to reach the next multiple of the alignment boundary, +which is usually @code{PARM_BOUNDARY}, or @code{FUNCTION_ARG_BOUNDARY} +if @code{FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY} is defined. This macro has a default definition which is right for most systems. For little-endian machines, the default is to pad upward. For @@ -4198,6 +4199,12 @@ with the specified mode and type. The d @code{PARM_BOUNDARY} for all arguments. @end deftypefn +@defmac FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY +Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY}. +Define this macro if you want the value of @code{FUNCTION_ARG_BOUNDARY} +to be used for this rounding instead. +@end defmac + @defmac FUNCTION_ARG_REGNO_P (@var{regno}) A C expression that is nonzero if @var{regno} is the number of a hard register in which function arguments are sometimes passed. This does Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in.orig +++ doc/tm.texi.in @@ -4151,9 +4151,10 @@ to pad out an argument with extra space. @code{enum direction}: either @code{upward} to pad above the argument, @code{downward} to pad below, or @code{none} to inhibit padding. -The @emph{amount} of padding is always just enough to reach the next -multiple of @code{TARGET_FUNCTION_ARG_BOUNDARY}; this macro does not -control it. +The @emph{amount} of padding is not controlled by this macro. It is +always just enough to reach the next multiple of the alignment boundary, +which is usually @code{PARM_BOUNDARY}, or @code{FUNCTION_ARG_BOUNDARY} +if @code{FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY} is defined. This macro has a default definition which is right for most systems. For little-endian machines, the default is to pad upward. For @@ -4186,6 +4187,12 @@ with the specified mode and type. The d @code{PARM_BOUNDARY} for all arguments. @end deftypefn +@defmac FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY +Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY}. +Define this macro if you want the value of @code{FUNCTION_ARG_BOUNDARY} +to be used for this rounding instead. +@end defmac + @defmac FUNCTION_ARG_REGNO_P (@var{regno}) A C expression that is nonzero if @var{regno} is the number of a hard register in which function arguments are sometimes passed. This does Index: function.c =================================================================== --- function.c.orig +++ function.c @@ -3709,7 +3709,7 @@ locate_and_pad_parm (enum machine_mode p { tree sizetree; enum direction where_pad; - unsigned int boundary; + unsigned int boundary, round_boundary; int reg_parm_stack_space = 0; int part_size_in_regs; @@ -3741,6 +3741,11 @@ locate_and_pad_parm (enum machine_mode p = type ? size_in_bytes (type) : size_int (GET_MODE_SIZE (passed_mode)); where_pad = FUNCTION_ARG_PADDING (passed_mode, type); boundary = targetm.calls.function_arg_boundary (passed_mode, type); +#ifdef FUNCTION_ARG_ROUND_TO_ARG_BOUNDARY + round_boundary = boundary; +#else + round_boundary = PARM_BOUNDARY; +#endif locate->where_pad = where_pad; /* Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT. */ @@ -3787,8 +3792,8 @@ locate_and_pad_parm (enum machine_mode p tree s2 = sizetree; if (where_pad != none && (!host_integerp (sizetree, 1) - || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % PARM_BOUNDARY)) - s2 = round_up (s2, PARM_BOUNDARY / BITS_PER_UNIT); + || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % round_boundary)) + s2 = round_up (s2, round_boundary / BITS_PER_UNIT); SUB_PARM_SIZE (locate->slot_offset, s2); } @@ -3840,8 +3845,8 @@ locate_and_pad_parm (enum machine_mode p if (where_pad != none && (!host_integerp (sizetree, 1) - || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % PARM_BOUNDARY)) - sizetree = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT); + || (tree_low_cst (sizetree, 1) * BITS_PER_UNIT) % round_boundary)) + sizetree = round_up (sizetree, round_boundary / BITS_PER_UNIT); ADD_PARM_SIZE (locate->size, sizetree);