public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <iain@sandoe.co.uk>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders.
Date: Thu, 26 Sep 2019 18:57:00 -0000	[thread overview]
Message-ID: <A76C99B2-E32E-41D7-9FF7-CC9979663724@sandoe.co.uk> (raw)
In-Reply-To: <20190924232333.GP9749@gate.crashing.org>

Hi Segher,

thanks for the pointers to how to simplify this!

> On 25 Sep 2019, at 00:23, Segher Boessenkool <segher@kernel.crashing.org> wrote:

> On Tue, Sep 24, 2019 at 08:31:16PM +0100, Iain Sandoe wrote:
>> This switches the picbase load and reload patterns to use the 'P' mode
>> iterator instead of writing an SI and DI pattern for each (and deletes the
>> old patterns).  No functional change intended.
> 
>> (define_expand "load_macho_picbase"
>> -  [(set (reg:SI LR_REGNO)
>> +  [(set (reg LR_REGNO)
> 
> This changes it to VOIDmode instead?  It should have been reg:P LR_REGNO?
> 
>> (define_expand "reload_macho_picbase"
>> -  [(set (reg:SI LR_REGNO)
>> +  [(set (reg LR_REGNO)
> 
> Same here.

As we discussed this is symptomatic of the fact that the expanders only exist in this
to pass the mode through.

We can eliminate them completely by using an “@pattern<mode>” in the actual
patterns (and updating callers to pass the mode as the first argument).

tested on powerpc-darwin9, powerpc64-linux-gnu (m32, m64)
applied to mainline,
thanks
Iain

gcc/ChangeLog:

2019-09-26  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/darwin.md: Replace the expanders for
	load_macho_picbase and reload_macho_picbase with use of '@'
	in their respective define_insns.
	(nonlocal_goto_receiver): Pass Pmode to gen_reload_macho_picbase.
	* config/rs6000/rs6000-logue.c (rs6000_emit_prologue): Pass
	Pmode to gen_load_macho_picbase.
	* config/rs6000/rs6000.md: Likewise.

diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index 4a284211af..a5c5a3af39 100644
--- a/gcc/config/rs6000/darwin.md
+++ b/gcc/config/rs6000/darwin.md
@@ -216,21 +216,7 @@ You should have received a copy of the GNU General Public License
        (match_dup 2))]
   "")
 
-(define_expand "load_macho_picbase"
-  [(set (reg LR_REGNO)
-        (unspec [(match_operand 0 "")]
-                   UNSPEC_LD_MPIC))]
-  "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
-{
-  if (TARGET_32BIT)
-    emit_insn (gen_load_macho_picbase_si (operands[0]));
-  else
-    emit_insn (gen_load_macho_picbase_di (operands[0]));
-
-  DONE;
-})
-
-(define_insn "load_macho_picbase_<mode>"
+(define_insn "@load_macho_picbase_<mode>"
   [(set (reg:P LR_REGNO)
        (unspec:P [(match_operand:P 0 "immediate_operand" "s")
                    (pc)] UNSPEC_LD_MPIC))]
@@ -284,21 +270,7 @@ You should have received a copy of the GNU General Public License
   "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
   [(set_attr "length" "8")])
 
-(define_expand "reload_macho_picbase"
-  [(set (reg LR_REGNO)
-        (unspec [(match_operand 0 "")]
-                   UNSPEC_RELD_MPIC))]
-  "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
-{
-  if (TARGET_32BIT)
-    emit_insn (gen_reload_macho_picbase_si (operands[0]));
-  else
-    emit_insn (gen_reload_macho_picbase_di (operands[0]));
-
-  DONE;
-})
-
-(define_insn "reload_macho_picbase_<mode>"
+(define_insn "@reload_macho_picbase_<mode>"
   [(set (reg:P LR_REGNO)
         (unspec:P [(match_operand:P 0 "immediate_operand" "s")
                    (pc)] UNSPEC_RELD_MPIC))]
@@ -342,7 +314,7 @@ You should have received a copy of the GNU General Public License
       ASM_GENERATE_INTERNAL_LABEL(tmplab, "Lnlgr", ++n);
       tmplrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
 
-      emit_insn (gen_reload_macho_picbase (tmplrtx));
+      emit_insn (gen_reload_macho_picbase (Pmode, tmplrtx));
       emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
       emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplrtx));
     }
diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c
index 633a253e43..e98893a440 100644
--- a/gcc/config/rs6000/rs6000-logue.c
+++ b/gcc/config/rs6000/rs6000-logue.c
@@ -3809,7 +3809,7 @@ rs6000_emit_prologue (void)
       if (!info->lr_save_p)
        emit_move_insn (gen_rtx_REG (Pmode, 0), lr);
 
-      emit_insn (gen_load_macho_picbase (src));
+      emit_insn (gen_load_macho_picbase (Pmode, src));
 
       emit_move_insn (gen_rtx_REG (Pmode,
                                   RS6000_PIC_OFFSET_TABLE_REGNUM),
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 4dbf85bbc9..c5443bab9e 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10053,7 +10053,7 @@
                                  CODE_LABEL_NUMBER (operands[0]));
       tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
 
-      emit_insn (gen_load_macho_picbase (tmplabrtx));
+      emit_insn (gen_load_macho_picbase (Pmode, tmplabrtx));
       emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
       emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
     }

  reply	other threads:[~2019-09-26 18:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24 19:31 [Darwin, PPC, Mode Iterators 1/n, committed] Use mode iterators in picbase patterns Iain Sandoe
2019-09-24 23:23 ` Segher Boessenkool
2019-09-26 18:57   ` Iain Sandoe [this message]
2019-09-27 19:29     ` [Darwin, PPC, Mode Iterators 3/n, committed] Update macho_correct_pic Iain Sandoe
2019-09-28 19:36       ` [Darwin, PPC, Mode Iterators 4/n, committed] Update macho_high Iain Sandoe
2019-09-29 20:59         ` [Darwin, PPC, Mode Iterators 5/n, committed] Update macho_low Iain Sandoe

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=A76C99B2-E32E-41D7-9FF7-CC9979663724@sandoe.co.uk \
    --to=iain@sandoe.co.uk \
    --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).