scripts/decodetree: Implement named field support
commit7e6c28be2739c2286fe09702adef4740d9a1ed41
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 23 May 2023 12:04:46 +0000 (23 13:04 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 30 May 2023 17:55:39 +0000 (30 10:55 -0700)
tree965bce7a22851a90abd1f2ea722c87799528131a
parent36d612448273d0c295f519d9df3b10208177487a
scripts/decodetree: Implement named field support

Implement support for named fields, i.e.  where one field is defined
in terms of another, rather than directly in terms of bits extracted
from the instruction.

The new method referenced_fields() on all the Field classes returns a
list of fields that this field references.  This just passes through,
except for the new NamedField class.

We can then use referenced_fields() to:
 * construct a list of 'dangling references' for a format or
   pattern, which is the fields that the format/pattern uses but
   doesn't define itself
 * do a topological sort, so that we output "field = value"
   assignments in an order that means that we assign a field before
   we reference it in a subsequent assignment
 * check when we output the code for a pattern whether we need to
   fill in the format fields before or after the pattern fields, and
   do other error checking

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230523120447.728365-6-peter.maydell@linaro.org>
scripts/decodetree.py