public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work058)] Group -mconst-anchor and -msection-anchors-offset together.
@ 2021-07-07 14:45 Michael Meissner
  0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2021-07-07 14:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:96ee4bd6e6370688ee08d47eb23560474e877931

commit 96ee4bd6e6370688ee08d47eb23560474e877931
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Wed Jul 7 10:45:38 2021 -0400

    Group -mconst-anchor and -msection-anchors-offset together.
    
    I've discovered that the -mconst-anchor code needs -fsection-anchors just
    like -msection-anchors-offset does.  This patch combines the processing of
    the two options.
    
    2021-07-07  Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
            * gcc/config/rs6000/rs6000.c (rs6000_option_override_internal):
            Combine -mconst-anchor and -msection-anchors-offset, and set
            -fsection-anchors for -mconst-anchor.

Diff:
---
 gcc/config/rs6000/rs6000.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 20a30727787..7677741d50b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4545,18 +4545,23 @@ rs6000_option_override_internal (bool global_init_p)
 	error ("%qs requires %qs", "-mlxvkq", "-mfloat128-hardware");
     }
 
-  /* Possibly set the const_anchor to the maximum value, based on whether we
-     have prefixed addressing.  */
-  if (TARGET_CONST_ANCHOR)
-    targetm.const_anchor = HOST_WIDE_INT_1 << (TARGET_PREFIXED ? 33 : 15);
-
-  /* Possibly set the minimum/maximum section anchor offset to the maximum
-     value, based on whether we have prefixed addressing.  */
-  if (TARGET_SECTION_ANCHOR_OFFSET)
+  /* Possibly set the const_anchor and min/max anchor values to the maximum
+     value, based on whether we have prefixed addressing.  Note both of these
+     options need -fsection-anchors enabled.  */
+  if (TARGET_SECTION_ANCHOR_OFFSET || TARGET_CONST_ANCHOR)
     {
       HOST_WIDE_INT shift_amount = TARGET_PREFIXED ? 33 : 15;
-      targetm.min_anchor_offset = -(HOST_WIDE_INT_1 << shift_amount);
-      targetm.max_anchor_offset = (HOST_WIDE_INT_1 << shift_amount) - 1;
+      HOST_WIDE_INT max_bits_plus_1 = HOST_WIDE_INT_1 << shift_amount;
+
+      if (TARGET_CONST_ANCHOR)
+	targetm.const_anchor = max_bits_plus_1;
+
+      if (TARGET_SECTION_ANCHOR_OFFSET)
+	{
+	  targetm.min_anchor_offset = -max_bits_plus_1;
+	  targetm.max_anchor_offset = max_bits_plus_1 - 1;
+	}
+
       if (!global_options_set.x_flag_section_anchors)
 	flag_section_anchors = true;
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-07 14:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 14:45 [gcc(refs/users/meissner/heads/work058)] Group -mconst-anchor and -msection-anchors-offset together Michael Meissner

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