From d9da94a1f029bbd0a9387838122f40ee44b65af5 Mon Sep 17 00:00:00 2001
From: "J\"orn Rennecke" <joern.rennecke@superh.com>
Date: Fri, 13 Dec 2002 20:20:28 +0000
Subject: [PATCH] *** empty log message ***

From-SVN: r60103
---
 gcc/ChangeLog       | 11 ++++++
 gcc/config/sh/sh.c  | 14 +++++++-
 gcc/config/sh/sh.h  |  1 +
 gcc/config/sh/sh.md | 86 ++++++++++++++++++++++-----------------------
 4 files changed, 68 insertions(+), 44 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a1ca49b6517d..a966a291b626 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+Fri Dec 13 16:02:27 2002  J"orn Rennecke <joern.rennecke@superh.com>
+
+	* sh.c (sh_register_operand): New function.
+	(prepare_move_operands): Use it.
+	* sh.h (PREDICATE_CODES): Add entry for sh_register_operand.
+	* sh.md (movsi_media, movsi_media_nofpu): Allow stores of 0.
+	(movqi_media, movhi_media, movdi_media, movdi_media_nofpu): Likewise.
+	(movdf_media, movdf_media_nofpu, movv4sf_i, movsf_media): Likewise.
+	(movsf_media_nofpu, movv2hi_i, movv4hi_i, movv8qi_i): Likewise.
+	(movv2si_i): Likewise.
+
 2002-12-13  Jim Wilson  <wilson@redhat.com>
 
 	* doc/extend.texi (Complex Numbers): Update info on debug info.
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 824914c42d22..75c9d263bfa5 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -724,7 +724,7 @@ prepare_move_operands (operands, mode)
     {
       /* Copy the source to a register if both operands aren't registers.  */
       if (! register_operand (operands[0], mode)
-	  && ! register_operand (operands[1], mode))
+	  && ! sh_register_operand (operands[1], mode))
 	operands[1] = copy_to_mode_reg (mode, operands[1]);
 
       /* This case can happen while generating code to move the result
@@ -7838,4 +7838,16 @@ sh_register_move_cost (mode, srcclass, dstclass)
   return 2 * ((GET_MODE_SIZE (mode) + 3) / 4U);
 }
 
+/* Like register_operand, but take into account that SHMEDIA can use
+   the constant zero like a general register.  */
+int
+sh_register_operand (op, mode)
+     rtx op;
+     enum machine_mode mode;
+{
+  if (op == CONST0_RTX (mode) && TARGET_SHMEDIA)
+    return 1;
+  return register_operand (op, mode);
+}
+
 #include "gt-sh.h"
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index f84e6fb8956f..57ebbb311aff 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -3227,6 +3227,7 @@ extern int rtx_equal_function_value_matters;
   {"mextr_bit_offset", {CONST_INT}},					\
   {"noncommutative_float_operator", {MINUS, DIV}},			\
   {"shmedia_6bit_operand", {SUBREG, REG, CONST_INT}},			\
+  {"sh_register_operand", {REG, SUBREG, CONST_INT}},			\
   {"target_reg_operand", {SUBREG, REG}},				\
   {"target_operand", {SUBREG, REG, LABEL_REF, SYMBOL_REF, CONST, UNSPEC}},\
   {"trunc_hi_operand", {SUBREG, REG, TRUNCATE}},			\
diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index 1df69d194958..4dbda27e4b9c 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -3463,16 +3463,16 @@
 
 (define_insn "*movsi_media"
   [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,r,r,m,f,m,f,r,f,*b,r,b")
-	(match_operand:SI 1 "general_movsrc_operand" "r,JS,ns,m,r,m,f,rU,f,f,r,*b,T"))]
+	(match_operand:SI 1 "general_movsrc_operand" "r,JS,ns,m,rU,m,f,rU,f,f,r,*b,T"))]
   "TARGET_SHMEDIA_FPU
    && (register_operand (operands[0], SImode)
-       || register_operand (operands[1], SImode))"
+       || sh_register_operand (operands[1], SImode))"
   "@
 	add.l	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.l	%m1, %0
-	st%M0.l	%m0, %1
+	st%M0.l	%m0, %N1
 	fld%M1.s	%m1, %0
 	fst%M0.s	%m0, %1
 	fmov.ls	%N1, %0
@@ -3486,16 +3486,16 @@
 
 (define_insn "*movsi_media_nofpu"
   [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,r,r,m,*b,r,b")
-	(match_operand:SI 1 "general_movsrc_operand" "r,JS,ns,m,r,r,*b,T"))]
+	(match_operand:SI 1 "general_movsrc_operand" "r,JS,ns,m,rU,r,*b,T"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], SImode)
-       || register_operand (operands[1], SImode))"
+       || sh_register_operand (operands[1], SImode))"
   "@
 	add.l	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.l	%m1, %0
-	st%M0.l	%m0, %1
+	st%M0.l	%m0, %N1
 	ptabs	%1, %0
 	gettr	%1, %0
 	pt	%1, %0"
