qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] decodetree: Add DisasContext to function part


From: Yoshinori Sato
Subject: [Qemu-devel] [PATCH] decodetree: Add DisasContext to function part
Date: Sat, 2 Mar 2019 15:39:26 +0900

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]