From 4413537c80b58978f61f468a5a36d1d75756d6b3 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 21 Jan 2020 15:07:24 -0800 Subject: [PATCH] util: Remove tmp argument from BITSET_FOREACH_SET macro Reviewed-by: Jason Ekstrand Tested-by: Marge Bot Part-of: --- src/compiler/nir/nir_phi_builder.c | 3 +-- .../drivers/etnaviv/etnaviv_compiler_nir_emit.h | 5 ++--- src/gallium/drivers/lima/ir/gp/regalloc.c | 13 +++++-------- src/intel/compiler/test_eu_validate.cpp | 9 +++------ src/mesa/main/performance_monitor.c | 3 +-- src/mesa/state_tracker/st_cb_perfmon.c | 3 +-- src/panfrost/midgard/midgard_schedule.c | 8 +++----- src/util/bitset.h | 8 ++++---- src/util/register_allocate.c | 3 +-- 9 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/compiler/nir/nir_phi_builder.c b/src/compiler/nir/nir_phi_builder.c index 97edea777f4..f8de1d78fc9 100644 --- a/src/compiler/nir/nir_phi_builder.c +++ b/src/compiler/nir/nir_phi_builder.c @@ -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; diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h index 0948a5b307f..fc6a8569aa0 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h @@ -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]); } diff --git a/src/gallium/drivers/lima/ir/gp/regalloc.c b/src/gallium/drivers/lima/ir/gp/regalloc.c index 91590d7364f..b268841839d 100644 --- a/src/gallium/drivers/lima/ir/gp/regalloc.c +++ b/src/gallium/drivers/lima/ir/gp/regalloc.c @@ -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); } diff --git a/src/intel/compiler/test_eu_validate.cpp b/src/intel/compiler/test_eu_validate.cpp index 6e099b553f7..16d1fc4faae 100644 --- a/src/intel/compiler/test_eu_validate.cpp +++ b/src/intel/compiler/test_eu_validate.cpp @@ -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; diff --git a/src/mesa/main/performance_monitor.c b/src/mesa/main/performance_monitor.c index 253d42d989c..3273f156368 100644 --- a/src/mesa/main/performance_monitor.c +++ b/src/mesa/main/performance_monitor.c @@ -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 */ diff --git a/src/mesa/state_tracker/st_cb_perfmon.c b/src/mesa/state_tracker/st_cb_perfmon.c index 914831f3d03..8025cb4a452 100644 --- a/src/mesa/state_tracker/st_cb_perfmon.c +++ b/src/mesa/state_tracker/st_cb_perfmon.c @@ -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]; diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index b88fe0e03c7..59efeb5a4f7 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -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; diff --git a/src/util/bitset.h b/src/util/bitset.h index f58d9f214e6..0fdfe205f39 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -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 diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c index 35273630459..85453d25290 100644 --- a/src/util/register_allocate.c +++ b/src/util/register_allocate.c @@ -342,10 +342,9 @@ void ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r) { struct ra_reg *reg = ®s->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 = ®s->regs[c]; unsigned i; for (i = 0; i < BITSET_WORDS(regs->count); i++) -- 2.30.2