public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Meissner <meissner@linux.ibm.com>
To: gcc-patches@gcc.gnu.org,
	Segher Boessenkool <segher@kernel.crashing.org>,
	 David Edelsohn <dje.gcc@gmail.com>,
	Michael Meissner <meissner@linux.ibm.com>
Subject: [PATCH, V4] PowerPC Turn on -mpcrel by default for -mcpu=future
Date: Mon, 6 Apr 2020 12:52:04 -0400	[thread overview]
Message-ID: <20200406165204.GA15583@ibm-tinman.the-meissners.org> (raw)

Commit message:
Enable -mpcrel for -mcpu=future if it is allowed by the ABI.

2020-04-06  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/linux64.h (PCREL_SUPPORTED_BY_OS): Enable
	prefixed PC-relative addressing if the ABI supports it.
	* config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Do not
	set OPTION_MASK_PREFIXED here.
	* config/rs6000/rs6000.c (rs6000_option_override_internal): Enable
	OPTION_MASK_PREFIXED and OPTION_MASK_PCREL on -mcpu=future by
	default if the current ABI allows the options.

I tested this on a little endian PowerPC power8 system, doing bootstrap and
make check.  There were no regressions.  I tested by hand the various
conditions where -mpcrel is not enabled, and they all used the normal power9
TOC references.

    -mcpu=power9			generates TOC;
    -mcpu=future -mcmodel=large		generates TOC;
    -mcpu=future -mcmode=small		generates TOC;
    -mcpu=future -mno-prefixed		generates TOC;
    -mcpu=future -mno-pcrel		generates TOC;
    -mcpu=future			generates PC-relative.

--- /tmp/apbaWN_linux64.h	2020-04-03 17:15:05.059677000 -0400
+++ gcc/config/rs6000/linux64.h	2020-04-03 17:01:05.580426937 -0400
@@ -640,3 +640,10 @@ extern int dot_symbols;
    enabling the __float128 keyword.  */
 #undef	TARGET_FLOAT128_ENABLE_TYPE
 #define TARGET_FLOAT128_ENABLE_TYPE 1
+
+/* Enable using prefixed PC-relative addressing on the 'future' machine if the
+   ABI supports it.  The ELF v2 ABI only supports PC-relative relocations for
+   the medium code model.  */
+#define PCREL_SUPPORTED_BY_OS	(TARGET_FUTURE && TARGET_PREFIXED	\
+				 && ELFv2_ABI_CHECK			\
+				 && (TARGET_CMODEL == CMODEL_MEDIUM))
--- /tmp/XzRKno_rs6000-cpus.def	2020-04-03 17:15:05.068676928 -0400
+++ gcc/config/rs6000/rs6000-cpus.def	2020-04-03 17:00:50.115550614 -0400
@@ -75,10 +75,14 @@
 				 | OPTION_MASK_P8_VECTOR		\
 				 | OPTION_MASK_P9_VECTOR)
 
-/* Support for a future processor's features.  Do not enable -mpcrel until it
-   is fully functional.  */
+/* Support for a future processor's features.  Do not set OPTION_MASK_PREFIXED
+   or OPTION_MASK_PCREL here.  Those options are enabled in the function
+   rs6000_option_override if the ABI supports them.  */
 #define ISA_FUTURE_MASKS_SERVER	(ISA_3_0_MASKS_SERVER			\
-				 | OPTION_MASK_FUTURE			\
+				 | OPTION_MASK_FUTURE)
+
+/* Flags that need to be turned off if -mno-future.  */
+#define OTHER_FUTURE_MASKS	(OPTION_MASK_PCREL			\
 				 | OPTION_MASK_PREFIXED)
 
 /* Flags that need to be turned off if -mno-future.  */
--- /tmp/nyxSRY_rs6000.c	2020-04-03 17:15:05.081676823 -0400
+++ gcc/config/rs6000/rs6000.c	2020-04-03 17:03:19.846353197 -0400
@@ -4020,6 +4020,12 @@ rs6000_option_override_internal (bool gl
       rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW;
     }
 
+  /* Enable -mprefixed by default on 64-bit 'future' systems.  */
+  if (TARGET_FUTURE && TARGET_POWERPC64
+      && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0)
+    rs6000_isa_flags |= OPTION_MASK_PREFIXED;
+
+
   /* -mprefixed (and hence -mpcrel) requires -mcpu=future.  */
   if (TARGET_PREFIXED && !TARGET_FUTURE)
     {
@@ -4171,6 +4177,14 @@ rs6000_option_override_internal (bool gl
   SUB3TARGET_OVERRIDE_OPTIONS;
 #endif
 
+#ifdef PCREL_SUPPORTED_BY_OS
+  /* If the ABI has support for PC-relative relocations, enable it by
+     default.  */
+  if (PCREL_SUPPORTED_BY_OS
+      && (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0)
+    rs6000_isa_flags |= OPTION_MASK_PCREL;
+#endif
+
   /* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until
       after the subtarget override options are done.  */
   if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM)

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

             reply	other threads:[~2020-04-06 16:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 16:52 Michael Meissner [this message]
2020-04-06 22:21 ` will schmidt
2020-04-07 22:58 ` Segher Boessenkool
2020-04-21 18:03   ` Michael Meissner
2020-04-21 19:15     ` Segher Boessenkool

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=20200406165204.GA15583@ibm-tinman.the-meissners.org \
    --to=meissner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.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).