Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tests/decode: Add tests for various named-field cases
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230523120447.728365-7-peter.maydell@linaro.org>
  • Loading branch information
pm215 authored and rth7680 committed May 30, 2023
1 parent 7e6c28b commit 276d77d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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
7 changes: 7 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions 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
14 changes: 14 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions tests/decode/meson.build
Expand Up @@ -7,6 +7,10 @@ err_tests = [
'err_field4.decode',
'err_field5.decode',
'err_field6.decode',
'err_field7.decode',
'err_field8.decode',
'err_field9.decode',
'err_field10.decode',
'err_init1.decode',
'err_init2.decode',
'err_init3.decode',
Expand Down Expand Up @@ -37,6 +41,7 @@ succ_tests = [
'succ_argset_type1.decode',
'succ_function.decode',
'succ_ident1.decode',
'succ_named_field.decode',
'succ_pattern_group_nest1.decode',
'succ_pattern_group_nest2.decode',
'succ_pattern_group_nest3.decode',
Expand Down
19 changes: 19 additions & 0 deletions 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

0 comments on commit 276d77d

Please sign in to comment.