This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: new argument macro: INITIAL_ARGS_SIZE
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: David Edelsohn <dje at watson dot ibm dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: 28 Feb 2002 17:01:35 +1100
- Subject: Re: new argument macro: INITIAL_ARGS_SIZE
- References: <200202280453.XAA24670@makai.watson.ibm.com>
>>>>> "David" == David Edelsohn <dje@watson.ibm.com> writes:
> This type of patch defining macros to a value or zero depending on
> TARGET_ALTIVEC_ABI is a reasonable approach for the GCC 3.1 branch. If
> the macros are defined wrong for PowerPC, we need to define them correctly
> for GCC 3.2 trunk, not this type of kludge. I would prefer to not put a
> kludge in the GCC 3.1 branch without a correct fix for GCC 3.2 trunk also
> ready.
Richard mentioned that the definitions apply to both altivec and non
altivec.
I don't understand the code to be of much use here, but here's the
updated patch making the changes for altivec AND non-altivec-- in
a non kludgey manner ;-). I still need to test more variants though.
IMO, this should go in both 3.1 and the trunk.
Finally, there's an additional patchlet for instantiate_virtual_regs
to take into account INITIAL_ARGS_SIZE, since with the latest
proposed changes, in_arg_offset was off and unaligned things.
Aldy
2002-02-28 Richard Henderson <rth@redhat.com>
Secretary: Aldy Hernandez <aldyh@redhat.com>
* doc/tm.texi (INITIAL_ARGS_SIZE): Document.
* defaults.h (INITIAL_ARGS_SIZE): New.
* calls.c (initialize_argument_information): Initialize
args_size->constant to INITIAL_ARGS_SIZE.
* function.c (assign_parms): Initialize stack_args_size.constant to
FIRST_PARM_OFFSET.
(instantiate_virtual_regs): Subtract INITIAL_ARGS_SIZE from
in_arg_offset.
2002-02-28 Aldy Hernandez <aldyh@redhat.com>
* config/rs6000/rs6000.h (STACK_POINTER_OFFSET): Set to 0.
(INITIAL_ARGS_SIZE): Define.
* config/rs6000/rs6000.c (setup_incoming_varargs): Adjust memory
offset in which to put registers by INITIAL_ARGS_SIZE.
Index: doc/tm.texi
===================================================================
RCS file: /cvs/uberbaum/gcc/doc/tm.texi,v
retrieving revision 1.102
diff -c -p -r1.102 tm.texi
*** tm.texi 2002/02/23 12:59:09 1.102
--- tm.texi 2002/02/28 05:48:43
*************** function.
*** 2609,2614 ****
--- 2609,2625 ----
If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
the first argument's address.
+ @findex INITIAL_ARGS_SIZE
+ @item INITIAL_ARGS_SIZE (@var{fundecl})
+ Offset from @code{virtual_outgoing_args} and
+ @code{virtual_incoming_args} to the first argument's address.
+
+ On some machines, the natural definition of
+ @code{virtual_outgoing_args} and
+ @code{virtual_incoming_args} are not as aligned as the stack pointer.
+ In these cases, use @code{INITIAL_ARGS_SIZE} and set
+ @code{STACK_POINTER_OFFSET} to zero.
+
@findex STACK_DYNAMIC_OFFSET
@item STACK_DYNAMIC_OFFSET (@var{fundecl})
Offset from the stack pointer register to an item dynamically allocated
Index: defaults.h
===================================================================
RCS file: /cvs/uberbaum/gcc/defaults.h,v
retrieving revision 1.64
diff -c -p -r1.64 defaults.h
*** defaults.h 2001/12/17 16:46:09 1.64
--- defaults.h 2002/02/28 05:48:43
*************** do { \
*** 365,370 ****
--- 365,377 ----
#define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
#endif
+ /* Offset from virtual_outgoing_args or virtual_incoming_args to the
+ first argument's address. If this is nonzero, STACK_POINTER_OFFSET
+ should be set to 0. */
+ #ifndef INITIAL_ARGS_SIZE
+ #define INITIAL_ARGS_SIZE(x) 0
+ #endif
+
/* By default, the C++ compiler will use function addresses in the
vtable entries. Setting this non-zero tells the compiler to use
function descriptors instead. The value of this macro says how
Index: calls.c
===================================================================
RCS file: /cvs/uberbaum/gcc/calls.c,v
retrieving revision 1.221
diff -c -p -r1.221 calls.c
*** calls.c 2002/02/11 13:33:07 1.221
--- calls.c 2002/02/28 05:48:45
*************** initialize_argument_information (num_act
*** 1136,1142 ****
int i;
tree p;
! args_size->constant = 0;
args_size->var = 0;
/* In this loop, we consider args in the order they are written.
--- 1136,1142 ----
int i;
tree p;
! args_size->constant = INITIAL_ARGS_SIZE (fndecl);
args_size->var = 0;
/* In this loop, we consider args in the order they are written.
Index: function.c
===================================================================
RCS file: /cvs/uberbaum/gcc/function.c,v
retrieving revision 1.347
diff -c -p -r1.347 function.c
*** function.c 2002/02/19 02:53:15 1.347
--- function.c 2002/02/28 05:48:48
*************** instantiate_virtual_regs (fndecl, insns)
*** 3486,3492 ****
--- 3486,3496 ----
unsigned int i;
/* Compute the offsets to use for this function. */
+ #ifdef INITIAL_ARGS_SIZE
+ in_arg_offset = FIRST_PARM_OFFSET (fndecl) - INITIAL_ARGS_SIZE (fndecl);
+ #else
in_arg_offset = FIRST_PARM_OFFSET (fndecl);
+ #endif
var_offset = STARTING_FRAME_OFFSET;
dynamic_offset = STACK_DYNAMIC_OFFSET (fndecl);
out_arg_offset = STACK_POINTER_OFFSET;
*************** assign_parms (fndecl)
*** 4269,4275 ****
--- 4273,4283 ----
internal_arg_pointer = virtual_incoming_args_rtx;
current_function_internal_arg_pointer = internal_arg_pointer;
+ #ifdef INITIAL_ARGS_SIZE
+ stack_args_size.constant = FIRST_PARM_OFFSET (context);
+ #else
stack_args_size.constant = 0;
+ #endif
stack_args_size.var = 0;
/* If struct value address is treated as the first argument, make it so. */
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.184
diff -c -p -r1.184 rs6000.h
*** rs6000.h 2002/02/21 02:34:20 1.184
--- rs6000.h 2002/02/28 05:48:50
*************** typedef struct rs6000_stack {
*** 1425,1432 ****
/* This is the difference between the logical top of stack and the actual sp.
! For the RS/6000, sp points past the fixed area. */
! #define STACK_POINTER_OFFSET RS6000_SAVE_AREA
/* Define this if the maximum size of all the outgoing args is to be
accumulated and pushed during the prologue. The amount can be
--- 1425,1438 ----
/* This is the difference between the logical top of stack and the actual sp.
! For the RS/6000, sp points past the fixed area, but we set to
! 0 because we defined INITIAL_ARGS_SIZE below. */
! #define STACK_POINTER_OFFSET 0
!
! /* Offset from virtual_outgoing_args or virtual_incoming_args to the
! first argument's address. If this is nonzero, STACK_POINTER_OFFSET
! should be set to 0. */
! #define INITIAL_ARGS_SIZE(FNDECL) RS6000_SAVE_AREA
/* Define this if the maximum size of all the outgoing args is to be
accumulated and pushed during the prologue. The amount can be
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.291
diff -c -p -r1.291 rs6000.c
*** rs6000.c 2002/02/25 02:30:32 1.291
--- rs6000.c 2002/02/28 05:48:54
*************** setup_incoming_varargs (cum, mode, type,
*** 2909,2923 ****
stack, or can we allocate this with assign_stack_local instead. */
cfun->machine->sysv_varargs_p = 1;
if (! no_rtl)
! save_area = plus_constant (virtual_stack_vars_rtx,
! - RS6000_VARARGS_SIZE);
first_reg_offset = next_cum.sysv_gregno - GP_ARG_MIN_REG;
}
else
{
first_reg_offset = next_cum.words;
! save_area = virtual_incoming_args_rtx;
cfun->machine->sysv_varargs_p = 0;
if (MUST_PASS_IN_STACK (mode, type))
--- 2909,2927 ----
stack, or can we allocate this with assign_stack_local instead. */
cfun->machine->sysv_varargs_p = 1;
if (! no_rtl)
! save_area
! = plus_constant (virtual_stack_vars_rtx,
! - RS6000_VARARGS_SIZE
! + INITIAL_ARGS_SIZE (current_function_decl));
first_reg_offset = next_cum.sysv_gregno - GP_ARG_MIN_REG;
}
else
{
first_reg_offset = next_cum.words;
! save_area
! = plus_constant (virtual_incoming_args_rtx,
! INITIAL_ARGS_SIZE (current_function_decl));
cfun->machine->sysv_varargs_p = 0;
if (MUST_PASS_IN_STACK (mode, type))