pan/bi: Pass 'first' through disassembler
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sun, 20 Sep 2020 13:29:08 +0000 (09:29 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 24 Sep 2020 11:27:22 +0000 (11:27 +0000)
Required to decode the registers of the first instruction of a clause
correctly.

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

src/panfrost/bifrost/disassemble.c
src/panfrost/bifrost/disassemble.h
src/panfrost/bifrost/gen_disasm.py

index 193316f..2d83a30 100644 (file)
@@ -144,7 +144,7 @@ static void dump_header(FILE *fp, struct bifrost_header header, bool verbose)
         }
 }
 
-static struct bifrost_reg_ctrl DecodeRegCtrl(FILE *fp, struct bifrost_regs regs)
+static struct bifrost_reg_ctrl DecodeRegCtrl(FILE *fp, struct bifrost_regs regs, bool first)
 {
         struct bifrost_reg_ctrl decoded = {};
         unsigned ctrl;
@@ -220,9 +220,9 @@ static unsigned GetRegToWrite(enum bifrost_reg_write_unit unit, struct bifrost_r
         }
 }
 
-static void dump_regs(FILE *fp, struct bifrost_regs srcs)
+static void dump_regs(FILE *fp, struct bifrost_regs srcs, bool first)
 {
-        struct bifrost_reg_ctrl ctrl = DecodeRegCtrl(fp, srcs);
+        struct bifrost_reg_ctrl ctrl = DecodeRegCtrl(fp, srcs, first);
         fprintf(fp, "# ");
         if (ctrl.read_reg0)
                 fprintf(fp, "port 0: r%d ", get_reg0(srcs));
@@ -251,9 +251,9 @@ static void dump_regs(FILE *fp, struct bifrost_regs srcs)
 }
 
 void
-bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs)
+bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs, bool first)
 {
-    struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs);
+    struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs, first);
     if (next_ctrl.fma_write_unit != REG_WRITE_NONE)
         fprintf(fp, "r%u:t0", GetRegToWrite(next_ctrl.fma_write_unit, *next_regs));
     else
@@ -261,9 +261,9 @@ bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs)
 }
 
 void
-bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs)
+bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs, bool first)
 {
-    struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs);
+    struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs, first);
     if (next_ctrl.add_write_unit != REG_WRITE_NONE)
         fprintf(fp, "r%u:t1", GetRegToWrite(next_ctrl.add_write_unit, *next_regs));
     else
@@ -703,11 +703,11 @@ static bool dump_clause(FILE *fp, uint32_t *words, unsigned *size, unsigned offs
 
                 if (verbose) {
                         fprintf(fp, "# regs: %016" PRIx64 "\n", instrs->reg_bits);
-                        dump_regs(fp, regs);
+                        dump_regs(fp, regs, i == 0);
                 }
 
-                bi_disasm_fma(fp, instrs[i].fma_bits, &regs, &next_regs, header.datareg, offset, &consts);
-                bi_disasm_add(fp, instrs[i].add_bits, &regs, &next_regs, header.datareg, offset, &consts);
+                bi_disasm_fma(fp, instrs[i].fma_bits, &regs, &next_regs, header.datareg, offset, &consts, i == 0);
+                bi_disasm_add(fp, instrs[i].add_bits, &regs, &next_regs, header.datareg, offset, &consts, i == 0);
         }
         fprintf(fp, "}\n");
 
index d692152..f63e04f 100644 (file)
@@ -50,12 +50,12 @@ struct bi_constants {
 };
 
 void
-bi_disasm_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts);
+bi_disasm_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first);
 
-void bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts);
+void bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first);
 
-void bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs);
-void bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs);
+void bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs, bool first);
+void bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs, bool first);
 
 void dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, struct bi_constants *consts, bool isFMA);
 
index e17155a..61080a3 100644 (file)
@@ -64,7 +64,7 @@ def decode_op(instructions, is_fma):
 
     # Generate checks in order
     template = """void
-bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts)
+bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first)
 {
 % for (i, (name, (emask, ebits), derived)) in enumerate(options):
 % if len(derived) > 0:
@@ -76,7 +76,7 @@ bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bif
 % else:
     ${"else " if i > 0 else ""}if (unlikely(((bits & ${hex(emask)}) == ${hex(ebits)})))
 % endif
-        bi_disasm_${name}(fp, bits, srcs, next_regs, staging_register, branch_offset, consts);
+        bi_disasm_${name}(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, first);
 % endfor
     else
         fprintf(fp, "INSTR_INVALID_ENC ${unit} %X\\n", bits);
@@ -89,7 +89,7 @@ bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bif
 # state. Sync prototypes to avoid moves when calling.
 
 disasm_op_template = Template("""static void
-bi_disasm_${c_name}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts)
+bi_disasm_${c_name}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first)
 {
     ${body.strip()}
 }
@@ -316,7 +316,7 @@ def disasm_op(name, op):
         body += disasm_mod(mod, skip_mods)
 
     body += '    fputs(" ", fp);\n'
-    body += '    bi_disasm_dest_{}(fp, next_regs);\n'.format('fma' if is_fma else 'add')
+    body += '    bi_disasm_dest_{}(fp, next_regs, first);\n'.format('fma' if is_fma else 'add')
 
     # Next up, each source. Source modifiers are inserterd here