From 568ae7efae7e4b90e213049efb8b6e4e12b47ca3 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 7 Dec 2017 12:44:09 -0800 Subject: scripts: Add decodetree.py To be used to decode ARM SVE, but could be used for any fixed-width ISA. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tests/decode/check.sh | 18 ++++++++++++++++++ tests/decode/err_argset1.decode | 5 +++++ tests/decode/err_argset2.decode | 5 +++++ tests/decode/err_field1.decode | 5 +++++ tests/decode/err_field2.decode | 5 +++++ tests/decode/err_field3.decode | 5 +++++ tests/decode/err_field4.decode | 6 ++++++ tests/decode/err_field5.decode | 5 +++++ tests/decode/err_init1.decode | 6 ++++++ tests/decode/err_init2.decode | 6 ++++++ tests/decode/err_init3.decode | 7 +++++++ tests/decode/err_init4.decode | 7 +++++++ tests/decode/err_overlap1.decode | 6 ++++++ tests/decode/err_overlap2.decode | 6 ++++++ tests/decode/err_overlap3.decode | 6 ++++++ tests/decode/err_overlap4.decode | 6 ++++++ tests/decode/err_overlap5.decode | 5 +++++ tests/decode/err_overlap6.decode | 6 ++++++ tests/decode/err_overlap7.decode | 6 ++++++ tests/decode/err_overlap8.decode | 5 +++++ tests/decode/err_overlap9.decode | 6 ++++++ 21 files changed, 132 insertions(+) create mode 100755 tests/decode/check.sh create mode 100644 tests/decode/err_argset1.decode create mode 100644 tests/decode/err_argset2.decode create mode 100644 tests/decode/err_field1.decode create mode 100644 tests/decode/err_field2.decode create mode 100644 tests/decode/err_field3.decode create mode 100644 tests/decode/err_field4.decode create mode 100644 tests/decode/err_field5.decode create mode 100644 tests/decode/err_init1.decode create mode 100644 tests/decode/err_init2.decode create mode 100644 tests/decode/err_init3.decode create mode 100644 tests/decode/err_init4.decode create mode 100644 tests/decode/err_overlap1.decode create mode 100644 tests/decode/err_overlap2.decode create mode 100644 tests/decode/err_overlap3.decode create mode 100644 tests/decode/err_overlap4.decode create mode 100644 tests/decode/err_overlap5.decode create mode 100644 tests/decode/err_overlap6.decode create mode 100644 tests/decode/err_overlap7.decode create mode 100644 tests/decode/err_overlap8.decode create mode 100644 tests/decode/err_overlap9.decode (limited to 'tests/decode') diff --git a/tests/decode/check.sh b/tests/decode/check.sh new file mode 100755 index 0000000..79a06c3 --- /dev/null +++ b/tests/decode/check.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# 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. + +PYTHON=$1 +DECODETREE=$2 +E=0 + +# All of these tests should produce errors +for i in err_*.decode; do + if $PYTHON $DECODETREE $i > /dev/null 2> /dev/null; then + # Pass, aka failed to fail. + echo FAIL: $i 1>&2 + E=1 + fi +done + +exit $E diff --git a/tests/decode/err_argset1.decode b/tests/decode/err_argset1.decode new file mode 100644 index 0000000..fcaebcc --- /dev/null +++ b/tests/decode/err_argset1.decode @@ -0,0 +1,5 @@ +# 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 duplicate member names +&args a a diff --git a/tests/decode/err_argset2.decode b/tests/decode/err_argset2.decode new file mode 100644 index 0000000..256b2f9 --- /dev/null +++ b/tests/decode/err_argset2.decode @@ -0,0 +1,5 @@ +# 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 invalid member names +&args a b c d0 0e diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode new file mode 100644 index 0000000..e07a5a7 --- /dev/null +++ b/tests/decode/err_field1.decode @@ -0,0 +1,5 @@ +# 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 invalid field syntax +%field asdf diff --git a/tests/decode/err_field2.decode b/tests/decode/err_field2.decode new file mode 100644 index 0000000..7664a3e --- /dev/null +++ b/tests/decode/err_field2.decode @@ -0,0 +1,5 @@ +# 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 invalid field width. +%field 0:33 diff --git a/tests/decode/err_field3.decode b/tests/decode/err_field3.decode new file mode 100644 index 0000000..87e680f --- /dev/null +++ b/tests/decode/err_field3.decode @@ -0,0 +1,5 @@ +# 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 invalid field position. +%field 31:2 diff --git a/tests/decode/err_field4.decode b/tests/decode/err_field4.decode new file mode 100644 index 0000000..888ce47 --- /dev/null +++ b/tests/decode/err_field4.decode @@ -0,0 +1,6 @@ +# 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 duplicate field name. +%field 0:1 +%field 0:1 diff --git a/tests/decode/err_field5.decode b/tests/decode/err_field5.decode new file mode 100644 index 0000000..b0c62af --- /dev/null +++ b/tests/decode/err_field5.decode @@ -0,0 +1,5 @@ +# 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 duplicate function specifier. +%field 0:1 !function=a !function=a diff --git a/tests/decode/err_init1.decode b/tests/decode/err_init1.decode new file mode 100644 index 0000000..da855bd --- /dev/null +++ b/tests/decode/err_init1.decode @@ -0,0 +1,6 @@ +# 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 uninitialized member in pattern. +&args a b +insn 00000000 00000000 00000000 b:8 &args diff --git a/tests/decode/err_init2.decode b/tests/decode/err_init2.decode new file mode 100644 index 0000000..b58de30 --- /dev/null +++ b/tests/decode/err_init2.decode @@ -0,0 +1,6 @@ +# 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 member initialized twice in pattern. +&args a b +insn 00000000 00000000 a:8 b:8 &args a=1 diff --git a/tests/decode/err_init3.decode b/tests/decode/err_init3.decode new file mode 100644 index 0000000..96790ab --- /dev/null +++ b/tests/decode/err_init3.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 member initialized twice in pattern + format. +&args a +@format ........ ........ a:16 &args +insn 00000000 00000000 a:16 @format diff --git a/tests/decode/err_init4.decode b/tests/decode/err_init4.decode new file mode 100644 index 0000000..4336d46 --- /dev/null +++ b/tests/decode/err_init4.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 uninitialized member in pattern + format. +&args a b +@format ........ ........ a:16 &args +insn 00000000 00000000 ........ ........ @format diff --git a/tests/decode/err_overlap1.decode b/tests/decode/err_overlap1.decode new file mode 100644 index 0000000..1ae6347 --- /dev/null +++ b/tests/decode/err_overlap1.decode @@ -0,0 +1,6 @@ +# 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 field overlapping fixedbits. +%field 0:1 +insn 00000000 00000000 00000000 00000000 %field diff --git a/tests/decode/err_overlap2.decode b/tests/decode/err_overlap2.decode new file mode 100644 index 0000000..1d6d7a3 --- /dev/null +++ b/tests/decode/err_overlap2.decode @@ -0,0 +1,6 @@ +# 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 field overlapping fixedbits w/format. +@format ........ ........ ........ ....... fld:1 +insn 00000000 00000000 00000000 00000000 @format diff --git a/tests/decode/err_overlap3.decode b/tests/decode/err_overlap3.decode new file mode 100644 index 0000000..3ab0c48 --- /dev/null +++ b/tests/decode/err_overlap3.decode @@ -0,0 +1,6 @@ +# 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 field overlapping unspecified bits. +%field 0:1 +insn 00000000 00000000 00000000 -------- %field diff --git a/tests/decode/err_overlap4.decode b/tests/decode/err_overlap4.decode new file mode 100644 index 0000000..53c5399 --- /dev/null +++ b/tests/decode/err_overlap4.decode @@ -0,0 +1,6 @@ +# 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 fixed bits overlapping unspecified bits. +@format ........ ........ ........ .......- +insn 00000000 00000000 00000000 00000000 @format diff --git a/tests/decode/err_overlap5.decode b/tests/decode/err_overlap5.decode new file mode 100644 index 0000000..df0e31f --- /dev/null +++ b/tests/decode/err_overlap5.decode @@ -0,0 +1,5 @@ +# 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 overlapping sub-fields. +%field 3:5 0:5 diff --git a/tests/decode/err_overlap6.decode b/tests/decode/err_overlap6.decode new file mode 100644 index 0000000..cc69fc8 --- /dev/null +++ b/tests/decode/err_overlap6.decode @@ -0,0 +1,6 @@ +# 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 overlapping fixed bits w/format. +@format ........ ........ ........ .......1 +insn 00000000 00000000 00000000 00000000 @format diff --git a/tests/decode/err_overlap7.decode b/tests/decode/err_overlap7.decode new file mode 100644 index 0000000..6f55529 --- /dev/null +++ b/tests/decode/err_overlap7.decode @@ -0,0 +1,6 @@ +# 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 overlapping patterns. +insn1 00000000 00000000 00000000 00000000 +insn2 00000000 00000000 00000000 00000000 diff --git a/tests/decode/err_overlap8.decode b/tests/decode/err_overlap8.decode new file mode 100644 index 0000000..df4bae8 --- /dev/null +++ b/tests/decode/err_overlap8.decode @@ -0,0 +1,5 @@ +# 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 not specified bit (. vs -). +insn 00000000 00000000 00000000 0000000. diff --git a/tests/decode/err_overlap9.decode b/tests/decode/err_overlap9.decode new file mode 100644 index 0000000..58b6ac1 --- /dev/null +++ b/tests/decode/err_overlap9.decode @@ -0,0 +1,6 @@ +# 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 not specified bit (. vs -) w/format. +@format ........ a:8 ........ b:7 . +insn 00000000 ........ 00000000 ........ @format -- cgit v1.1