isaspec: Add "displayname" for altering {NAME} when decoding
authorConnor Abbott <cwabbott0@gmail.com>
Wed, 21 Jun 2023 16:27:42 +0000 (18:27 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 28 Jul 2023 18:41:57 +0000 (18:41 +0000)
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>

docs/drivers/freedreno/isaspec.rst
src/compiler/isaspec/decode.py
src/compiler/isaspec/isa.py

index cb4dfc5..19b41ee 100644 (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}``.
 
index aaf267f..9e05fa0 100755 (executable)
@@ -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()},
index e87f191..894d3c5 100644 (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: