From 576113abdb10ebdd141cdd3adb6884973c3d3c1d Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Fri, 27 Sep 2019 19:23:39 +0000
Subject: [PATCH] [Darwin, PPC, Mode Iterators 3/n] Update macho_correct_pic.

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

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.

From-SVN: r276196
---
 gcc/ChangeLog               |  8 ++++++
 gcc/config/rs6000/darwin.md | 51 +++++++++----------------------------
 gcc/config/rs6000/rs6000.md |  3 ++-
 3 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 37037ab4cc60..c935cf3d3d46 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
 2019-09-27  David Malcolm  <dmalcolm@redhat.com>
 
 	* fibonacci_heap.h (fibonacci_heap::empty): Make const.
diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md
index a5c5a3af39e6..b2a52d81b3f4 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 c5443bab9e80..46167e5f20fb 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
-- 
GitLab