Add pass_va_arg_by_reference
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 20 Aug 2019 08:50:59 +0000 (08:50 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 20 Aug 2019 08:50:59 +0000 (08:50 +0000)
This patch splits out a common idiom from the va_arg gimplification
routines, so that there's only one place to update later.

2019-08-20  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* calls.h (pass_va_arg_by_reference): Declare.
* calls.c (pass_va_arg_by_reference): New function.
* config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it.
* config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise.
* config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise.
(mips_gimplify_va_arg_expr): Likewise.
* config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise.
* config/s390/s390.c (s390_gimplify_va_arg): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
* config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise.
* config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise.
* config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise.
* config/visium/visium.c (visium_gimplify_va_arg): Likewise.
* config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
* targhooks.c (std_gimplify_va_arg_expr): Likewise.

From-SVN: r274695

20 files changed:
gcc/ChangeLog
gcc/calls.c
gcc/calls.h
gcc/config/aarch64/aarch64.c
gcc/config/alpha/alpha.c
gcc/config/gcn/gcn.c
gcc/config/i386/i386.c
gcc/config/ia64/ia64.c
gcc/config/mips/mips.c
gcc/config/msp430/msp430.c
gcc/config/pa/pa.c
gcc/config/rs6000/rs6000-call.c
gcc/config/s390/s390.c
gcc/config/sparc/sparc.c
gcc/config/spu/spu.c
gcc/config/tilegx/tilegx.c
gcc/config/tilepro/tilepro.c
gcc/config/visium/visium.c
gcc/config/xtensa/xtensa.c
gcc/targhooks.c

index 7975480b788c28c5669b8bba0df4a6c463478bd6..81d672f8970b901f506a160cb7ddd5bf83629115 100644 (file)
@@ -1,3 +1,26 @@
+2019-08-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * calls.h (pass_va_arg_by_reference): Declare.
+       * calls.c (pass_va_arg_by_reference): New function.
+       * config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it.
+       * config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise.
+       * config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise.
+       * config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
+       * config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
+       * config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise.
+       (mips_gimplify_va_arg_expr): Likewise.
+       * config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise.
+       * config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
+       * config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise.
+       * config/s390/s390.c (s390_gimplify_va_arg): Likewise.
+       * config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
+       * config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise.
+       * config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise.
+       * config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise.
+       * config/visium/visium.c (visium_gimplify_va_arg): Likewise.
+       * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
+       * targhooks.c (std_gimplify_va_arg_expr): Likewise.
+
 2019-08-20  Richard Biener  <rguenther@suse.de>
 
        PR target/91498
index 54e30e6cb0dc304b0e4e584dab0b250fb5063802..f49f052bd4af8fb258acd67a31c13e6622bae30a 100644 (file)
@@ -927,6 +927,15 @@ pass_by_reference (CUMULATIVE_ARGS *ca, machine_mode mode,
                                          type, named_arg);
 }
 
+/* Return true if TYPE should be passed by reference when passed to
+   the "..." arguments of a function.  */
+
+bool
+pass_va_arg_by_reference (tree type)
+{
+  return pass_by_reference (NULL, TYPE_MODE (type), type, false);
+}
+
 /* Return true if TYPE, which is passed by reference, should be callee
    copied instead of caller copied.  */
 
index 128bb5130749f93e4da28e99df9c02931e90a69a..2f41fa34abb21a58af943015950ee19f981b8b5f 100644 (file)
@@ -35,6 +35,7 @@ extern void fixup_tail_calls (void);
 
 extern bool pass_by_reference (CUMULATIVE_ARGS *, machine_mode,
                               tree, bool);
+extern bool pass_va_arg_by_reference (tree);
 extern bool reference_callee_copied (CUMULATIVE_ARGS *, machine_mode,
                                     tree, bool);
 extern void maybe_warn_alloc_args_overflow (tree, tree, tree[2], int[2]);
index be0162244a28ea1609087648e45a763445826969..bbcafa951c94f7dfe2a8effd39cb60257d8d2f5d 100644 (file)
@@ -14271,7 +14271,7 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   HOST_WIDE_INT size, rsize, adjust, align;
   tree t, u, cond1, cond2;
 
-  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect_p = pass_va_arg_by_reference (type);
   if (indirect_p)
     type = build_pointer_type (type);
 
index d551af74e1ee5dc7ca0103571afc89823814f14e..74ca95e12a8e7b7c5e75dbcfaf8e900be638b03a 100644 (file)
@@ -6330,7 +6330,7 @@ alpha_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
   t = fold_convert (build_nonstandard_integer_type (64, 0), offset_field);
   offset = get_initialized_tmp_var (t, pre_p, NULL);
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
 
   if (indirect)
     {
index 2c1158f2df0a91d16733ea045b48bf9e92d940ff..0826c819dd61a0b737a1796478f291e70d3464c1 100644 (file)
@@ -2493,7 +2493,7 @@ gcn_gimplify_va_arg_expr (tree valist, tree type,
   tree t, u;
   bool indirect;
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
     {
       type = ptr;
index 647bcbef0506f4f5ad561535c1e303a9cd045682..e6244eafaac488fb4f272627879e32ea1d53800c 100644 (file)
@@ -4307,7 +4307,7 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
   ovf = build3 (COMPONENT_REF, TREE_TYPE (f_ovf), valist, f_ovf, NULL_TREE);
   sav = build3 (COMPONENT_REF, TREE_TYPE (f_sav), valist, f_sav, NULL_TREE);
 
-  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect_p = pass_va_arg_by_reference (type);
   if (indirect_p)
     type = build_pointer_type (type);
   size = arg_int_size_in_bytes (type);
index a07244e2206226852682072b18444c130de063c8..4449151b6e1467060a49f90ef274e7a5976d78f5 100644 (file)
@@ -5147,7 +5147,7 @@ ia64_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
                      gimple_seq *post_p)
 {
   /* Variable sized types are passed by reference.  */
-  if (pass_by_reference (NULL, TYPE_MODE (type), type, false))
+  if (pass_va_arg_by_reference (type))
     {
       tree ptrtype = build_pointer_type (type);
       tree addr = std_gimplify_va_arg_expr (valist, ptrtype, pre_p, post_p);
index 45ddec13e9f47c90833db81e74c4d9ca456a272c..fd5d78d1d13b47bd95a2b57ee04d601b1ceea80e 100644 (file)
@@ -6780,7 +6780,7 @@ mips_std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   unsigned HOST_WIDE_INT align, boundary;
   bool indirect;
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
     type = build_pointer_type (type);
 
@@ -6867,7 +6867,7 @@ mips_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   tree addr;
   bool indirect_p;
 
-  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
+  indirect_p = pass_va_arg_by_reference (type);
   if (indirect_p)
     type = build_pointer_type (type);
 
index fedbdf52c5c3e1fb26b62b46bc72702af2c02eb0..84762f9edb431e17abbda85db8e86a1d56e41c11 100644 (file)
@@ -856,7 +856,7 @@ msp430_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   unsigned HOST_WIDE_INT align, boundary;
   bool indirect;
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
     type = build_pointer_type (type);
 
index 0ab95d84c3a66809e89c3bf23fca175f590be276..778e1364540612a494a8be1ddc217348cec03211 100644 (file)
@@ -6377,7 +6377,7 @@ hppa_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
       unsigned int size, ofs;
       bool indirect;
 
-      indirect = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
+      indirect = pass_va_arg_by_reference (type);
       if (indirect)
        {
          type = ptr;
index 62aa4bf6be4e688898877fd054c4fe5f37b5067a..f7c5384e92eff110a53998b67af90d11bc9e277a 100644 (file)
@@ -2690,7 +2690,7 @@ rs6000_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
   int regalign = 0;
   gimple *stmt;
 
-  if (pass_by_reference (NULL, TYPE_MODE (type), type, false))
+  if (pass_va_arg_by_reference (type))
     {
       t = rs6000_gimplify_va_arg (valist, ptrtype, pre_p, post_p);
       return build_va_arg_indirect_ref (t);
index 74f1d254a33a3959dc997cfed4eb3b085206fe85..4ea600a832521397cd6edd8acfa207014fa6e960 100644 (file)
@@ -12476,7 +12476,7 @@ s390_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
 
   s390_check_type_for_vector_abi (type, true, false);
 
-  if (pass_by_reference (NULL, TYPE_MODE (type), type, false))
+  if (pass_va_arg_by_reference (type))
     {
       if (TARGET_DEBUG_ARG)
        {
index a15f27f442c1fe523334a8872337fda7cb0214cd..e5cf9a8dfb1ef799c8aeca1a1b0ba2c87e9254f0 100644 (file)
@@ -7935,7 +7935,7 @@ sparc_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
   bool indirect;
   tree ptrtype = build_pointer_type (type);
 
-  if (pass_by_reference (NULL, TYPE_MODE (type), type, false))
+  if (pass_va_arg_by_reference (type))
     {
       indirect = true;
       size = rsize = UNITS_PER_WORD;
index f88ad19aa6f7e8fb2451c650c8bad93d8fd499ad..50bf40e865bc6272b05036454ed7832af59b9ed4 100644 (file)
@@ -4053,8 +4053,7 @@ spu_gimplify_va_arg_expr (tree valist, tree type, gimple_seq * pre_p,
 
   /* if an object is dynamically sized, a pointer to it is passed
      instead of the object itself. */
-  pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type,
-                                          false);
+  pass_by_reference_p = pass_va_arg_by_reference (type);
   if (pass_by_reference_p)
     type = build_pointer_type (type);
   size = int_size_in_bytes (type);
index 575780fcccb4befda0392fb853b265f943d30031..849fda551b63688990af4051c8d8940d1ab435cd 100644 (file)
@@ -471,8 +471,7 @@ tilegx_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
 
   /* If an object is dynamically sized, a pointer to it is passed
      instead of the object itself.  */
-  pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type,
-                                          false);
+  pass_by_reference_p = pass_va_arg_by_reference (type);
 
   if (pass_by_reference_p)
     type = build_pointer_type (type);
index b4adfa49985f221d193cf7a4f9ea56004e45a450..8091ee05922daf6c669efbe7a31d600305592652 100644 (file)
@@ -419,8 +419,7 @@ tilepro_gimplify_va_arg_expr (tree valist, tree type, gimple_seq * pre_p,
 
   /* if an object is dynamically sized, a pointer to it is passed
      instead of the object itself.  */
-  pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type,
-                                          false);
+  pass_by_reference_p = pass_va_arg_by_reference (type);
 
   if (pass_by_reference_p)
     type = build_pointer_type (type);
index 431f64cfcad3351f39dd42c38d1d72e2f68b6f35..4ff331362f7daf931a3d4b4de059b54d0a26aa80 100644 (file)
@@ -1637,8 +1637,7 @@ visium_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
   tree f_ovfl, f_gbase, f_fbase, f_gbytes, f_fbytes;
   tree ovfl, base, bytes;
   HOST_WIDE_INT size, rsize;
-  const bool by_reference_p
-    = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  const bool by_reference_p = pass_va_arg_by_reference (type);
   const bool float_reg_arg_p
     = (TARGET_FPU && !by_reference_p
        && ((GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT
index a99956755ec0bc5d5bb9152ac3190ff48132d9b8..9c90c146896040119be1366d8f93a43dcae41b05 100644 (file)
@@ -3252,7 +3252,7 @@ xtensa_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   tree lab_false, lab_over, lab_false2;
   bool indirect;
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
     type = build_pointer_type (type);
 
index 111ed2ea816c7643e2957de6e5ee1f42321d7200..8a83ce8332c295dd19d7639f30d79b7580b561b8 100644 (file)
@@ -2177,7 +2177,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
   if (ARGS_GROW_DOWNWARD)
     gcc_unreachable ();
 
-  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  indirect = pass_va_arg_by_reference (type);
   if (indirect)
     type = build_pointer_type (type);