This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
[RFA:] Fix for lsb0? in -gen-extract-word, take 2.
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: <cgen at sources dot redhat dot com>
- Date: Mon, 24 Jun 2002 21:50:00 -0400 (EDT)
- Subject: [RFA:] Fix for lsb0? in -gen-extract-word, take 2.
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