public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [RFA:] Fix for lsb0? in -gen-extract-word, take 3.
@ 2002-06-25  4:37 Hans-Peter Nilsson
  2002-06-27 12:07 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2002-06-25  4:37 UTC (permalink / raw)
  To: cgen

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFA:] Fix for lsb0? in -gen-extract-word, take 3.
  2002-06-25  4:37 [RFA:] Fix for lsb0? in -gen-extract-word, take 3 Hans-Peter Nilsson
@ 2002-06-27 12:07 ` Doug Evans
  2002-06-27 15:02   ` Frank Ch. Eigler
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2002-06-27 12:07 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: cgen

Hans-Peter Nilsson writes:
 > 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).

Either unified or context is fine.
In this case I think unified is much more readable.

 > Perhaps it can let some of those
 > unknown ports which currently must kludge "lsb0? == #f" to now
 > define "lsb0? == #t"?

It's unfortunate such ports didn't forge ahead with the correct
choice and work through the bugs.  (Oh My God, s/w under development
has bugs?!)

 > Ok to commit?

Yes, thanks!
I didn't study the lsb0? case too hard.  If you're happy I'm happy.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA:] Fix for lsb0? in -gen-extract-word, take 3.
  2002-06-27 12:07 ` Doug Evans
@ 2002-06-27 15:02   ` Frank Ch. Eigler
  0 siblings, 0 replies; 3+ messages in thread
From: Frank Ch. Eigler @ 2002-06-27 15:02 UTC (permalink / raw)
  To: Doug Evans; +Cc: Hans-Peter Nilsson, cgen

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

Hi -


On Thu, Jun 27, 2002 at 12:07:31PM -0700, Doug Evans wrote:
> [...]
>  > Perhaps it can let some of those
>  > unknown ports which currently must kludge "lsb0? == #f" to now
>  > define "lsb0? == #t"?
> 
> It's unfortunate such ports didn't forge ahead with the correct
> choice and work through the bugs.  [...]

Well, crafty as that sounds, it is the case that if someone chooses
to model a chip with lsb0=#f, and use cgen in that better-defined
regime, then a patch that breaks that regime is suspect.  Merely
labelling the status quo an "incorrect choice" doesn't quite
satisfy the burden of proof.

Anyway, this is all moot until we test some of the more adventurous
targets.  Once HP's patches are all in, we can run some tests and
report back.


- FChE

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-27 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-25  4:37 [RFA:] Fix for lsb0? in -gen-extract-word, take 3 Hans-Peter Nilsson
2002-06-27 12:07 ` Doug Evans
2002-06-27 15:02   ` Frank Ch. Eigler

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