From: Alyssa Rosenzweig Date: Fri, 26 Jul 2019 16:20:52 +0000 (-0700) Subject: pan/midgard: Add mir_is_written_before helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=481447cb00821fdc81d7ab328a8c70a02546cf78;p=mesa.git pan/midgard: Add mir_is_written_before helper Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index f3fd92ad50b..528dfacdc3b 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -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 */ diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index d8e52982b68..61427e7c3d5 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -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; +}