public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Darwin, PPC, Mode Iterators 1/n, committed] Use mode iterators in picbase patterns.
@ 2019-09-24 19:31 Iain Sandoe
  2019-09-24 23:23 ` Segher Boessenkool
  0 siblings, 1 reply; 6+ messages in thread
From: Iain Sandoe @ 2019-09-24 19:31 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool

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.

Tested on powerpc-darwin9, powerpc64-linux-gnu,
applied to mainline
thanks
Iain

gcc/ChangeLog:

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

	* config/rs6000/rs6000.md (load_macho_picbase_<mode>): New, using
	the 'P' mode iterator, replacing the (removed) SI and DI variants.
	(reload_macho_picbase_<mode>): Likewise.

diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index 471058dd41..4a284211af 100644
--- a/gcc/config/rs6000/darwin.md
+++ b/gcc/config/rs6000/darwin.md
@@ -217,7 +217,7 @@ You should have received a copy of the GNU General Public License
   "")
 
 (define_expand "load_macho_picbase"
-  [(set (reg:SI LR_REGNO)
+  [(set (reg LR_REGNO)
         (unspec [(match_operand 0 "")]
                    UNSPEC_LD_MPIC))]
   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
@@ -230,9 +230,9 @@ You should have received a copy of the GNU General Public License
   DONE;
 })
 
-(define_insn "load_macho_picbase_si"
-  [(set (reg:SI LR_REGNO)
-       (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
+(define_insn "load_macho_picbase_<mode>"
+  [(set (reg:P LR_REGNO)
+       (unspec:P [(match_operand:P 0 "immediate_operand" "s")
                    (pc)] UNSPEC_LD_MPIC))]
   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
 {
@@ -246,22 +246,6 @@ You should have received a copy of the GNU General Public License
   [(set_attr "type" "branch")
    (set_attr "cannot_copy" "yes")])
 
-(define_insn "load_macho_picbase_di"
-  [(set (reg:DI LR_REGNO)
-       (unspec:DI [(match_operand:DI 0 "immediate_operand" "s")
-                   (pc)] UNSPEC_LD_MPIC))]
-  "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT"
-{
-#if TARGET_MACHO
-  machopic_should_output_picbase_label (); /* Update for new func.  */
-#else
-  gcc_unreachable ();
-#endif
-  return "bcl 20,31,%0\n%0:";
-}
-  [(set_attr "type" "branch")
-   (set_attr "cannot_copy" "yes")])
-
 (define_expand "macho_correct_pic"
   [(set (match_operand 0 "")
        (plus (match_operand 1 "")
@@ -301,7 +285,7 @@ You should have received a copy of the GNU General Public License
   [(set_attr "length" "8")])
 
 (define_expand "reload_macho_picbase"
-  [(set (reg:SI LR_REGNO)
+  [(set (reg LR_REGNO)
         (unspec [(match_operand 0 "")]
                    UNSPEC_RELD_MPIC))]
   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
@@ -314,9 +298,9 @@ You should have received a copy of the GNU General Public License
   DONE;
 })
 
-(define_insn "reload_macho_picbase_si"
-  [(set (reg:SI LR_REGNO)
-        (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
+(define_insn "reload_macho_picbase_<mode>"
+  [(set (reg:P LR_REGNO)
+        (unspec:P [(match_operand:P 0 "immediate_operand" "s")
                    (pc)] UNSPEC_RELD_MPIC))]
   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
 {
@@ -337,29 +321,6 @@ You should have received a copy of the GNU General Public License
   [(set_attr "type" "branch")
    (set_attr "cannot_copy" "yes")])
 
-(define_insn "reload_macho_picbase_di"
-  [(set (reg:DI LR_REGNO)
-       (unspec:DI [(match_operand:DI 0 "immediate_operand" "s")
-                   (pc)] UNSPEC_RELD_MPIC))]
-  "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT"
-{
-#if TARGET_MACHO
-  if (machopic_should_output_picbase_label ())
-    {
-      static char tmp[64];
-      const char *cnam = machopic_get_function_picbase ();
-      snprintf (tmp, 64, "bcl 20,31,%s\n%s:\n%%0:", cnam, cnam);
-      return tmp;
-    }
-  else
-#else
-  gcc_unreachable ();
-#endif
-    return "bcl 20,31,%0\n%0:";
-}
-  [(set_attr "type" "branch")
-   (set_attr "cannot_copy" "yes")])
-
 ;; We need to restore the PIC register, at the site of nonlocal label.
 
 (define_insn_and_split "nonlocal_goto_receiver"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Darwin, PPC, Mode Iterators 1/n, committed] Use mode iterators in picbase patterns.
  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   ` [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders Iain Sandoe
  0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2019-09-24 23:23 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: GCC Patches

Hi Iain,

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.


Segher

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders.
  2019-09-24 23:23 ` Segher Boessenkool
@ 2019-09-26 18:57   ` Iain Sandoe
  2019-09-27 19:29     ` [Darwin, PPC, Mode Iterators 3/n, committed] Update macho_correct_pic Iain Sandoe
  0 siblings, 1 reply; 6+ messages in thread
From: Iain Sandoe @ 2019-09-26 18:57 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

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));
     }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Darwin, PPC, Mode Iterators 3/n, committed] Update macho_correct_pic.
  2019-09-26 18:57   ` [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders Iain Sandoe
@ 2019-09-27 19:29     ` Iain Sandoe
  2019-09-28 19:36       ` [Darwin, PPC, Mode Iterators 4/n, committed] Update macho_high Iain Sandoe
  0 siblings, 1 reply; 6+ messages in thread
From: Iain Sandoe @ 2019-09-27 19:29 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool

Drop the expander and use a mode expander on the define_insn
for macho_correct_pic instead.  Update callers.

tested on powerpc-darwin9, powerpc64-linux-gnu
applied to mainline,
thanks
Iain

gcc/ChangeLog:

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

	* config/rs6000/darwin.md (@macho_correct_pic_<mode>): New,
	replaces the expander and two define_insn entries.
	(@reload_macho_picbase_<mode>): Update gen_macho_correct_pic
	call.
	* config/rs6000/rs6000.md (builtin_setjmp_receiver): Likewise.

diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index a5c5a3af39..b2a52d81b3 100644
--- a/gcc/config/rs6000/darwin.md
+++ b/gcc/config/rs6000/darwin.md
@@ -216,6 +216,16 @@ You should have received a copy of the GNU General Public License
        (match_dup 2))]
   "")
 
