isaspec: Add "displayname" for altering {NAME} when decoding

In afuc, we have the situation where there are a number of ALU
instructions with two (almost) completely different encodings, including
a different opcode location, etc. These need to be different leaf
bitsets with different names for the encoder to work, because otherwise
the encoder has no way of descriminating between them, but when
displaying them we want to use the same name. This adds a small facility
to make the name used for {NAME} when displaying and for the opcode
when encoding different, so that e.g. OPC_ADDI can display as "add"
instead of "addi".

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23949>
This commit is contained in:
Connor Abbott 2023-06-21 18:27:42 +02:00 committed by Marge Bot
parent c237539d62
commit 86b17d96b3
3 changed files with 15 additions and 1 deletions

View file

@ -184,6 +184,19 @@ decoding. The display template consists of references to fields (which may
be derived fields) specified as ``{FIELDNAME}`` and other characters
which are just echoed through to the resulting decoded bitset.
The special field reference ``{NAME}`` prints the name of the bitset. This is
often useful when the ``<display>`` element is at a higher level than the
leaves of the hierarchy, for example a whole class of similar instructions that
only differ in opcode.
Sometimes there may be multiple variants of an instruction that must be
different bitsets, for example because they are so different that they must
derive from different bitsets, but they have the same name. Because bitset
names must be unique in the encoder, this can be a problem, but this can worked
around with the ``displayname`` attribute on the ``bitset`` which changes how
``{NAME}`` is displayed but not the name used in the encoder. ``displayname``
is only useful for leaf bitsets.
It is possible to define a line column alignment value per field to influence
the visual output. It needs to be specified as ``{FIELDNAME:align=xx}``.

View file

@ -158,7 +158,7 @@ static const struct isa_bitset bitset_${bitset.get_c_name()}_gen_${bitset.gen_mi
% if bitset.extends is not None:
.parent = &bitset_${isa.bitsets[bitset.extends].get_c_name()}_gen_${isa.bitsets[bitset.extends].gen_min},
% endif
.name = "${name}",
.name = "${bitset.display_name}",
.gen = {
.min = ${bitset.get_gen_min()},
.max = ${bitset.get_gen_max()},

View file

@ -247,6 +247,7 @@ class BitSet(object):
self.isa = isa
self.xml = xml
self.name = xml.attrib['name']
self.display_name = xml.attrib['displayname'] if 'displayname' in xml.attrib else self.name
# Used for generated encoder, to de-duplicate encoding for
# similar instructions: