diff mbox

[PATCHv2] PowerPC: Add msingle-pic-base option.

Message ID OF91F809C9.F6AEE490-ONC12577EA.002C8098-C12577EA.002CA088@transmode.se
State New
Headers show

Commit Message

Joakim Tjernlund Nov. 29, 2010, 8:07 a.m. UTC
David Edelsohn <dje.gcc@gmail.com> wrote on 2010/11/29 01:24:22:
>
> This patch is okay, but would you please make the order consistent in
> the first hunk so both are
>
> (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
>              && !TARGET_SINGLE_PIC_BASE
>
> Thanks, David

Sure, like this?

From a9321d3549b5d29024c4bb011bf6e75903aef4e9 Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Date: Sat, 9 Oct 2010 12:45:39 +0200
Subject: [PATCHv3] PowerPC: Add msingle-pic-base option.

Do not generate fPIC/fpic prologue nor save
and restore PIC register.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 v2: Use Var instead of Mask and add some docs per
     Michael Meissner <meissner@linux.vnet.ibm.com>
 v3: Make order in if statement consistent.

 gcc/config/rs6000/rs6000.c   |    5 +++++
 gcc/config/rs6000/rs6000.opt |    4 ++++
 gcc/doc/invoke.texi          |    9 ++++++++-
 3 files changed, 17 insertions(+), 1 deletions(-)

--
1.7.2.2

Comments

David Edelsohn Nov. 29, 2010, 10:11 p.m. UTC | #1
Yes.

Thanks, David

On Mon, Nov 29, 2010 at 3:07 AM, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> David Edelsohn <dje.gcc@gmail.com> wrote on 2010/11/29 01:24:22:
>>
>> This patch is okay, but would you please make the order consistent in
>> the first hunk so both are
>>
>> (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
>>              && !TARGET_SINGLE_PIC_BASE
>>
>> Thanks, David
>
> Sure, like this?
>
> From a9321d3549b5d29024c4bb011bf6e75903aef4e9 Mon Sep 17 00:00:00 2001
> From: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> Date: Sat, 9 Oct 2010 12:45:39 +0200
> Subject: [PATCHv3] PowerPC: Add msingle-pic-base option.
>
> Do not generate fPIC/fpic prologue nor save
> and restore PIC register.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  v2: Use Var instead of Mask and add some docs per
>     Michael Meissner <meissner@linux.vnet.ibm.com>
>  v3: Make order in if statement consistent.
>
>  gcc/config/rs6000/rs6000.c   |    5 +++++
>  gcc/config/rs6000/rs6000.opt |    4 ++++
>  gcc/doc/invoke.texi          |    9 ++++++++-
>  3 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index 63f8ef9..310d28b 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -16036,8 +16036,10 @@ rs6000_reg_live_or_pic_offset_p (int reg)
>   return ((df_regs_ever_live_p (reg)
>            && (!call_used_regs[reg]
>                || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
> +                  && !TARGET_SINGLE_PIC_BASE
>                    && TARGET_TOC && TARGET_MINIMAL_TOC)))
>           || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
> +             && !TARGET_SINGLE_PIC_BASE
>               && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
>                   || (DEFAULT_ABI == ABI_DARWIN && flag_pic))));
>  }
> @@ -16737,6 +16739,9 @@ rs6000_emit_prologue (void)
>       insn = emit_insn (generate_set_vrsave (reg, info, 0));
>     }
>
> +  if (TARGET_SINGLE_PIC_BASE)
> +    return; /* Do not set PIC register */
> +
>   /* If we are using RS6000_PIC_OFFSET_TABLE_REGNUM, we need to set it up.  */
>   if ((TARGET_TOC && TARGET_MINIMAL_TOC && get_pool_size () != 0)
>       || (DEFAULT_ABI == ABI_V4
> diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
> index 8a62352..2adb6dd 100644
> --- a/gcc/config/rs6000/rs6000.opt
> +++ b/gcc/config/rs6000/rs6000.opt
> @@ -119,6 +119,10 @@ mupdate
>  Target Report RejectNegative InverseMask(NO_UPDATE, UPDATE)
>  Generate load/store with update instructions
>
> +msingle-pic-base
> +Target Report Var(TARGET_SINGLE_PIC_BASE) Init(0)
> +Do not load the PIC register in function prologues
> +
>  mavoid-indexed-addresses
>  Target Report Var(TARGET_AVOID_XFORM) Init(-1)
>  Avoid generation of indexed load/store instructions when possible
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 393e418..fc30537 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -728,7 +728,7 @@ See RS/6000 and PowerPC Options.
>  -mstrict-align  -mno-strict-align  -mrelocatable @gol
>  -mno-relocatable  -mrelocatable-lib  -mno-relocatable-lib @gol
>  -mtoc  -mno-toc  -mlittle  -mlittle-endian  -mbig  -mbig-endian @gol
> --mdynamic-no-pic  -maltivec  -mswdiv @gol
> +-mdynamic-no-pic  -maltivec  -mswdiv  -msingle-pic-base @gol
>  -mprioritize-restricted-insns=@var{priority} @gol
>  -msched-costly-dep=@var{dependence_type} @gol
>  -minsert-sched-nops=@var{scheme} @gol
> @@ -14129,6 +14129,13 @@ relocatable, but that its external references are relocatable.  The
>  resulting code is suitable for applications, but not shared
>  libraries.
>
> +@item -msingle-pic-base
> +@opindex msingle-pic-base
> +Treat the register used for PIC addressing as read-only, rather than
> +loading it in the prologue for each function.  The run-time system is
> +responsible for initializing this register with an appropriate value
> +before execution begins.
> +
>  @item -mprioritize-restricted-insns=@var{priority}
>  @opindex mprioritize-restricted-insns
>  This option controls the priority that is assigned to
> --
> 1.7.2.2
>
>
Nathan Froyd Nov. 30, 2010, 1:49 a.m. UTC | #2
On Mon, Nov 29, 2010 at 05:11:00PM -0500, David Edelsohn wrote:
> On Mon, Nov 29, 2010 at 3:07 AM, Joakim Tjernlund
> <joakim.tjernlund@transmode.se> wrote:
> > David Edelsohn <dje.gcc@gmail.com> wrote on 2010/11/29 01:24:22:
> >> This patch is okay, but would you please make the order consistent in
> >> the first hunk so both are
> >>
> >> (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
> >>              && !TARGET_SINGLE_PIC_BASE
> >
> > Sure, like this?
>
> Yes.

Given David's OK, I have committed the patch on Joakim's behalf with the
following ChangeLog as r167283:

2010-11-29  Joakim Tjernlund  <Joakim.Tjernlund@transmode.se>

	* config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Check
	TARGET_SINGLE_PIC_BASE for RS6000_PIC_OFFSET_TABLE_REGNUM.
	(rs6000_emit_prologue): Don't set PIC register if
	TARGET_SINGLE_PIC_BASE.
	* config/rs6000/rs6000.opt (msingle-pic-base): New option.
	* doc/invoke.texi (msingle-pic-base): Document.

-Nathan
Joakim Tjernlund Nov. 30, 2010, 7:12 a.m. UTC | #3
Nathan Froyd <froydnj@codesourcery.com> wrote on 2010/11/30 02:49:41:
>
> On Mon, Nov 29, 2010 at 05:11:00PM -0500, David Edelsohn wrote:
> > On Mon, Nov 29, 2010 at 3:07 AM, Joakim Tjernlund
> > <joakim.tjernlund@transmode.se> wrote:
> > > David Edelsohn <dje.gcc@gmail.com> wrote on 2010/11/29 01:24:22:
> > >> This patch is okay, but would you please make the order consistent in
> > >> the first hunk so both are
> > >>
> > >> (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
> > >>              && !TARGET_SINGLE_PIC_BASE
> > >
> > > Sure, like this?
> >
> > Yes.
>
> Given David's OK, I have committed the patch on Joakim's behalf with the
> following ChangeLog as r167283:
>
> 2010-11-29  Joakim Tjernlund  <Joakim.Tjernlund@transmode.se>
>
>    * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Check
>    TARGET_SINGLE_PIC_BASE for RS6000_PIC_OFFSET_TABLE_REGNUM.
>    (rs6000_emit_prologue): Don't set PIC register if
>    TARGET_SINGLE_PIC_BASE.
>    * config/rs6000/rs6000.opt (msingle-pic-base): New option.
>    * doc/invoke.texi (msingle-pic-base): Document.

Thank you!

In what release will this be in?

         Jocke
Nathan Froyd Dec. 1, 2010, 3:31 p.m. UTC | #4
On Tue, Nov 30, 2010 at 08:12:56AM +0100, Joakim Tjernlund wrote:
> In what release will this be in?

It will be in the upcoming 4.6 release.  It's David's call whether this
patch is eligible for a backport to the 4.5 or even 4.4 trees.

-Nathan
David Edelsohn Dec. 6, 2010, 9:42 p.m. UTC | #5
On Wed, Dec 1, 2010 at 10:31 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> On Tue, Nov 30, 2010 at 08:12:56AM +0100, Joakim Tjernlund wrote:
>> In what release will this be in?
>
> It will be in the upcoming 4.6 release.  It's David's call whether this
> patch is eligible for a backport to the 4.5 or even 4.4 trees.

GCC 4.4 is too old.  The patch could be backported to the GCC 4.5
branch, but that branch is fairly mature and I am not sure what
benefit is gained at this point.

- David
Joakim Tjernlund Dec. 7, 2010, 12:50 a.m. UTC | #6
David Edelsohn <dje.gcc@gmail.com> wrote on 2010/12/06 22:42:39:
>
> On Wed, Dec 1, 2010 at 10:31 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> > On Tue, Nov 30, 2010 at 08:12:56AM +0100, Joakim Tjernlund wrote:
> >> In what release will this be in?
> >
> > It will be in the upcoming 4.6 release.  It's David's call whether this
> > patch is eligible for a backport to the 4.5 or even 4.4 trees.
>
> GCC 4.4 is too old.  The patch could be backported to the GCC 4.5
> branch, but that branch is fairly mature and I am not sure what
> benefit is gained at this point.

You think 4.5 is old already? Before 4.6 is even out?
4.5 isn't used by many on a daily basis as far as I can tell, not to
mention 4.6.

 Jocke
Andrew Pinski Dec. 7, 2010, 12:55 a.m. UTC | #7
On Mon, Dec 6, 2010 at 4:50 PM, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> You think 4.5 is old already? Before 4.6 is even out?
> 4.5 isn't used by many on a daily basis as far as I can tell, not to
> mention 4.6.

Let me explain that GCC 4.5 is a release branch.  We don't like to put
new features into a release branch as that means it could unstablize
the branch such the next release of the 3.5.x series is worse than the
previous one.  That is something we don't want to happen.  New
features always go on the trunk and it is decided based on how the
change could be unstable might backport the change (most likely not
for new features).  This is standard software release practice as far
as I know it.

-- Pinski
Gerald Pfeifer Jan. 6, 2011, 12:57 p.m. UTC | #8
On Mon, 29 Nov 2010, Nathan Froyd wrote:
> Given David's OK, I have committed the patch on Joakim's behalf with the
> following ChangeLog as r167283:
> 
> 2010-11-29  Joakim Tjernlund  <Joakim.Tjernlund@transmode.se>
> 
> 	* config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Check
> 	TARGET_SINGLE_PIC_BASE for RS6000_PIC_OFFSET_TABLE_REGNUM.
> 	(rs6000_emit_prologue): Don't set PIC register if
> 	TARGET_SINGLE_PIC_BASE.
> 	* config/rs6000/rs6000.opt (msingle-pic-base): New option.
> 	* doc/invoke.texi (msingle-pic-base): Document.

I don't see this in http://gcc.gnu.org/gcc-4.6/changes.html yet.

Would you mind adding this, and any other relevant changes for
the release you are aware of?

Gerald
diff mbox

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 63f8ef9..310d28b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16036,8 +16036,10 @@  rs6000_reg_live_or_pic_offset_p (int reg)
   return ((df_regs_ever_live_p (reg)
            && (!call_used_regs[reg]
                || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
+		   && !TARGET_SINGLE_PIC_BASE
                    && TARGET_TOC && TARGET_MINIMAL_TOC)))
           || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM
+	      && !TARGET_SINGLE_PIC_BASE
               && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
                   || (DEFAULT_ABI == ABI_DARWIN && flag_pic))));
 }
