summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/ir3/ir3_ra.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-02-02 12:54:25 -0500
committerRob Clark <[email protected]>2015-03-08 17:42:43 -0400
commitf8f7548f466509bf881db1826ef6dd23ffe2acdf (patch)
tree13d3cd580e757965f3fbd0120c3130ee654132d0 /src/gallium/drivers/freedreno/ir3/ir3_ra.c
parent26b79ac3e40624726bff5101dfe892d3ee2ba607 (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3/ir3_ra.c')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_ra.c19
1 files changed, 11 insertions, 8 deletions
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);
}
}