* Use pass_by_reference consistently
@ 2004-07-15 6:46 Richard Henderson
0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 2004-07-15 6:46 UTC (permalink / raw)
To: gcc-patches
Adjusts all of the target gimplifier routines to consistently use
the interface presented by pass_by_reference.
Compile tested on all targets.
r~
* 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.
Index: alpha/alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.375
diff -c -p -d -u -r1.375 alpha.c
--- alpha/alpha.c 14 Jul 2004 06:24:08 -0000 1.375
+++ alpha/alpha.c 14 Jul 2004 21:14:11 -0000
@@ -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
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
/* 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
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
fold_convert (TREE_TYPE (offset_field), offset));
gimplify_and_add (t, pre_p);
+ if (indirect)
+ r = build_fold_indirect_ref (r);
+
return r;
}
\f
Index: c4x/c4x.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/c4x/c4x.c,v
retrieving revision 1.154
diff -c -p -d -u -r1.154 c4x.c
--- c4x/c4x.c 14 Jul 2004 07:30:21 -0000 1.154
+++ c4x/c4x.c 14 Jul 2004 21:14:12 -0000
@@ -733,12 +733,20 @@ c4x_gimplify_va_arg_expr (tree valist, t
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;
}
Index: i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.691
diff -c -p -d -u -r1.691 i386.c
--- i386/i386.c 14 Jul 2004 06:24:15 -0000 1.691
+++ i386/i386.c 14 Jul 2004 21:14:12 -0000
@@ -3281,14 +3281,10 @@ ix86_gimplify_va_arg (tree valist, tree
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,
Index: i860/i860.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i860/i860.c,v
retrieving revision 1.46
diff -c -p -d -u -r1.46 i860.c
--- i860/i860.c 8 Jul 2004 23:37:00 -0000 1.46
+++ i860/i860.c 14 Jul 2004 21:14:13 -0000
@@ -1932,6 +1932,7 @@ i860_gimplify_va_arg_expr (tree valist,
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,
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,
}
addr = fold_convert (type_ptr, addr);
+ if (indirect)
+ addr = build_fold_indirect_ref (addr);
return build_fold_indirect_ref (addr);
}
Index: ia64/ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.304
diff -c -p -d -u -r1.304 ia64.c
--- ia64/ia64.c 14 Jul 2004 06:24:15 -0000 1.304
+++ ia64/ia64.c 14 Jul 2004 21:14:13 -0000
@@ -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);
Index: rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.667
diff -c -p -d -u -r1.667 rs6000.c
--- rs6000/rs6000.c 14 Jul 2004 14:57:46 -0000 1.667
+++ rs6000/rs6000.c 14 Jul 2004 21:14:16 -0000
@@ -5451,29 +5451,20 @@ rs6000_gimplify_va_arg (tree valist, tre
{
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, tre
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, tre
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, tre
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);
}
Index: sh/sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.281
diff -c -p -d -u -r1.281 sh.c
--- sh/sh.c 14 Jul 2004 06:24:23 -0000 1.281
+++ sh/sh.c 14 Jul 2004 21:14:16 -0000
@@ -6322,7 +6322,7 @@ sh_gimplify_va_arg_expr (tree valist, tr
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);
Index: xtensa/xtensa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.c,v
retrieving revision 1.64
diff -c -p -d -u -r1.64 xtensa.c
--- xtensa/xtensa.c 14 Jul 2004 19:52:46 -0000 1.64
+++ xtensa/xtensa.c 14 Jul 2004 21:14:17 -0000
@@ -2479,6 +2479,11 @@ xtensa_gimplify_va_arg_expr (tree valist
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
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-07-14 21:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-15 6:46 Use pass_by_reference consistently Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).