pan/midgard: Move uniforms to special registers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 24 Jul 2019 20:29:36 +0000 (13:29 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 25 Jul 2019 13:37:22 +0000 (06:37 -0700)
The load/store pipes can't take a uniform register in, so an explicit
move is necessary here.

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

index 8b91a63e82e03f91b2d3d230600d51d82eca138d..abe8b3e90c511befc9574f024476e87e48a4ea9e 100644 (file)
@@ -375,6 +375,7 @@ void mir_rewrite_index_dst(compiler_context *ctx, unsigned old, unsigned new);
 void mir_rewrite_index_src_single(midgard_instruction *ins, unsigned old, unsigned new);
 void mir_rewrite_index_src_tag(compiler_context *ctx, unsigned old, unsigned new, unsigned tag);
 bool mir_single_use(compiler_context *ctx, unsigned value);
+bool mir_special_index(compiler_context *ctx, unsigned idx);
 
 /* MIR printing */
 
index 93262f4b13f7beb4a9e6da5f8c53504823fc7a5e..1be224b84644812aab9e46b7fe03eea366b31361 100644 (file)
@@ -125,4 +125,22 @@ mir_nontrivial_source2_mod(midgard_instruction *ins)
         return mir_nontrivial_mod(src2, is_int, ins->mask);
 }
 
+/* Checks if an index will be used as a special register -- basically, if we're
+ * used as the input to a non-ALU op */
 
+bool
+mir_special_index(compiler_context *ctx, unsigned idx)
+{
+        mir_foreach_instr_global(ctx, ins) {
+                bool is_ldst = ins->type == TAG_LOAD_STORE_4;
+                bool is_tex = ins->type == TAG_TEXTURE_4;
+
+                if (!(is_ldst || is_tex))
+                        continue;
+
+                if (mir_has_arg(ins, idx))
+                        return true;
+        }
+
+        return false;
+}
index 227b943a8f9addb6724a9297aa014c221da87364..b494d3b5b2f82ebb42327fdf120154c649f6f794 100644 (file)
@@ -69,9 +69,13 @@ midgard_promote_uniforms(compiler_context *ctx, unsigned register_pressure)
                 ctx->uniform_cutoff = MAX2(ctx->uniform_cutoff, address + 1);
                 unsigned promoted = SSA_FIXED_REGISTER(uniform_reg);
 
-                /* We do need the move for safety for a non-SSA dest */
+                /* We do need the move for safety for a non-SSA dest, or if
+                 * we're being fed into a special class */
 
-                if (ins->ssa_args.dest >= ctx->func->impl->ssa_alloc) {
+                bool needs_move = ins->ssa_args.dest >= ctx->func->impl->ssa_alloc;
+                needs_move |= mir_special_index(ctx, ins->ssa_args.dest);
+
+                if (needs_move) {
                         midgard_instruction mov = v_mov(promoted, blank_alu_src, ins->ssa_args.dest);
                         mir_insert_instruction_before(ins, mov);
                 } else {