summaryrefslogtreecommitdiff
path: root/gcc/config/nds32
diff options
context:
space:
mode:
authorjasonwucj <jasonwucj@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-03 09:32:08 +0000
committerjasonwucj <jasonwucj@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-03 09:32:08 +0000
commitfb0c8d3aeae82fc162a455e3168a274c0e78e237 (patch)
tree33ea55e625ec39ec2556b27bac874c594b7587b6 /gcc/config/nds32
parentaecde6b1a1133b0ddd25b779c7bb5e7e572d856a (diff)
downloadgcc-fb0c8d3aeae82fc162a455e3168a274c0e78e237.tar.gz
[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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214861 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/nds32')
-rw-r--r--gcc/config/nds32/nds32.c50
-rw-r--r--gcc/config/nds32/nds32.h3
2 files changed, 50 insertions, 3 deletions
diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 54abc969bd3..a94d576d7eb 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 c446041793b..3f4c3ae3d5c 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. */