From 062fff1bad236d95d8ceabdf120207bcf4bbe01c Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 8 Jul 2004 15:17:48 -0700 Subject: [PATCH] cris-protos.h (cris_expand_builtin_va_arg): Remove. * config/cris/cris-protos.h (cris_expand_builtin_va_arg): Remove. * config/cris/cris.c (TARGET_GIMPLIFY_VA_ARG_EXPR): New. (cris_gimplify_va_arg_expr): Rewrite from cris_expand_builtin_va_arg. * config/cris/cris.h (EXPAND_BUILTIN_VA_ARG): Remove. From-SVN: r84321 --- gcc/ChangeLog | 7 +++ gcc/config/cris/cris-protos.h | 4 -- gcc/config/cris/cris.c | 86 +++++------------------------------ gcc/config/cris/cris.h | 8 ---- 4 files changed, 18 insertions(+), 87 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a7f9992d556..b5bf198e0f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -4,6 +4,13 @@ * config/ia64/ia64.c (ia64_dfa_new_cycle): Fix typo in comparison of asm_noperands result. +2004-07-08 Richard Henderson + + * config/cris/cris-protos.h (cris_expand_builtin_va_arg): Remove. + * config/cris/cris.c (TARGET_GIMPLIFY_VA_ARG_EXPR): New. + (cris_gimplify_va_arg_expr): Rewrite from cris_expand_builtin_va_arg. + * config/cris/cris.h (EXPAND_BUILTIN_VA_ARG): Remove. + 2004-07-08 Richard Henderson * builtins.c (ind_gimplify_va_arg_expr): New. diff --git a/gcc/config/cris/cris-protos.h b/gcc/config/cris/cris-protos.h index d5d43dfac59..0e65dc2da8c 100644 --- a/gcc/config/cris/cris-protos.h +++ b/gcc/config/cris/cris-protos.h @@ -45,10 +45,6 @@ extern int cris_symbol (rtx); extern void cris_output_addr_const (FILE *, rtx); extern int cris_cfun_uses_pic_table (void); extern void cris_target_asm_named_section (const char *, unsigned int); - -# ifdef TREE_CODE -extern rtx cris_expand_builtin_va_arg (tree, tree); -# endif #endif /* RTX_CODE */ extern void cris_pragma_expand_mul (struct cpp_reader *); diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 9ca9d2d3551..4ca9cb9c979 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -116,6 +116,8 @@ static void cris_init_libfuncs (void); static bool cris_rtx_costs (rtx, int, int, int *); static int cris_address_cost (rtx); +static tree cris_gimplify_va_arg_expr (tree, tree, tree *, tree *); + /* The function cris_target_asm_function_epilogue puts the last insn to output here. It always fits; there won't be a symbol operand. Used in delay_slots_for_epilogue and function_epilogue. */ @@ -189,6 +191,8 @@ int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION; #undef TARGET_SETUP_INCOMING_VARARGS #define TARGET_SETUP_INCOMING_VARARGS cris_setup_incoming_varargs +#undef TARGET_GIMPLIFY_VA_ARG_EXPR +#define TARGET_GIMPLIFY_VA_ARG_EXPR cris_gimplify_va_arg_expr struct gcc_target targetm = TARGET_INITIALIZER; @@ -2785,84 +2789,16 @@ cris_init_libfuncs (void) set_optab_libfunc (umod_optab, SImode, "__Umod"); } -/* The EXPAND_BUILTIN_VA_ARG worker. This is modified from the - "standard" implementation of va_arg: read the value from the current - address and increment by the size of one or two registers. The - important difference for CRIS is that if the type is - pass-by-reference, then perform an indirection. */ +/* The va_arg gimplifier. All we need to do here special is notice + when we we've got a pass-by-reference. */ -rtx -cris_expand_builtin_va_arg (tree valist, tree type) +static tree +cris_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) { - tree addr_tree, t; - rtx addr; - tree passed_size = size_zero_node; - tree type_size = NULL; - tree size3 = size_int (3); - tree size4 = size_int (4); - tree size8 = size_int (8); - tree rounded_size; - - /* Get AP. */ - addr_tree = valist; - - if (type == error_mark_node - || (type_size = TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (type))) == NULL - || TREE_OVERFLOW (type_size)) - /* Presumably an error; the size isn't computable. A message has - supposedly been emitted elsewhere. */ - rounded_size = size_zero_node; + if (FUNCTION_ARG_PASS_BY_REFERENCE (dummy, TYPE_MODE (type), type, dummy)) + return ind_gimplify_va_arg_expr (valist, type, pre_p, post_p); else - rounded_size - = fold (build (MULT_EXPR, sizetype, - fold (build (TRUNC_DIV_EXPR, sizetype, - fold (build (PLUS_EXPR, sizetype, - type_size, size3)), - size4)), - size4)); - - if (!integer_zerop (rounded_size)) - { - /* Check if the type is passed by value or by reference. Values up - to 8 bytes are passed by-value, padded to register-size (4 - bytes). Larger values and varying-size types are passed - by reference. */ - passed_size - = (!really_constant_p (type_size) - ? size4 - : fold (build (COND_EXPR, sizetype, - fold (build (GT_EXPR, sizetype, - rounded_size, - size8)), - size4, - rounded_size))); - - addr_tree - = (!really_constant_p (type_size) - ? build1 (INDIRECT_REF, build_pointer_type (type), addr_tree) - : fold (build (COND_EXPR, TREE_TYPE (addr_tree), - fold (build (GT_EXPR, sizetype, - rounded_size, - size8)), - build1 (INDIRECT_REF, build_pointer_type (type), - addr_tree), - addr_tree))); - } - - addr = expand_expr (addr_tree, NULL_RTX, Pmode, EXPAND_NORMAL); - addr = copy_to_reg (addr); - - if (!integer_zerop (rounded_size)) - { - /* Compute new value for AP. */ - t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, - build (PLUS_EXPR, TREE_TYPE (valist), valist, - passed_size)); - TREE_SIDE_EFFECTS (t) = 1; - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - } - - return addr; + return std_gimplify_va_arg_expr (valist, type, pre_p, post_p); } /* The INIT_EXPANDERS worker sets the per-function-data initializer and diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 7b028e062e9..3eabb51ba62 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -1051,14 +1051,6 @@ struct cum_args {int regs;}; documentation. */ -/* Node: Varargs */ - -/* FIXME: This and other EXPAND_BUILTIN_VA_... target macros are not - documented, although used by several targets. */ -#define EXPAND_BUILTIN_VA_ARG(VALIST, TYPE) \ - cris_expand_builtin_va_arg (VALIST, TYPE) - - /* Node: Trampolines */ /* This looks too complicated, and it is. I assigned r7 to be the -- 2.30.2