pan/midgard: Add mir_is_written_before helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 26 Jul 2019 16:20:52 +0000 (09:20 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 26 Jul 2019 16:20:52 +0000 (09:20 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/mir.c

index f3fd92a..528dfac 100644 (file)
@@ -381,6 +381,7 @@ void mir_rewrite_index_src_tag(compiler_context *ctx, unsigned old, unsigned new
 bool mir_single_use(compiler_context *ctx, unsigned value);
 bool mir_special_index(compiler_context *ctx, unsigned idx);
 unsigned mir_use_count(compiler_context *ctx, unsigned value);
+bool mir_is_written_before(compiler_context *ctx, midgard_instruction *ins, unsigned node);
 
 /* MIR printing */
 
index d8e5298..61427e7 100644 (file)
@@ -175,3 +175,22 @@ mir_special_index(compiler_context *ctx, unsigned idx)
 
         return false;
 }
+
+/* Is a node written before a given instruction? */
+
+bool
+mir_is_written_before(compiler_context *ctx, midgard_instruction *ins, unsigned node)
+{
+        if ((node < 0) || (node >= SSA_FIXED_MINIMUM))
+                return true;
+
+        mir_foreach_instr_global(ctx, q) {
+                if (q == ins)
+                        break;
+
+                if (q->ssa_args.dest == node)
+                        return true;
+        }
+
+        return false;
+}