pan/bi: Add unused instruction mechanism
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 7 Dec 2020 03:42:37 +0000 (22:42 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 23 Dec 2020 17:06:56 +0000 (17:06 +0000)
Certain instructions are highly unlikely to ever be used in the Bifrost
compiler, due to differences in the Mesa stack versus the Arm compiler,
as well as hardware features added speculatively and that never became
API visible. It doesn't make sense to include these instructions in the
IR, so let's disable them, while retaining complete disassembly.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8213>

src/panfrost/bifrost/gen_disasm.py
src/panfrost/bifrost/isa_parse.py

index a4aa66a..f80a97f 100644 (file)
@@ -25,7 +25,7 @@ import itertools
 from isa_parse import parse_instructions, opname_to_c, expand_states
 from mako.template import Template
 
-instructions = parse_instructions(sys.argv[1])
+instructions = parse_instructions(sys.argv[1], include_unused = True)
 
 # Constructs a reserved mask for a derived to cull impossible encodings
 
index 9b4e8a6..c0dccbc 100644 (file)
@@ -96,7 +96,8 @@ def parse_instruction(ins):
             'immediates': [],
             'swaps': [],
             'derived': [],
-            'staging': ins.attrib.get('staging', '')
+            'staging': ins.attrib.get('staging', ''),
+            'unused': ins.attrib.get('unused', False),
     }
 
     if 'exact' in ins.attrib:
@@ -146,12 +147,19 @@ def parse_instruction(ins):
 
     return variants
 
-def parse_instructions(xml):
+def parse_instructions(xml, include_unused = False):
     final = {}
     instructions = ET.parse(xml).getroot().findall('ins')
 
     for ins in instructions:
-        final[ins.attrib['name']] = parse_instruction(ins)
+        parsed = parse_instruction(ins)
+
+        # Some instructions are for useful disassembly only and can be stripped
+        # out of the compiler, particularly useful for release builds
+        if parsed[0][1]["unused"] and not include_unused:
+            continue
+
+        final[ins.attrib['name']] = parsed
 
     return final