public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: cgen@sourceware.org
Subject: Problem in cgen-generated sim insn decoder.
Date: Mon, 28 Dec 2009 23:47:00 -0000	[thread overview]
Message-ID: <20091228234650.GA9733@doriath.ww600.siemens.net> (raw)

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

                 reply	other threads:[~2009-12-28 23:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091228234650.GA9733@doriath.ww600.siemens.net \
    --to=dbaryshkov@gmail.com \
    --cc=cgen@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).