From d4a6a4d9a0a2f8e25a7799ca4054bdf3aba374b3 Mon Sep 17 00:00:00 2001 From: Chung-Ju Wu Date: Wed, 3 Sep 2014 09:32:08 +0000 Subject: [PATCH] [NDS32] Implement TARGET_SETUP_INCOMING_VARARGS target hook. * config/nds32/nds32.c (nds32_setup_incoming_varargs): New implementation for TARGET_SETUP_INCOMING_VARARGS. (nds32_strict_argument_naming): Refine comment. * config/nds32/nds32.h (TARGET_SOFT_FLOAT, TARGET_HARD_FLOAT): Define for future implementation. From-SVN: r214861 --- gcc/ChangeLog | 8 ++++++++ gcc/config/nds32/nds32.c | 50 +++++++++++++++++++++++++++++++++++++++++++++--- gcc/config/nds32/nds32.h | 3 +++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d620cb2..c8ac8b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-09-03 Chung-Ju Wu + + * config/nds32/nds32.c (nds32_setup_incoming_varargs): New + implementation for TARGET_SETUP_INCOMING_VARARGS. + (nds32_strict_argument_naming): Refine comment. + * config/nds32/nds32.h (TARGET_SOFT_FLOAT, TARGET_HARD_FLOAT): + Define for future implementation. + 2014-09-03 Ilya Tocar * config/i386/adxintrin.h (_subborrow_u32): New. diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index 54abc96..a94d576 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -1551,12 +1551,53 @@ nds32_warn_func_return (tree decl) /* Implementing the Varargs Macros. */ +static void +nds32_setup_incoming_varargs (cumulative_args_t ca, + enum machine_mode mode, + tree type, + int *pretend_args_size, + int second_time ATTRIBUTE_UNUSED) +{ + unsigned int total_args_regs; + unsigned int num_of_used_regs; + unsigned int remaining_reg_count; + CUMULATIVE_ARGS *cum; + + /* If we are under hard float abi, we do not need to set *pretend_args_size. + So that all nameless arguments are pushed by caller and all situation + can be handled by GCC itself. */ + if (TARGET_HARD_FLOAT) + return; + + /* We are using NDS32_MAX_GPR_REGS_FOR_ARGS registers, + counting from NDS32_GPR_ARG_FIRST_REGNUM, for saving incoming arguments. + However, for nameless(anonymous) arguments, we should push them on the + stack so that all the nameless arguments appear to have been passed + consecutively in the memory for accessing. Hence, we need to check and + exclude the registers that are used for named arguments. */ + + cum = get_cumulative_args (ca); + + /* The MODE and TYPE describe the last argument. + We need those information to determine the remaining registers + for varargs. */ + total_args_regs + = NDS32_MAX_GPR_REGS_FOR_ARGS + NDS32_GPR_ARG_FIRST_REGNUM; + num_of_used_regs + = NDS32_AVAILABLE_REGNUM_FOR_GPR_ARG (cum->gpr_offset, mode, type) + + NDS32_NEED_N_REGS_FOR_ARG (mode, type); + + remaining_reg_count = total_args_regs - num_of_used_regs; + *pretend_args_size = remaining_reg_count * UNITS_PER_WORD; + + return; +} + static bool nds32_strict_argument_naming (cumulative_args_t ca ATTRIBUTE_UNUSED) { - /* Return true so that all the named arguments for FUNCTION_ARG have named=1. - If return false, for the variadic function, all named arguments EXCEPT - the last are treated as named. */ + /* If this hook returns true, the named argument of FUNCTION_ARG is always + true for named arguments, and false for unnamed arguments. */ return true; } @@ -3328,6 +3369,9 @@ nds32_target_alignment (rtx label) /* Implementing the Varargs Macros. */ +#undef TARGET_SETUP_INCOMING_VARARGS +#define TARGET_SETUP_INCOMING_VARARGS nds32_setup_incoming_varargs + #undef TARGET_STRICT_ARGUMENT_NAMING #define TARGET_STRICT_ARGUMENT_NAMING nds32_strict_argument_naming diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h index c446041..3f4c3ae 100644 --- a/gcc/config/nds32/nds32.h +++ b/gcc/config/nds32/nds32.h @@ -336,6 +336,9 @@ enum nds32_builtins #define TARGET_ISA_V3 (nds32_arch_option == ARCH_V3) #define TARGET_ISA_V3M (nds32_arch_option == ARCH_V3M) +#define TARGET_SOFT_FLOAT 1 +#define TARGET_HARD_FLOAT 0 + /* ------------------------------------------------------------------------ */ /* Controlling the Compilation Driver. */ -- 2.7.4