freedreno/ir3: add more disasm stats
[mesa.git] / src / freedreno / ir3 / disasm-a3xx.c
index b84163106fb437022456155d6bdc3ac617b55892..2555c739082fd3613c7c8205009af5719d0872ca 100644 (file)
@@ -277,10 +277,21 @@ static void print_reg_stats(struct disasm_ctx *ctx)
        // Note this count of instructions includes rptN, which matches
        // up to how mesa prints this:
        fprintf(ctx->out, "%s- shaderdb: %d instructions, %d nops, %d non-nops, "
-                       "(%d instlen), %d half, %d full\n",
+                       "(%d instlen), %u last-baryf, %d half, %d full\n",
                        levels[ctx->level], ctx->stats->instructions, ctx->stats->nops,
                        ctx->stats->instructions - ctx->stats->nops, ctx->stats->instlen,
-                       halfreg, fullreg);
+                       ctx->stats->last_baryf, halfreg, fullreg);
+       fprintf(ctx->out, "%s- shaderdb: %u cat0, %u cat1, %u cat2, %u cat3, "
+                       "%u cat4, %u cat5, %u cat6, %u cat7\n",
+                       levels[ctx->level],
+                       ctx->stats->instrs_per_cat[0],
+                       ctx->stats->instrs_per_cat[1],
+                       ctx->stats->instrs_per_cat[2],
+                       ctx->stats->instrs_per_cat[3],
+                       ctx->stats->instrs_per_cat[4],
+                       ctx->stats->instrs_per_cat[5],
+                       ctx->stats->instrs_per_cat[6],
+                       ctx->stats->instrs_per_cat[7]);
        fprintf(ctx->out, "%s- shaderdb: %d (ss), %d (sy)\n", levels[ctx->level],
                        ctx->stats->ss, ctx->stats->sy);
 }
@@ -1529,7 +1540,7 @@ static void print_single_instr(struct disasm_ctx *ctx, instr_t *instr)
 static bool print_instr(struct disasm_ctx *ctx, uint32_t *dwords, int n)
 {
        instr_t *instr = (instr_t *)dwords;
-       uint32_t opc = instr_opc(instr, ctx->gpu_id);
+       opc_t opc = _OPC(instr->opc_cat, instr_opc(instr, ctx->gpu_id));
        unsigned nop = 0;
        unsigned cycles = ctx->stats->instructions;
 
@@ -1538,15 +1549,18 @@ static bool print_instr(struct disasm_ctx *ctx, uint32_t *dwords, int n)
                                instr->opc_cat, n, cycles++, dwords[1], dwords[0]);
        }
 
-       /* NOTE: order flags are printed is a bit fugly.. but for now I
-        * try to match the order in llvm-a3xx disassembler for easy
-        * diff'ing..
-        */
+       if (opc == OPC_BARY_F)
+               ctx->stats->last_baryf = ctx->stats->instructions;
 
        ctx->repeat = instr_repeat(instr);
        ctx->stats->instructions += 1 + ctx->repeat;
        ctx->stats->instlen++;
 
+       /* NOTE: order flags are printed is a bit fugly.. but for now I
+        * try to match the order in llvm-a3xx disassembler for easy
+        * diff'ing..
+        */
+
        if (instr->sync) {
                fprintf(ctx->out, "(sy)");
                ctx->stats->sy++;
@@ -1567,16 +1581,30 @@ static bool print_instr(struct disasm_ctx *ctx, uint32_t *dwords, int n)
                nop = (instr->cat2.src2_r * 2) + instr->cat2.src1_r;
        else if ((instr->opc_cat == 3) && (instr->cat3.src1_r || instr->cat3.src2_r))
                nop = (instr->cat3.src2_r * 2) + instr->cat3.src1_r;
-       ctx->stats->instructions += nop;
-       ctx->stats->nops += nop;
-       if (opc == OPC_NOP)
-               ctx->stats->nops += 1 + ctx->repeat;
        if (nop)
                fprintf(ctx->out, "(nop%d) ", nop);
 
        if (instr->ul && ((2 <= instr->opc_cat) && (instr->opc_cat <= 4)))
                fprintf(ctx->out, "(ul)");
 
+       ctx->stats->instructions += nop;
+       ctx->stats->nops += nop;
+       if (opc == OPC_NOP) {
+               ctx->stats->nops += 1 + ctx->repeat;
+               ctx->stats->instrs_per_cat[0] += 1 + ctx->repeat;
+       } else {
+               ctx->stats->instrs_per_cat[instr->opc_cat] += 1 + ctx->repeat;
+               ctx->stats->instrs_per_cat[0] += nop;
+       }
+
+       if (opc == OPC_MOV) {
+               if (instr->cat1.src_type == instr->cat1.dst_type) {
+                       ctx->stats->mov_count += 1 + ctx->repeat;
+               } else {
+                       ctx->stats->cov_count += 1 + ctx->repeat;
+               }
+       }
+
        print_single_instr(ctx, instr);
        fprintf(ctx->out, "\n");