+(define_insn "@macho_correct_pic_<mode>"
+  [(set (match_operand:P 0 "gpc_reg_operand" "=r")
+       (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
+                (unspec:P [(match_operand:P 2 "immediate_operand" "s")
+                            (match_operand:P 3 "immediate_operand" "s")]
+                           UNSPEC_MPIC_CORRECT)))]
+  "DEFAULT_ABI == ABI_DARWIN"
+  "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
+  [(set_attr "length" "8")])
+
 (define_insn "@load_macho_picbase_<mode>"
   [(set (reg:P LR_REGNO)
        (unspec:P [(match_operand:P 0 "immediate_operand" "s")
@@ -232,44 +242,6 @@ You should have received a copy of the GNU General Public License
   [(set_attr "type" "branch")
    (set_attr "cannot_copy" "yes")])
 
-(define_expand "macho_correct_pic"
-  [(set (match_operand 0 "")
-       (plus (match_operand 1 "")
-                (unspec [(match_operand 2 "")
-                            (match_operand 3 "")]
-                           UNSPEC_MPIC_CORRECT)))]
-  "DEFAULT_ABI == ABI_DARWIN"
-{
-  if (TARGET_32BIT)
-    emit_insn (gen_macho_correct_pic_si (operands[0], operands[1], operands[2],
-              operands[3]));
-  else
-    emit_insn (gen_macho_correct_pic_di (operands[0], operands[1], operands[2],
-              operands[3]));
-
-  DONE;
-})
-
-(define_insn "macho_correct_pic_si"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-       (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-                (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
-                            (match_operand:SI 3 "immediate_operand" "s")]
-                           UNSPEC_MPIC_CORRECT)))]
-  "DEFAULT_ABI == ABI_DARWIN"
-  "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
-  [(set_attr "length" "8")])
-
-(define_insn "macho_correct_pic_di"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-       (plus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
-                (unspec:DI [(match_operand:DI 2 "immediate_operand" "s")
-                            (match_operand:DI 3 "immediate_operand" "s")]
-                           16)))]
-  "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
-  "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
-  [(set_attr "length" "8")])
-
 (define_insn "@reload_macho_picbase_<mode>"
   [(set (reg:P LR_REGNO)
         (unspec:P [(match_operand:P 0 "immediate_operand" "s")
@@ -316,7 +288,8 @@ You should have received a copy of the GNU General Public License
 
       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));
+      emit_insn (gen_macho_correct_pic (Pmode, picreg, picreg,
+                                       picrtx, tmplrtx));
     }
   else
     /* Not using PIC reg, no reload needed.  */
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index c5443bab9e..46167e5f20 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10055,7 +10055,8 @@
 
       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));
