From f8f7548f466509bf881db1826ef6dd23ffe2acdf Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 2 Feb 2015 12:54:25 -0500 Subject: freedreno/ir3: helpful iterator macros I remembered that we are using c99.. which makes some sugary iterator macros easier. So introduce iterator macros to iterate all src registers and all SSA src instructions. The _n variants also return the src #, since there are a handful of places that need this. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_ra.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gallium/drivers/freedreno/ir3/ir3_ra.c') diff --git a/src/gallium/drivers/freedreno/ir3/ir3_ra.c b/src/gallium/drivers/freedreno/ir3/ir3_ra.c index 75ea4d69301..03180b13b18 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_ra.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_ra.c @@ -389,7 +389,7 @@ static void instr_assign_src(struct ir3_ra_ctx *ctx, static void instr_assign(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr, unsigned name) { - struct ir3_instruction *n; + struct ir3_instruction *n, *src; struct ir3_register *reg = instr->regs[0]; /* check if already assigned: */ @@ -404,12 +404,15 @@ static void instr_assign(struct ir3_ra_ctx *ctx, /* and rename any subsequent use of result of this instr: */ for (n = instr->next; n && !ctx->error; n = n->next) { - unsigned i; + foreach_ssa_src_n(src, i, n) { + unsigned r = i + 1; - for (i = 1; i < n->regs_count; i++) { - reg = n->regs[i]; - if ((reg->flags & IR3_REG_SSA) && (reg->instr == instr)) - instr_assign_src(ctx, n, i, name); + /* skip address / etc (non real sources): */ + if (r >= n->regs_count) + continue; + + if (src == instr) + instr_assign_src(ctx, n, r, name); } } @@ -420,9 +423,9 @@ static void instr_assign(struct ir3_ra_ctx *ctx, * to the actual instruction: */ if (is_meta(instr) && (instr->opc == OPC_META_FO)) { - struct ir3_instruction *src = ssa(instr->regs[1]); debug_assert(name >= instr->fo.off); - if (src) + + foreach_ssa_src(src, instr) instr_assign(ctx, src, name - instr->fo.off); } } -- cgit v1.2.3