public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [patch v2] Get rid of stack trampolines for nested functions (3/4)
Date: Sun, 04 Sep 2016 20:15:00 -0000	[thread overview]
Message-ID: <2332440.uHF5nx4qG9@arcturus.home> (raw)
In-Reply-To: <1518726.5fkcUnkpqM@arcturus.home>

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

These are the individual back-end changes.  Only the architectures for which 
native platforms are available are changed for now.  The changes were tested 
at AdaCore over the years for every architecture and I'll retest them if they 
are accepted, except for those I cannot access any more (Alpha, MIPS, PA).


2016-07-04  Eric Botcazou  <ebotcazou@adacore.com>

	* config/aarch64/aarch64.h(TARGET_CUSTOM_FUNCTION_DESCRIPTORS):Define
	* config/alpha/alpha.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS):Likewise.
	* config/arm/arm.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
	* config/arm/arm.c (arm_function_ok_for_sibcall): Return false for an
	indirect call by descriptor if all the argument registers are used.
	(arm_relayout_function): Use FUNCTION_ALIGNMENT.
	* config/i386/i386.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Define.
	* config/ia64/ia64.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
	* config/mips/mips.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
	* config/pa/pa.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
	* config/rs6000/rs6000.h(TARGET_CUSTOM_FUNCTION_DESCRIPTORS):Likewise
	* config/sparc/sparc.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS):Likewise.

-- 
Eric Botcazou

[-- Attachment #2: p3.diff --]
[-- Type: text/x-patch, Size: 6102 bytes --]

Index: config/aarch64/aarch64.h
===================================================================
--- config/aarch64/aarch64.h	(revision 239944)
+++ config/aarch64/aarch64.h	(working copy)
@@ -806,6 +806,10 @@ typedef struct
    correctly.  */
 #define TRAMPOLINE_SECTION text_section
 
+/* Use custom descriptors instead of trampolines when possible, but
+   TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2
+
 /* To start with.  */
 #define BRANCH_COST(SPEED_P, PREDICTABLE_P) \
   (aarch64_branch_cost (SPEED_P, PREDICTABLE_P))
Index: config/alpha/alpha.h
===================================================================
--- config/alpha/alpha.h	(revision 239944)
+++ config/alpha/alpha.h	(working copy)
@@ -996,3 +996,6 @@ extern long alpha_auto_offset;
 #define NO_IMPLICIT_EXTERN_C
 
 #define TARGET_SUPPORTS_WIDE_INT 1
+
+/* Use custom descriptors instead of trampolines when possible if not VMS.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS (TARGET_ABI_OPEN_VMS ? 0 : 1)
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 239944)
+++ config/arm/arm.c	(working copy)
@@ -6818,6 +6818,29 @@ arm_function_ok_for_sibcall (tree decl, tree exp)
       && DECL_WEAK (decl))
     return false;
 
+  /* We cannot do a tailcall for an indirect call by descriptor if all the
+     argument registers are used because the only register left to load the
+     address is IP and it will already contain the static chain.  */
+  if (!decl && CALL_EXPR_BY_DESCRIPTOR (exp) && !flag_trampolines)
+    {
+      tree fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp)));
+      CUMULATIVE_ARGS cum;
+      cumulative_args_t cum_v;
+
+      arm_init_cumulative_args (&cum, fntype, NULL_RTX, NULL_TREE);
+      cum_v = pack_cumulative_args (&cum);
+
+      for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
+	{
+	  tree type = TREE_VALUE (t);
+	  if (!VOID_TYPE_P (type))
+	    arm_function_arg_advance (cum_v, TYPE_MODE (type), type, true);
+	}
+
+      if (!arm_function_arg (cum_v, SImode, integer_type_node, true))
+	return false;
+    }
+
   /* Everything else is ok.  */
   return true;
 }
@@ -30187,7 +30210,9 @@ arm_relayout_function (tree fndecl)
     callee_tree = target_option_default_node;
 
   struct cl_target_option *opts = TREE_TARGET_OPTION (callee_tree);
-  SET_DECL_ALIGN (fndecl, FUNCTION_BOUNDARY_P (opts->x_target_flags));
+  SET_DECL_ALIGN (fndecl,
+		  FUNCTION_ALIGNMENT
+		  (FUNCTION_BOUNDARY_P (opts->x_target_flags)));
 }
 
 /* Inner function to process the attribute((target(...))), take an argument and
Index: config/arm/arm.h
===================================================================
--- config/arm/arm.h	(revision 239944)
+++ config/arm/arm.h	(working copy)
@@ -1645,6 +1645,10 @@ typedef struct
 
 /* Alignment required for a trampoline in bits.  */
 #define TRAMPOLINE_ALIGNMENT  32
+
+/* Use custom descriptors instead of trampolines when possible, but
+   TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2
 \f
 /* Addressing modes, and classification of registers for them.  */
 #define HAVE_POST_INCREMENT   1
