pan/bi: Add staging register counts to ISA.xml
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 23 Dec 2020 16:30:17 +0000 (11:30 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 23 Dec 2020 17:06:57 +0000 (17:06 +0000)
Message-passing instructions that read/write staging registers access
either:

* a fixed number of registers
* vecsize registers (/2 for LD/ST_CVT if register_format is 16-bit)
* a computed number for TEXC

This adds the fixed counts into the XML for the first type and space to
specify the latter types.

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

src/panfrost/bifrost/ISA.xml
src/panfrost/bifrost/isa_parse.py

index 2541130..bdfff87 100644 (file)
     <mod name="neg2" start="12" size="1" opt="neg"/>
   </ins>
 
-  <ins name="+ACMPSTORE.i32" staging="r" mask="0xffdc0" exact="0x648c0" message="atomic">
+  <ins name="+ACMPSTORE.i32" staging="r=2" mask="0xffdc0" exact="0x648c0" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
   </ins>
 
-  <ins name="+ACMPSTORE.i64" staging="r" mask="0xffdc0" exact="0x64900" message="atomic">
+  <ins name="+ACMPSTORE.i64" staging="r=4" mask="0xffdc0" exact="0x64900" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
   </ins>
 
-  <ins name="+ACMPXCHG.i32" staging="rw" mask="0xffdc0" exact="0x644c0" message="atomic">
+  <ins name="+ACMPXCHG.i32" staging="rw=2" mask="0xffdc0" exact="0x644c0" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
   </ins>
 
-  <ins name="+ACMPXCHG.i64" staging="rw" mask="0xffdc0" exact="0x64500" message="atomic">
+  <ins name="+ACMPXCHG.i64" staging="rw=4" mask="0xffdc0" exact="0x64500" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
   </ins>
 
-  <ins name="+ATEST" staging="w" mask="0xfff00" exact="0xc8f00" message="atest">
+  <ins name="+ATEST" staging="w=1" mask="0xfff00" exact="0xc8f00" message="atest">
     <src start="0" mask="0xf7"/>
     <src start="3" mask="0xf7"/>
     <mod name="widen1" start="6" size="2">
     </mod>
   </ins>
 
-  <ins name="+ATOM_CX" staging="rw" mask="0xffe00" exact="0xd7400" message="atomic">
+  <ins name="+ATOM_CX" staging="rw=sr_count" mask="0xffe00" exact="0xd7400" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
+    <!-- not actually encoded, but used for IR -->
+    <immediate name="sr_count" size="4" pseudo="true"/>
   </ins>
 
-  <ins name="+AXCHG.i32" staging="rw" mask="0xffdc0" exact="0x640c0" message="atomic">
+  <ins name="+AXCHG.i32" staging="rw=1" mask="0xffdc0" exact="0x640c0" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
   </ins>
 
-  <ins name="+AXCHG.i64" staging="rw" mask="0xffdc0" exact="0x64100" message="atomic">
+  <ins name="+AXCHG.i64" staging="rw=2" mask="0xffdc0" exact="0x64100" message="atomic">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="9" size="1" opt="wls"/>
 
   <ins name="+BARRIER" mask="0xfffff" exact="0xd7874" message="barrier"/>
 
-  <ins name="+BLEND" staging="r" mask="0xffe00" exact="0xca800" message="blend">
+  <ins name="+BLEND" staging="r=4" mask="0xffe00" exact="0xca800" message="blend">
     <src start="0"/>
     <src start="3" mask="0xf7"/>
     <src start="6" mask="0xf7"/>
     </mod>
   </ins>
 
-  <ins name="+LD_ATTR" staging="w" message="attribute">
+  <ins name="+LD_ATTR" staging="w=format" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </encoding>
   </ins>
 
-  <ins name="+LD_ATTR_IMM" staging="w" message="attribute">
+  <ins name="+LD_ATTR_IMM" staging="w=format" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <immediate name="attribute_index" start="6" size="4"/>
     </encoding>
   </ins>
 
-  <ins name="+LD_ATTR_TEX" staging="w" message="attribute">
+  <ins name="+LD_ATTR_TEX" staging="w=format" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </encoding>
   </ins>
 
-  <ins name="+LD_CVT" staging="w" mask="0xff800" exact="0xc9000" message="load">
+  <ins name="+LD_CVT" staging="w=format" mask="0xff800" exact="0xc9000" message="load">
     <src start="0"/>
     <src start="3"/>
     <src start="6" mask="0xf7"/>
     </mod>
   </ins>
 
-  <ins name="+LD_GCLK.u64" staging="w" mask="0xffff8" exact="0xd7800" message="attribute">
+  <ins name="+LD_GCLK.u64" staging="w=1" mask="0xffff8" exact="0xd7800" message="attribute">
     <mod name="source" start="0" size="3">
       <reserved/>
       <reserved/>
     </mod>
   </ins>
 
-  <ins name="+LD_TILE" staging="w" mask="0xff800" exact="0xcb000" message="tile">
+  <ins name="+LD_TILE" staging="w=vecsize" mask="0xff800" exact="0xcb000" message="tile">
     <src start="0"/>
     <src start="3"/>
     <src start="6" mask="0xf7"/>
     </mod>
   </ins>
 
-  <ins name="+LD_VAR" staging="w" message="varying">
+  <ins name="+LD_VAR" staging="w=vecsize" message="varying">
     <src start="0"/>
     <src start="3"/>
     <mod name="vecsize" start="8" size="2">
     </encoding>
   </ins>
 
-  <ins name="+LD_VAR_FLAT" staging="w" message="varying">
+  <ins name="+LD_VAR_FLAT" staging="w=format" message="varying">
     <src start="3"/>
     <mod name="vecsize" start="8" size="2">
       <opt>none</opt>
     </encoding>
   </ins>
 
-  <ins name="+LD_VAR_FLAT_IMM" staging="w" message="varying">
+  <ins name="+LD_VAR_FLAT_IMM" staging="w=format" message="varying">
     <immediate name="index" start="3" size="5"/>
     <mod name="vecsize" start="8" size="2">
       <opt>none</opt>
     </encoding>
   </ins>
 
-  <ins name="+LD_VAR_IMM" staging="w" message="varying">
+  <ins name="+LD_VAR_IMM" staging="w=format" message="varying">
     <src start="0"/>
     <immediate name="index" start="3" size="5"/>
     <mod name="vecsize" start="8" size="2">
     </encoding>
   </ins>
 
-  <ins name="+LD_VAR_SPECIAL" staging="w" message="varying">
+  <ins name="+LD_VAR_SPECIAL" staging="w=format" message="varying">
     <src start="0"/>
     <mod name="varying_name" size="5">
       <opt>point</opt>
     </encoding>
   </ins>
 
-  <ins name="+LEA_ATTR" staging="w" message="attribute">
+  <ins name="+LEA_ATTR" staging="w=3" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </encoding>
   </ins>
 
-  <ins name="+LEA_ATTR_IMM" staging="w" message="attribute">
+  <ins name="+LEA_ATTR_IMM" staging="w=3" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <immediate name="attribute_index" start="6" size="4"/>
     </encoding>
   </ins>
 
-  <ins name="+LEA_ATTR_TEX" staging="w" message="attribute">
+  <ins name="+LEA_ATTR_TEX" staging="w=3" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </encoding>
   </ins>
 
-  <ins name="+LEA_TEX" staging="w" mask="0xff600" exact="0xd6600" message="attribute">
+  <ins name="+LEA_TEX" staging="w=3" mask="0xff600" exact="0xd6600" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </mod>
   </ins>
 
-  <ins name="+LEA_TEX_IMM" staging="w" mask="0xff000" exact="0xd6000" message="attribute">
+  <ins name="+LEA_TEX_IMM" staging="w=3" mask="0xff000" exact="0xd6000" message="attribute">
     <src start="0"/>
     <src start="3"/>
     <immediate name="texture_index" start="6" size="5"/>
     </mod>
   </ins>
 
-  <ins name="+LOAD.i128" staging="w" mask="0xffe00" exact="0x61000" message="load">
+  <ins name="+LOAD.i128" staging="w=4" mask="0xffe00" exact="0x61000" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+LOAD.i16" staging="w" message="load">
+  <ins name="+LOAD.i16" staging="w=1" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </encoding>
   </ins>
 
-  <ins name="+LOAD.i24" staging="w" mask="0xffe00" exact="0x65000" message="load">
+  <ins name="+LOAD.i24" staging="w=1" mask="0xffe00" exact="0x65000" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+LOAD.i32" staging="w" message="load">
+  <ins name="+LOAD.i32" staging="w=1" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </encoding>
   </ins>
 
-  <ins name="+LOAD.i48" staging="w" mask="0xffe00" exact="0x65200" message="load">
+  <ins name="+LOAD.i48" staging="w=2" mask="0xffe00" exact="0x65200" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+LOAD.i64" staging="w" mask="0xffe00" exact="0x60e00" message="load">
+  <ins name="+LOAD.i64" staging="w=2" mask="0xffe00" exact="0x60e00" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+LOAD.i8" staging="w" message="load">
+  <ins name="+LOAD.i8" staging="w=1" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </encoding>
   </ins>
 
-  <ins name="+LOAD.i96" staging="w" mask="0xffe00" exact="0x65400" message="load">
+  <ins name="+LOAD.i96" staging="w=3" mask="0xffe00" exact="0x65400" message="load">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     <src start="6"/>
   </ins>
 
-  <ins name="+STORE.i128" staging="r" mask="0xffe00" exact="0x61200" message="store">
+  <ins name="+STORE.i128" staging="r=4" mask="0xffe00" exact="0x61200" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i16" staging="r" mask="0xffe00" exact="0x62800" message="store">
+  <ins name="+STORE.i16" staging="r=1" mask="0xffe00" exact="0x62800" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i24" staging="r" mask="0xffe00" exact="0x65800" message="store">
+  <ins name="+STORE.i24" staging="r=1" mask="0xffe00" exact="0x65800" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i32" staging="r" mask="0xffe00" exact="0x62c00" message="store">
+  <ins name="+STORE.i32" staging="r=1" mask="0xffe00" exact="0x62c00" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i48" staging="r" mask="0xffe00" exact="0x65a00" message="store">
+  <ins name="+STORE.i48" staging="r=2" mask="0xffe00" exact="0x65a00" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i64" staging="r" mask="0xffe00" exact="0x62e00" message="store">
+  <ins name="+STORE.i64" staging="r=2" mask="0xffe00" exact="0x62e00" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i8" staging="r" mask="0xffe00" exact="0x62000" message="store">
+  <ins name="+STORE.i8" staging="r=1" mask="0xffe00" exact="0x62000" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+STORE.i96" staging="r" mask="0xffe00" exact="0x65c00" message="store">
+  <ins name="+STORE.i96" staging="r=3" mask="0xffe00" exact="0x65c00" message="store">
     <src start="0"/>
     <src start="3"/>
     <mod name="seg" start="6" size="3">
     </mod>
   </ins>
 
-  <ins name="+ST_CVT" staging="r" mask="0xff800" exact="0xc9800" message="store">
+  <ins name="+ST_CVT" staging="r=format" mask="0xff800" exact="0xc9800" message="store">
     <src start="0"/>
     <src start="3"/>
     <src start="6" mask="0xf7"/>
     </mod>
   </ins>
 
-  <ins name="+ST_TILE" staging="r" mask="0xff800" exact="0xcb800" message="tile">
+  <ins name="+ST_TILE" staging="r=vecsize" mask="0xff800" exact="0xcb800" message="tile">
     <src start="0"/>
     <src start="3"/>
     <src start="6" mask="0xf7"/>
     </mod>
   </ins>
 
-  <ins name="+TEXC" staging="rw" mask="0xffc00" exact="0xd7000" message="tex">
+  <ins name="+TEXC" staging="rw=sr_count" mask="0xffc00" exact="0xd7000" message="tex">
     <src start="0"/>
     <src start="3"/>
     <src start="6" mask="0xf7"/>
     <mod name="skip" start="9" size="1" opt="skip"/>
+    <!-- not actually encoded, but used for IR -->
+    <immediate name="sr_count" size="4" pseudo="true"/>
   </ins>
 
-  <ins name="+TEXS_2D.f16" staging="w" mask="0xfc000" exact="0xd8000" message="tex">
+  <ins name="+TEXS_2D.f16" staging="w=4" mask="0xfc000" exact="0xd8000" message="tex">
     <src start="0"/>
     <src start="3"/>
     <immediate name="texture_index" start="6" size="3"/>
     </mod>
   </ins>
 
-  <ins name="+TEXS_2D.f32" staging="w" mask="0xfc000" exact="0x58000" message="tex">
+  <ins name="+TEXS_2D.f32" staging="w=2" mask="0xfc000" exact="0x58000" message="tex">
     <src start="0"/>
     <src start="3"/>
     <immediate name="texture_index" start="6" size="3"/>
     </mod>
   </ins>
 
-  <ins name="+TEXS_CUBE.f16" staging="w" mask="0xfc000" exact="0xdc000" message="tex">
+  <ins name="+TEXS_CUBE.f16" staging="w=2" mask="0xfc000" exact="0xdc000" message="tex">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     <mod name="skip" start="9" size="1" opt="skip"/>
   </ins>
 
-  <ins name="+TEXS_CUBE.f32" staging="w" mask="0xfc000" exact="0x5c000" message="tex">
+  <ins name="+TEXS_CUBE.f32" staging="w=4" mask="0xfc000" exact="0x5c000" message="tex">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
     </mod>
   </ins>
 
-  <ins name="+VAR_TEX.f16" staging="w" mask="0xffd00" exact="0xca100" message="vartex">
+  <ins name="+VAR_TEX.f16" staging="w=2" mask="0xffd00" exact="0xca100" message="vartex">
     <immediate name="varying_index" start="0" size="3"/>
     <immediate name="texture_index" start="3" size="2"/>
     <mod name="update" size="1">
     </derived>
   </ins>
 
-  <ins name="+VAR_TEX.f32" staging="w" mask="0xffd00" exact="0xca000" message="vartex">
+  <ins name="+VAR_TEX.f32" staging="w=4" mask="0xffd00" exact="0xca000" message="vartex">
     <immediate name="varying_index" start="0" size="3"/>
     <immediate name="texture_index" start="3" size="2"/>
     <mod name="update" size="1">
     </mod>
   </ins>
 
-  <ins name="+ZS_EMIT" staging="w" mask="0xff800" exact="0xd7800" message="z_stencil">
+  <ins name="+ZS_EMIT" staging="w=1" mask="0xff800" exact="0xd7800" message="z_stencil">
     <src start="0"/>
     <src start="3"/>
     <src start="6"/>
index f0824d0..c05ce55 100644 (file)
@@ -89,14 +89,15 @@ def parse_copy(enc, existing):
             if ex[0][0] == name:
                 ex[0][1] = node.get('start')
 
-def parse_instruction(ins):
+def parse_instruction(ins, include_pseudo):
     common = {
             'srcs': [],
             'modifiers': [],
             'immediates': [],
             'swaps': [],
             'derived': [],
-            'staging': ins.attrib.get('staging', ''),
+            'staging': ins.attrib.get('staging', '').split('=')[0],
+            'staging_count': ins.attrib.get('staging', '=0').split('=')[1],
             'unused': ins.attrib.get('unused', False),
             'pseudo': ins.attrib.get('pseudo', False),
             'message': ins.attrib.get('message', 'none'),
@@ -110,7 +111,11 @@ def parse_instruction(ins):
         common['srcs'].append([int(src.attrib['start'], 0), mask])
 
     for imm in ins.findall('immediate'):
-        common['immediates'].append([imm.attrib['name'], int(imm.attrib['start']), int(imm.attrib['size'])])
+        if imm.attrib.get('pseudo', False) and not include_pseudo:
+            continue
+
+        start = int(imm.attrib['start']) if 'start' in imm.attrib else None
+        common['immediates'].append([imm.attrib['name'], start, int(imm.attrib['size'])])
 
     common['derived'] = parse_derived(ins)
     common['modifiers'] = parse_modifiers(ins)
@@ -154,7 +159,7 @@ def parse_instructions(xml, include_unused = False, include_pseudo = False):
     instructions = ET.parse(xml).getroot().findall('ins')
 
     for ins in instructions:
-        parsed = parse_instruction(ins)
+        parsed = parse_instruction(ins, include_pseudo)
 
         # Some instructions are for useful disassembly only and can be stripped
         # out of the compiler, particularly useful for release builds