public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Broken extractor for 16/32 ISAs
@ 2001-05-31 18:17 Ben Elliston
  0 siblings, 0 replies; only message in thread
From: Ben Elliston @ 2001-05-31 18:17 UTC (permalink / raw)
  To: cgen

Along the same lines as my post last night concerning decoding of
mixed 16 and 32 bit instructions (with lsb0? set to #t), here is
another problem.

I have been looking at the code generated for extraction functions --
for those who are new, these functions are responsible for extracting
the operands from instruction words.

Here is the scenario, involving an ISA with a mix of 16 and 32 bit
instructions (and lsb0?  set to #f, so most significant bit is bit 0).
My 16 bit instructions are laid out like so:

	     +---------+---------+
	     | insn16  | another |
	     +---------+---------+
	     0        15

(where another is the instruction following insn16 in memory, but of
 no significance to us here; it was merely fetched at the same time as
 insn16).

And the 32 bit instructions are laid out like so:

	     +-------------------+
	     |	    insn32       |
	     +-------------------+
	     0			31

The code that implements, say, EXTRACT_MSB0_INT assumes that words
less than 32 bits in size will be laid out like so:

	     +---------+---------+
	     |         |  insn16 |
	     +---------+---------+
	               0        15

Is this assumption correct?  If so, what is the right place to shift
insn16 down by 16 bits?  There is no opportunity I can see for the
mainline code to examine the insn's length between decoding and
extraction (and besides, this is not target specific!).

Here is a kludge that has worked around it, but I wonder what the
ideal fix should be?

Ben


Index: utils-gen.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/utils-gen.scm,v
retrieving revision 1.15
diff -u -r1.15 utils-gen.scm
--- utils-gen.scm       2001/01/06 12:06:18     1.15
+++ utils-gen.scm       2001/06/01 01:00:17
@@ -89,7 +89,11 @@
                          (else (error "unsupported mode class"
                                       (mode:class (ifld-mode f)))))
                        " ("
-                       base-value ", "
+                       (if (and (not (current-arch-insn-lsb0?))
+                                (> (- 32 total-length) 0))
+                           (string-append base-value " >> " (number->string (- 32 total-length)))
+                           base-value)
+                       ", "
                        (number->string total-length) ", "
                        ; ??? Is passing total-length right here?
                        (number->string (+ (ifld-start f total-length)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-31 18:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-31 18:17 Broken extractor for 16/32 ISAs Ben Elliston

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