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]

[RFA:] Fix for lsb0? in -gen-extract-word, take 3.


Bummer, I forgot to change (current-arch-insn-lsb0?) to lsb0? as
per Doug Evans's recommendation.  That and comment tweaks are
the only changes.  Sending the patch in unified format this
time, just for fun.  (This particular patch is *slightly* more
readable in that format, IMHO).

This patch is supposed to only *fix a bug* in the lsb0? == #t
case.  It doesn't change the (IMHO) unfortunate choice to have
different internal bitfield representations that depends on
"lsb0?" or anything like that.  I like to think that to be a
good reason to review it.  Perhaps it can let some of those
unknown ports which currently must kludge "lsb0? == #f" to now
define "lsb0? == #t"?

I'll set up build trees for the CGEN-generated sim targets in
the sourceware tree and check generated files for diffs if I
find reason to fix more bugs.

Ok to commit?

	* utils-gen.scm (-gen-extract-word): Handle lsb0?.

Index: utils-gen.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils-gen.scm,v
retrieving revision 1.6
diff -p -c -u -p -r1.6 utils-gen.scm
cvs server: conflicting specifications of output style
--- utils-gen.scm	14 Nov 2001 19:46:43 -0000	1.6
+++ utils-gen.scm	25 Jun 2002 11:13:21 -0000
@@ -114,33 +114,45 @@
 ; Subroutine of -gen-ifld-extract-beyond to extract the relevant value
 ; from WORD-NAME and move it into place.
 
-(define (-gen-extract-word word-name word-start word-length start length
+(define (-gen-extract-word word-name word-start word-length
+			   field-start field-length
 			   unsigned? lsb0?)
-  ; ??? lsb0?
-  (let ((word-end (+ word-start word-length))
-	(end (+ start length))
-	(base (if (< start word-start) word-start start)))
+  (let* ((word-end (+ word-start word-length))
+	 (start (if lsb0? (+ 1 (- field-start field-length)) field-start))
+	 (end (+ start field-length))
+	 (base (if (< start word-start) word-start start)))
     (string-append "("
 		   "EXTRACT_"
-		   (if (current-arch-insn-lsb0?) "LSB0" "MSB0")
+		   (if lsb0? "LSB0" "MSB0")
 		   (if (and (not unsigned?)
 			    ; Only want sign extension for word with sign bit.
-			    (bitrange-overlap? start 1 word-start word-length
+			    (bitrange-overlap? field-start 1
+					       word-start word-length
 					       lsb0?))
 		       "_INT ("
 		       "_UINT (")
+		   ; What to extract from.
 		   word-name
 		   ", "
+		   ; Size of this chunk.
 		   (number->string word-length)
 		   ", "
-		   (number->string (if (< start word-start)
-				       0
-				       (- start word-start)))
+		   ; MSB of this chunk.
+		   (number->string
+		    (if lsb0?
+			(if (> end word-end)
+			    (- word-end 1)
+			    (- end word-start 1))
+			(if (< start word-start)
+			    0
+			    (- start word-start))))
 		   ", "
+		   ; Length of field within this chunk.
 		   (number->string (if (< end word-end)
 				       (- end base)
 				       (- word-end base)))
 		   ") << "
+		   ; Adjustment for this chunk within a full field.
 		   (number->string (if (> end word-end)
 				       (- end word-end)
 				       0))

brgds, H-P


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