[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 0/6] decodetree: support named fields
From: |
Peter Maydell |
Subject: |
[PATCH 0/6] decodetree: support named fields |
Date: |
Tue, 23 May 2023 13:04:41 +0100 |
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
- [PATCH 0/6] decodetree: support named fields,
Peter Maydell <=
- [PATCH 1/6] tests/decodetree/check.sh: Exit failure for all failures, Peter Maydell, 2023/05/23
- [PATCH 2/6] docs: Document decodetree named field syntax, Peter Maydell, 2023/05/23
- [PATCH 3/6] scripts/decodetree: Pass lvalue-formatter function to str_extract(), Peter Maydell, 2023/05/23
- [PATCH 5/6] scripts/decodetree: Implement named field support, Peter Maydell, 2023/05/23
- [PATCH 6/6] tests/decode: Add tests for various named-field cases, Peter Maydell, 2023/05/23