pan/midgard: Add mir_rewrite_index_src_single helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 19 Jul 2019 17:50:34 +0000 (10:50 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 22 Jul 2019 15:20:34 +0000 (08:20 -0700)
Rather than rewriting an index away across the whole block, we expose
finer (per-instruction) granularity for rewrites.

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

index 2af902dbe7150b2809f8a070d80c51c53c7ad77f..294831c352e2a90880e4b02b56bf5f49858640b5 100644 (file)
@@ -365,6 +365,7 @@ mir_is_alu_bundle(midgard_bundle *bundle)
 void mir_rewrite_index(compiler_context *ctx, unsigned old, unsigned new);
 void mir_rewrite_index_src(compiler_context *ctx, unsigned old, unsigned new);
 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);
 
 /* MIR printing */
 
index 6adc1350c0a25980aebc9ce03c106c04a651039c..c606cb3ddf798e10e098c0307121b9075499d545 100644 (file)
 
 #include "compiler.h"
 
+void mir_rewrite_index_src_single(midgard_instruction *ins, unsigned old, unsigned new)
+{
+        if (ins->ssa_args.src0 == old)
+                ins->ssa_args.src0 = new;
+
+        if (ins->ssa_args.src1 == old &&
+            !ins->ssa_args.inline_constant)
+                ins->ssa_args.src1 = new;
+}
+
+
 void
 mir_rewrite_index_src(compiler_context *ctx, unsigned old, unsigned new)
 {
         mir_foreach_instr_global(ctx, ins) {
-                if (ins->ssa_args.src0 == old)
-                        ins->ssa_args.src0 = new;
-
-                if (ins->ssa_args.src1 == old &&
-                    !ins->ssa_args.inline_constant)
-                        ins->ssa_args.src1 = new;
+                mir_rewrite_index_src_single(ins, old, new);
         }
 }