Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
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 */
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;
+}