From 86b17d96b3af5940c61b88ac915ca431b271223b Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 21 Jun 2023 18:27:42 +0200 Subject: [PATCH] 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: --- docs/drivers/freedreno/isaspec.rst | 13 +++++++++++++ src/compiler/isaspec/decode.py | 2 +- src/compiler/isaspec/isa.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/drivers/freedreno/isaspec.rst b/docs/drivers/freedreno/isaspec.rst index cb4dfc5..19b41ee 100644 --- a/docs/drivers/freedreno/isaspec.rst +++ b/docs/drivers/freedreno/isaspec.rst @@ -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 ```` 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}``. diff --git a/src/compiler/isaspec/decode.py b/src/compiler/isaspec/decode.py index aaf267f..9e05fa0 100755 --- a/src/compiler/isaspec/decode.py +++ b/src/compiler/isaspec/decode.py @@ -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()}, diff --git a/src/compiler/isaspec/isa.py b/src/compiler/isaspec/isa.py index e87f191..894d3c5 100644 --- a/src/compiler/isaspec/isa.py +++ b/src/compiler/isaspec/isa.py @@ -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: -- 2.7.4