This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SH: use register names instead of numbers


On Nov 22, 2000, Joern Rennecke <amylaar@redhat.com> wrote:

> Add a comment here saying that is to recognize the mova_const pattern.

Here's the revised version, to be installed after the large register
naming patch.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/sh/sh.md (mova_const): New pattern.
	(GOTaddr2picreg): Use it.
	* config/sh/sh.c (broken_move): Match it.
	(mova_p): Don't match it.
	(machine_dependent_reorg): Adjust it.

Index: gcc/config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.70
diff -u -p -r1.70 sh.c
--- gcc/config/sh/sh.c 2000/11/09 07:45:15 1.70
+++ gcc/config/sh/sh.c 2000/11/18 22:11:53
@@ -2071,7 +2071,11 @@ broken_move (insn)
 	  /* We can load any 8 bit value if we don't care what the high
 	     order bits end up as.  */
 	  && GET_MODE (SET_DEST (pat)) != QImode
-	  && CONSTANT_P (SET_SRC (pat))
+	  && (CONSTANT_P (SET_SRC (pat))
+	      /* Match mova_const.  */
+	      || (GET_CODE (SET_SRC (pat)) == UNSPEC
+		  && XINT (SET_SRC (pat), 1) == MOVA_UNSPEC
+		  && GET_CODE (XVECEXP (SET_SRC (pat), 0, 0)) == CONST))
 	  && ! (TARGET_SH3E
 		&& GET_CODE (SET_SRC (pat)) == CONST_DOUBLE
 		&& (fp_zero_operand (SET_SRC (pat))
@@ -2097,7 +2100,9 @@ mova_p (insn)
   return (GET_CODE (insn) == INSN
 	  && GET_CODE (PATTERN (insn)) == SET
 	  && GET_CODE (SET_SRC (PATTERN (insn))) == UNSPEC
-	  && XINT (SET_SRC (PATTERN (insn)), 1) == MOVA_UNSPEC);
+	  && XINT (SET_SRC (PATTERN (insn)), 1) == MOVA_UNSPEC
+	  /* Don't match mova_const.  */
+	  && XVECEXP (SET_SRC (PATTERN (insn)), 0, 0) == LABEL_REF);
 }
 
 /* Find the last barrier from insn FROM which is close enough to hold the
@@ -3280,14 +3284,11 @@ machine_dependent_reorg (first)
 		      XEXP (clobber, 0) = gen_rtx_SCRATCH (Pmode);
 		    }
 		  /* This is a mova needing a label.  Create it.  */
-		  else if (GET_CODE (src) == CONST
-			   && GET_CODE (XEXP (src, 0)) == UNSPEC
-			   && XINT (XEXP (src, 0), 1) == MOVA_UNSPEC
-			   && GET_CODE (XVECEXP (XEXP (src, 0),
-						 0, 0)) == CONST)
+		  else if (GET_CODE (src) == UNSPEC
+			   && XINT (src, 1) == MOVA_UNSPEC
+			   && GET_CODE (XVECEXP (src, 0, 0)) == CONST)
 		    {
-		      lab = add_constant (XVECEXP (XEXP (src, 0),
-						   0, 0), mode, 0);
+		      lab = add_constant (XVECEXP (src, 0, 0), mode, 0);
 		      newsrc = gen_rtx_LABEL_REF (VOIDmode, lab);
 		      newsrc = gen_rtx_UNSPEC (VOIDmode,
 					       gen_rtvec (1, newsrc),
Index: gcc/config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.md,v
retrieving revision 1.55
diff -u -p -r1.55 sh.md
--- gcc/config/sh/sh.md 2000/11/10 16:01:27 1.55
+++ gcc/config/sh/sh.md 2000/11/18 22:11:55
@@ -3470,8 +3470,17 @@
   [(set_attr "in_delay_slot" "no")
    (set_attr "type" "arith")])
 
+;; machine_dependent_reorg() will make this a `mova'.
+(define_insn "mova_const"
+  [(set (reg:SI 0)
+	(unspec [(match_operand 0 "immediate_operand" "i")] 1))]
+  ""
+  "#"
+  [(set_attr "in_delay_slot" "no")
+   (set_attr "type" "arith")])
+
 (define_expand "GOTaddr2picreg"
   [(set (reg:SI R0_REG)
-	(const (unspec [(const (unspec [(match_dup 1)] PIC_UNSPEC))]
-		       MOVA_UNSPEC)))
+	(unspec [(const (unspec [(match_dup 1)] PIC_UNSPEC))]
+		MOVA_UNSPEC))
    (set (match_dup 0) (const (unspec [(match_dup 1)] PIC_UNSPEC)))
    (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
   "" "

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]