qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] decodetree: Allow custom var width load functions
@ 2021-04-13 18:16 Luis Pires
  2021-04-13 19:42 ` Luis Fernando Fujita Pires
  2021-04-14  1:10 ` Richard Henderson
  0 siblings, 2 replies; 3+ messages in thread
From: Luis Pires @ 2021-04-13 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, Luis Pires, richard.henderson

This is useful in situations where you want decodetree
to handle variable width instructions but you want to
provide custom code to load the instructions. Suppressing
the generation of the load function is necessary to avoid
compilation errors due to the load function being unused.

This will be used by the PowerPC decodetree code.

Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
---
 scripts/decodetree.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index fef5eeaf42..c88dbdb4c3 100644
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -1277,9 +1277,10 @@ def main():
     global anyextern
 
     decode_scope = 'static '
+    noloadfunc = False
 
     long_opts = ['decode=', 'translate=', 'output=', 'insnwidth=',
-                 'static-decode=', 'varinsnwidth=']
+                 'static-decode=', 'varinsnwidth=', 'noloadfunc']
     try:
         (opts, args) = getopt.gnu_getopt(sys.argv[1:], 'o:vw:', long_opts)
     except getopt.GetoptError as err:
@@ -1311,6 +1312,8 @@ def main():
                 deposit_function = 'deposit64'
             elif insnwidth != 32:
                 error(0, 'cannot handle insns of width', insnwidth)
+        elif o == '--noloadfunc':
+            noloadfunc = True
         else:
             assert False, 'unhandled option'
 
@@ -1400,12 +1403,13 @@ def main():
     output(i4, 'return false;\n')
     output('}\n')
 
-    if variablewidth:
-        output('\n', decode_scope, insntype, ' ', decode_function,
-               '_load(DisasContext *ctx)\n{\n',
-               '    ', insntype, ' insn = 0;\n\n')
-        stree.output_code(4, 0, 0, 0)
-        output('}\n')
+    if not noloadfunc:
+        if variablewidth:
+            output('\n', decode_scope, insntype, ' ', decode_function,
+                   '_load(DisasContext *ctx)\n{\n',
+                   '    ', insntype, ' insn = 0;\n\n')
+            stree.output_code(4, 0, 0, 0)
+            output('}\n')
 
     if output_file:
         output_fd.close()
-- 
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] decodetree: Allow custom var width load functions
  2021-04-13 18:16 [PATCH] decodetree: Allow custom var width load functions Luis Pires
@ 2021-04-13 19:42 ` Luis Fernando Fujita Pires
  2021-04-14  1:10 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Luis Fernando Fujita Pires @ 2021-04-13 19:42 UTC (permalink / raw)
  To: Luis Fernando Fujita Pires, qemu-devel; +Cc: qemu-ppc, richard.henderson

Please ignore this. I'll resend as part of a patch series.

-----Original Message-----
From: Luis Pires <luis.pires@eldorado.org.br> 
Sent: terça-feira, 13 de abril de 2021 15:16
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org; qemu-ppc@nongnu.org; Luis Fernando Fujita Pires <luis.pires@eldorado.org.br>
Subject: [PATCH] decodetree: Allow custom var width load functions

This is useful in situations where you want decodetree to handle variable width instructions but you want to provide custom code to load the instructions. Suppressing the generation of the load function is necessary to avoid compilation errors due to the load function being unused.

This will be used by the PowerPC decodetree code.

Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
---
 scripts/decodetree.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py index fef5eeaf42..c88dbdb4c3 100644
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -1277,9 +1277,10 @@ def main():
     global anyextern
 
     decode_scope = 'static '
+    noloadfunc = False
 
     long_opts = ['decode=', 'translate=', 'output=', 'insnwidth=',
-                 'static-decode=', 'varinsnwidth=']
+                 'static-decode=', 'varinsnwidth=', 'noloadfunc']
     try:
         (opts, args) = getopt.gnu_getopt(sys.argv[1:], 'o:vw:', long_opts)
     except getopt.GetoptError as err:
@@ -1311,6 +1312,8 @@ def main():
                 deposit_function = 'deposit64'
             elif insnwidth != 32:
                 error(0, 'cannot handle insns of width', insnwidth)
+        elif o == '--noloadfunc':
+            noloadfunc = True
         else:
             assert False, 'unhandled option'
 
@@ -1400,12 +1403,13 @@ def main():
     output(i4, 'return false;\n')
     output('}\n')
 
-    if variablewidth:
-        output('\n', decode_scope, insntype, ' ', decode_function,
-               '_load(DisasContext *ctx)\n{\n',
-               '    ', insntype, ' insn = 0;\n\n')
-        stree.output_code(4, 0, 0, 0)
-        output('}\n')
+    if not noloadfunc:
+        if variablewidth:
+            output('\n', decode_scope, insntype, ' ', decode_function,
+                   '_load(DisasContext *ctx)\n{\n',
+                   '    ', insntype, ' insn = 0;\n\n')
+            stree.output_code(4, 0, 0, 0)
+            output('}\n')
 
     if output_file:
         output_fd.close()
--
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] decodetree: Allow custom var width load functions
  2021-04-13 18:16 [PATCH] decodetree: Allow custom var width load functions Luis Pires
  2021-04-13 19:42 ` Luis Fernando Fujita Pires
@ 2021-04-14  1:10 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2021-04-14  1:10 UTC (permalink / raw)
  To: Luis Pires, qemu-devel; +Cc: qemu-ppc

On 4/13/21 11:16 AM, Luis Pires wrote:
> This is useful in situations where you want decodetree
> to handle variable width instructions but you want to
> provide custom code to load the instructions. Suppressing
> the generation of the load function is necessary to avoid
> compilation errors due to the load function being unused.
> 
> This will be used by the PowerPC decodetree code.
> 
> Signed-off-by: Luis Pires<luis.pires@eldorado.org.br>
> ---
>   scripts/decodetree.py | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)

So, in the previous cases where we have very controlled "variable length", 
we've simply created separate decode files each with fixed length.

E.g. for arm thumb, in thumb_tr_translate_insn:

     insn = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b);
     is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn);
...
     if (is_16bit) {
         disas_thumb_insn(dc, insn);
     } else {
         disas_thumb2_insn(dc, insn);
     }

Similarly, riscv's decode_opc.

I would think that Power would work the same, with 32-bit and 64-bit 
instructions.  I'd like you to talk me through what you want to do here.


r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-14  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 18:16 [PATCH] decodetree: Allow custom var width load functions Luis Pires
2021-04-13 19:42 ` Luis Fernando Fujita Pires
2021-04-14  1:10 ` Richard Henderson

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 NNTP newsgroup(s).