public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [01/13] Add pass_va_arg_by_reference
Date: Mon, 19 Aug 2019 15:16:00 -0000	[thread overview]
Message-ID: <mptwof9chq8.fsf@arm.com> (raw)
In-Reply-To: <mpt1rxhdwbz.fsf@arm.com> (Richard Sandiford's message of "Mon,	19 Aug 2019 16:11:12 +0100")

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-19  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.

Index: gcc/calls.h
===================================================================
--- gcc/calls.h	2019-03-08 18:15:33.696751769 +0000
+++ gcc/calls.h	2019-08-19 15:58:10.742205564 +0100
@@ -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: gcc/calls.c
===================================================================
--- gcc/calls.c	2019-08-13 22:35:04.921302360 +0100
+++ gcc/calls.c	2019-08-19 15:58:10.742205564 +0100
@@ -927,6 +927,15 @@ pass_by_reference (CUMULATIVE_ARGS *ca,
 					  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: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c	2019-08-15 10:00:02.366735649 +0100
+++ gcc/config/aarch64/aarch64.c	2019-08-19 15:58:10.746205533 +0100
@@ -14271,7 +14271,7 @@ aarch64_gimplify_va_arg_expr (tree valis
   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: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c	2019-08-13 22:35:11.721252311 +0100
+++ gcc/config/alpha/alpha.c	2019-08-19 15:58:10.750205506 +0100
@@ -6330,7 +6330,7 @@ alpha_gimplify_va_arg (tree valist, tree
   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: gcc/config/gcn/gcn.c
===================================================================
--- gcc/config/gcn/gcn.c	2019-08-13 22:35:11.733252223 +0100
+++ gcc/config/gcn/gcn.c	2019-08-19 15:58:10.750205506 +0100
@@ -2493,7 +2493,7 @@ gcn_gimplify_va_arg_expr (tree valist, t
   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: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	2019-08-19 15:57:56.338309784 +0100
+++ gcc/config/i386/i386.c	2019-08-19 15:58:10.754205475 +0100
@@ -4307,7 +4307,7 @@ ix86_gimplify_va_arg (tree valist, tree
   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: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c	2019-08-13 22:35:11.741252166 +0100
+++ gcc/config/ia64/ia64.c	2019-08-19 15:58:10.754205475 +0100
@@ -5147,7 +5147,7 @@ ia64_gimplify_va_arg (tree valist, tree
 		      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: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2019-08-13 22:35:11.741252166 +0100
+++ gcc/config/mips/mips.c	2019-08-19 15:58:10.758205447 +0100
@@ -6780,7 +6780,7 @@ mips_std_gimplify_va_arg_expr (tree vali
   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 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: gcc/config/msp430/msp430.c
===================================================================
--- gcc/config/msp430/msp430.c	2019-08-15 15:26:04.800237365 +0100
+++ gcc/config/msp430/msp430.c	2019-08-19 15:58:10.758205447 +0100
@@ -856,7 +856,7 @@ msp430_gimplify_va_arg_expr (tree valist
   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: gcc/config/pa/pa.c
===================================================================
--- gcc/config/pa/pa.c	2019-08-13 22:35:11.749252108 +0100
+++ gcc/config/pa/pa.c	2019-08-19 15:58:10.762205420 +0100
@@ -6377,7 +6377,7 @@ hppa_gimplify_va_arg_expr (tree valist,
       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: gcc/config/rs6000/rs6000-call.c
===================================================================
--- gcc/config/rs6000/rs6000-call.c	2019-08-13 22:35:11.765251990 +0100
+++ gcc/config/rs6000/rs6000-call.c	2019-08-19 15:58:10.762205420 +0100
@@ -2690,7 +2690,7 @@ rs6000_gimplify_va_arg (tree valist, tre
   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: gcc/config/s390/s390.c
===================================================================
--- gcc/config/s390/s390.c	2019-08-13 22:35:11.789251813 +0100
+++ gcc/config/s390/s390.c	2019-08-19 15:58:10.762205420 +0100
@@ -12476,7 +12476,7 @@ s390_gimplify_va_arg (tree valist, tree
 
   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: gcc/config/sparc/sparc.c
===================================================================
--- gcc/config/sparc/sparc.c	2019-08-13 22:35:11.797251752 +0100
+++ gcc/config/sparc/sparc.c	2019-08-19 15:58:10.766205389 +0100
@@ -7935,7 +7935,7 @@ sparc_gimplify_va_arg (tree valist, tree
   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: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	2019-08-13 22:35:11.801251725 +0100
+++ gcc/config/spu/spu.c	2019-08-19 15:58:10.766205389 +0100
@@ -4053,8 +4053,7 @@ spu_gimplify_va_arg_expr (tree valist, t
 
   /* 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: gcc/config/tilegx/tilegx.c
===================================================================
--- gcc/config/tilegx/tilegx.c	2019-08-13 22:35:11.805251695 +0100
+++ gcc/config/tilegx/tilegx.c	2019-08-19 15:58:10.766205389 +0100
@@ -471,8 +471,7 @@ tilegx_gimplify_va_arg_expr (tree valist
 
   /* 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: gcc/config/tilepro/tilepro.c
===================================================================
--- gcc/config/tilepro/tilepro.c	2019-08-13 22:35:11.805251695 +0100
+++ gcc/config/tilepro/tilepro.c	2019-08-19 15:58:10.766205389 +0100
@@ -419,8 +419,7 @@ tilepro_gimplify_va_arg_expr (tree valis
 
   /* 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: gcc/config/visium/visium.c
===================================================================
--- gcc/config/visium/visium.c	2019-03-18 12:24:58.875434349 +0000
+++ gcc/config/visium/visium.c	2019-08-19 15:58:10.766205389 +0100
@@ -1637,8 +1637,7 @@ visium_gimplify_va_arg (tree valist, tre
   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: gcc/config/xtensa/xtensa.c
===================================================================
--- gcc/config/xtensa/xtensa.c	2019-08-13 22:35:11.805251695 +0100
+++ gcc/config/xtensa/xtensa.c	2019-08-19 15:58:10.766205389 +0100
@@ -3252,7 +3252,7 @@ xtensa_gimplify_va_arg_expr (tree valist
   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: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c	2019-08-15 15:26:09.232205170 +0100
+++ gcc/targhooks.c	2019-08-19 15:58:10.766205389 +0100
@@ -2177,7 +2177,7 @@ std_gimplify_va_arg_expr (tree valist, t
   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);
 

  reply	other threads:[~2019-08-19 15:12 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 15:15 [00/13] Pass an argument descriptor to target hooks Richard Sandiford
2019-08-19 15:16 ` Richard Sandiford [this message]
2019-08-19 20:04   ` [01/13] Add pass_va_arg_by_reference Jeff Law
2019-08-19 15:17 ` [02/13] Add must_pass_va_arg_in_stack Richard Sandiford
2019-08-19 20:05   ` Jeff Law
2019-08-19 15:18 ` [03/13] Use function_arg_info for TARGET_ARG_PARTIAL_BYTES Richard Sandiford
2019-08-19 20:42   ` Jeff Law
2019-08-19 15:19 ` [04/13] Use function_arg_info for TARGET_PASS_BY_REFERENCE Richard Sandiford
2019-08-19 20:43   ` Jeff Law
2019-08-19 15:20 ` [05/13] Use function_arg_info for TARGET_SETUP_INCOMING_ARGS Richard Sandiford
2019-08-19 20:50   ` Jeff Law
2019-08-19 15:21 ` [06/13] Use function_arg_info for TARGET_FUNCTION_(INCOMING_)ARG Richard Sandiford
2019-08-19 21:07   ` Jeff Law
2019-08-19 15:22 ` [07/13] Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCE Richard Sandiford
2019-08-19 21:11   ` Jeff Law
2019-08-19 15:23 ` [08/13] Use function_arg_info for TARGET_CALLEE_COPIES Richard Sandiford
2019-08-19 21:16   ` Jeff Law
2019-08-19 15:24 ` [09/13] Use function_arg_info for TARGET_MUST_PASS_IN_STACK Richard Sandiford
2019-08-19 22:04   ` Jeff Law
2019-08-19 15:47 ` [10/13] Add a apply_pass_by_reference_rules helper Richard Sandiford
2019-08-19 22:19   ` Jeff Law
2019-08-19 15:51 ` [11/13] Make function.c use function_arg_info internally Richard Sandiford
2019-08-19 22:47   ` Jeff Law
2019-08-19 15:52 ` [13/13] Add a pass_by_reference flag to function_arg_info Richard Sandiford
2019-08-19 22:54   ` Jeff Law
2019-08-19 15:52 ` [12/13] Make calls.c use function_arg_info internally Richard Sandiford
2019-08-19 22:49   ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mptwof9chq8.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).