freedreno/ir3: add tracking for # of instructions per category
authorRob Clark <robdclark@chromium.org>
Thu, 6 Aug 2020 16:24:50 +0000 (09:24 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 11 Aug 2020 01:12:18 +0000 (01:12 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6243>

src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_shader.c
src/gallium/drivers/freedreno/ir3/ir3_gallium.c

index 124b41f9a3a06620662deb59e801c12950d6388b..c8d066088b487c34938f3b862ce1e818110fabba 100644 (file)
@@ -954,10 +954,17 @@ void * ir3_assemble(struct ir3_shader_variant *v)
                        if ((instr->opc == OPC_BARY_F) && (instr->regs[0]->flags & IR3_REG_EI))
                                info->last_baryf = info->instrs_count;
 
-                       info->instrs_count += 1 + instr->repeat + instr->nop;
-                       info->nops_count += instr->nop;
-                       if (instr->opc == OPC_NOP)
-                               info->nops_count += 1 + instr->repeat;
+                       unsigned instrs_count = 1 + instr->repeat + instr->nop;
+                       unsigned nops_count = instr->nop;
+
+                       if (instr->opc == OPC_NOP) {
+                               nops_count = 1 + instr->repeat;
+                               info->instrs_per_cat[0] += nops_count;
+                       } else {
+                               info->instrs_per_cat[opc_cat(instr->opc)] += instrs_count;
+                               info->instrs_per_cat[0] += nops_count;
+                       }
+
                        if (instr->opc == OPC_MOV) {
                                if (instr->cat1.src_type == instr->cat1.dst_type) {
                                        info->mov_count += 1 + instr->repeat;
@@ -965,6 +972,10 @@ void * ir3_assemble(struct ir3_shader_variant *v)
                                        info->cov_count += 1 + instr->repeat;
                                }
                        }
+
+                       info->instrs_count += instrs_count;
+                       info->nops_count += nops_count;
+
                        dwords += 2;
 
                        if (instr->flags & IR3_INSTR_SS) {
index 2f5423238e0a6c9fff4b22ec7774bec155326ca1..cb42636f285c3096c68d8158b7c15fdce5d24752 100644 (file)
@@ -65,6 +65,9 @@ struct ir3_info {
        uint16_t sstall;
 
        uint16_t last_baryf;     /* instruction # of last varying fetch */
+
+       /* Number of instructions of a given category: */
+       uint16_t instrs_per_cat[8];
 };
 
 struct ir3_register {
index f91c4508c6a3f4049f74797da5f6e0e480276952..519fafec900e22ffd3d2317cb9ba87ea6455bf20 100644 (file)
@@ -615,6 +615,17 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out)
                        so->info.max_reg + 1,
                        so->constlen);
 
+       fprintf(out, "; %s prog %d/%d: %u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7, \n",
+                       type, so->shader->id, so->id,
+                       so->info.instrs_per_cat[0],
+                       so->info.instrs_per_cat[1],
+                       so->info.instrs_per_cat[2],
+                       so->info.instrs_per_cat[3],
+                       so->info.instrs_per_cat[4],
+                       so->info.instrs_per_cat[5],
+                       so->info.instrs_per_cat[6],
+                       so->info.instrs_per_cat[7]);
+
        fprintf(out, "; %s prog %d/%d: %u sstall, %u (ss), %u (sy), %d max_sun, %d loops\n",
                        type, so->shader->id, so->id,
                        so->info.sstall,
index af3079068960e002e08e05311eb95c241b6dde88..810c3b2051ef35b023722725d1f3321747fd8520 100644 (file)
@@ -52,6 +52,7 @@ dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug
        pipe_debug_message(debug, SHADER_INFO,
                        "%s shader: %u inst, %u nops, %u non-nops, %u mov, %u cov, "
                        "%u dwords, %u last-baryf, %u half, %u full, %u constlen, "
+                       "%u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7, "
                        "%u sstall, %u (ss), %u (sy), %d max_sun, %d loops\n",
                        ir3_shader_stage(v),
                        v->info.instrs_count,
@@ -64,6 +65,14 @@ dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug
                        v->info.max_half_reg + 1,
                        v->info.max_reg + 1,
                        v->constlen,
+                       v->info.instrs_per_cat[0],
+                       v->info.instrs_per_cat[1],
+                       v->info.instrs_per_cat[2],
+                       v->info.instrs_per_cat[3],
+                       v->info.instrs_per_cat[4],
+                       v->info.instrs_per_cat[5],
+                       v->info.instrs_per_cat[6],
+                       v->info.instrs_per_cat[7],
                        v->info.sstall,
                        v->info.ss, v->info.sy,
                        v->max_sun, v->loops);