From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29839 invoked by alias); 25 Jun 2002 11:37:29 -0000 Mailing-List: contact cgen-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sources.redhat.com Received: (qmail 29812 invoked from network); 25 Jun 2002 11:37:24 -0000 Received: from unknown (HELO krynn.axis.se) (193.13.178.10) by sources.redhat.com with SMTP; 25 Jun 2002 11:37:24 -0000 Received: from ignucius.axis.se (root@ignucius.axis.se [10.13.1.18]) by krynn.axis.se (8.12.2/8.12.2/Debian -5) with ESMTP id g5PBbMS3029387; Tue, 25 Jun 2002 13:37:22 +0200 Received: (from hp@localhost) by ignucius.axis.se (8.9.3/8.9.3/Debian 8.9.3-21) id NAA29644; Tue, 25 Jun 2002 13:37:22 +0200 Date: Tue, 25 Jun 2002 04:37:00 -0000 Message-Id: <200206251137.NAA29644@ignucius.axis.se> From: Hans-Peter Nilsson To: cgen@sources.redhat.com Subject: [RFA:] Fix for lsb0? in -gen-extract-word, take 3. X-SW-Source: 2002-q2/txt/msg00048.txt.bz2 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