freedreno/ir3: make foreach_src declare cursor ptr
authorRob Clark <robdclark@chromium.org>
Sat, 16 May 2020 19:01:08 +0000 (12:01 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 19 May 2020 16:06:17 +0000 (16:06 +0000)
To match how the newer iterators work.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5048>

src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_a6xx.c
src/freedreno/ir3/ir3_cp.c
src/freedreno/ir3/ir3_delay.c
src/freedreno/ir3/ir3_legalize.c
src/freedreno/ir3/ir3_postsched.c
src/freedreno/ir3/ir3_ra.c
src/freedreno/ir3/ir3_ra.h

index 2974be2..547cf62 100644 (file)
@@ -1063,8 +1063,9 @@ static inline unsigned ir3_cat3_absneg(opc_t opc)
 /* iterator for an instructions's sources (reg), also returns src #: */
 #define foreach_src_n(__srcreg, __n, __instr) \
        if ((__instr)->regs_count) \
-               for (unsigned __cnt = (__instr)->regs_count - 1, __n = 0; __n < __cnt; __n++) \
-                       if ((__srcreg = (__instr)->regs[__n + 1]))
+               for (struct ir3_register *__srcreg = (void *)~0; __srcreg; __srcreg = NULL) \
+                       for (unsigned __cnt = (__instr)->regs_count - 1, __n = 0; __n < __cnt; __n++) \
+                               if ((__srcreg = (__instr)->regs[__n + 1]))
 
 /* iterator for an instructions's sources (reg): */
 #define foreach_src(__srcreg, __instr) \
@@ -1155,8 +1156,6 @@ static inline bool __is_false_dep(struct ir3_instruction *instr, unsigned n)
 static inline bool
 check_src_cond(struct ir3_instruction *instr, bool (*cond)(struct ir3_instruction *))
 {
-       struct ir3_register *reg;
-
        /* Note that this is also used post-RA so skip the ssa iterator: */
        foreach_src (reg, instr) {
                struct ir3_instruction *src = reg->instr;
index e297e34..cef110d 100644 (file)
@@ -445,8 +445,6 @@ ir3_a6xx_fixup_atomic_dests(struct ir3 *ir, struct ir3_shader_variant *so)
 
        foreach_block (block, &ir->block_list) {
                foreach_instr_safe (instr, &block->instr_list) {
-                       struct ir3_register *reg;
-
                        foreach_src (reg, instr) {
                                struct ir3_instruction *src = reg->instr;
 
index f3116b8..7b6c365 100644 (file)
@@ -639,8 +639,6 @@ eliminate_output_mov(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr)
 static void
 instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr)
 {
-       struct ir3_register *reg;
-
        if (instr->regs_count == 0)
                return;
 
index 15434fd..2ea8ee5 100644 (file)
@@ -49,7 +49,6 @@ ignore_dep(struct ir3_instruction *assigner,
 
        if (assigner->barrier_class & IR3_BARRIER_ARRAY_W) {
                struct ir3_register *dst = assigner->regs[0];
-               struct ir3_register *src;
 
                debug_assert(dst->flags & IR3_REG_ARRAY);
 
@@ -198,7 +197,6 @@ delay_calc_srcn(struct ir3_block *block,
        unsigned delay = 0;
 
        if (is_meta(assigner)) {
-               struct ir3_register *src;
                foreach_src (src, assigner) {
                        unsigned d;
 
@@ -320,7 +318,6 @@ ir3_delay_calc(struct ir3_block *block, struct ir3_instruction *instr,
                bool soft, bool pred)
 {
        unsigned delay = 0;
-       struct ir3_register *src;
 
        foreach_src_n (src, i, instr) {
                unsigned d = 0;
index a143c4d..c59c065 100644 (file)
@@ -113,7 +113,6 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
        list_inithead(&block->instr_list);
 
        foreach_instr_safe (n, &instr_list) {
-               struct ir3_register *reg;
                unsigned i;
 
                n->flags &= ~(IR3_INSTR_SS | IR3_INSTR_SY);
@@ -151,7 +150,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
                 * resulting in undefined results:
                 */
                for (i = 0; i < n->regs_count; i++) {
-                       reg = n->regs[i];
+                       struct ir3_register *reg = n->regs[i];
 
                        if (reg_gpr(reg)) {
 
@@ -181,7 +180,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
                }
 
                if (n->regs_count > 0) {
-                       reg = n->regs[0];
+                       struct ir3_register *reg = n->regs[0];
                        if (regmask_get(&state->needs_ss_war, reg)) {
                                n->flags |= IR3_INSTR_SS;
                                last_input_needs_ss = false;
index a9a14d2..109b964 100644 (file)
@@ -400,7 +400,6 @@ static void
 calculate_deps(struct ir3_postsched_deps_state *state,
                struct ir3_postsched_node *node)
 {
-       struct ir3_register *reg;
        int b;
 
        /* Add dependencies on instructions that previously (or next,
@@ -441,7 +440,7 @@ calculate_deps(struct ir3_postsched_deps_state *state,
        /* And then after we update the state for what this instruction
         * wrote:
         */
-       reg = node->instr->regs[0];
+       struct ir3_register *reg = node->instr->regs[0];
        if (reg->flags & IR3_REG_RELATIV) {
                /* mark the entire array as written: */
                struct ir3_array *arr = ir3_lookup_array(state->ctx->ir, reg->array.id);
@@ -679,7 +678,6 @@ cleanup_self_movs(struct ir3 *ir)
 {
        foreach_block (block, &ir->block_list) {
                foreach_instr_safe (instr, &block->instr_list) {
-                       struct ir3_register *reg;
 
                        foreach_src (reg, instr) {
                                if (!reg->instr)
index 72e145c..cc05d0c 100644 (file)
@@ -156,7 +156,6 @@ get_definer(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr,
                 * need to find the distance between where actual array starts
                 * and collect..  that probably doesn't happen currently.
                 */
-               struct ir3_register *src;
                int dsz, doff;
 
                /* note: don't use foreach_ssa_src as this gets called once
@@ -1238,7 +1237,6 @@ static void
 ra_block_alloc(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 {
        foreach_instr (instr, &block->instr_list) {
-               struct ir3_register *reg;
 
                if (writes_gpr(instr)) {
                        if (should_assign(ctx, instr)) {
@@ -1481,7 +1479,6 @@ ra_precolor_assigned(struct ir3_ra_ctx *ctx)
 
                        precolor(ctx, instr);
 
-                       struct ir3_register *src;
                        foreach_src (src, instr) {
                                if (!src->instr)
                                        continue;
@@ -1519,7 +1516,6 @@ ra_sanity_check(struct ir3 *ir)
                                debug_assert(dst->num == (src->num + instr->split.off));
                        } else if (instr->opc == OPC_META_COLLECT) {
                                struct ir3_register *dst = instr->regs[0];
-                               struct ir3_register *src;
 
                                foreach_src_n (src, n, instr) {
                                        debug_assert(dst->num == (src->num - n));
index 7acfdd0..437223b 100644 (file)
@@ -308,7 +308,6 @@ __ra_init_use_itr(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr)
 
        ctx->namecnt = ctx->nameidx = 0;
 
-       struct ir3_register *reg;
        foreach_src (reg, instr) {
                if (reg->flags & IR3_REG_ARRAY) {
                        struct ir3_array *arr =