From patchwork Fri Oct 8 13:58:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [lm32] hookize FUNCTION_ARG &co. Date: Fri, 08 Oct 2010 03:58:56 -0000 From: Nathan Froyd X-Patchwork-Id: 67212 Message-Id: <1286546336-17894-1-git-send-email-froydnj@codesourcery.com> To: gcc-patches@gcc.gnu.org The patch below hookizes FUNCTION_ARG and related macros for the lm32 backend. Nothing special here. Tested by inspection with cross to lm32-elf. I plan to commit this under the obvious rule after waiting a week for comments/approval. * config/lm32/lm32-protos.h (lm32_function_arg): Delete. * config/lm32/lm32.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete. * config/mcore/mcore.c (mcore_function_arg): Declare. Make static. Take a const_tree and a bool. (mcore_function_arg_advance): New function. (TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define. --- gcc/config/lm32/lm32-protos.h | 3 +-- gcc/config/lm32/lm32.c | 28 +++++++++++++++++++++++----- gcc/config/lm32/lm32.h | 3 --- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/gcc/config/lm32/lm32-protos.h b/gcc/config/lm32/lm32-protos.h index 51e191b..ef78578 100644 --- a/gcc/config/lm32/lm32-protos.h +++ b/gcc/config/lm32/lm32-protos.h @@ -26,8 +26,7 @@ extern void lm32_expand_prologue (void); extern void lm32_expand_epilogue (void); extern void lm32_print_operand (FILE *file, rtx op, int letter); extern void lm32_print_operand_address (FILE *file, rtx addr); -extern rtx lm32_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, - tree type, int named); +extern void lm32_override_options (void); extern HOST_WIDE_INT lm32_compute_initial_elimination_offset (int from, int to); extern int lm32_can_use_return (void); diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index 671f0e1..6f641b7 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -76,6 +76,13 @@ static bool lm32_legitimate_address_p (enum machine_mode mode, rtx x, bool strict); static HOST_WIDE_INT lm32_compute_frame_size (int size); static void lm32_option_override (void); +static bool lm32_handle_option (size_t code, const char *arg, int value); +static rtx lm32_function_arg (CUMULATIVE_ARGS * cum, + enum machine_mode mode, const_tree type, + bool named); +static void lm32_function_arg_advance (CUMULATIVE_ARGS * cum, + enum machine_mode mode, + const_tree type, bool named); #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE lm32_option_override @@ -89,6 +96,10 @@ static void lm32_option_override (void); #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_SETUP_INCOMING_VARARGS #define TARGET_SETUP_INCOMING_VARARGS lm32_setup_incoming_varargs +#undef TARGET_FUNCTION_ARG +#define TARGET_FUNCTION_ARG lm32_function_arg +#undef TARGET_FUNCTION_ARG_ADVANCE +#define TARGET_FUNCTION_ARG_ADVANCE lm32_function_arg_advance #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true #undef TARGET_MIN_ANCHOR_OFFSET @@ -604,9 +615,9 @@ lm32_print_operand_address (FILE * file, rtx addr) NAMED is nonzero if this argument is a named parameter (otherwise it is an extra parameter matching an ellipsis). */ -rtx -lm32_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, - tree type, int named) +static rtx +lm32_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named) { if (mode == VOIDmode) /* Compute operand 2 of the call insn. */ @@ -615,10 +626,17 @@ lm32_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, if (targetm.calls.must_pass_in_stack (mode, type)) return NULL_RTX; - if (!named || (cum + LM32_NUM_REGS2 (mode, type) > LM32_NUM_ARG_REGS)) + if (!named || (*cum + LM32_NUM_REGS2 (mode, type) > LM32_NUM_ARG_REGS)) return NULL_RTX; - return gen_rtx_REG (mode, cum + LM32_FIRST_ARG_REG); + return gen_rtx_REG (mode, *cum + LM32_FIRST_ARG_REG); +} + +static void +lm32_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named ATTRIBUTE_UNUSED) +{ + *cum += LM32_NUM_REGS2 (mode, type); } HOST_WIDE_INT diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h index b0c2d59..5eb64bb 100644 --- a/gcc/config/lm32/lm32.h +++ b/gcc/config/lm32/lm32.h @@ -287,9 +287,6 @@ enum reg_class #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \ (CUM) = 0 -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - (CUM) += LM32_NUM_REGS2 (MODE, TYPE) - #define FUNCTION_ARG_REGNO_P(r) \ (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))