From: Hans-Peter Nilsson <hp@bitrange.com>
To: <cgen@sources.redhat.com>
Subject: [RFA:] Fix for lsb0? in -gen-extract-word, take 2.
Date: Mon, 24 Jun 2002 18:50:00 -0000 [thread overview]
Message-ID: <Pine.BSF.4.30.0206242149010.46015-100000@dair.pair.com> (raw)
Here's a less intrusive fix since I couldn't wrap my head around
what adjustment there should be for the "<<" expression. I
can't figure out whether it actually has lsb0?-issues at all, so
I'll not touch it. Again, only tested on the CRIS (wip) target.
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 -r1.6 utils-gen.scm
*** utils-gen.scm 14 Nov 2001 19:46:43 -0000 1.6
--- utils-gen.scm 25 Jun 2002 01:20:12 -0000
***************
*** 114,146 ****
; 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
unsigned? lsb0?)
! ; ??? lsb0?
! (let ((word-end (+ word-start word-length))
! (end (+ start length))
! (base (if (< start word-start) word-start start)))
(string-append "("
"EXTRACT_"
(if (current-arch-insn-lsb0?) "LSB0" "MSB0")
(if (and (not unsigned?)
; Only want sign extension for word with sign bit.
! (bitrange-overlap? start 1 word-start word-length
lsb0?))
"_INT ("
"_UINT (")
word-name
", "
(number->string word-length)
", "
! (number->string (if (< start word-start)
! 0
! (- start word-start)))
", "
(number->string (if (< end word-end)
(- end base)
(- word-end base)))
") << "
(number->string (if (> end word-end)
(- end word-end)
0))
--- 114,158 ----
; 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
! field-start field-length
unsigned? lsb0?)
! (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 (and (not unsigned?)
; Only want sign extension for word with sign bit.
! (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)
", "
! ; MSB of this piece.
! (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 piece within a full field.
(number->string (if (> end word-end)
(- end word-end)
0))
brgds, H-P
next reply other threads:[~2002-06-25 1:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-24 18:50 Hans-Peter Nilsson [this message]
2002-06-24 20:48 ` Frank Ch. Eigler
2002-06-24 21:06 ` Doug Evans
2002-06-25 3:20 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.BSF.4.30.0206242149010.46015-100000@dair.pair.com \
--to=hp@bitrange.com \
--cc=cgen@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).