All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Subject: [Qemu-devel] [PATCH] decodetree: Add DisasContext to function part
Date: Sat,  2 Mar 2019 15:39:26 +0900	[thread overview]
Message-ID: <20190302063926.11488-1-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <20190131210851.9842-1-richard.henderson@linaro.org>

OK. RX decoder works fine.

Since it is necessary to read additional bytes in the function
of the operand, we need to have DisasContext passed as an argument.

> %b2_li_2	18:2 !function=li
"li" read more extra byte. It use cpu_env in DisasContext.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 scripts/decodetree.py | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index e23d43e354..fa9a75ccad 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -387,7 +387,11 @@ class FunctionField:
         return self.func + '(' + str(self.base) + ')'
 
     def str_extract(self):
-        return self.func + '(' + self.base.str_extract() + ')'
+        if variablewidth:
+            ctx = 'ctx, '
+        else:
+            ctx = ''
+        return self.func + '(' + ctx + self.base.str_extract() + ')'
 
     def __eq__(self, other):
         return self.func == other.func and self.base == other.base
@@ -454,7 +458,11 @@ class Format(General):
         return 'extract_' + self.name
 
     def output_extract(self):
-        output('static void ', self.extract_name(), '(',
+        if variablewidth:
+            ctx_p = 'DisasContext *ctx, '
+        else:
+            ctx_p = ''
+        output('static void ', self.extract_name(), '(' + ctx_p,
                self.base.struct_name(), ' *a, ', insntype, ' insn)\n{\n')
         for n, f in self.fields.items():
             output('    a->', n, ' = ', f.str_extract(), ';\n')
@@ -468,10 +476,14 @@ class Pattern(General):
     def output_decl(self):
         global translate_scope
         global translate_prefix
+        if variablewidth:
+            ctx_p = 'DisasContext *ctx, '
+        else:
+            ctx_p = ''
         output('typedef ', self.base.base.struct_name(),
                ' arg_', self.name, ';\n')
         output(translate_scope, 'bool ', translate_prefix, '_', self.name,
-               '(DisasContext *ctx, arg_', self.name, ' *a);\n')
+               '(', ctx_p, 'arg_', self.name, ' *a);\n')
 
     def output_code(self, i, extracted, outerbits, outermask):
         global translate_prefix
@@ -479,7 +491,8 @@ class Pattern(General):
         arg = self.base.base.name
         output(ind, '/* ', self.file, ':', str(self.lineno), ' */\n')
         if not extracted:
-            output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);\n')
+            output(ind, self.base.extract_name(),
+                   '(ctx, &u.f_', arg, ', insn);\n')
         for n, f in self.fields.items():
             output(ind, 'u.f_', arg, '.', n, ' = ', f.str_extract(), ';\n')
         output(ind, 'return ', translate_prefix, '_', self.name,
@@ -890,11 +903,16 @@ class Tree:
     def output_code(self, i, extracted, outerbits, outermask):
         ind = str_indent(i)
 
+        if variablewidth:
+            ctx = 'ctx, '
+        else:
+            ctx = ''
         # If we identified all nodes below have the same format,
         # extract the fields now.
         if not extracted and self.base:
             output(ind, self.base.extract_name(),
-                   '(&u.f_', self.base.base.name, ', insn);\n')
+                   '(', ctx, '&u.f_', self.base.base.name,
+                   ', insn);\n')
             extracted = True
 
         # Attempt to aid the compiler in producing compact switch statements.
@@ -994,7 +1012,7 @@ class SizeTree:
         # If we need to load more bytes to test, do so now.
         if extracted < self.width:
             output(ind, 'insn = ', decode_function,
-                   '_load_bytes(s, insn, {0}, {1});\n'
+                   '_load_bytes(ctx, insn, {0}, {1});\n'
                    .format(extracted / 8, self.width / 8));
             extracted = self.width
 
@@ -1048,7 +1066,7 @@ class SizeLeaf:
         # If we need to load more bytes, do so now.
         if extracted < self.width:
             output(ind, 'insn = ', decode_function,
-                   '_load_bytes(s, insn, {0}, {1});\n'
+                   '_load_bytes(ctx, insn, {0}, {1});\n'
                    .format(extracted / 8, self.width / 8));
             extracted = self.width
         output(ind, 'return insn;\n')
-- 
2.11.0

      parent reply	other threads:[~2019-03-02  6:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 21:08 [Qemu-devel] [PATCH 0/2] decodetree: Support for variable-length ISAs Richard Henderson
2019-01-31 21:08 ` [Qemu-devel] [PATCH 1/2] decodetree: Initial support " Richard Henderson
2022-06-29 13:07   ` Peter Maydell
2019-01-31 21:08 ` [Qemu-devel] [PATCH 2/2] decodetree: Expand a decode_load function Richard Henderson
2019-02-02  8:16 ` [Qemu-devel] [PATCH 0/2] decodetree: Support for variable-length ISAs Yoshinori Sato
2019-03-02  6:39 ` Yoshinori Sato [this message]

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=20190302063926.11488-1-ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.