diff mbox

alpha: add support for -fsection-anchors

Message ID 00242F84-2407-480D-BAB7-698E3157C0DC@adacore.com
State New
Headers show

Commit Message

Tristan Gingold Nov. 4, 2011, 2:52 p.m. UTC
Hi,

the alpha/vms ABI uses a per-function TOC/GOT, not unlike AIX.  As a consequence, -fsection-anchors really reduce the size of the TOC and even of the code.

This patch adds support of -fsection-anchors on alpha, and enable by default on Alpha/VMA (although it is still off at -O0).  This is a port of a similar patch we had for gcc 4.5

Tested on trunk by building alpha64-dec-vms and alpha-linux.

Richard, as it impacts all alpha targets, do you have any objection ?

Tristan.

2011-11-04  Tristan Gingold  <gingold@adacore.com>

	* common/config/alpha/alpha-common.c (alpha_option_init_struct):
	New function.
	(TARGET_OPTION_INIT_STRUCT): Define.
	* config/alpha/alpha.c (TARGET_MIN_ANCHOR_OFFSET)
	(TARGET_MAX_ANCHOR_OFFSET)
	(TARGET_USE_BLOCKS_FOR_CONSTANT_P): Redefine.

index fcf5369..8a366b6 100644

Comments

Richard Henderson Nov. 4, 2011, 3:21 p.m. UTC | #1
On 11/04/2011 07:52 AM, Tristan Gingold wrote:
> Richard, as it impacts all alpha targets, do you have any objection ?

I suspect not.  We might even see what we can do about enabling it
by default for all alpha targets...


r~
Tristan Gingold Nov. 7, 2011, 8:34 a.m. UTC | #2
On Nov 4, 2011, at 4:21 PM, Richard Henderson wrote:

> On 11/04/2011 07:52 AM, Tristan Gingold wrote:
>> Richard, as it impacts all alpha targets, do you have any objection ?
> 
> I suspect not.  We might even see what we can do about enabling it
> by default for all alpha targets…

Committed.  I let maintainers for the other OSes decide wether they want it by default or not.

Tristan.
diff mbox

Patch

--- a/gcc/common/config/alpha/alpha-common.c
+++ b/gcc/common/config/alpha/alpha-common.c
@@ -36,6 +36,17 @@  static const struct default_options alpha_option_optimization_table[] =
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
+static void
+alpha_option_init_struct (struct gcc_options *opts ATTRIBUTE_UNUSED)
+{
+#if TARGET_ABI_OPEN_VMS
+  /* Enable section anchors by default.  */
+  opts->x_flag_section_anchors = 1;
+#endif
+}
+
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
@@ -75,6 +86,9 @@  alpha_handle_option (struct gcc_options *opts,
 #undef TARGET_HANDLE_OPTION
 #define TARGET_HANDLE_OPTION alpha_handle_option
 
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT alpha_option_init_struct
+
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE alpha_option_optimization_table
 
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 682e5be..9a43f80 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -9643,6 +9643,14 @@  alpha_conditional_register_usage (void)
 #define TARGET_STDARG_OPTIMIZE_HOOK alpha_stdarg_optimize_hook
 #endif
 
+/* Use 16-bits anchor.  */
+#undef TARGET_MIN_ANCHOR_OFFSET
+#define TARGET_MIN_ANCHOR_OFFSET -0x7fff - 1
+#undef TARGET_MAX_ANCHOR_OFFSET
+#define TARGET_MAX_ANCHOR_OFFSET 0x7fff
+#undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
+#define TARGET_USE_BLOCKS_FOR_CONSTANT_P hook_bool_mode_const_rtx_true
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS alpha_rtx_costs
 #undef TARGET_ADDRESS_COST