diff options
author | Rob Clark <[email protected]> | 2015-02-02 12:54:25 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2015-03-08 17:42:43 -0400 |
commit | f8f7548f466509bf881db1826ef6dd23ffe2acdf (patch) | |
tree | 13d3cd580e757965f3fbd0120c3130ee654132d0 /src/gallium/drivers/freedreno/ir3/ir3_depth.c | |
parent | 26b79ac3e40624726bff5101dfe892d3ee2ba607 (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_depth.c')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_depth.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_depth.c b/src/gallium/drivers/freedreno/ir3/ir3_depth.c index 8ff62ba70a6..0cda62bf102 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_depth.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_depth.c @@ -102,7 +102,7 @@ static void insert_by_depth(struct ir3_instruction *instr) static void ir3_instr_depth(struct ir3_instruction *instr) { - unsigned i; + struct ir3_instruction *src; /* if we've already visited this instruction, bail now: */ if (ir3_instr_check_mark(instr)) @@ -110,19 +110,15 @@ static void ir3_instr_depth(struct ir3_instruction *instr) instr->depth = 0; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *src = instr->regs[i]; - if (src->flags & IR3_REG_SSA) { - unsigned sd; + foreach_ssa_src_n(src, i, instr) { + unsigned sd; - /* visit child to compute it's depth: */ - ir3_instr_depth(src->instr); + /* visit child to compute it's depth: */ + ir3_instr_depth(src); - sd = ir3_delayslots(src->instr, instr, i-1) + - src->instr->depth; + sd = ir3_delayslots(src, instr, i) + src->depth; - instr->depth = MAX2(instr->depth, sd); - } + instr->depth = MAX2(instr->depth, sd); } /* meta-instructions don't add cycles, other than PHI.. which |