public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Installed] Patch to sh movdi_const and movdi_const_32bit
@ 2002-11-18  6:06 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2002-11-18  6:06 UTC (permalink / raw)
  To: gcc-patches

GOTOFF_P was recently extended to allow a constant offset, but
older code in movdi_const and movdi_const_32bit didn't expect that.

Patch tested on sh64-elf, fixes rtl checking failures.
Approved by Alex off-list.

Richard


	* config/sh/sh-protos.h (sh_mark_label): Declare.
	* config/sh/sh.c (sh_mark_label): New function, taken from
	movdi_const, but fixing the case when the address has an addend.
	* config/sh/sh.md (movdi_const, movdi_const_32bit): Use it.

Index: config/sh/sh-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh-protos.h,v
retrieving revision 1.32
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.32 sh-protos.h
*** config/sh/sh-protos.h	4 Nov 2002 16:57:10 -0000	1.32
--- config/sh/sh-protos.h	15 Nov 2002 11:08:39 -0000
*************** extern int sh_cfun_interrupt_handler_p P
*** 128,133 ****
--- 128,134 ----
  extern void sh_initialize_trampoline PARAMS ((rtx, rtx, rtx));
  extern enum reg_class sh_cannot_change_mode_class
  	      PARAMS ((enum machine_mode, enum machine_mode));
+ extern void sh_mark_label PARAMS ((rtx, int));
  
  #ifdef HARD_CONST
  extern void fpscr_set_from_mem PARAMS ((int, HARD_REG_SET));
Index: config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.178
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.178 sh.c
*** config/sh/sh.c	4 Nov 2002 16:57:10 -0000	1.178
--- config/sh/sh.c	15 Nov 2002 11:08:40 -0000
*************** sh_cannot_change_mode_class (from, to)
*** 7753,7758 ****
--- 7744,7771 ----
  	 }
      }
    return NO_REGS;
+ }
+ 
+ 
+ /* If ADDRESS refers to a CODE_LABEL, add NUSES to the number of times
+    that label is used.  */
+ 
+ void
+ sh_mark_label (address, nuses)
+      rtx address;
+      int nuses;
+ {
+   if (GOTOFF_P (address))
+     {
+       /* Extract the label or symbol.  */
+       address = XEXP (address, 0);
+       if (GET_CODE (address) == PLUS)
+ 	address = XEXP (address, 0);
+       address = XVECEXP (address, 0, 0);
+     }
+   if (GET_CODE (address) == LABEL_REF
+       && GET_CODE (XEXP (address, 0)) == CODE_LABEL)
+     LABEL_NUSES (XEXP (address, 0)) += nuses;
  }
  
  #include "gt-sh.h"
Index: config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.md,v
retrieving revision 1.125
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.125 sh.md
*** config/sh/sh.md	31 Oct 2002 12:53:06 -0000	1.125
--- config/sh/sh.md	15 Nov 2002 11:08:40 -0000
*************** (define_expand "movdi_const"
*** 3868,3881 ****
     && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
    "
  {
!   if (GET_CODE (operands[1]) == LABEL_REF
!       && GET_CODE (XEXP (operands[1], 0)) == CODE_LABEL)
!     LABEL_NUSES (XEXP (operands[1], 0)) += 4;
!   else if (GOTOFF_P (operands[1])
! 	   && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == LABEL_REF
! 	   && (GET_CODE (XEXP (XVECEXP (XEXP (operands[1], 0), 0, 0), 0))
! 	       == CODE_LABEL))
!     LABEL_NUSES (XEXP (XVECEXP (XEXP (operands[1], 0), 0, 0), 0)) += 4;
  }")
  
  (define_expand "movdi_const_32bit"
--- 3861,3867 ----
     && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
    "
  {
!   sh_mark_label (operands[1], 4);
  }")
  
  (define_expand "movdi_const_32bit"
*************** (define_expand "movdi_const_32bit"
*** 3897,3910 ****
     && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
    "
  {
!   if (GET_CODE (operands[1]) == LABEL_REF
!       && GET_CODE (XEXP (operands[1], 0)) == CODE_LABEL)
!     LABEL_NUSES (XEXP (operands[1], 0)) += 2;
!   else if (GOTOFF_P (operands[1])
! 	   && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == LABEL_REF
! 	   && (GET_CODE (XEXP (XVECEXP (XEXP (operands[1], 0), 0, 0), 0))
! 	       == CODE_LABEL))
!     LABEL_NUSES (XEXP (XVECEXP (XEXP (operands[1], 0), 0, 0), 0)) += 2;
  }")
  
  (define_expand "movdi_const_16bit"
--- 3883,3889 ----
     && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
    "
  {
!   sh_mark_label (operands[1], 2);
  }")
  
  (define_expand "movdi_const_16bit"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-18 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18  6:06 [Installed] Patch to sh movdi_const and movdi_const_32bit Richard Sandiford

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