From: Richard Henderson Date: Fri, 9 Jul 2004 00:02:54 +0000 (-0700) Subject: iq2000-protos.h (iq2000_va_arg): Remove. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcdfad42332acdcd747e25fa6ab63d9cae8cf08f;p=gcc.git iq2000-protos.h (iq2000_va_arg): Remove. * config/iq2000/iq2000-protos.h (iq2000_va_arg): Remove. * config/iq2000/iq2000.c (TARGET_GIMPLIFY_VA_ARG_EXPR): New. (iq2000_gimplify_va_arg_expr): Rewrite from iq2000_va_arg. * config/iq2000/iq2000.h (EXPAND_BUILTIN_VA_ARG): Remove. From-SVN: r84330 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 63a702bc2e7..330f1756a95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2004-07-08 Richard Henderson + * config/iq2000/iq2000-protos.h (iq2000_va_arg): Remove. + * config/iq2000/iq2000.c (TARGET_GIMPLIFY_VA_ARG_EXPR): New. + (iq2000_gimplify_va_arg_expr): Rewrite from iq2000_va_arg. + * config/iq2000/iq2000.h (EXPAND_BUILTIN_VA_ARG): Remove. + * config/frv/frv-protos.h (frv_expand_builtin_va_arg): Remove. * config/frv/frv.c (TARGET_GIMPLIFY_VA_ARG_EXPR): New. (frv_gimplify_va_arg_expr): Rewrite from frv_expand_builtin_va_arg. diff --git a/gcc/config/iq2000/iq2000-protos.h b/gcc/config/iq2000/iq2000-protos.h index dadcc232dde..60c34bc37ab 100644 --- a/gcc/config/iq2000/iq2000-protos.h +++ b/gcc/config/iq2000/iq2000-protos.h @@ -52,7 +52,6 @@ extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mo extern struct rtx_def * function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, int); extern int function_arg_partial_nregs (CUMULATIVE_ARGS *, enum machine_mode, tree, int); extern void iq2000_va_start (tree, rtx); -extern rtx iq2000_va_arg (tree, tree); extern rtx iq2000_function_value (tree, tree); #endif diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index b2e117a9676..ab7a7b52d11 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -171,6 +171,7 @@ static bool iq2000_rtx_costs (rtx, int, int, int *); static int iq2000_address_cost (rtx); static void iq2000_select_section (tree, int, unsigned HOST_WIDE_INT); static bool iq2000_return_in_memory (tree, tree); +static tree iq2000_gimplify_va_arg_expr (tree, tree, tree *, tree *); #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS iq2000_init_builtins @@ -199,6 +200,8 @@ static bool iq2000_return_in_memory (tree, tree); #define TARGET_SETUP_INCOMING_VARARGS iq2000_setup_incoming_varargs #undef TARGET_STRICT_ARGUMENT_NAMING #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true +#undef TARGET_GIMPLIFY_VA_ARG_EXPR +#define TARGET_GIMPLIFY_VA_ARG_EXPR iq2000_gimplify_va_arg_expr #undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE hook_int_void_1 @@ -1590,200 +1593,13 @@ iq2000_va_start (tree valist, rtx nextarg) /* Implement va_arg. */ -rtx -iq2000_va_arg (tree valist, tree type) +static tree +iq2000_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) { - HOST_WIDE_INT size, rsize; - rtx addr_rtx; - tree t; - int indirect; - rtx r, lab_over = NULL_RTX, lab_false; - tree f_ovfl, f_gtop, f_ftop, f_goff, f_foff; - tree ovfl, gtop, ftop, goff, foff; - - size = int_size_in_bytes (type); - rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD; - indirect - = function_arg_pass_by_reference (NULL, TYPE_MODE (type), type, 0); - if (indirect) - { - size = POINTER_SIZE / BITS_PER_UNIT; - rsize = UNITS_PER_WORD; - } - - addr_rtx = gen_reg_rtx (Pmode); - - { - /* Case of all args in a merged stack. No need to check bounds, - just advance valist along the stack. */ - tree gpr = valist; - - if (! indirect - && TYPE_ALIGN (type) > (unsigned) BITS_PER_WORD) - { - t = build (PLUS_EXPR, TREE_TYPE (gpr), gpr, - build_int_2 (2*UNITS_PER_WORD - 1, 0)); - t = build (BIT_AND_EXPR, TREE_TYPE (t), t, - build_int_2 (-2*UNITS_PER_WORD, -1)); - t = build (MODIFY_EXPR, TREE_TYPE (gpr), gpr, t); - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - } - - t = build (POSTINCREMENT_EXPR, TREE_TYPE (gpr), gpr, - size_int (rsize)); - r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL); - if (r != addr_rtx) - emit_move_insn (addr_rtx, r); - - /* Flush the POSTINCREMENT. */ - emit_queue(); - - if (indirect) - { - r = gen_rtx_MEM (Pmode, addr_rtx); - set_mem_alias_set (r, get_varargs_alias_set ()); - emit_move_insn (addr_rtx, r); - } - else - { - if (BYTES_BIG_ENDIAN && rsize != size) - addr_rtx = plus_constant (addr_rtx, rsize - size); - } - return addr_rtx; - } - - /* Not a simple merged stack. Need ptrs and indexes left by va_start. */ - f_ovfl = TYPE_FIELDS (va_list_type_node); - f_gtop = TREE_CHAIN (f_ovfl); - f_ftop = TREE_CHAIN (f_gtop); - f_goff = TREE_CHAIN (f_ftop); - f_foff = TREE_CHAIN (f_goff); - - ovfl = build (COMPONENT_REF, TREE_TYPE (f_ovfl), valist, f_ovfl, NULL_TREE); - gtop = build (COMPONENT_REF, TREE_TYPE (f_gtop), valist, f_gtop, NULL_TREE); - ftop = build (COMPONENT_REF, TREE_TYPE (f_ftop), valist, f_ftop, NULL_TREE); - goff = build (COMPONENT_REF, TREE_TYPE (f_goff), valist, f_goff, NULL_TREE); - foff = build (COMPONENT_REF, TREE_TYPE (f_foff), valist, f_foff, NULL_TREE); - - lab_false = gen_label_rtx (); - lab_over = gen_label_rtx (); - - if (TREE_CODE (type) == REAL_TYPE) - { - /* Emit code to branch if foff == 0. */ - r = expand_expr (foff, NULL_RTX, TYPE_MODE (TREE_TYPE (foff)), - EXPAND_NORMAL); - emit_cmp_and_jump_insns (r, const0_rtx, EQ, - const1_rtx, GET_MODE (r), 1, lab_false); - - /* Emit code for addr_rtx = ftop - foff. */ - t = build (MINUS_EXPR, TREE_TYPE (ftop), ftop, foff ); - r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL); - if (r != addr_rtx) - emit_move_insn (addr_rtx, r); - - /* Emit code for foff-=8. - Advances the offset up FPR save area by one double. */ - t = build (MINUS_EXPR, TREE_TYPE (foff), foff, build_int_2 (8, 0)); - t = build (MODIFY_EXPR, TREE_TYPE (foff), foff, t); - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - - emit_queue (); - emit_jump (lab_over); - emit_barrier (); - emit_label (lab_false); - - /* If a 4-byte int is followed by an 8-byte float, then - natural alignment causes a 4 byte gap. - So, dynamically adjust ovfl up to a multiple of 8. */ - t = build (BIT_AND_EXPR, TREE_TYPE (ovfl), ovfl, - build_int_2 (7, 0)); - t = build (PLUS_EXPR, TREE_TYPE (ovfl), ovfl, t); - t = build (MODIFY_EXPR, TREE_TYPE (ovfl), ovfl, t); - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - - /* Emit code for addr_rtx = the ovfl pointer into overflow area. - Postincrement the ovfl pointer by 8. */ - t = build (POSTINCREMENT_EXPR, TREE_TYPE(ovfl), ovfl, - size_int (8)); - r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL); - if (r != addr_rtx) - emit_move_insn (addr_rtx, r); - - emit_queue(); - emit_label (lab_over); - return addr_rtx; - } + if (function_arg_pass_by_reference (NULL, TYPE_MODE (type), type, 0)) + return ind_gimplify_va_arg_expr (valist, type, pre_p, post_p); else - { - /* Not REAL_TYPE. */ - int step_size; - - if (TREE_CODE (type) == INTEGER_TYPE - && TYPE_PRECISION (type) == 64) - { - /* int takes 32 bits of the GPR save area, but - longlong takes an aligned 64 bits. So, emit code - to zero the low order bits of goff, thus aligning - the later calculation of (gtop-goff) upwards. */ - t = build (BIT_AND_EXPR, TREE_TYPE (goff), goff, - build_int_2 (-8, -1)); - t = build (MODIFY_EXPR, TREE_TYPE (goff), goff, t); - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - } - - /* Emit code to branch if goff == 0. */ - r = expand_expr (goff, NULL_RTX, TYPE_MODE (TREE_TYPE (goff)), - EXPAND_NORMAL); - emit_cmp_and_jump_insns (r, const0_rtx, EQ, - const1_rtx, GET_MODE (r), 1, lab_false); - - /* Emit code for addr_rtx = gtop - goff. */ - t = build (MINUS_EXPR, TREE_TYPE (gtop), gtop, goff); - r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL); - if (r != addr_rtx) - emit_move_insn (addr_rtx, r); - - if (TYPE_PRECISION (type) == 64) - step_size = 8; - else - step_size = UNITS_PER_WORD; - - /* Emit code for goff = goff - step_size. - Advances the offset up GPR save area over the item. */ - t = build (MINUS_EXPR, TREE_TYPE (goff), goff, - build_int_2 (step_size, 0)); - t = build (MODIFY_EXPR, TREE_TYPE (goff), goff, t); - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); - - emit_queue(); - emit_jump (lab_over); - emit_barrier (); - emit_label (lab_false); - - /* Emit code for addr_rtx -> overflow area, postinc by step_size. */ - t = build (POSTINCREMENT_EXPR, TREE_TYPE(ovfl), ovfl, - size_int (step_size)); - r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL); - if (r != addr_rtx) - emit_move_insn (addr_rtx, r); - - emit_queue(); - emit_label (lab_over); - - if (indirect) - { - r = gen_rtx_MEM (Pmode, addr_rtx); - set_mem_alias_set (r, get_varargs_alias_set ()); - emit_move_insn (addr_rtx, r); - } - else - { - if (BYTES_BIG_ENDIAN && rsize != size) - addr_rtx = plus_constant (addr_rtx, rsize - size); - } - return addr_rtx; - } + return std_gimplify_va_arg_expr (valist, type, pre_p, post_p); } /* Allocate a chunk of memory for per-function machine-dependent data. */ diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h index 086db3ba834..d4e27c1aae3 100644 --- a/gcc/config/iq2000/iq2000.h +++ b/gcc/config/iq2000/iq2000.h @@ -544,10 +544,6 @@ typedef struct iq2000_args #define EXPAND_BUILTIN_VA_START(valist, nextarg) \ iq2000_va_start (valist, nextarg) -/* Implement `va_arg'. */ -#define EXPAND_BUILTIN_VA_ARG(valist, type) \ - iq2000_va_arg (valist, type) - /* Trampolines for Nested Functions. */