From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: [PATCH 6/6] tests/decode: Add tests for various named-field cases
Date: Tue, 23 May 2023 13:04:47 +0100 [thread overview]
Message-ID: <20230523120447.728365-7-peter.maydell@linaro.org> (raw)
In-Reply-To: <20230523120447.728365-1-peter.maydell@linaro.org>
Add some tests for various cases of named-field use, both ones that
should work and ones that should be diagnosed as errors.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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 +++++++++++++++++++
6 files changed, 56 insertions(+), 1 deletion(-)
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
diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode
index e07a5a73e0e..85c3f326d07 100644
--- a/tests/decode/err_field1.decode
+++ b/tests/decode/err_field1.decode
@@ -2,4 +2,4 @@
# See the COPYING.LIB file in the top-level directory.
# Diagnose invalid field syntax
-%field asdf
+%field 1asdf
diff --git a/tests/decode/err_field10.decode b/tests/decode/err_field10.decode
new file mode 100644
index 00000000000..3e672b7459e
--- /dev/null
+++ b/tests/decode/err_field10.decode
@@ -0,0 +1,7 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose formats which refer to undefined fields
+%field1 field2:3
+@fmt ........ ........ ........ ........ %field1
+insn 00000000 00000000 00000000 00000000 @fmt
diff --git a/tests/decode/err_field7.decode b/tests/decode/err_field7.decode
new file mode 100644
index 00000000000..51fad7cceaf
--- /dev/null
+++ b/tests/decode/err_field7.decode
@@ -0,0 +1,7 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose fields whose definitions form a loop
+%field1 field2:3
+%field2 field1:4
+insn 00000000 00000000 00000000 00000000 %field1 %field2
diff --git a/tests/decode/err_field8.decode b/tests/decode/err_field8.decode
new file mode 100644
index 00000000000..cc47c08a459
--- /dev/null
+++ b/tests/decode/err_field8.decode
@@ -0,0 +1,8 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose patterns which refer to undefined fields
+&f1 f1 a
+%field1 field2:3
+@fmt ........ ........ ........ .... a:4 &f1
+insn 00000000 00000000 00000000 0000 .... @fmt f1=%field1
diff --git a/tests/decode/err_field9.decode b/tests/decode/err_field9.decode
new file mode 100644
index 00000000000..e7361d521ba
--- /dev/null
+++ b/tests/decode/err_field9.decode
@@ -0,0 +1,14 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose fields where the format refers to a field defined in the
+# pattern and the pattern refers to a field defined in the format.
+# This is theoretically not impossible to implement, but is not
+# supported by the script at this time.
+&abcd a b c d
+%refa a:3
+%refc c:4
+# Format defines 'c' and sets 'b' to an indirect ref to 'a'
+@fmt ........ ........ ........ c:8 &abcd b=%refa
+# Pattern defines 'a' and sets 'd' to an indirect ref to 'c'
+insn 00000000 00000000 00000000 ........ @fmt d=%refc a=6
diff --git a/tests/decode/succ_named_field.decode b/tests/decode/succ_named_field.decode
new file mode 100644
index 00000000000..e64b3f93568
--- /dev/null
+++ b/tests/decode/succ_named_field.decode
@@ -0,0 +1,19 @@
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# field using a named_field
+%imm_sz 8:8 sz:3
+insn 00000000 00000000 ........ 00000000 imm_sz=%imm_sz sz=1
+
+# Ditto, via a format. Here a field in the format
+# references a named field defined in the insn pattern:
+&imm_a imm alpha
+%foo 0:16 alpha:4
+@foo 00000001 ........ ........ ........ &imm_a imm=%foo
+i1 ........ 00000000 ........ ........ @foo alpha=1
+i2 ........ 00000001 ........ ........ @foo alpha=2
+
+# Here the named field is defined in the format and referenced
+# from the insn pattern:
+@bar 00000010 ........ ........ ........ &imm_a alpha=4
+i3 ........ 00000000 ........ ........ @bar imm=%foo
--
2.34.1
next prev parent reply other threads:[~2023-05-23 12:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Peter Maydell [this message]
2023-05-23 18:20 ` [PATCH 6/6] tests/decode: Add tests for various named-field cases Richard Henderson
2023-05-24 10:26 ` Peter Maydell
2023-05-26 17:07 ` Richard Henderson
2023-05-26 19:49 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230523120447.728365-7-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).