From: Hans-Peter Nilsson Date: Sun, 30 Jun 2002 22:48:48 +0000 (+0000) Subject: * utils-gen.scm (-gen-extract-word): Handle lsb0?. X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=7067c2ec4a69f1fb4c50aa6f3b1c4de8da9947f9;p=cgen.git * utils-gen.scm (-gen-extract-word): Handle lsb0?. --- diff --git a/ChangeLog b/ChangeLog index 1e0b8cc..9b415f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-07-01 Hans-Peter Nilsson + + * utils-gen.scm (-gen-extract-word): Handle lsb0?. + 2002-06-25 J"orn Rennecke * cpu/sh64-compact.cpu (movw5): Use Correct operand field for reg. diff --git a/utils-gen.scm b/utils-gen.scm index 8f1ea77..e51900a 100644 --- a/utils-gen.scm +++ b/utils-gen.scm @@ -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))