Mesa (main): pan/bi: Print the clause of branch targets

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Aug 1 13:17:00 UTC 2021


Module: Mesa
Branch: main
Commit: 8574ca4491815647e69ff529d8c81391080de4c1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8574ca4491815647e69ff529d8c81391080de4c1

Author: Icecream95 <ixn at disroot.org>
Date:   Sat Jul 31 11:57:38 2021 +1200

pan/bi: Print the clause of branch targets

Rather than just printing an offset such as '(pc + 192)', print the
target of branches as a clause number that matches up with the clause
headers printed by disassemble_bifrost.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12153>

---

 src/panfrost/bifrost/disassemble.c | 15 ++++++++-------
 src/panfrost/bifrost/disassemble.h |  2 +-
 src/panfrost/bifrost/gen_disasm.py |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c
index 3609d8fbf55..392974e7567 100644
--- a/src/panfrost/bifrost/disassemble.c
+++ b/src/panfrost/bifrost/disassemble.c
@@ -241,7 +241,7 @@ static void dump_const_imm(FILE *fp, uint32_t imm)
 }
 
 static void
-dump_pc_imm(FILE *fp, uint64_t imm, enum bi_constmod mod, bool high32)
+dump_pc_imm(FILE *fp, uint64_t imm, unsigned branch_offset, enum bi_constmod mod, bool high32)
 {
         if (mod == BI_CONSTMOD_PC_HI && !high32) {
                 dump_const_imm(fp, imm);
@@ -276,7 +276,8 @@ dump_pc_imm(FILE *fp, uint64_t imm, enum bi_constmod mod, bool high32)
                 unreachable("Invalid PC modifier");
         }
 
-        fprintf(fp, "(pc + %" PRId64 ")", offs);
+        assert((offs & 15) == 0);
+        fprintf(fp, "clause_%" PRId64, branch_offset + (offs / 16));
 
         if (mod == BI_CONSTMOD_PC_LO && high32)
                 fprintf(fp, " >> 32");
@@ -301,7 +302,7 @@ const_fau_to_idx(unsigned fau_value)
         return map[fau_value];
 }
 
-static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, struct bi_constants *consts, bool high32)
+static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, unsigned branch_offset, struct bi_constants *consts, bool high32)
 {
         if (srcs.fau_idx & 0x80) {
                 unsigned uniform = (srcs.fau_idx & 0x7f);
@@ -311,7 +312,7 @@ static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, struct bi_constants
                 uint64_t imm = consts->raw[idx];
                 imm |= (srcs.fau_idx & 0xf);
                 if (consts->mods[idx] != BI_CONSTMOD_NONE)
-                        dump_pc_imm(fp, imm, consts->mods[idx], high32);
+                        dump_pc_imm(fp, imm, branch_offset, consts->mods[idx], high32);
                 else if (high32)
                         dump_const_imm(fp, imm >> 32);
                 else
@@ -362,7 +363,7 @@ static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, struct bi_constants
 }
 
 void
-dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, struct bi_constants *consts, bool isFMA)
+dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, unsigned branch_offset, struct bi_constants *consts, bool isFMA)
 {
         switch (src) {
         case 0:
@@ -381,10 +382,10 @@ dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, struct bi_constants *
                         fprintf(fp, "t"); // i.e. the output of FMA this cycle
                 break;
         case 4:
-                dump_fau_src(fp, srcs, consts, false);
+                dump_fau_src(fp, srcs, branch_offset, consts, false);
                 break;
         case 5:
-                dump_fau_src(fp, srcs, consts, true);
+                dump_fau_src(fp, srcs, branch_offset, consts, true);
                 break;
         case 6:
                 fprintf(fp, "t0");
diff --git a/src/panfrost/bifrost/disassemble.h b/src/panfrost/bifrost/disassemble.h
index 6eb37260868..1e39c20d658 100644
--- a/src/panfrost/bifrost/disassemble.h
+++ b/src/panfrost/bifrost/disassemble.h
@@ -42,6 +42,6 @@ void bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bi
 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);
+void dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, unsigned branch_offset, struct bi_constants *consts, bool isFMA);
 
 #endif
diff --git a/src/panfrost/bifrost/gen_disasm.py b/src/panfrost/bifrost/gen_disasm.py
index 11acf5ae9b3..01ab6290cd4 100644
--- a/src/panfrost/bifrost/gen_disasm.py
+++ b/src/panfrost/bifrost/gen_disasm.py
@@ -326,7 +326,7 @@ def disasm_op(name, op):
 
     for i, (pos, mask) in enumerate(srcs):
         body += '    fputs(", ", fp);\n'
-        body += '    dump_src(fp, _BITS(bits, {}, 3), *srcs, consts, {});\n'.format(pos, "true" if is_fma else "false")
+        body += '    dump_src(fp, _BITS(bits, {}, 3), *srcs, branch_offset, consts, {});\n'.format(pos, "true" if is_fma else "false")
 
         # Error check if needed
         if (mask != 0xFF):



More information about the mesa-commit mailing list