pan/midgard: Add mir_calculate_temp_count helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 4 Oct 2019 01:51:05 +0000 (21:51 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 4 Oct 2019 02:29:50 +0000 (22:29 -0400)
This allows us to fill in ctx->temp_count explicitly, even if we haven't
squished down the MIR.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/mir.c

index a338557a7a0ac7ef2adef0a3fdaac7493e06f0a1..66cb34f9db508e678a4c634e7ca70f2cbcc89d24 100644 (file)
@@ -525,6 +525,7 @@ bool mir_nontrivial_outmod(midgard_instruction *ins);
 void mir_insert_instruction_before_scheduled(compiler_context *ctx, midgard_block *block, midgard_instruction *tag, midgard_instruction ins);
 void mir_insert_instruction_after_scheduled(compiler_context *ctx, midgard_block *block, midgard_instruction *tag, midgard_instruction ins);
 void mir_flip(midgard_instruction *ins);
+void mir_compute_temp_count(compiler_context *ctx);
 
 /* MIR goodies */
 
index f02527ff219ba17b9cbad035d4390f078a27d54a..e19ed4f98a6c38b574d34fde9309fbb68e6d7788 100644 (file)
@@ -544,3 +544,21 @@ mir_flip(midgard_instruction *ins)
         ins->alu.src1 = ins->alu.src2;
         ins->alu.src2 = temp;
 }
+
+/* Before squashing, calculate ctx->temp_count just by observing the MIR */
+
+void
+mir_compute_temp_count(compiler_context *ctx)
+{
+        if (ctx->temp_count)
+                return;
+
+        unsigned max_dest = 0;
+
+        mir_foreach_instr_global(ctx, ins) {
+                if (ins->dest < SSA_FIXED_MINIMUM)
+                        max_dest = MAX2(max_dest, ins->dest);
+        }
+
+        ctx->temp_count = max_dest;
+}