From 123148b532a990e5fdf956cd563327af1391b2df Mon Sep 17 00:00:00 2001 From: Bernd Schmidt Date: Tue, 12 Jul 2011 14:57:28 +0000 Subject: [PATCH] tm.texi.in (FUNCTION_ARG_PADDING): Mention TARGET_FUNCTION_ARG_ROUND_BOUNDARY. * 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. From-SVN: r176207 --- gcc/ChangeLog | 11 +++++++++++ gcc/doc/tm.texi | 13 ++++++++++--- gcc/doc/tm.texi.in | 8 +++++--- gcc/function.c | 12 +++++++----- gcc/target.def | 9 +++++++++ gcc/targhooks.c | 7 +++++++ gcc/targhooks.h | 2 ++ 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d519a80a74a..903c11733d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2011-07-12 Bernd Schmidt + + * 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. + 2011-07-12 Richard Guenther * tree-ssa-copyrename.c (rename_ssa_copies): Zero statistics. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index c0648a5657c..faf8b6c66f8 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4180,9 +4180,9 @@ to pad out an argument with extra space. The value should be of type @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 @@ -4215,6 +4215,13 @@ with the specified mode and type. The default hook returns @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 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 3660d36d7b5..d823faeed53 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -4166,9 +4166,9 @@ to pad out an argument with extra space. The value should be of type @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 @@ -4201,6 +4201,8 @@ with the specified mode and type. The default hook returns @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 diff --git a/gcc/function.c b/gcc/function.c index 0b2f5aa5c37..894930f75bb 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3705,7 +3705,7 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, { 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; @@ -3737,6 +3737,8 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, = 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. */ @@ -3783,8 +3785,8 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, 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); } @@ -3836,8 +3838,8 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, 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); diff --git a/gcc/target.def b/gcc/target.def index c67f0bacf7f..9f03ac922ac 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2021,6 +2021,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 diff --git a/gcc/targhooks.c b/gcc/targhooks.c index bcb8a12bc4e..f69b39626a6 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -614,6 +614,13 @@ default_function_arg_boundary (enum machine_mode mode ATTRIBUTE_UNUSED, 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) { diff --git a/gcc/targhooks.h b/gcc/targhooks.h index ce89d32afca..62e888445bb 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -115,6 +115,8 @@ extern rtx default_function_incoming_arg (cumulative_args_t, 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); -- 2.30.2