Index: config/i386/i386.h
===================================================================
--- config/i386/i386.h	(revision 239944)
+++ config/i386/i386.h	(working copy)
@@ -2670,6 +2670,9 @@ extern void debug_dispatch_window (int);
 
 #define TARGET_SUPPORTS_WIDE_INT 1
 
+/* Use custom descriptors instead of trampolines when possible.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1
+
 /*
 Local variables:
 version-control: t
Index: config/ia64/ia64.h
===================================================================
--- config/ia64/ia64.h	(revision 239944)
+++ config/ia64/ia64.h	(working copy)
@@ -1714,4 +1714,7 @@ struct GTY(()) machine_function
 /* Switch on code for querying unit reservations.  */
 #define CPU_UNITS_QUERY 1
 
+/* IA-64 already uses descriptors for its standard calling sequence.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 0
+
 /* End of ia64.h */
Index: config/mips/mips.h
===================================================================
--- config/mips/mips.h	(revision 239944)
+++ config/mips/mips.h	(working copy)
@@ -3413,3 +3413,7 @@ struct GTY(())  machine_function {
 #define ENABLE_LD_ST_PAIRS \
   (TARGET_LOAD_STORE_PAIRS && (TUNE_P5600 || TUNE_I6400) \
    && !TARGET_MICROMIPS && !TARGET_FIX_24K)
+
+/* Use custom descriptors instead of trampolines when possible, but
+   TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2
Index: config/pa/pa.h
===================================================================
--- config/pa/pa.h	(revision 239944)
+++ config/pa/pa.h	(working copy)
@@ -1313,3 +1313,6 @@ do {									     \
    seven and four instructions, respectively.  */  
 #define MAX_PCREL17F_OFFSET \
   (flag_pic ? (TARGET_HPUX ? 198164 : 221312) : 240000)
+
+/* HP-PA already uses descriptors for its standard calling sequence.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 0
Index: config/rs6000/rs6000.h
===================================================================
--- config/rs6000/rs6000.h	(revision 239944)
+++ config/rs6000/rs6000.h	(working copy)
@@ -2914,3 +2914,6 @@ extern GTY(()) tree rs6000_builtin_types[RS6000_BT
 extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
 
 #define TARGET_SUPPORTS_WIDE_INT 1
+
+/* Use custom descriptors instead of trampolines when possible if not AIX.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS (DEFAULT_ABI == ABI_AIX ? 0 : 1)
Index: config/sparc/sparc.h
===================================================================
--- config/sparc/sparc.h	(revision 239944)
+++ config/sparc/sparc.h	(working copy)
@@ -1817,3 +1817,6 @@ extern int sparc_indent_opcode;
 #define SPARC_LOW_FE_EXCEPT_VALUES 0
 
 #define TARGET_SUPPORTS_WIDE_INT 1
+
+/* Use custom descriptors instead of trampolines when possible.  */
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1

  parent reply	other threads:[~2016-09-04 20:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-04 20:10 [patch v2] Get rid of stack trampolines for nested functions (0/4) Eric Botcazou
2016-09-04 20:12 ` [patch v2] Get rid of stack trampolines for nested functions (1/4) Eric Botcazou
2016-09-12 19:41   ` Jeff Law
2016-09-12 19:45   ` Jeff Law
2016-12-05 20:52   ` Ian Lance Taylor
2016-12-05 21:29     ` Lynn A. Boger
2016-12-05 22:41       ` Ian Lance Taylor
2016-12-05 22:12     ` Eric Botcazou
2016-12-06 17:52       ` Eric Botcazou
2016-12-06 20:18         ` Ian Lance Taylor
2016-12-06 21:59           ` Lynn A. Boger
2016-12-06 22:26             ` Eric Botcazou
2016-12-07 13:38               ` Lynn A. Boger
2016-12-07 13:56                 ` Eric Botcazou
2016-12-07  7:23           ` Eric Botcazou
2017-03-23 16:48   ` Andreas Schwab
2017-03-28 17:01     ` Eric Botcazou
2017-03-29 10:05       ` Andreas Schwab
2017-03-29 14:05         ` Eric Botcazou
2017-03-29 14:15           ` Andreas Schwab
2016-09-04 20:14 ` [patch v2] Get rid of stack trampolines for nested functions (2/4) Eric Botcazou
2016-09-04 20:15 ` Eric Botcazou [this message]
2016-09-05 10:52   ` [patch v2] Get rid of stack trampolines for nested functions (3/4) Segher Boessenkool
2016-09-12 19:56   ` Jeff Law
2016-09-04 21:31 ` [patch v2] Get rid of stack trampolines for nested functions (4/4) Eric Botcazou
2016-10-16 20:29 ` [patch v2] Get rid of stack trampolines for nested functions (0/4) Eric Botcazou
2016-10-17 10:40   ` Andreas Schwab
2016-10-17 11:14     ` Eric Botcazou
2016-10-17 22:35     ` Eric Botcazou

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=2332440.uHF5nx4qG9@arcturus.home \
    --to=ebotcazou@adacore.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).