+      emit_insn (gen_macho_correct_pic (Pmode, picreg, picreg,
+                                       picrtx, tmplabrtx));
     }
   else
 #endif

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Darwin, PPC, Mode Iterators 4/n, committed] Update macho_high.
  2019-09-27 19:29     ` [Darwin, PPC, Mode Iterators 3/n, committed] Update macho_correct_pic Iain Sandoe
@ 2019-09-28 19:36       ` Iain Sandoe
  2019-09-29 20:59         ` [Darwin, PPC, Mode Iterators 5/n, committed] Update macho_low Iain Sandoe
  0 siblings, 1 reply; 6+ messages in thread
From: Iain Sandoe @ 2019-09-28 19:36 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool

(since Segher asked,  ’n’ is approximately 8 - some of the patterns will be
 harder to convert)

Drop the expander for macho_high and use a mode iterator on the define_insn
for @macho_high_<mode> instead.

as usual, tested on powerpc-darwin9 and powerpc64-linux-gnu
applied to mainline
thanks
Iain

gcc/ChangeLog:

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

	* config/darwin.c (gen_macho_high): Amend to include the mode
	argument.
	(machopic_indirect_data_reference): Amend gen_macho_high call
	to include mode argument.
	(machopic_legitimize_pic_address): Likewise.
	* config/rs6000/rs6000.c (rs6000_legitimize_address):
	* config/rs6000/darwin.md (@macho_high_<mode>): New, replaces
	the macho_high expander and two define_insn entries.

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 3e4bbffc92..1f72c07ab7 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "lto-section-names.h"
 #include "intl.h"
+#include "optabs.h"
 
 /* Darwin supports a feature called fix-and-continue, which is used
    for rapid turn around debugging.  When code is compiled with the
@@ -108,7 +109,7 @@ section * darwin_sections[NUM_DARWIN_SECTIONS];
 
 /* While we transition to using in-tests instead of ifdef'd code.  */
 #if !HAVE_lo_sum
-#define gen_macho_high(a,b) (a)
+#define gen_macho_high(m,a,b) (a)
 #define gen_macho_low(a,b,c) (a)
 #endif
 
@@ -654,7 +655,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
            {
          /* Create a new register for CSE opportunities.  */
          rtx hi_reg = (!can_create_pseudo_p () ? reg : gen_reg_rtx (Pmode));
-         emit_insn (gen_macho_high (hi_reg, orig));
+         emit_insn (gen_macho_high (Pmode, hi_reg, orig));
          emit_insn (gen_macho_low (reg, hi_reg, orig));
              return reg;
            }
@@ -858,7 +859,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg)
              rtx asym = XEXP (orig, 0);
              rtx mem;
 
-             emit_insn (gen_macho_high (temp_reg, asym));
+             emit_insn (gen_macho_high (Pmode, temp_reg, asym));
              mem = gen_const_mem (GET_MODE (orig),
                                   gen_rtx_LO_SUM (Pmode, temp_reg,
                                                   copy_rtx (asym)));
diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index b2a52d81b3..0c63a31755 100644
--- a/gcc/config/rs6000/darwin.md
+++ b/gcc/config/rs6000/darwin.md
@@ -150,31 +150,12 @@ You should have received a copy of the GNU General Public License
    stfd %0,lo16(%2)(%1)"
   [(set_attr "type" "store")])
 
-;; Mach-O PIC trickery.
-(define_expand "macho_high"
-  [(set (match_operand 0 "")
-       (high (match_operand 1 "")))]
-  "TARGET_MACHO"
-{
-  if (TARGET_64BIT)
-    emit_insn (gen_macho_high_di (operands[0], operands[1]));
-  else
-    emit_insn (gen_macho_high_si (operands[0], operands[1]));
+;; Mach-O PIC.
 
-  DONE;
-})
-
-(define_insn "macho_high_si"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
-       (high:SI (match_operand 1 "" "")))]
-  "TARGET_MACHO && ! TARGET_64BIT"
-  "lis %0,ha16(%1)")
-  
-
-(define_insn "macho_high_di"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
-       (high:DI (match_operand 1 "" "")))]
-  "TARGET_MACHO && TARGET_64BIT"
+(define_insn "@macho_high_<mode>"
+  [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
+       (high:P (match_operand 1 "" "")))]
+  "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN)"
   "lis %0,ha16(%1)")
 
 (define_expand "macho_low"
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 81aec9c54a..f136dcbf8c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -7978,7 +7978,7 @@ rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
       if (TARGET_ELF)
        emit_insn (gen_elf_high (reg, x));
       else
-       emit_insn (gen_macho_high (reg, x));
+       emit_insn (gen_macho_high (Pmode, reg, x));
       return gen_rtx_LO_SUM (Pmode, reg, x);
     }
   else if (TARGET_TOC
@@ -9691,7 +9691,7 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode)
                  return;
                }
 #endif
-             emit_insn (gen_macho_high (target, operands[1]));
+             emit_insn (gen_macho_high (Pmode, target, operands[1]));
              emit_insn (gen_macho_low (operands[0], target, operands[1]));
              return;
            }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Darwin, PPC, Mode Iterators 5/n, committed] Update macho_low.
  2019-09-28 19:36       ` [Darwin, PPC, Mode Iterators 4/n, committed] Update macho_high Iain Sandoe
