public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Problem in cgen-generated sim insn decoder.
@ 2009-12-28 23:47 Dmitry Eremin-Solenikov
  0 siblings, 0 replies; only message in thread
From: Dmitry Eremin-Solenikov @ 2009-12-28 23:47 UTC (permalink / raw)
  To: cgen

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

Hello,

Just to remind, I'm trying to do a cgen-based m68hc08 description.
Currently I've stumbled upon sim insn decoder. All the extract_ifmt_*
parts of @cpu@_decode expect to have entire insn bits in entire_insn
aligned to the LSB bit of that value. The problem is that
instructions of my MCU are of variable length and I use lsb0=#f setting.

I found two solutions for my case:
* First one is to teach extract() part of mloop.in more details about
  insn lengths, so that it finds on it's own what is the length of the
  insn and pushes the correct entire_insn to @cpu@_decode.

  I find this pre-parsing clumsy and unclean.

* Another one is to change the API of @cpu@_decode to require
  entire_insn to be msb-aligned if the ISA is lsb0=#f.

  The patch is really simple (see attach), however it can (and most
  probably will) break other lsb0=#f arches (m32r/m32c).

Could you please comment on this topic?

-- 
With best wishes
Dmitry


[-- Attachment #2: cgen-sim-decode.patch --]
[-- Type: text/x-diff, Size: 529 bytes --]

diff --git a/cgen/sim-decode.scm b/cgen/sim-decode.scm
index 0c6d48c..42c41ec 100644
--- a/cgen/sim-decode.scm
+++ b/cgen/sim-decode.scm
@@ -437,7 +437,10 @@ void
        (string-append
 	"    CGEN_INSN_WORD insn = "
 	(if (adata-integral-insn? CURRENT-ARCH)
-	    "entire_insn;\n"
+	    (if (current-arch-insn-lsb0?)
+	      "entire_insn;\n"
+	      (string-append
+	        "entire_insn >> (sizeof(UINT) * 8 - " (number->string (sfmt-length sfmt)) ");\n" ))
 	    "base_insn;\n"))
        "")
    (gen-define-field-macro sfmt)

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

only message in thread, other threads:[~2009-12-28 23:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-28 23:47 Problem in cgen-generated sim insn decoder Dmitry Eremin-Solenikov

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