This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN 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]

[patch] xstormy16: fix add/sub bug


The psw needs to be set last, but its value depends on the inputs
*before* they are possibly changed by setting the destination, so...

Index: cgen/ChangeLog
2002-03-05  DJ Delorie  <dj at redhat dot com>

	* cpu/xstormy16.cpu (set-psw-add): Use temporaries to prevent
	prematurely overwriting needed inputs.
	(set-psw-sub): Likewise.
  
Index: sid/component/cgen-cpu/xstormy16/ChangeLog
2002-03-05  DJ Delorie  <dj at redhat dot com>

	* xstormy16-sem.cxx: Regenerate.

Index: cgen/cpu/xstormy16.cpu
===================================================================
RCS file: /cvs/src/src/cgen/cpu/xstormy16.cpu,v
retrieving revision 1.6
diff -p -2 -r1.6  cgen/cpu/xstormy16.cpu
*** cgen/cpu/xstormy16.cpu	18 Feb 2003 22:57:08 -0000	1.6
--- cgen/cpu/xstormy16.cpu	6 Mar 2003 00:30:17 -0000
***************
*** 425,438 ****
  ; The all-purpose addition operation.
  (define-pmacro (set-psw-add Rd index a b c)
!   (sequence ((HI value))
      (set value (addc a b c))
      (set (reg HI h-gr index) value)
!     (set psw (or (or (and psw #x0F80)
! 		     (basic-psw value))
! 		 (or (or (sll HI (add-oflag HI a b c) 4)
! 			 (sll HI (add-cflag HI a b c) 2))
! 		     (or (and (srl HI (addc HI (and a #xF) (and b #xF) c) 
! 				   1) #x8)
! 			 (sll index 12)))))))
  
  ; Set the PSW for a subtraction of a-b into Rd, but don't actually
--- 425,440 ----
  ; The all-purpose addition operation.
  (define-pmacro (set-psw-add Rd index a b c)
!   (sequence ((HI value) (HI newpsw))
      (set value (addc a b c))
+     (set newpsw (or (or (and psw #x0F80)
+ 			(basic-psw value))
+ 		    (or (or (sll HI (add-oflag HI a b c) 4)
+ 			    (sll HI (add-cflag HI a b c) 2))
+ 			(or (and (srl HI (addc HI (and a #xF) (and b #xF) c) 
+ 				      1) #x8)
+ 			    (sll index 12)))))
      (set (reg HI h-gr index) value)
!     (set psw newpsw)
!     ))
  
  ; Set the PSW for a subtraction of a-b into Rd, but don't actually
***************
*** 453,460 ****
  ; just using a carry for both).
  (define-pmacro (set-psw-sub Rd index a b c)
!   (sequence ((HI value))
      (set value (subc a b c))
!     (set (reg HI h-gr index) value)
!     (set psw (or (or (and psw #x0F80)
  		     (basic-psw value))
  		 (or (or (sll HI (sub-oflag HI a b c) 4)
--- 455,461 ----
  ; just using a carry for both).
  (define-pmacro (set-psw-sub Rd index a b c)
!   (sequence ((HI value) (HI newpsw))
      (set value (subc a b c))
!     (set newpsw (or (or (and psw #x0F80)
  		     (basic-psw value))
  		 (or (or (sll HI (sub-oflag HI a b c) 4)
***************
*** 462,466 ****
  		     (or (and (srl HI (subc HI (and a #xF) (and b #xF) c)
  				   1) #x8)
! 			 (sll index 12)))))))
  
  ; A 17-bit rotate-left operation
--- 463,470 ----
  		     (or (and (srl HI (subc HI (and a #xF) (and b #xF) c)
  				   1) #x8)
! 			 (sll index 12)))))
!     (set (reg HI h-gr index) value)
!     (set psw newpsw)
!     ))
  
  ; A 17-bit rotate-left operation


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