util: Remove tmp argument from BITSET_FOREACH_SET macro
authorMatt Turner <mattst88@gmail.com>
Tue, 21 Jan 2020 23:07:24 +0000 (15:07 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jan 2020 01:52:43 +0000 (01:52 +0000)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3499>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3499>

src/compiler/nir/nir_phi_builder.c
src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h
src/gallium/drivers/lima/ir/gp/regalloc.c
src/intel/compiler/test_eu_validate.cpp
src/mesa/main/performance_monitor.c
src/mesa/state_tracker/st_cb_perfmon.c
src/panfrost/midgard/midgard_schedule.c
src/util/bitset.h
src/util/register_allocate.c

index 97edea777f4dfabfcc437effbc9d9fdba4a32698..f8de1d78fc97677d218ecf69037c3d7c5d73aa09 100644 (file)
@@ -132,8 +132,7 @@ nir_phi_builder_add_value(struct nir_phi_builder *pb, unsigned num_components,
 
    pb->iter_count++;
 
-   BITSET_WORD tmp;
-   BITSET_FOREACH_SET(i, tmp, defs, pb->num_blocks) {
+   BITSET_FOREACH_SET(i, defs, pb->num_blocks) {
       if (pb->work[i] < pb->iter_count)
          pb->W[w_end++] = pb->blocks[i];
       pb->work[i] = pb->iter_count;
index 0948a5b307f04249bdea3320c3c2789d12650c77..fc6a8569aa076903952b112bd86698aa349e05fa 100644 (file)
@@ -814,13 +814,12 @@ live_defs(nir_function_impl *impl, struct live_def *defs, unsigned *live_map)
    /* apply live_in/live_out to ranges */
 
    nir_foreach_block(block, impl) {
-      BITSET_WORD tmp;
       int i;
 
-      BITSET_FOREACH_SET(i, tmp, block->live_in, state.num_defs)
+      BITSET_FOREACH_SET(i, block->live_in, state.num_defs)
          range_include(&state.defs[i], block_live_index[block->index]);
 
-      BITSET_FOREACH_SET(i, tmp, block->live_out, state.num_defs)
+      BITSET_FOREACH_SET(i, block->live_out, state.num_defs)
          range_include(&state.defs[i], block_live_index[block->index + 1]);
    }
 
index 91590d7364f1924e99821cf4c45fc5132968389f..b268841839d7f0340521a1f0131ac6edd059454c 100644 (file)
@@ -191,14 +191,13 @@ static void add_all_interferences(struct regalloc_ctx *ctx,
                                   BITSET_WORD *live_regs)
 {
    int live_node;
-   BITSET_WORD tmp;
-   BITSET_FOREACH_SET(live_node, tmp, live_nodes, ctx->comp->cur_index) {
+   BITSET_FOREACH_SET(live_node, live_nodes, ctx->comp->cur_index) {
       add_interference(ctx, i,
                        live_node + ctx->comp->cur_reg);
    }
 
    int live_reg;
-   BITSET_FOREACH_SET(live_reg, tmp, ctx->live, ctx->comp->cur_index) {
+   BITSET_FOREACH_SET(live_reg, ctx->live, ctx->comp->cur_index) {
       add_interference(ctx, i, live_reg);
    }
 
@@ -211,11 +210,10 @@ static void print_liveness(struct regalloc_ctx *ctx,
       return;
 
    int live_idx;
-   BITSET_WORD tmp;
-   BITSET_FOREACH_SET(live_idx, tmp, live_reg, ctx->comp->cur_reg) {
+   BITSET_FOREACH_SET(live_idx, live_reg, ctx->comp->cur_reg) {
       printf("reg%d ", live_idx);
    }
-   BITSET_FOREACH_SET(live_idx, tmp, live_val, ctx->comp->cur_index) {
+   BITSET_FOREACH_SET(live_idx, live_val, ctx->comp->cur_index) {
       printf("%d ", live_idx);
    }
    printf("\n");
@@ -446,8 +444,7 @@ static void assign_regs(struct regalloc_ctx *ctx)
       block->live_out_phys = 0;
 
       int reg_idx;
-      BITSET_WORD tmp;
-      BITSET_FOREACH_SET(reg_idx, tmp, block->live_out, ctx->comp->cur_reg) {
+      BITSET_FOREACH_SET(reg_idx, block->live_out, ctx->comp->cur_reg) {
          if (BITSET_TEST(block->def_out, reg_idx)) {
             block->live_out_phys |= (1ull << ctx->registers[reg_idx].assigned_color);
          }
index 6e099b553f7cb51d17ff1daf39681fda62d2b606..16d1fc4faae17d242a26d07e9869fca36d4e2f53 100644 (file)
@@ -353,8 +353,7 @@ TEST_P(validation_test, invalid_type_encoding)
        * encodings are rejected by the validator.
        */
       int e;
-      BITSET_WORD tmp;
-      BITSET_FOREACH_SET(e, tmp, invalid_encodings, num_encodings) {
+      BITSET_FOREACH_SET(e, invalid_encodings, num_encodings) {
          if (file == FIXED_GRF) {
             brw_MOV(p, g0, g0);
             brw_inst_set_src0_vstride(&devinfo, last_inst, BRW_VERTICAL_STRIDE_4);
@@ -432,8 +431,7 @@ TEST_P(validation_test, invalid_type_encoding_3src_a16)
     * encodings are rejected by the validator.
     */
    int e;
-   BITSET_WORD tmp;
-   BITSET_FOREACH_SET(e, tmp, invalid_encodings, num_encodings) {
+   BITSET_FOREACH_SET(e, invalid_encodings, num_encodings) {
       for (unsigned i = 0; i < 2; i++) {
          if (i == 0) {
             brw_MAD(p, g0, g0, g0, g0);
@@ -525,8 +523,7 @@ TEST_P(validation_test, invalid_type_encoding_3src_a1)
     * encodings are rejected by the validator.
     */
    int e;
-   BITSET_WORD tmp;
-   BITSET_FOREACH_SET(e, tmp, invalid_encodings, num_encodings) {
+   BITSET_FOREACH_SET(e, invalid_encodings, num_encodings) {
       const unsigned hw_type = e & 0x7;
       const unsigned exec_type = e >> 3;
 
index 253d42d989c507ba7aeff35a52c4611c73e83bbc..3273f156368ed6468c2c2b9db8c50f9b8418a47f 100644 (file)
@@ -568,9 +568,8 @@ perf_monitor_result_size(const struct gl_context *ctx,
 
    for (group = 0; group < ctx->PerfMonitor.NumGroups; group++) {
       const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[group];
-      BITSET_WORD tmp;
 
-      BITSET_FOREACH_SET(counter, tmp, m->ActiveCounters[group], g->NumCounters) {
+      BITSET_FOREACH_SET(counter, m->ActiveCounters[group], g->NumCounters) {
          const struct gl_perf_monitor_counter *c = &g->Counters[counter];
 
          size += sizeof(uint32_t); /* Group ID */
index 914831f3d03a3671ebbc585330391b6d77911d2c..8025cb4a4522e3c70312f2c20bcc425e35820f07 100644 (file)
@@ -88,9 +88,8 @@ init_perf_monitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
    for (gid = 0; gid < ctx->PerfMonitor.NumGroups; gid++) {
       const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[gid];
       const struct st_perf_monitor_group *stg = &st->perfmon[gid];
-      BITSET_WORD tmp;
 
-      BITSET_FOREACH_SET(cid, tmp, m->ActiveCounters[gid], g->NumCounters) {
+      BITSET_FOREACH_SET(cid, m->ActiveCounters[gid], g->NumCounters) {
          const struct st_perf_monitor_counter *stc = &stg->counters[cid];
          struct st_perf_counter_object *cntr =
             &stm->active_counters[stm->num_active_counters];
index b88fe0e03c74f01819d3618059051ce517823978..59efeb5a4f76598000947d28fe29aefb3dde1557 100644 (file)
@@ -300,8 +300,7 @@ mir_update_worklist(
          * where possible. */
 
         unsigned i;
-        BITSET_WORD tmp;
-        BITSET_FOREACH_SET(i, tmp, done->dependents, count) {
+        BITSET_FOREACH_SET(i, done->dependents, count) {
                 assert(instructions[i]->nr_dependencies);
 
                 if (!(--instructions[i]->nr_dependencies))
@@ -482,7 +481,6 @@ mir_choose_instruction(
 
         /* Iterate to find the best instruction satisfying the predicate */
         unsigned i;
-        BITSET_WORD tmp;
 
         signed best_index = -1;
         bool best_conditional = false;
@@ -494,11 +492,11 @@ mir_choose_instruction(
         unsigned max_active = 0;
         unsigned max_distance = 6;
 
-        BITSET_FOREACH_SET(i, tmp, worklist, count) {
+        BITSET_FOREACH_SET(i, worklist, count) {
                 max_active = MAX2(max_active, i);
         }
 
-        BITSET_FOREACH_SET(i, tmp, worklist, count) {
+        BITSET_FOREACH_SET(i, worklist, count) {
                 if ((max_active - i) >= max_distance)
                         continue;
 
index f58d9f214e647c98ecb3f8752212c50fe6dda08b..0fdfe205f39e93ed525ae8f74bebd5310bce06dc 100644 (file)
@@ -133,13 +133,13 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp,
  * Iterates over each set bit in a set
  *
  * @param __i    iteration variable, bit number
- * @param __tmp  an internally-used temporary bitset
  * @param __set  the bitset to iterate (will not be modified)
  * @param __size number of bits in the set to consider
  */
-#define BITSET_FOREACH_SET(__i, __tmp, __set, __size) \
-   for (__tmp = *(__set), __i = 0; \
-        (__i = __bitset_next_set(__i, &__tmp, __set, __size)) < __size;)
+#define BITSET_FOREACH_SET(__i, __set, __size) \
+   for (BITSET_WORD __tmp = *(__set), *__foo = &__tmp; __foo != NULL; __foo = NULL) \
+      for (__i = 0; \
+           (__i = __bitset_next_set(__i, &__tmp, __set, __size)) < __size;)
 
 #ifdef __cplusplus
 
index 352736304599100178c71a84dae40f7dbe289e66..85453d2529021dba62847e3b7608ea8009acd2c4 100644 (file)
@@ -342,10 +342,9 @@ void
 ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r)
 {
    struct ra_reg *reg = &regs->regs[r];
-   BITSET_WORD tmp;
    int c;
 
-   BITSET_FOREACH_SET(c, tmp, reg->conflicts, regs->count) {
+   BITSET_FOREACH_SET(c, reg->conflicts, regs->count) {
       struct ra_reg *other = &regs->regs[c];
       unsigned i;
       for (i = 0; i < BITSET_WORDS(regs->count); i++)