This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Broken extractor for 16/32 ISAs


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]