@@ -3635,15 +3635,15 @@
 
 (define_insn "*movqi_media"
   [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,r,m")
-	(match_operand:QI 1 "general_movsrc_operand" "r,JS,m,r"))]
+	(match_operand:QI 1 "general_movsrc_operand" "r,JS,m,rU"))]
   "TARGET_SHMEDIA
    && (arith_reg_operand (operands[0], QImode)
-       || arith_reg_operand (operands[1], QImode))"
+       || arith_reg_or_0_operand (operands[1], QImode))"
   "@
 	add.l	%1, r63, %0
 	movi	%1, %0
 	ld%M1.ub	%m1, %0
-	st%M0.b	%m0, %1"
+	st%M0.b	%m0, %N1"
   [(set_attr "type" "arith_media,arith_media,load_media,store_media")])
 
 (define_expand "movqi"
@@ -3687,16 +3687,16 @@
 
 (define_insn "*movhi_media"
   [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m")
-	(match_operand:HI 1 "general_movsrc_operand" "r,JS,n,m,r"))]
+	(match_operand:HI 1 "general_movsrc_operand" "r,JS,n,m,rU"))]
   "TARGET_SHMEDIA
    && (arith_reg_operand (operands[0], HImode)
-       || arith_reg_operand (operands[1], HImode))"
+       || arith_reg_or_0_operand (operands[1], HImode))"
   "@
 	add.l	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.w	%m1, %0
-	st%M0.w	%m0, %1"
+	st%M0.w	%m0, %N1"
   [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")])
 
 (define_split
@@ -3791,16 +3791,16 @@
 
 (define_insn "*movdi_media"
   [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,rl,m,f,m,f,r,f,*b,r,b")
-	(match_operand:DI 1 "general_movsrc_operand" "r,JS,iF,m,rl,m,f,rU,f,f,r,*b,T"))]
+	(match_operand:DI 1 "general_movsrc_operand" "r,JS,iF,m,rlU,m,f,rU,f,f,r,*b,T"))]
   "TARGET_SHMEDIA_FPU
    && (register_operand (operands[0], DImode)
-       || register_operand (operands[1], DImode))"
+       || sh_register_operand (operands[1], DImode))"
   "@
 	add	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1
+	st%M0.q	%m0, %N1
 	fld%M1.d	%m1, %0
 	fst%M0.d	%m0, %1
 	fmov.qd	%N1, %0
@@ -3814,16 +3814,16 @@
 
 (define_insn "*movdi_media_nofpu"
   [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,rl,m,*b,r,b")
-	(match_operand:DI 1 "general_movsrc_operand" "r,JS,iF,m,rl,r,*b,T"))]
+	(match_operand:DI 1 "general_movsrc_operand" "r,JS,iF,m,rlU,r,*b,T"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], DImode)
-       || register_operand (operands[1], DImode))"
+       || sh_register_operand (operands[1], DImode))"
   "@
 	add	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1
+	st%M0.q	%m0, %N1
 	ptabs	%1, %0
 	gettr	%1, %0
 	pt	%1, %0"
@@ -4083,10 +4083,10 @@
 
 (define_insn "movdf_media"
   [(set (match_operand:DF 0 "general_movdst_operand" "=f,f,r,r,r,f,m,r,m")
-	(match_operand:DF 1 "general_movsrc_operand" "f,rU,f,r,F,m,f,m,r"))]
+	(match_operand:DF 1 "general_movsrc_operand" "f,rU,f,r,F,m,f,m,rU"))]
   "TARGET_SHMEDIA_FPU
    && (register_operand (operands[0], DFmode)
-       || register_operand (operands[1], DFmode))"
+       || sh_register_operand (operands[1], DFmode))"
   "@
 	fmov.d	%1, %0
 	fmov.qd	%N1, %0
@@ -4096,20 +4096,20 @@
 	fld%M1.d	%m1, %0
 	fst%M0.d	%m0, %1
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1"
+	st%M0.q	%m0, %N1"
   [(set_attr "type" "fmove_media,fload_media,dfpconv_media,arith_media,*,fload_media,fstore_media,load_media,store_media")])
 
 (define_insn "movdf_media_nofpu"
   [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,r,m")
-	(match_operand:DF 1 "general_movsrc_operand" "r,F,m,r"))]
+	(match_operand:DF 1 "general_movsrc_operand" "r,F,m,rU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], DFmode)
-       || register_operand (operands[1], DFmode))"
+       || sh_register_operand (operands[1], DFmode))"
   "@
 	add	%1, r63, %0
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1"
+	st%M0.q	%m0, %N1"
   [(set_attr "type" "arith_media,*,load_media,store_media")])
 
 (define_split
@@ -4693,7 +4693,7 @@
 
 (define_insn_and_split "*movv4sf_i"
   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=f,f,m")
-	(match_operand:V4SF 1 "general_operand" "fU,m,f"))]
+	(match_operand:V4SF 1 "general_operand" "fU,m,fU"))]
   "TARGET_SHMEDIA_FPU"
   "#"
   "&& reload_completed"
