Re: [Qemu-devel] [PATCH v3] scripts: Add decodetree.py

2018-02-13 Thread Richard Henderson
On 02/13/2018 02:05 AM, Peter Maydell wrote:
> Trivial-but-important nit: all these new files are missing
> copyright-and-license comment headers.

Oops, fixed.  I also added a one-line comment describing what each of the tests
are attempting.


r~




Re: [Qemu-devel] [PATCH v3] scripts: Add decodetree.py

2018-02-13 Thread Peter Maydell
On 13 February 2018 at 07:21, Richard Henderson
 wrote:
> To be used to decode ARM SVE, but could be used for any fixed-width ISA.
>
> Signed-off-by: Richard Henderson 

>  create mode 100755 scripts/decodetree.py
>  create mode 100755 tests/decode/check.sh
>  create mode 100644 tests/decode/err_argset1.def
>  create mode 100644 tests/decode/err_argset2.def
>  create mode 100644 tests/decode/err_field1.def
>  create mode 100644 tests/decode/err_field2.def
>  create mode 100644 tests/decode/err_field3.def
>  create mode 100644 tests/decode/err_field4.def
>  create mode 100644 tests/decode/err_field5.def
>  create mode 100644 tests/decode/err_init1.def
>  create mode 100644 tests/decode/err_init2.def
>  create mode 100644 tests/decode/err_init3.def
>  create mode 100644 tests/decode/err_init4.def
>  create mode 100644 tests/decode/err_overlap1.def
>  create mode 100644 tests/decode/err_overlap2.def
>  create mode 100644 tests/decode/err_overlap3.def
>  create mode 100644 tests/decode/err_overlap4.def
>  create mode 100644 tests/decode/err_overlap5.def
>  create mode 100644 tests/decode/err_overlap6.def
>  create mode 100644 tests/decode/err_overlap7.def
>  create mode 100644 tests/decode/err_overlap8.def
>  create mode 100644 tests/decode/err_overlap9.def
>

Trivial-but-important nit: all these new files are missing
copyright-and-license comment headers.

thanks
-- PMM



[Qemu-devel] [PATCH v3] scripts: Add decodetree.py

2018-02-12 Thread Richard Henderson
To be used to decode ARM SVE, but could be used for any fixed-width ISA.

Signed-off-by: Richard Henderson 

---

Changes since v2:
  * Fix tests/decode/err_init3.def.
  * Mark main decoder static by default.
  * Properly diagnose unspecified bits.
  * Remove output file on error.
- I had been doing this in the Makefile, but all told
  it's cleaner to do it in the script.

Changes since v1:
  * Pass pycodestyle-{2,3}.
  * Support 16-bit and 32-bit insns (I have a def file for thumb1).
  * Testsuite (only negative tests so far).
  * Called translate functions default to static.
  * Notice duplicate assignments and missing assignments to fields.
  * Use '-' to indicate a non-decoded bit, as opposed to '.' which
must be filled in elsewhere by a format or a field.
---
 scripts/decodetree.py | 1044 +
 tests/Makefile.include|9 +-
 tests/decode/check.sh |   16 +
 tests/decode/err_argset1.def  |1 +
 tests/decode/err_argset2.def  |1 +
 tests/decode/err_field1.def   |1 +
 tests/decode/err_field2.def   |1 +
 tests/decode/err_field3.def   |1 +
 tests/decode/err_field4.def   |2 +
 tests/decode/err_field5.def   |1 +
 tests/decode/err_init1.def|2 +
 tests/decode/err_init2.def|2 +
 tests/decode/err_init3.def|3 +
 tests/decode/err_init4.def|3 +
 tests/decode/err_overlap1.def |2 +
 tests/decode/err_overlap2.def |2 +
 tests/decode/err_overlap3.def |2 +
 tests/decode/err_overlap4.def |2 +
 tests/decode/err_overlap5.def |1 +
 tests/decode/err_overlap6.def |2 +
 tests/decode/err_overlap7.def |2 +
 tests/decode/err_overlap8.def |1 +
 tests/decode/err_overlap9.def |2 +
 23 files changed, 1102 insertions(+), 1 deletion(-)
 create mode 100755 scripts/decodetree.py
 create mode 100755 tests/decode/check.sh
 create mode 100644 tests/decode/err_argset1.def
 create mode 100644 tests/decode/err_argset2.def
 create mode 100644 tests/decode/err_field1.def
 create mode 100644 tests/decode/err_field2.def
 create mode 100644 tests/decode/err_field3.def
 create mode 100644 tests/decode/err_field4.def
 create mode 100644 tests/decode/err_field5.def
 create mode 100644 tests/decode/err_init1.def
 create mode 100644 tests/decode/err_init2.def
 create mode 100644 tests/decode/err_init3.def
 create mode 100644 tests/decode/err_init4.def
 create mode 100644 tests/decode/err_overlap1.def
 create mode 100644 tests/decode/err_overlap2.def
 create mode 100644 tests/decode/err_overlap3.def
 create mode 100644 tests/decode/err_overlap4.def
 create mode 100644 tests/decode/err_overlap5.def
 create mode 100644 tests/decode/err_overlap6.def
 create mode 100644 tests/decode/err_overlap7.def
 create mode 100644 tests/decode/err_overlap8.def
 create mode 100644 tests/decode/err_overlap9.def

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
new file mode 100755
index 00..f0b33a937e
--- /dev/null
+++ b/scripts/decodetree.py
@@ -0,0 +1,1044 @@
+#!/usr/bin/env python
+#
+# Generate a decoding tree from a specification file.
+#
+# The tree is built from instruction "patterns".  A pattern may represent
+# a single architectural instruction or a group of same, depending on what
+# is convenient for further processing.
+#
+# Each pattern has "fixedbits" & "fixedmask", the combination of which
+# describes the condition under which the pattern is matched:
+#
+#   (insn & fixedmask) == fixedbits
+#
+# Each pattern may have "fields", which are extracted from the insn and
+# passed along to the translator.  Examples of such are registers,
+# immediates, and sub-opcodes.
+#
+# In support of patterns, one may declare fields, argument sets, and
+# formats, each of which may be re-used to simplify further definitions.
+#
+# *** Field syntax:
+#
+# field_def := '%' identifier ( unnamed_field )+ ( !function=identifier )?
+# unnamed_field := number ':' ( 's' ) number
+#
+# For unnamed_field, the first number is the least-significant bit position of
+# the field and the second number is the length of the field.  If the 's' is
+# present, the field is considered signed.  If multiple unnamed_fields are
+# present, they are concatenated.  In this way one can define disjoint fields.
+#
+# If !function is specified, the concatenated result is passed through the
+# named function, taking and returning an integral value.
+#
+# FIXME: the fields of the structure into which this result will be stored
+# is restricted to "int".  Which means that we cannot expand 64-bit items.
+#
+# Field examples:
+#
+#   %disp   0:s16  -- sextract(i, 0, 16)
+#   %imm9   16:6 10:3  -- extract(i, 16, 6) << 3 | extract(i, 10, 3)
+#   %disp12 0:s1 1:1 2:10  -- sextract(i, 0, 1) << 11
+# | extract(i, 1, 1) << 10
+# | extract(i, 2, 10)
+#   %shimm8 5:s8 13:1 !function=expand_shimm8
+#  --