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]
Other format: [Raw text]

Re: [patch] Re: reload vs adds with clobbers


> I think you want a comment explaining why the !N is there.  Otherwise it 
> is an obvious bug, and the next person will want to fix it by removing 
> the !N alternative.

I've attached a patch that uses a new Z constraint.  Better?

> Curious that you set the length to 2 instead of 0, but maybe there is an 
> undocumented reason why you had to do that also?  If so, if probably 
> should be in a comment also.

Nope, just a mistake.

2003-06-04  DJ Delorie  <dj@redhat.com>

	* config/stormy16/stormy16.c (xstormy16_extra_constraint_p): Add Z,
	which matches (const_int 0) for addhi3.
	* config/stormy16/stormy16.md: Document known constraints.
	(addhi3): Handle adding zero.

  
Index: config/stormy16/stormy16.c
===================================================================
RCS file: /usr/dj/gnu/gcc/repository/gcc/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.46
diff -p -2 -r1.46  config/stormy16/stormy16.c
*** config/stormy16/stormy16.c	2 Jun 2003 14:15:15 -0000	1.46
--- config/stormy16/stormy16.c	9 Jun 2003 21:46:12 -0000
***************
*** 1,4 ****
  /* Xstormy16 target functions.
!    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
     Free Software Foundation, Inc.
     Contributed by Red Hat, Inc.
--- 1,4 ----
  /* Xstormy16 target functions.
!    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
     Free Software Foundation, Inc.
     Contributed by Red Hat, Inc.
*************** xstormy16_extra_constraint_p (x, c)
*** 697,700 ****
--- 697,706 ----
        return (GET_CODE (x) == CONST_INT
  	      && (INTVAL (x) < 2 || INTVAL (x) > 15));
+ 
+       /* 'Z' is for CONST_INT value zero.  This is for adding zero to
+ 	 a register in addhi3, which would otherwise require a carry.  */
+     case 'Z':
+       return (GET_CODE (x) == CONST_INT
+ 	      && (INTVAL (x) == 0));
  
      default:
Index: config/stormy16/stormy16.md
===================================================================
RCS file: /usr/dj/gnu/gcc/repository/gcc/gcc/config/stormy16/stormy16.md,v
retrieving revision 1.13
diff -p -2 -r1.13  config/stormy16/stormy16.md
*** config/stormy16/stormy16.md	24 May 2003 16:54:04 -0000	1.13
--- config/stormy16/stormy16.md	9 Jun 2003 21:47:36 -0000
***************
*** 1,4 ****
  ;; XSTORMY16 Machine description template
! ;; Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
  ;; Contributed by Red Hat, Inc.
  
--- 1,4 ----
  ;; XSTORMY16 Machine description template
! ;; Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
  ;; Contributed by Red Hat, Inc.
  
***************
*** 22,25 ****
--- 22,49 ----
  ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  
+ ;; Constraints
+ ;; a  $0
+ ;; b  $1
+ ;; c  $2
+ ;; d  $8
+ ;; e  $0..$7
+ ;; t  $0..$1
+ ;; y  Carry
+ ;; z  $8..$9
+ ;; I  0..3
+ ;; J  2**N mask
+ ;; K  2**N antimask
+ ;; L  0..255
+ ;; M  -255..0
+ ;; N  -3..0
+ ;; O  1..4
+ ;; P  -4..-1
+ ;; Q  post-inc mem (push)
+ ;; R  pre-dec mem (pop)
+ ;; S  immediate mem
+ ;; T  Rx
+ ;; U  -inf..1 or 16..inf
+ ;; Z  0
+ 
  
  ;; ::::::::::::::::::::
***************
*** 278,289 ****
  ; will fail in some cases.
  (define_insn "addhi3"
!   [(set (match_operand:HI 0 "register_operand" "=r,r,T,T,r,r,r")
! 	(plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,0")
! 		 (match_operand:HI 2 "xs_hi_nonmemory_operand" "O,P,L,M,Ir,N,i")))
!    (clobber (match_scratch:BI 3 "=X,X,&y,&y,&y,&y,&y"))]
    ""
    "@
     inc %0,%o2
     dec %0,%O2
     add Rx,%2
     sub Rx,#%n2
--- 302,314 ----
  ; will fail in some cases.
  (define_insn "addhi3"
!   [(set (match_operand:HI 0 "register_operand" "=r,r,r,T,T,r,r,r")
! 	(plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,0,0")
! 		 (match_operand:HI 2 "xs_hi_nonmemory_operand" "O,P,Z,L,M,Ir,N,i")))
!    (clobber (match_scratch:BI 3 "=X,X,X,&y,&y,&y,&y,&y"))]
    ""
    "@
     inc %0,%o2
     dec %0,%O2
+    ;
     add Rx,%2
     sub Rx,#%n2
***************
*** 291,295 ****
     sub %0,#%n2
     add %0,%2"
!   [(set_attr "length" "2,2,2,2,2,2,4")])
  
  ; Reload can generate addition operations.  The SECONDARY_RELOAD_CLASS
--- 316,320 ----
     sub %0,#%n2
     add %0,%2"
!   [(set_attr "length" "2,2,0,2,2,2,2,4")])
  
  ; Reload can generate addition operations.  The SECONDARY_RELOAD_CLASS


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