From 1f297471a0bec68c1410e96e64c686537cd60860 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 19 Jul 2019 10:50:34 -0700 Subject: [PATCH] pan/midgard: Add mir_rewrite_index_src_single helper Rather than rewriting an index away across the whole block, we expose finer (per-instruction) granularity for rewrites. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 1 + src/panfrost/midgard/mir.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index 2af902dbe71..294831c352e 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -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 */ diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 6adc1350c0a..c606cb3ddf7 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -23,16 +23,22 @@ #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); } } -- 2.30.2