@@ -16737,6 +16739,9 @@  rs6000_emit_prologue (void)
       insn = emit_insn (generate_set_vrsave (reg, info, 0));
     }

+  if (TARGET_SINGLE_PIC_BASE)
+    return; /* Do not set PIC register */
+
   /* If we are using RS6000_PIC_OFFSET_TABLE_REGNUM, we need to set it up.  */
   if ((TARGET_TOC && TARGET_MINIMAL_TOC && get_pool_size () != 0)
       || (DEFAULT_ABI == ABI_V4
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 8a62352..2adb6dd 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -119,6 +119,10 @@  mupdate
 Target Report RejectNegative InverseMask(NO_UPDATE, UPDATE)
 Generate load/store with update instructions

+msingle-pic-base
+Target Report Var(TARGET_SINGLE_PIC_BASE) Init(0)
+Do not load the PIC register in function prologues
+
 mavoid-indexed-addresses
 Target Report Var(TARGET_AVOID_XFORM) Init(-1)
 Avoid generation of indexed load/store instructions when possible
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 393e418..fc30537 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -728,7 +728,7 @@  See RS/6000 and PowerPC Options.
 -mstrict-align  -mno-strict-align  -mrelocatable @gol
 -mno-relocatable  -mrelocatable-lib  -mno-relocatable-lib @gol
 -mtoc  -mno-toc  -mlittle  -mlittle-endian  -mbig  -mbig-endian @gol
--mdynamic-no-pic  -maltivec  -mswdiv @gol
+-mdynamic-no-pic  -maltivec  -mswdiv  -msingle-pic-base @gol
 -mprioritize-restricted-insns=@var{priority} @gol
 -msched-costly-dep=@var{dependence_type} @gol
 -minsert-sched-nops=@var{scheme} @gol
@@ -14129,6 +14129,13 @@  relocatable, but that its external references are relocatable.  The
 resulting code is suitable for applications, but not shared
 libraries.

+@item -msingle-pic-base
+@opindex msingle-pic-base
+Treat the register used for PIC addressing as read-only, rather than
+loading it in the prologue for each function.  The run-time system is
+responsible for initializing this register with an appropriate value
+before execution begins.
+
 @item -mprioritize-restricted-insns=@var{priority}
 @opindex mprioritize-restricted-insns
 This option controls the priority that is assigned to