[PATCH 0/6] decodetree: support named fields

Peter Maydell posted 6 patches 11 months, 2 weeks ago
Failed in applying to current master (apply log)
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>
docs/devel/decodetree.rst            |  33 +++-
tests/decode/err_field1.decode       |   2 +-
tests/decode/err_field10.decode      |   7 +
tests/decode/err_field7.decode       |   7 +
tests/decode/err_field8.decode       |   8 +
tests/decode/err_field9.decode       |  14 ++
tests/decode/succ_named_field.decode |  19 +++
scripts/decodetree.py                | 239 +++++++++++++++++++++++++--
tests/decode/check.sh                |   1 +
9 files changed, 310 insertions(+), 20 deletions(-)
create mode 100644 tests/decode/err_field10.decode
create mode 100644 tests/decode/err_field7.decode
create mode 100644 tests/decode/err_field8.decode
create mode 100644 tests/decode/err_field9.decode
create mode 100644 tests/decode/succ_named_field.decode
[PATCH 0/6] decodetree: support named fields
Posted by Peter Maydell 11 months, 2 weeks ago
This patchset adds support to the decodetree generator
for "named fields", where one field can refer to some
other already extracted field, as well as to portions
of the instruction word. The specific case where I want
this is for some load/store insns in the A64 decoder:

# Load/store with an unsigned 12 bit immediate, which is scaled by the
# element size. The function gets the sz:imm and returns the scaled immediate.
# For vectors, opc bit 1 (insn bit 23) is effectively bit 2 of the size.
%uimm_scaled    10:12 sz:3 !function=uimm_scaled
@ldst_uimm      .. ... . .. .. ............ rn:5 rt:5 &ldst_imm unpriv=0 p=0 w=0 imm=%uimm_scaled
STR_i           sz:2 111 0 01 00 ............ ..... ..... @ldst_uimm sign=0 ext=0
LDR_i           00 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=0
LDR_i           01 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=1
LDR_i           10 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=2
LDR_i           11 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=3
LDR_i           00 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=0
LDR_i           01 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=1
LDR_i           10 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=2
LDR_i           00 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 ext=1 sz=0
LDR_i           01 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 ext=1 sz=1

Here we need to manually decode the sz field in bits 31:30 because
of the complexity of the sign/ext and the parts of the encode space
that are UNDEF (or are prefetch). And we want to use a !function
to do the "scale the immediate offset by the size of the datatype"
so we can use the same LDR_i and STR_i trans_ functions that we
already have for the unscaled-immediate loads and stores.

But at the moment you can't re-decode bits in a %field that are fixed
in the instruction pattern, and you can't refer to the
already-decoded sz value directly. This patchset implements the
syntax used above where the %field can refer to another field,
e.g. 'sz:2'.

Patch 1 fixes a trivial bug in the check.sh script that meant
that failures weren't reported up to meson.

thanks
-- PMM

Peter Maydell (6):
  tests/decodetree/check.sh: Exit failure for all failures
  docs: Document decodetree named field syntax
  scripts/decodetree: Pass lvalue-formatter function to str_extract()
  scripts/decodetree: Implement a topological sort
  scripts/decodetree: Implement named field support
  tests/decode: Add tests for various named-field cases

 docs/devel/decodetree.rst            |  33 +++-
 tests/decode/err_field1.decode       |   2 +-
 tests/decode/err_field10.decode      |   7 +
 tests/decode/err_field7.decode       |   7 +
 tests/decode/err_field8.decode       |   8 +
 tests/decode/err_field9.decode       |  14 ++
 tests/decode/succ_named_field.decode |  19 +++
 scripts/decodetree.py                | 239 +++++++++++++++++++++++++--
 tests/decode/check.sh                |   1 +
 9 files changed, 310 insertions(+), 20 deletions(-)
 create mode 100644 tests/decode/err_field10.decode
 create mode 100644 tests/decode/err_field7.decode
 create mode 100644 tests/decode/err_field8.decode
 create mode 100644 tests/decode/err_field9.decode
 create mode 100644 tests/decode/succ_named_field.decode

-- 
2.34.1