From: Richard Henderson Date: Wed, 14 Jul 2004 21:19:39 +0000 (-0700) Subject: alpha.c (alpha_gimplify_va_arg_1): Move indirect ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08b0dc1be57ef0eca483f684c76e3add21fbd507;p=gcc.git alpha.c (alpha_gimplify_va_arg_1): Move indirect ... * config/alpha/alpha.c (alpha_gimplify_va_arg_1): Move indirect ... (alpha_gimplify_va_arg): ... handling here. Use pass_by_reference. * config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Use pass_by_reference. * config/i386/i386.c (ix86_gimplify_va_arg): Likewise. * config/i860/i860.c (i860_gimplify_va_arg_expr): Likewise. * config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise. * config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Likewise. * config/sh/sh.c (sh_gimplify_va_arg_expr): Likewise. * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise. From-SVN: r84713 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83b177b8f28..7d03ff9bb8a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2004-07-14 Richard Henderson + + * config/alpha/alpha.c (alpha_gimplify_va_arg_1): Move indirect ... + (alpha_gimplify_va_arg): ... handling here. Use pass_by_reference. + * config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Use pass_by_reference. + * config/i386/i386.c (ix86_gimplify_va_arg): Likewise. + * config/i860/i860.c (i860_gimplify_va_arg_expr): Likewise. + * config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise. + * config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Likewise. + * config/sh/sh.c (sh_gimplify_va_arg_expr): Likewise. + * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise. + 2004-07-14 Mike Stump * config/darwin.h (WINT_TYPE): Define to be int to match diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 8ed7b78d72c..e10468b8eaf 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -6239,7 +6239,6 @@ static tree alpha_gimplify_va_arg_1 (tree type, tree base, tree offset, tree *pre_p) { tree type_size, ptr_type, addend, t, addr, internal_post; - bool indirect; /* If the type could not be passed in registers, skip the block reserved for the registers. */ @@ -6253,15 +6252,8 @@ alpha_gimplify_va_arg_1 (tree type, tree base, tree offset, tree *pre_p) addend = offset; ptr_type = build_pointer_type (type); - indirect = false; - if (TYPE_MODE (type) == TFmode || TYPE_MODE (type) == TCmode) - { - type = ptr_type; - ptr_type = build_pointer_type (type); - indirect = true; - } - else if (TREE_CODE (type) == COMPLEX_TYPE) + if (TREE_CODE (type) == COMPLEX_TYPE) { tree real_part, imag_part, real_temp; @@ -6292,8 +6284,6 @@ alpha_gimplify_va_arg_1 (tree type, tree base, tree offset, tree *pre_p) /* Build the final address and force that value into a temporary. */ addr = build (PLUS_EXPR, ptr_type, fold_convert (ptr_type, base), fold_convert (ptr_type, addend)); - if (indirect) - addr = build (INDIRECT_REF, type, addr); internal_post = NULL; gimplify_expr (&addr, pre_p, &internal_post, is_gimple_val, fb_rvalue); append_to_statement_list (internal_post, pre_p); @@ -6320,6 +6310,7 @@ static tree alpha_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) { tree offset_field, base_field, offset, base, t, r; + bool indirect; if (TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK) return std_gimplify_va_arg_expr (valist, type, pre_p, post_p); @@ -6339,6 +6330,10 @@ alpha_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) t = fold_convert (lang_hooks.types.type_for_size (64, 0), offset_field); offset = get_initialized_tmp_var (t, pre_p, NULL); + indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + if (indirect) + type = build_pointer_type (type); + /* Find the value. Note that this will be a stable indirection, or a composite of stable indirections in the case of complex. */ r = alpha_gimplify_va_arg_1 (type, base, offset, pre_p); @@ -6348,6 +6343,9 @@ alpha_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) fold_convert (TREE_TYPE (offset_field), offset)); gimplify_and_add (t, pre_p); + if (indirect) + r = build_fold_indirect_ref (r); + return r; } diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index f1863cb68fb..4e6dd8f5484 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -733,12 +733,20 @@ c4x_gimplify_va_arg_expr (tree valist, tree type, tree *post_p ATTRIBUTE_UNUSED) { tree t; + bool indirect; + + indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + if (indirect) + type = build_pointer_type (type); t = build (PREDECREMENT_EXPR, TREE_TYPE (valist), valist, build_int_2 (int_size_in_bytes (type), 0)); t = fold_convert (build_pointer_type (type), t); t = build_fold_indirect_ref (t); + if (indirect) + t = build_fold_indirect_ref (t); + return t; } diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0349979fb14..02af192d010 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3281,14 +3281,10 @@ ix86_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) ovf = build (COMPONENT_REF, TREE_TYPE (f_ovf), valist, f_ovf, NULL_TREE); sav = build (COMPONENT_REF, TREE_TYPE (f_sav), valist, f_sav, NULL_TREE); + indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false); + if (indirect_p) + type = build_pointer_type (type); size = int_size_in_bytes (type); - if (size == -1) - { - /* Variable-size types are passed by reference. */ - indirect_p = 1; - type = build_pointer_type (type); - size = int_size_in_bytes (type); - } rsize = (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; container = construct_container (TYPE_MODE (type), type, 0, diff --git a/gcc/config/i860/i860.c b/gcc/config/i860/i860.c index 1dc58a40051..d4976680997 100644 --- a/gcc/config/i860/i860.c +++ b/gcc/config/i860/i860.c @@ -1932,6 +1932,7 @@ i860_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) tree size, t, u, addr, type_ptr; tree reg, n_reg, sav_ofs, lim_reg; HOST_WIDE_INT isize; + bool indirect; #ifdef I860_SVR4_VA_LIST f_gpr = TYPE_FIELDS (va_list_type_node); @@ -1950,6 +1951,9 @@ i860_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) mem = build (COMPONENT_REF, TREE_TYPE (f_mem), valist, f_mem, NULL_TREE); sav = build (COMPONENT_REF, TREE_TYPE (f_sav), valist, f_sav, NULL_TREE); + indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + if (indirect) + type = build_pointer_type (type); size = size_in_bytes (type); type_ptr = build_pointer_type (type); @@ -2029,6 +2033,8 @@ i860_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) } addr = fold_convert (type_ptr, addr); + if (indirect) + addr = build_fold_indirect_ref (addr); return build_fold_indirect_ref (addr); } diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 7e19f6ba043..86c271cee2e 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -3970,7 +3970,7 @@ static tree ia64_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) { /* Variable sized types are passed by reference. */ - if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) + if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) { tree ptrtype = build_pointer_type (type); tree addr = std_gimplify_va_arg_expr (valist, ptrtype, pre_p, post_p); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 704b8d3a05e..b6ee8313b14 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5451,29 +5451,20 @@ rs6000_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) { tree f_gpr, f_fpr, f_res, f_ovf, f_sav; tree gpr, fpr, ovf, sav, reg, t, u; - int indirect_p, size, rsize, n_reg, sav_ofs, sav_scale; + int size, rsize, n_reg, sav_ofs, sav_scale; tree lab_false, lab_over, addr; int align; tree ptrtype = build_pointer_type (type); + if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) + { + t = rs6000_gimplify_va_arg (valist, ptrtype, pre_p, post_p); + return build_fold_indirect_ref (t); + } + if (DEFAULT_ABI != ABI_V4) { - /* Variable sized types are passed by reference, as are AltiVec - vectors when 32-bit and not using the AltiVec ABI extension. */ - if (int_size_in_bytes (type) < 0 - || (TARGET_32BIT - && !TARGET_ALTIVEC_ABI - && ALTIVEC_VECTOR_MODE (TYPE_MODE (type)))) - { - /* Args grow upward. */ - t = build2 (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist, - size_int (POINTER_SIZE / BITS_PER_UNIT)); - t = build1 (NOP_EXPR, build_pointer_type (ptrtype), t); - t = build_fold_indirect_ref (t); - return build_fold_indirect_ref (t); - } - if (targetm.calls.split_complex_arg - && TREE_CODE (type) == COMPLEX_TYPE) + if (targetm.calls.split_complex_arg && TREE_CODE (type) == COMPLEX_TYPE) { tree elem_type = TREE_TYPE (type); enum machine_mode elem_mode = TYPE_MODE (elem_type); @@ -5517,25 +5508,10 @@ rs6000_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) rsize = (size + 3) / 4; align = 1; - if (AGGREGATE_TYPE_P (type) - || TYPE_MODE (type) == TFmode - || (!TARGET_ALTIVEC_ABI && ALTIVEC_VECTOR_MODE (TYPE_MODE (type)))) - { - /* Aggregates, long doubles, and AltiVec vectors are passed by - reference. */ - indirect_p = 1; - reg = gpr; - n_reg = 1; - sav_ofs = 0; - sav_scale = 4; - size = 4; - rsize = 1; - } - else if (TARGET_HARD_FLOAT && TARGET_FPRS - && (TYPE_MODE (type) == SFmode || TYPE_MODE (type) == DFmode)) + if (TARGET_HARD_FLOAT && TARGET_FPRS + && (TYPE_MODE (type) == SFmode || TYPE_MODE (type) == DFmode)) { /* FP args go in FP registers, if present. */ - indirect_p = 0; reg = fpr; n_reg = 1; sav_ofs = 8*4; @@ -5546,7 +5522,6 @@ rs6000_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) else { /* Otherwise into GP registers. */ - indirect_p = 0; reg = gpr; n_reg = rsize; sav_ofs = 0; @@ -5637,14 +5612,7 @@ rs6000_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p) append_to_statement_list (t, pre_p); } - if (indirect_p) - { - addr = fold_convert (build_pointer_type (ptrtype), addr); - addr = build_fold_indirect_ref (addr); - } - else - addr = fold_convert (ptrtype, addr); - + addr = fold_convert (ptrtype, addr); return build_fold_indirect_ref (addr); } diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index b3b2ab381b5..7f99cab4ab6 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -6322,7 +6322,7 @@ sh_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, HOST_WIDE_INT size, rsize; tree tmp, pptr_type_node; tree addr, lab_over, result = NULL; - int pass_by_ref = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type); + int pass_by_ref = pass_by_reference (NULL, TYPE_MODE (type), type, false); if (pass_by_ref) type = build_pointer_type (type); diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 940ba0eca47..29e72d4e341 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -2479,6 +2479,11 @@ xtensa_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree f_ndx, ndx; tree type_size, array, orig_ndx, addr, size, va_size, t; tree lab_false, lab_over, lab_false2; + bool indirect; + + indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + if (indirect) + type = build_pointer_type (type); /* Handle complex values as separate real and imaginary parts. */ if (TREE_CODE (type) == COMPLEX_TYPE) @@ -2637,6 +2642,8 @@ xtensa_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, addr = build (MINUS_EXPR, ptr_type_node, addr, t); addr = fold_convert (build_pointer_type (type), addr); + if (indirect) + addr = build_fold_indirect_ref (addr); return build_fold_indirect_ref (addr); }