This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] fr30: Hookize some target macros. (part 2)
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: nickc at redhat dot com
- Date: Thu, 29 Jan 2004 04:20:37 -0500 (EST)
- Subject: [patch] fr30: Hookize some target macros. (part 2)
Hi,
Attached is a patch to hookize some target macros that I forgot to
take care of.
The only reason why the hunk for fr30_setup_incoming_varargs is big is
that there is a if statement wrapping fr30_setup_incoming_varargs
in SETUP_INCOMING_VARARGS.
Two functions, fr30_num_arg_regs and fr30_function_arg_partial_nregs,
use int to represent enum machine_mode. I have straightened these
out.
The patch also removes some target-independent comments about target
macros that mention deprecated macro, such as STRUCT_VALUE_REGNUM and
RETURN_IN_MEMORY.
Built fr30-elf. OK to apply?
Kazu Hirata
2004-01-29 Kazu Hirata <kazu@cs.umass.edu>
* config/fr30/fr30-protos.h: Remove the prototype for
fr30_setup_incoming_varargs.
Update the prototypes for fr30_num_arg_regs and
fr30_function_arg_partial_nregs.
* config/fr30/fr30.c (TARGET_STRUCT_VALUE_RTX): New.
(TARGET_SETUP_INCOMING_VARARGS): Likewise.
(fr30_setup_incoming_varargs): Make it static.
Add argument second_time. Don't do anything when second_time
is nonzero.
(fr30_num_arg_regs): Change the type of the first argument to
enum machine_mode.
(fr30_function_arg_partial_nregs): Change the type of the
second argument to enum machine_mode.
* config/fr30/fr30.h (STRUCT_VALUE): Remove.
(SETUP_INCOMING_VARARGS): Remove.
Remove some target-independent comments about target macros.
Index: fr30-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/fr30/fr30-protos.h,v
retrieving revision 1.7
diff -c -r1.7 fr30-protos.h
*** fr30-protos.h 5 Dec 2003 09:38:29 -0000 1.7
--- fr30-protos.h 29 Jan 2004 09:09:43 -0000
***************
*** 29,34 ****
--- 29,37 ----
extern rtx fr30_move_double (rtx *);
#ifdef TREE_CODE
extern rtx fr30_va_arg (tree, tree);
+ extern int fr30_num_arg_regs (enum machine_mode, tree);
+ extern int fr30_function_arg_partial_nregs (CUMULATIVE_ARGS,
+ enum machine_mode, tree, int);
#endif /* TREE_CODE */
#ifdef HAVE_MACHINE_MODES
#define Mmode enum machine_mode
***************
*** 43,51 ****
#undef Mmode
#endif /* HAVE_MACHINE_MODES */
#endif /* RTX_CODE */
-
- #ifdef TREE_CODE
- extern int fr30_num_arg_regs (int, tree);
- extern int fr30_function_arg_partial_nregs (CUMULATIVE_ARGS, int, tree, int);
- extern void fr30_setup_incoming_varargs (CUMULATIVE_ARGS, int, tree, int *);
- #endif /* TREE_CODE */
--- 46,48 ----
Index: fr30.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/fr30/fr30.c,v
retrieving revision 1.37
diff -c -r1.37 fr30.c
*** fr30.c 29 Jan 2004 01:40:48 -0000 1.37
--- fr30.c 29 Jan 2004 09:09:44 -0000
***************
*** 121,126 ****
--- 121,128 ----
/* Zero structure to initialize current_frame_info. */
static struct fr30_frame_info zero_frame_info;
+ static void fr30_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
+ tree, int *, int);
static rtx fr30_pass_by_reference (tree, tree);
static rtx fr30_pass_by_value (tree, tree);
***************
*** 152,157 ****
--- 154,165 ----
#undef TARGET_PROMOTE_PROTOTYPES
#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
+ #undef TARGET_STRUCT_VALUE_RTX
+ #define TARGET_STRUCT_VALUE_RTX hook_rtx_tree_int_null
+
+ #undef TARGET_SETUP_INCOMING_VARARGS
+ #define TARGET_SETUP_INCOMING_VARARGS fr30_setup_incoming_varargs
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Returns the number of bytes offset between FROM_REG and TO_REG
***************
*** 407,439 ****
ARG_REGS_USED_SO_FAR has *not* been updated for the last named argument
which has type TYPE and mode MODE, and we rely on this fact. */
! void
! fr30_setup_incoming_varargs (CUMULATIVE_ARGS arg_regs_used_so_far,
! int int_mode,
tree type ATTRIBUTE_UNUSED,
! int *pretend_size)
{
! enum machine_mode mode = (enum machine_mode)int_mode;
! int size;
! /* All BLKmode values are passed by reference. */
! if (mode == BLKmode)
! abort ();
!
! /* ??? This run-time test as well as the code inside the if
! statement is probably unnecessary. */
! if (targetm.calls.strict_argument_naming (&arg_regs_used_so_far))
! /* If TARGET_STRICT_ARGUMENT_NAMING returns true, then the last named
! arg must not be treated as an anonymous arg. */
! arg_regs_used_so_far += fr30_num_arg_regs (int_mode, type);
! size = FR30_NUM_ARG_REGS - arg_regs_used_so_far;
! if (size <= 0)
! return;
! * pretend_size = (size * UNITS_PER_WORD);
}
/*}}}*/
--- 415,450 ----
ARG_REGS_USED_SO_FAR has *not* been updated for the last named argument
which has type TYPE and mode MODE, and we rely on this fact. */
! static void
! fr30_setup_incoming_varargs (CUMULATIVE_ARGS *arg_regs_used_so_far,
! enum machine_mode mode,
tree type ATTRIBUTE_UNUSED,
! int *pretend_size,
! int second_time)
{
! if (!second_time)
! {
! int size;
! /* All BLKmode values are passed by reference. */
! if (mode == BLKmode)
! abort ();
!
! /* ??? This run-time test as well as the code inside the if
! statement is probably unnecessary. */
! if (targetm.calls.strict_argument_naming (arg_regs_used_so_far))
! /* If TARGET_STRICT_ARGUMENT_NAMING returns true, then the last named
! arg must not be treated as an anonymous arg. */
! arg_regs_used_so_far += fr30_num_arg_regs (mode, type);
! size = FR30_NUM_ARG_REGS - *arg_regs_used_so_far;
! if (size <= 0)
! return;
! * pretend_size = (size * UNITS_PER_WORD);
! }
}
/*}}}*/
***************
*** 662,670 ****
/* Compute the number of word sized registers needed to hold a
function argument of mode INT_MODE and tree type TYPE. */
int
! fr30_num_arg_regs (int int_mode, tree type)
{
- enum machine_mode mode = (enum machine_mode) int_mode;
int size;
if (MUST_PASS_IN_STACK (mode, type))
--- 673,680 ----
/* Compute the number of word sized registers needed to hold a
function argument of mode INT_MODE and tree type TYPE. */
int
! fr30_num_arg_regs (enum machine_mode mode, tree type)
{
int size;
if (MUST_PASS_IN_STACK (mode, type))
***************
*** 687,693 ****
parameters to the function. */
int
! fr30_function_arg_partial_nregs (CUMULATIVE_ARGS cum, int int_mode,
tree type, int named)
{
/* Unnamed arguments, ie those that are prototyped as ...
--- 697,703 ----
parameters to the function. */
int
! fr30_function_arg_partial_nregs (CUMULATIVE_ARGS cum, enum machine_mode mode,
tree type, int named)
{
/* Unnamed arguments, ie those that are prototyped as ...
***************
*** 702,708 ****
are needed because the parameter must be passed on the stack)
then return zero, as this parameter does not require partial
register, partial stack stack space. */
! if (cum + fr30_num_arg_regs (int_mode, type) <= FR30_NUM_ARG_REGS)
return 0;
/* Otherwise return the number of registers that would be used. */
--- 712,718 ----
are needed because the parameter must be passed on the stack)
then return zero, as this parameter does not require partial
register, partial stack stack space. */
! if (cum + fr30_num_arg_regs (mode, type) <= FR30_NUM_ARG_REGS)
return 0;
/* Otherwise return the number of registers that would be used. */
Index: fr30.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/fr30/fr30.h,v
retrieving revision 1.47
diff -c -r1.47 fr30.h
*** fr30.h 29 Jan 2004 01:40:48 -0000 1.47
--- fr30.h 29 Jan 2004 09:09:44 -0000
***************
*** 783,806 ****
/*}}}*/
/*{{{ How Scalar Function Values are Returned. */
- /* A C expression to create an RTX representing the place where a function
- returns a value of data type VALTYPE. VALTYPE is a tree node representing a
- data type. Write `TYPE_MODE (VALTYPE)' to get the machine mode used to
- represent that type. On many machines, only the mode is relevant.
- (Actually, on most machines, scalar values are returned in the same place
- regardless of mode).
-
- If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same promotion
- rules specified in `PROMOTE_MODE' if VALTYPE is a scalar type.
-
- If the precise function being called is known, FUNC is a tree node
- (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer. This makes it
- possible to use a different value-returning convention for specific
- functions when all their calls are known.
-
- `FUNCTION_VALUE' is not used for return vales with aggregate data types,
- because these are returned in another way. See `STRUCT_VALUE_REGNUM' and
- related macros, below. */
#define FUNCTION_VALUE(VALTYPE, FUNC) \
gen_rtx_REG (TYPE_MODE (VALTYPE), RETURN_VALUE_REGNUM)
--- 783,788 ----
***************
*** 826,846 ****
/*}}}*/
/*{{{ How Large Values are Returned. */
- /* Define this macro to be 1 if all structure and union return values must be
- in memory. Since this results in slower code, this should be defined only
- if needed for compatibility with other compilers or with an ABI. If you
- define this macro to be 0, then the conventions used for structure and union
- return values are decided by the `RETURN_IN_MEMORY' macro.
-
- If not defined, this defaults to the value 1. */
#define DEFAULT_PCC_STRUCT_RETURN 1
- /* If the structure value address is not passed in a register, define
- `STRUCT_VALUE' as an expression returning an RTX for the place where the
- address is passed. If it returns 0, the address is passed as an "invisible"
- first argument. */
- #define STRUCT_VALUE 0
-
/*}}}*/
/*{{{ Generating Code for Profiling. */
--- 808,815 ----
***************
*** 862,902 ****
fprintf (FILE, "\t call @r0\n" ); \
fprintf (FILE, ".word\tLP%d\n", LABELNO); \
}
-
- /*}}}*/
- /*{{{ Implementing the VARARGS Macros. */
-
- /* This macro offers an alternative to using `__builtin_saveregs' and defining
- the macro `EXPAND_BUILTIN_SAVEREGS'. Use it to store the anonymous register
- arguments into the stack so that all the arguments appear to have been
- passed consecutively on the stack. Once this is done, you can use the
- standard implementation of varargs that works for machines that pass all
- their arguments on the stack.
-
- The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure, containing
- the values that obtain after processing of the named arguments. The
- arguments MODE and TYPE describe the last named argument--its machine mode
- and its data type as a tree node.
-
- The macro implementation should do two things: first, push onto the stack
- all the argument registers *not* used for the named arguments, and second,
- store the size of the data thus pushed into the `int'-valued variable whose
- name is supplied as the argument PRETEND_ARGS_SIZE. The value that you
- store here will serve as additional offset for setting up the stack frame.
-
- Because you must generate code to push the anonymous arguments at compile
- time without knowing their data types, `SETUP_INCOMING_VARARGS' is only
- useful on machines that have just a single category of argument register and
- use it uniformly for all data types.
-
- If the argument SECOND_TIME is nonzero, it means that the arguments of the
- function are being analyzed for the second time. This happens for an inline
- function, which is not actually compiled until the end of the source file.
- The macro `SETUP_INCOMING_VARARGS' should not generate any instructions in
- this case. */
- #define SETUP_INCOMING_VARARGS(ARGS_SO_FAR, MODE, TYPE, PRETEND_ARGS_SIZE, SECOND_TIME) \
- if (! SECOND_TIME) \
- fr30_setup_incoming_varargs (ARGS_SO_FAR, MODE, TYPE, & PRETEND_ARGS_SIZE)
/*}}}*/
/*{{{ Trampolines for Nested Functions. */
--- 831,836 ----