qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] decodetree: support named fields
@ 2023-05-23 12:04 Peter Maydell
  2023-05-23 12:04 ` [PATCH 1/6] tests/decodetree/check.sh: Exit failure for all failures Peter Maydell
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Peter Maydell @ 2023-05-23 12:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

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



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

end of thread, other threads:[~2023-05-26 19:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23 12:04 [PATCH 0/6] decodetree: support named fields Peter Maydell
2023-05-23 12:04 ` [PATCH 1/6] tests/decodetree/check.sh: Exit failure for all failures Peter Maydell
2023-05-23 17:49   ` Richard Henderson
2023-05-23 12:04 ` [PATCH 2/6] docs: Document decodetree named field syntax Peter Maydell
2023-05-23 17:59   ` Richard Henderson
2023-05-23 12:04 ` [PATCH 3/6] scripts/decodetree: Pass lvalue-formatter function to str_extract() Peter Maydell
2023-05-23 18:02   ` Richard Henderson
2023-05-23 12:04 ` [PATCH 4/6] scripts/decodetree: Implement a topological sort Peter Maydell
2023-05-23 18:12   ` Richard Henderson
2023-05-23 12:04 ` [PATCH 5/6] scripts/decodetree: Implement named field support Peter Maydell
2023-05-23 18:17   ` Richard Henderson
2023-05-23 12:04 ` [PATCH 6/6] tests/decode: Add tests for various named-field cases Peter Maydell
2023-05-23 18:20   ` Richard Henderson
2023-05-24 10:26   ` Peter Maydell
2023-05-26 17:07     ` Richard Henderson
2023-05-26 19:49       ` Peter Maydell

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).