From patchwork Fri May 27 15:54:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 97701 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 5A99FB6F95 for ; Sat, 28 May 2011 01:54:30 +1000 (EST) Received: (qmail 31031 invoked by alias); 27 May 2011 15:54:28 -0000 Received: (qmail 31016 invoked by uid 22791); 27 May 2011 15:54:26 -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; Fri, 27 May 2011 15:54:10 +0000 Received: (qmail 4863 invoked from network); 27 May 2011 15:54:09 -0000 Received: from unknown (HELO ?84.152.188.204?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 May 2011 15:54:09 -0000 Message-ID: <4DDFC91C.60200@codesourcery.com> Date: Fri, 27 May 2011 15:54:04 +0000 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Paolo Bonzini CC: "Joseph S. Myers" , GCC Patches Subject: Re: C6X port 8/11: A new FUNCTION_ARG macro References: <4DC956D0.3040306@codesourcery.com> <4DC95D5A.5020105@codesourcery.com> <4DCBFF53.2050205@codesourcery.com> <4DD21712.2090704@gnu.org> In-Reply-To: <4DD21712.2090704@gnu.org> 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 05/17/2011 06:34 AM, Paolo Bonzini wrote: > On 05/12/2011 05:40 PM, Bernd Schmidt wrote: >> + if (targetm.calls.function_arg_round_to_arg_boundary (passed_mode, >> type)) >> + round_boundary = boundary; >> + else >> + round_boundary = PARM_BOUNDARY; > > Why add an if, instead of making the new target hook > function_arg_round_boundary? The default implementation can then reuse > default_function_arg_boundary and C6X will redefine it to > c6x_function_arg_boundary. Like this? Untested so far beyond making sure it builds. Bernd * doc/tm.texi.in (FUNCTION_ARG_PADDING): Mention TARGET_FUNCTION_ARG_ROUND_BOUNDARY. (TARGET_FUNCTION_ARG_ROUND_BOUNDARY): Add hook. * function.c (locate_and_pad_parm): Take it into account. * target.def (function_arg_round_boundary): New hook. * targhooks.c (default_function_arg_round_boundary): New function. * targhooks.h (default_function_arg_round_boundary): Declare. * doc/tm.texi: Regenerate. Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 174339) +++ gcc/doc/tm.texi (working copy) @@ -4165,9 +4165,9 @@ 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, but by the +target hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}. It is +always just enough to reach the next multiple of that boundary. This macro has a default definition which is right for most systems. For little-endian machines, the default is to pad upward. For @@ -4200,6 +4200,13 @@ with the specified mode and type. The d @code{PARM_BOUNDARY} for all arguments. @end deftypefn +@deftypefn {Target Hook} {unsigned int} TARGET_FUNCTION_ARG_ROUND_BOUNDARY (enum machine_mode @var{mode}, const_tree @var{type}) +Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY}, +which is the default value for this hook. You can define this hook to +return a different value if an argument size must be rounded to a larger +value. +@end deftypefn + @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: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 174339) +++ gcc/doc/tm.texi.in (working copy) @@ -4153,9 +4153,9 @@ 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, but by the +target hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}. It is +always just enough to reach the next multiple of that boundary. This macro has a default definition which is right for most systems. For little-endian machines, the default is to pad upward. For @@ -4188,6 +4188,8 @@ with the specified mode and type. The d @code{PARM_BOUNDARY} for all arguments. @end deftypefn +@hook TARGET_FUNCTION_ARG_ROUND_BOUNDARY + @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: gcc/targhooks.c =================================================================== --- gcc/targhooks.c (revision 174339) +++ gcc/targhooks.c (working copy) @@ -614,6 +614,13 @@ default_function_arg_boundary (enum mach return PARM_BOUNDARY; } +unsigned int +default_function_arg_round_boundary (enum machine_mode mode ATTRIBUTE_UNUSED, + const_tree type ATTRIBUTE_UNUSED) +{ + return PARM_BOUNDARY; +} + void hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED) { Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 174339) +++ gcc/targhooks.h (working copy) @@ -115,6 +115,8 @@ extern rtx default_function_incoming_arg (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); extern unsigned int default_function_arg_boundary (enum machine_mode, const_tree); +extern unsigned int default_function_arg_round_boundary (enum machine_mode, + const_tree); extern bool hook_bool_const_rtx_commutative_p (const_rtx, int); extern rtx default_function_value (const_tree, const_tree, bool); extern rtx default_libcall_value (enum machine_mode, const_rtx); Index: gcc/target.def =================================================================== --- gcc/target.def (revision 174339) +++ gcc/target.def (working copy) @@ -2055,6 +2055,15 @@ DEFHOOK unsigned int, (enum machine_mode mode, const_tree type), default_function_arg_boundary) +DEFHOOK +(function_arg_round_boundary, + "Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},\n\ +which is the default value for this hook. You can define this hook to\n\ +return a different value if an argument size must be rounded to a larger\n\ +value.", + unsigned int, (enum machine_mode mode, const_tree type), + default_function_arg_round_boundary) + /* Return the diagnostic message string if function without a prototype is not allowed for this 'val' argument; NULL otherwise. */ DEFHOOK Index: gcc/function.c =================================================================== --- gcc/function.c (revision 174339) +++ gcc/function.c (working copy) @@ -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,8 @@ 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); + round_boundary = targetm.calls.function_arg_round_boundary (passed_mode, + type); locate->where_pad = where_pad; /* Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT. */ @@ -3787,8 +3789,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 +3842,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);