This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[fr30] hookize FUNCTION_ARG &co.
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: nickc at redhat dot com
- Date: Fri, 8 Oct 2010 09:58:18 -0400
- Subject: [fr30] hookize FUNCTION_ARG &co.
The patch below hookizes FUNCTION_ARG and related macros for the fr30
backend. Nothing special here.
Tested by inspection with cross to fr30-elf. I plan to commit this
under the obvious rule after waiting a week for comments/approval.
* config/fr30/fr30-protos.h (fr30_num_arg_regs): Delete.
* config/fr30/fr30.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
* config/fr30/fr30.c (fr30_num_arg_regs): Make static. Take a
const_tree.
(fr30_function_arg): New function.
(fr30_function_arg_advance): New function.
(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.
---
gcc/config/fr30/fr30-protos.h | 3 ---
gcc/config/fr30/fr30.c | 40 ++++++++++++++++++++++++++++++++++++++--
gcc/config/fr30/fr30.h | 17 -----------------
3 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/gcc/config/fr30/fr30-protos.h b/gcc/config/fr30/fr30-protos.h
index 0ea28a3..37fc2a2 100644
--- a/gcc/config/fr30/fr30-protos.h
+++ b/gcc/config/fr30/fr30-protos.h
@@ -26,9 +26,6 @@ extern int fr30_check_multiple_regs (rtx *, int, int);
extern void fr30_print_operand (FILE *, rtx, int);
extern void fr30_print_operand_address (FILE *, rtx);
extern rtx fr30_move_double (rtx *);
-#ifdef TREE_CODE
-extern int fr30_num_arg_regs (enum machine_mode, tree);
-#endif /* TREE_CODE */
#ifdef HAVE_MACHINE_MODES
#define Mmode enum machine_mode
extern int fr30_const_double_is_zero (rtx);
diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c
index 118de0a..50cf00c 100644
--- a/gcc/config/fr30/fr30.c
+++ b/gcc/config/fr30/fr30.c
@@ -119,10 +119,15 @@ static void fr30_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
static bool fr30_must_pass_in_stack (enum machine_mode, const_tree);
static int fr30_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
tree, bool);
+static rtx fr30_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+ const_tree, bool);
+static void fr30_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+ const_tree, bool);
static bool fr30_frame_pointer_required (void);
static bool fr30_can_eliminate (const int, const int);
static void fr30_asm_trampoline_template (FILE *);
static void fr30_trampoline_init (rtx, tree, rtx);
+static int fr30_num_arg_regs (enum machine_mode, const_tree);
#define FRAME_POINTER_MASK (1 << (FRAME_POINTER_REGNUM))
#define RETURN_POINTER_MASK (1 << (RETURN_POINTER_REGNUM))
@@ -155,6 +160,10 @@ static void fr30_trampoline_init (rtx, tree, rtx);
#define TARGET_PASS_BY_REFERENCE hook_pass_by_reference_must_pass_in_stack
#undef TARGET_ARG_PARTIAL_BYTES
#define TARGET_ARG_PARTIAL_BYTES fr30_arg_partial_bytes
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG fr30_function_arg
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE fr30_function_arg_advance
#undef TARGET_SETUP_INCOMING_VARARGS
#define TARGET_SETUP_INCOMING_VARARGS fr30_setup_incoming_varargs
@@ -698,8 +707,8 @@ fr30_must_pass_in_stack (enum machine_mode mode, const_tree type)
/* 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)
+static int
+fr30_num_arg_regs (enum machine_mode mode, const_tree type)
{
int size;
@@ -743,6 +752,33 @@ fr30_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
return (FR30_NUM_ARG_REGS - *cum) * UNITS_PER_WORD;
}
+static rtx
+fr30_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+ const_tree type, bool named)
+{
+ if (!named
+ || fr30_must_pass_in_stack (mode, type)
+ || *cum >= FR30_NUM_ARG_REGS)
+ return NULL_RTX;
+ else
+ return gen_rtx_REG (mode, *cum + FIRST_ARG_REGNUM);
+}
+
+/* A C statement (sans semicolon) to update the summarizer variable CUM to
+ advance past an argument in the argument list. The values MODE, TYPE and
+ NAMED describe that argument. Once this is done, the variable CUM is
+ suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
+
+ This macro need not do anything if the argument in question was passed on
+ the stack. The compiler knows how to track the amount of stack space used
+ for arguments without any special help. */
+static void
+fr30_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+ const_tree type, bool named)
+{
+ *cum += named * fr30_num_arg_regs (mode, type);
+}
+
/*}}}*/
/*{{{ Operand predicates */
diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h
index ed675b1..90fc065 100644
--- a/gcc/config/fr30/fr30.h
+++ b/gcc/config/fr30/fr30.h
@@ -575,12 +575,6 @@ enum reg_class
#define FR30_NUM_ARG_REGS 4
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
- ( (NAMED) == 0 ? NULL_RTX \
- : targetm.calls.must_pass_in_stack (MODE, TYPE) ? NULL_RTX \
- : (CUM) >= FR30_NUM_ARG_REGS ? NULL_RTX \
- : gen_rtx_REG (MODE, CUM + FIRST_ARG_REGNUM))
-
/* A C type for declaring a variable that is used as the first argument of
`FUNCTION_ARG' and other related values. For some target machines, the type
`int' suffices and can hold the number of bytes of argument so far.
@@ -614,17 +608,6 @@ enum reg_class
#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
(CUM) = 0
-/* A C statement (sans semicolon) to update the summarizer variable CUM to
- advance past an argument in the argument list. The values MODE, TYPE and
- NAMED describe that argument. Once this is done, the variable CUM is
- suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
-
- This macro need not do anything if the argument in question was passed on
- the stack. The compiler knows how to track the amount of stack space used
- for arguments without any special help. */
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
- (CUM) += (NAMED) * fr30_num_arg_regs (MODE, TYPE)
-
/* A C expression that is nonzero if REGNO is the number of a hard register in
which function arguments are sometimes passed. This does *not* include
implicit arguments such as the static chain and the structure-value address.
--
1.7.0.4