From patchwork Thu Sep 2 01:50:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [spu] hookize FUNCTION_ARG &co. Date: Wed, 01 Sep 2010 15:50:38 -0000 From: Nathan Froyd X-Patchwork-Id: 63439 Message-Id: <20100902015037.GI16898@codesourcery.com> To: gcc-patches@gcc.gnu.org Cc: uweigand@de.ibm.com This patch hookizes FUNCTION_ARG and related macros for the spu backend. Nothing exciting here. Sanity-checked with cross to spu-elf. I plan to commit this under the obvious rule after waiting a week for comments. -Nathan * config/spu/spu-protos.h (spu_function_arg): Delete. * config/spu/spu.h (FUNCTION_ARG): Delete. (FUNCTION_ARG_ADVANCE): Move code to ... * config/spu/spu.c (spu_function_arg_advance): New function. (spu_function_arg): Make static. Take a const_tree and a bool. (spu_setup_incoming_varargs): Call spu_function_arg_advance. (TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define. diff --git a/gcc/config/spu/spu-protos.h b/gcc/config/spu/spu-protos.h index 6bf4f65..55c884c 100644 --- a/gcc/config/spu/spu-protos.h +++ b/gcc/config/spu/spu-protos.h @@ -57,8 +57,6 @@ extern int spu_constant_address_p (rtx x); extern int spu_legitimate_constant_p (rtx x); extern int spu_initial_elimination_offset (int from, int to); extern rtx spu_function_value (const_tree type, const_tree func); -extern rtx spu_function_arg (int cum, enum machine_mode mode, tree type, - int named); extern void spu_setup_incoming_varargs (int *cum, enum machine_mode mode, tree type, int *pretend_size, int no_rtl); diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index ec78859..41e1815 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -188,6 +188,10 @@ static tree spu_handle_vector_attribute (tree * node, tree name, tree args, static int spu_naked_function_p (tree func); static bool spu_pass_by_reference (CUMULATIVE_ARGS *cum, enum machine_mode mode, const_tree type, bool named); +static rtx spu_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named); +static void spu_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named); static tree spu_build_builtin_va_list (void); static void spu_va_start (tree, rtx); static tree spu_gimplify_va_arg_expr (tree valist, tree type, @@ -389,6 +393,12 @@ static const struct attribute_spec spu_attribute_table[] = #undef TARGET_PASS_BY_REFERENCE #define TARGET_PASS_BY_REFERENCE spu_pass_by_reference +#undef TARGET_FUNCTION_ARG +#define TARGET_FUNCTION_ARG spu_function_arg + +#undef TARGET_FUNCTION_ARG_ADVANCE +#define TARGET_FUNCTION_ARG_ADVANCE spu_function_arg_advance + #undef TARGET_MUST_PASS_IN_STACK #define TARGET_MUST_PASS_IN_STACK must_pass_in_stack_var_size @@ -3986,10 +3996,10 @@ spu_function_value (const_tree type, const_tree func ATTRIBUTE_UNUSED) return gen_rtx_REG (mode, FIRST_RETURN_REGNUM); } -rtx -spu_function_arg (CUMULATIVE_ARGS cum, +static rtx +spu_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, - tree type, int named ATTRIBUTE_UNUSED) + const_tree type, bool named ATTRIBUTE_UNUSED) { int byte_size; @@ -4022,6 +4032,19 @@ spu_function_arg (CUMULATIVE_ARGS cum, return gen_rtx_REG (mode, FIRST_ARG_REGNUM + cum); } +static void +spu_function_arg_advance (CUMULATIVE_ARGS * cum, enum machine_mode mode, + const_tree type, bool named ATTRIBUTE_UNUSED) +{ + *cum += (type && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST + ? 1 + : mode == BLKmode + ? ((int_size_in_bytes (type) + 15) / 16) + : mode == VOIDmode + ? 1 + : HARD_REGNO_NREGS (cum, mode)); +} + /* Variable sized types are passed by reference. */ static bool spu_pass_by_reference (CUMULATIVE_ARGS * cum ATTRIBUTE_UNUSED, @@ -4230,7 +4253,7 @@ spu_setup_incoming_varargs (CUMULATIVE_ARGS * cum, enum machine_mode mode, /* cum currently points to the last named argument, we want to start at the next argument. */ - FUNCTION_ARG_ADVANCE (ncum, mode, type, 1); + spu_function_arg_advance (&ncum, mode, type, true); offset = -STACK_POINTER_OFFSET; for (regno = ncum; regno < MAX_REGISTER_ARGS; regno++) diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h index 5772c6f..0fe273d 100644 --- a/gcc/config/spu/spu.h +++ b/gcc/config/spu/spu.h @@ -337,22 +337,11 @@ targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin; \ /* Register Arguments */ -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ - (spu_function_arg((CUM),(MODE),(TYPE),(NAMED))) - #define CUMULATIVE_ARGS int #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \ ((CUM) = 0) -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - ((CUM) += \ - (TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST ? 1 \ - : (MODE) == BLKmode ? ((int_size_in_bytes(TYPE)+15) / 16) \ - : (MODE) == VOIDmode ? 1 \ - : HARD_REGNO_NREGS(CUM,MODE)) - - /* The SPU ABI wants 32/64-bit types at offset 0 in the quad-word on the stack. 8/16-bit types should be at offsets 3/2 respectively. */ #define FUNCTION_ARG_OFFSET(MODE, TYPE) \