@ 2019-09-29 20:59         ` Iain Sandoe
  0 siblings, 0 replies; 6+ messages in thread
From: Iain Sandoe @ 2019-09-29 20:59 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool

Replace the define_expand and two define_insns with a single
@macho_low_<mode> and update callers.

as usual, tested on powerpc-darwin9 and powerpc64-linux-gnu
applied to mainline
thanks
Iain

gcc/ChangeLog:

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

	* config/darwin.c (gen_macho_low):Amend to include the mode
	argument.
	(machopic_indirect_data_reference): Amend gen_macho_low call
	to include mode argument
	* config/rs6000/rs6000.c (emit_move): Likewise. Amend a comment.
	* config/rs6000/darwin.md (@macho_low_<mode>): New, replaces
	the macho_high expander and two define_insn entries.

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 1f72c07ab7..3a1be5a29b 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -110,7 +110,7 @@ section * darwin_sections[NUM_DARWIN_SECTIONS];
 /* While we transition to using in-tests instead of ifdef'd code.  */
 #if !HAVE_lo_sum
 #define gen_macho_high(m,a,b) (a)
-#define gen_macho_low(a,b,c) (a)
+#define gen_macho_low(m,a,b,c) (a)
 #endif
 
 /* True if we're setting __attribute__ ((ms_struct)).  */
@@ -656,7 +656,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
          /* Create a new register for CSE opportunities.  */
          rtx hi_reg = (!can_create_pseudo_p () ? reg : gen_reg_rtx (Pmode));
          emit_insn (gen_macho_high (Pmode, hi_reg, orig));
-         emit_insn (gen_macho_low (reg, hi_reg, orig));
+         emit_insn (gen_macho_low (Pmode, reg, hi_reg, orig));
              return reg;
            }
          else if (DARWIN_X86)
diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index 0c63a31755..3994447f38 100644
--- a/gcc/config/rs6000/darwin.md
+++ b/gcc/config/rs6000/darwin.md
@@ -158,32 +158,11 @@ You should have received a copy of the GNU General Public License
   "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN)"
   "lis %0,ha16(%1)")
 
-(define_expand "macho_low"
-  [(set (match_operand 0 "")
-       (lo_sum (match_operand 1 "")
-                  (match_operand 2 "")))]
-   "TARGET_MACHO"
-{
-  if (TARGET_64BIT)
-    emit_insn (gen_macho_low_di (operands[0], operands[1], operands[2]));
-  else
-    emit_insn (gen_macho_low_si (operands[0], operands[1], operands[2]));
-
-  DONE;
-})
-
-(define_insn "macho_low_si"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-       (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
-                  (match_operand 2 "" "")))]
-   "TARGET_MACHO && ! TARGET_64BIT"
-   "la %0,lo16(%2)(%1)")
-
-(define_insn "macho_low_di"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-       (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
+(define_insn "@macho_low_<mode>"
+  [(set (match_operand:P 0 "gpc_reg_operand" "=r")
+       (lo_sum:P (match_operand:P 1 "gpc_reg_operand" "b")
                   (match_operand 2 "" "")))]
-   "TARGET_MACHO && TARGET_64BIT"
+   "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN)"
    "la %0,lo16(%2)(%1)")
 
 (define_split
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a34415349e..1eb13176dd 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -9682,6 +9682,8 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode)
          if (DEFAULT_ABI == ABI_DARWIN)
            {
 #if TARGET_MACHO
+             /* This is not PIC code, but could require the subset of
+                indirections used by mdynamic-no-pic.  */
              if (MACHO_DYNAMIC_NO_PIC_P)
                {
                  /* Take care of any required data indirection.  */
@@ -9693,7 +9695,8 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode)
                }
 #endif
              emit_insn (gen_macho_high (Pmode, target, operands[1]));
-             emit_insn (gen_macho_low (operands[0], target, operands[1]));
+             emit_insn (gen_macho_low (Pmode, operands[0],
+                                       target, operands[1]));
              return;
            }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-29 20:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders Iain Sandoe
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

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