@@ -4791,10 +4791,10 @@
 
 (define_insn "movsf_media"
   [(set (match_operand:SF 0 "general_movdst_operand" "=f,f,r,r,r,f,m,r,m")
-	(match_operand:SF 1 "general_movsrc_operand" "f,rU,f,r,F,m,f,m,r"))]
+	(match_operand:SF 1 "general_movsrc_operand" "f,rU,f,r,F,m,f,m,rU"))]
   "TARGET_SHMEDIA_FPU
    && (register_operand (operands[0], SFmode)
-       || register_operand (operands[1], SFmode))"
+       || sh_register_operand (operands[1], SFmode))"
   "@
 	fmov.s	%1, %0
 	fmov.ls	%N1, %0
@@ -4804,20 +4804,20 @@
 	fld%M1.s	%m1, %0
 	fst%M0.s	%m0, %1
 	ld%M1.l	%m1, %0
-	st%M0.l	%m0, %1"
+	st%M0.l	%m0, %N1"
   [(set_attr "type" "fmove_media,fload_media,fpconv_media,arith_media,*,fload_media,fstore_media,load_media,store_media")])
 
 (define_insn "movsf_media_nofpu"
   [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,m")
-	(match_operand:SF 1 "general_movsrc_operand" "r,F,m,r"))]
+	(match_operand:SF 1 "general_movsrc_operand" "r,F,m,rU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], SFmode)
-       || register_operand (operands[1], SFmode))"
+       || sh_register_operand (operands[1], SFmode))"
   "@
 	add.l	%1, r63, %0
 	#
 	ld%M1.l	%m1, %0
-	st%M0.l	%m0, %1"
+	st%M0.l	%m0, %N1"
   [(set_attr "type" "arith_media,*,load_media,store_media")])
 
 (define_split
@@ -9155,16 +9155,16 @@
 
 (define_insn "movv8qi_i"
   [(set (match_operand:V8QI 0 "general_movdst_operand" "=r,r,r,rl,m")
-	(match_operand:V8QI 1 "general_movsrc_operand" "r,JSU,nW,m,rl"))]
+	(match_operand:V8QI 1 "general_movsrc_operand" "r,JSU,nW,m,rlU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], V8QImode)
-       || register_operand (operands[1], V8QImode))"
+       || sh_register_operand (operands[1], V8QImode))"
   "@
 	add	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1"
+	st%M0.q	%m0, %N1"
   [(set_attr "type"   "arith_media,arith_media,*,load_media,store_media")
    (set_attr "length" "4,4,16,4,4")])
 
@@ -9247,16 +9247,16 @@
 
 (define_insn "movv2hi_i"
   [(set (match_operand:V2HI 0 "general_movdst_operand" "=r,r,r,rl,m")
-	(match_operand:V2HI 1 "general_movsrc_operand" "r,JSU,nW,m,rl"))]
+	(match_operand:V2HI 1 "general_movsrc_operand" "r,JSU,nW,m,rlU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], V2HImode)
-       || register_operand (operands[1], V2HImode))"
+       || sh_register_operand (operands[1], V2HImode))"
   "@
 	addz.l	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.l	%m1, %0
-	st%M0.l	%m0, %1"
+	st%M0.l	%m0, %N1"
   [(set_attr "type"   "arith_media,arith_media,*,load_media,store_media")
    (set_attr "length" "4,4,16,4,4")])
 
@@ -9268,16 +9268,16 @@
 
 (define_insn "movv4hi_i"
   [(set (match_operand:V4HI 0 "general_movdst_operand" "=r,r,r,rl,m")
-	(match_operand:V4HI 1 "general_movsrc_operand" "r,JSU,nW,m,rl"))]
+	(match_operand:V4HI 1 "general_movsrc_operand" "r,JSU,nW,m,rlU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], V4HImode)
-       || register_operand (operands[1], V4HImode))"
+       || sh_register_operand (operands[1], V4HImode))"
   "@
 	add	%1, r63, %0
 	movi	%1, %0
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1"
+	st%M0.q	%m0, %N1"
   [(set_attr "type"   "arith_media,arith_media,*,load_media,store_media")
    (set_attr "length" "4,4,16,4,4")])
 
@@ -9289,16 +9289,16 @@
 
 (define_insn "movv2si_i"
   [(set (match_operand:V2SI 0 "general_movdst_operand" "=r,r,r,rl,m")
-	(match_operand:V2SI 1 "general_movsrc_operand" "r,JSU,nW,m,rl"))]
+	(match_operand:V2SI 1 "general_movsrc_operand" "r,JSU,nW,m,rlU"))]
   "TARGET_SHMEDIA
    && (register_operand (operands[0], V2SImode)
-       || register_operand (operands[1], V2SImode))"
+       || sh_register_operand (operands[1], V2SImode))"
   "@
 	add	%1, r63, %0
 	#
 	#
 	ld%M1.q	%m1, %0
-	st%M0.q	%m0, %1"
+	st%M0.q	%m0, %N1"
   [(set_attr "type"   "arith_media,arith_media,*,load_media,store_media")
    (set_attr "length" "4,4,16,4,4")])
 
-- 
GitLab