diff --git a/src/asahi/compiler/agx_opt_promote_constants.c b/src/asahi/compiler/agx_opt_promote_constants.c index 1a21f62127f..1d508840c55 100644 --- a/src/asahi/compiler/agx_opt_promote_constants.c +++ b/src/asahi/compiler/agx_opt_promote_constants.c @@ -84,8 +84,7 @@ pass(agx_context *ctx, void *memctx) uint64_t *values = rzalloc_array(memctx, uint64_t, ctx->alloc); /* Set of SSA indices that map to immediate values */ - BITSET_WORD *is_immediate = - rzalloc_array(memctx, BITSET_WORD, BITSET_WORDS(ctx->alloc)); + BITSET_WORD *is_immediate = BITSET_RZALLOC(memctx, ctx->alloc); /* Gather constant definitions and use */ agx_foreach_instr_global(ctx, I) { diff --git a/src/asahi/compiler/agx_pressure_schedule.c b/src/asahi/compiler/agx_pressure_schedule.c index 82c2b81b5c0..35961bee876 100644 --- a/src/asahi/compiler/agx_pressure_schedule.c +++ b/src/asahi/compiler/agx_pressure_schedule.c @@ -204,8 +204,7 @@ pressure_schedule_block(agx_context *ctx, agx_block *block, struct sched_ctx *s) signed orig_max_pressure = 0; unsigned nr_ins = 0; - memcpy(s->live, block->live_out, - BITSET_WORDS(ctx->alloc) * sizeof(BITSET_WORD)); + memcpy(s->live, block->live_out, BITSET_BYTES(ctx->alloc)); agx_foreach_instr_in_block_rev(block, I) { pressure += calculate_pressure_delta(I, s->live); @@ -214,8 +213,7 @@ pressure_schedule_block(agx_context *ctx, agx_block *block, struct sched_ctx *s) nr_ins++; } - memcpy(s->live, block->live_out, - BITSET_WORDS(ctx->alloc) * sizeof(BITSET_WORD)); + memcpy(s->live, block->live_out, BITSET_BYTES(ctx->alloc)); /* off by a constant, that's ok */ signed max_pressure = 0; diff --git a/src/asahi/compiler/agx_spill.c b/src/asahi/compiler/agx_spill.c index c47a9a940de..98c318aa8a3 100644 --- a/src/asahi/compiler/agx_spill.c +++ b/src/asahi/compiler/agx_spill.c @@ -1205,8 +1205,8 @@ agx_spill(agx_context *ctx, unsigned k, bool remat_only) BITSET_WORD *S = ralloc_array(memctx, BITSET_WORD, BITSET_WORDS(n)); agx_foreach_block(ctx, block) { - memset(W, 0, BITSET_WORDS(n) * sizeof(BITSET_WORD)); - memset(S, 0, BITSET_WORDS(n) * sizeof(BITSET_WORD)); + memset(W, 0, BITSET_BYTES(n)); + memset(S, 0, BITSET_BYTES(n)); struct spill_ctx sctx = { .memctx = memctx, diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 980f3ba73f4..f9a899e161b 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -567,7 +567,7 @@ add_var_use_deref(nir_deref_instr *deref, struct hash_table *live, ainfo = ralloc(live, struct uniform_array_info); unsigned num_bits = MAX2(1, glsl_get_aoa_size(deref->var->type)); - ainfo->indices = rzalloc_array(live, BITSET_WORD, BITSET_WORDS(num_bits)); + ainfo->indices = BITSET_RZALLOC(live, num_bits); ainfo->deref_list = ralloc(live, struct util_dynarray); util_dynarray_init(ainfo->deref_list, live); diff --git a/src/compiler/glsl/gl_nir_link_varyings.c b/src/compiler/glsl/gl_nir_link_varyings.c index 699c6272895..e1f40f415dd 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.c +++ b/src/compiler/glsl/gl_nir_link_varyings.c @@ -1976,8 +1976,7 @@ xfb_decl_store(struct xfb_decl *xfb_decl, const struct gl_constants *consts, assert(last_component < max_components); if (!used_components[buffer]) { - used_components[buffer] = - rzalloc_array(mem_ctx, BITSET_WORD, BITSET_WORDS(max_components)); + used_components[buffer] = BITSET_RZALLOC(mem_ctx, max_components); } used = used_components[buffer]; diff --git a/src/compiler/isaspec/isaspec_decode_impl.c b/src/compiler/isaspec/isaspec_decode_impl.c index 19643d9bd28..c3f9a5ce108 100644 --- a/src/compiler/isaspec/isaspec_decode_impl.c +++ b/src/compiler/isaspec/isaspec_decode_impl.c @@ -967,10 +967,8 @@ isa_disasm(void *bin, int sz, FILE *out, const struct isa_decode_options *option state->num_instr = sz / (BITMASK_WORDS * sizeof(BITSET_WORD)); if (state->options->branch_labels) { - state->branch_targets = rzalloc_size(state, - sizeof(BITSET_WORD) * BITSET_WORDS(state->num_instr)); - state->call_targets = rzalloc_size(state, - sizeof(BITSET_WORD) * BITSET_WORDS(state->num_instr)); + state->branch_targets = BITSET_RZALLOC(state, state->num_instr); + state->call_targets = BITSET_RZALLOC(state, state->num_instr); /* Do a pre-pass to find all the branch targets: */ state->print.out = fopen("/dev/null", "w"); diff --git a/src/compiler/nir/nir_opt_call.c b/src/compiler/nir/nir_opt_call.c index 59d355489df..7b8747d3b48 100644 --- a/src/compiler/nir/nir_opt_call.c +++ b/src/compiler/nir/nir_opt_call.c @@ -50,7 +50,7 @@ remat_ssa_def(nir_builder *b, nir_def *def, struct hash_table *remap_table, struct hash_table *phi_value_table, struct nir_phi_builder *phi_builder, BITSET_WORD *def_blocks) { - memset(def_blocks, 0, BITSET_WORDS(b->impl->num_blocks) * sizeof(BITSET_WORD)); + memset(def_blocks, 0, BITSET_BYTES(b->impl->num_blocks)); BITSET_SET(def_blocks, nir_def_block(def)->index); BITSET_SET(def_blocks, nir_cursor_current_block(b->cursor)->index); struct nir_phi_builder_value *val = diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c index a61e6964c56..759c798e690 100644 --- a/src/compiler/nir/nir_opt_dce.c +++ b/src/compiler/nir/nir_opt_dce.c @@ -215,8 +215,7 @@ nir_opt_dce_impl(nir_function_impl *impl) { assert(impl->structured); - BITSET_WORD *defs_live = rzalloc_array(NULL, BITSET_WORD, - BITSET_WORDS(impl->ssa_alloc)); + BITSET_WORD *defs_live = BITSET_RZALLOC(NULL, impl->ssa_alloc); struct exec_list dead_instrs; exec_list_make_empty(&dead_instrs); diff --git a/src/compiler/nir/nir_opt_load_skip_helpers.c b/src/compiler/nir/nir_opt_load_skip_helpers.c index e0a17c12bb0..75010065dc3 100644 --- a/src/compiler/nir/nir_opt_load_skip_helpers.c +++ b/src/compiler/nir/nir_opt_load_skip_helpers.c @@ -98,8 +98,7 @@ nir_opt_load_skip_helpers(nir_shader *shader, nir_opt_load_skip_helpers_options nir_function_impl *impl = nir_shader_get_entrypoint(shader); struct helper_state hs = { - .needs_helpers = rzalloc_array(NULL, BITSET_WORD, - BITSET_WORDS(impl->ssa_alloc)), + .needs_helpers = BITSET_RZALLOC(NULL, impl->ssa_alloc), .options = options, }; nir_instr_worklist_init(&hs.worklist); diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 012554ccc28..d2769a796d2 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -1828,7 +1828,7 @@ validate_dominance(nir_function_impl *impl, validate_state *state) state->block = NULL; } - memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); + memset(state->ssa_defs_found, 0, BITSET_BYTES(impl->ssa_alloc)); validate_ssa_dominance(impl, state); /* Restore the old dominance metadata */ @@ -1931,10 +1931,10 @@ validate_divergence(nir_function_impl *impl, validate_state *state) block_divergence_metadata *blocks = ralloc_array(state->mem_ctx, block_divergence_metadata, state->blocks->size); - BITSET_WORD *ssa_divergence = rzalloc_array(state->mem_ctx, BITSET_WORD, - BITSET_WORDS(impl->ssa_alloc)); - BITSET_WORD *loop_invariance = rzalloc_array(state->mem_ctx, BITSET_WORD, - BITSET_WORDS(impl->ssa_alloc)); + BITSET_WORD *ssa_divergence = BITSET_RZALLOC(state->mem_ctx, + impl->ssa_alloc); + BITSET_WORD *loop_invariance = BITSET_RZALLOC(state->mem_ctx, + impl->ssa_alloc); set_foreach(state->blocks, entry) { nir_block *block = (nir_block *)entry->key; @@ -2158,7 +2158,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) state->ssa_defs_found = reralloc(state->mem_ctx, state->ssa_defs_found, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); - memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); + memset(state->ssa_defs_found, 0, BITSET_BYTES(impl->ssa_alloc)); _mesa_set_clear(state->blocks, NULL); _mesa_set_resize(state->blocks, impl->num_blocks); @@ -2346,7 +2346,7 @@ nir_validate_ssa_dominance(nir_shader *shader, const char *when) state.ssa_defs_found = reralloc(state.mem_ctx, state.ssa_defs_found, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); - memset(state.ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); + memset(state.ssa_defs_found, 0, BITSET_BYTES(impl->ssa_alloc)); state.impl = impl; validate_ssa_dominance(impl, &state); diff --git a/src/freedreno/ir3/ir3_shared_ra.c b/src/freedreno/ir3/ir3_shared_ra.c index a122c17e728..4a0b6ef041d 100644 --- a/src/freedreno/ir3/ir3_shared_ra.c +++ b/src/freedreno/ir3/ir3_shared_ra.c @@ -1238,8 +1238,7 @@ record_pred_live_outs(struct ra_ctx *ctx, struct ir3_block *block) if (state->visited) continue; - state->live_out = rzalloc_array(NULL, BITSET_WORD, - BITSET_WORDS(ctx->live->definitions_count)); + state->live_out = BITSET_RZALLOC(NULL, ctx->live->definitions_count); rb_tree_foreach (struct ra_interval, interval, diff --git a/src/freedreno/ir3/ir3_spill.c b/src/freedreno/ir3/ir3_spill.c index c665eb18abc..1e5f39aa3f4 100644 --- a/src/freedreno/ir3/ir3_spill.c +++ b/src/freedreno/ir3/ir3_spill.c @@ -1791,8 +1791,7 @@ record_pred_live_outs(struct ra_spill_ctx *ctx, struct ir3_block *block) if (state->visited) continue; - state->live_out = rzalloc_array(ctx, BITSET_WORD, - BITSET_WORDS(ctx->live->definitions_count)); + state->live_out = BITSET_RZALLOC(ctx, ctx->live->definitions_count); rb_tree_foreach (struct ra_spill_interval, interval, diff --git a/src/freedreno/ir3/ir3_validate.c b/src/freedreno/ir3/ir3_validate.c index b920273af66..ba98c1dac68 100644 --- a/src/freedreno/ir3/ir3_validate.c +++ b/src/freedreno/ir3/ir3_validate.c @@ -628,7 +628,7 @@ ir3_validate(struct ir3 *ir) ctx->ir = ir; ctx->defs_count = ir->instr_count + 1; /* serialno comes from pre-incrementing this. */ - ctx->defs = rzalloc_array(ctx, BITSET_WORD, BITSET_WORDS(ctx->defs_count)); + ctx->defs = BITSET_RZALLOC(ctx, ctx->defs_count); ctx->rpt_set = _mesa_pointer_set_create(ctx); ctx->rpt_block = NULL; diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 6d2b7f7d16d..fa1a3ce0d35 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -484,7 +484,7 @@ ntt_allocate_regs(struct ntt_compile *c, nir_function_impl *impl) ntt_live_regs(c, impl); unsigned *ra_map = ralloc_array(c, unsigned, c->num_temps); - unsigned *released = rzalloc_array(c, BITSET_WORD, BITSET_WORDS(c->num_temps)); + unsigned *released = BITSET_RZALLOC(c, c->num_temps); /* No RA on NIR array regs */ for (int i = 0; i < c->first_non_array_temp; i++) diff --git a/src/imagination/pco/pco_trans_nir.c b/src/imagination/pco/pco_trans_nir.c index e82f1922ff5..26acb2a742a 100644 --- a/src/imagination/pco/pco_trans_nir.c +++ b/src/imagination/pco/pco_trans_nir.c @@ -3796,10 +3796,8 @@ static pco_func *trans_func(trans_ctx *tctx, nir_function_impl *impl) assert(func->num_params == 0 && func->params == NULL); /* Gather types. */ - tctx->float_types = - rzalloc_array(NULL, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); - tctx->int_types = - rzalloc_array(NULL, BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); + tctx->float_types = BITSET_RZALLOC(NULL, impl->ssa_alloc); + tctx->int_types = BITSET_RZALLOC(NULL, impl->ssa_alloc); nir_gather_types(impl, tctx->float_types, tctx->int_types); tctx->flag = PCO_CF_NODE_FLAG_BODY; diff --git a/src/kosmickrisp/vulkan/kk_query_table.c b/src/kosmickrisp/vulkan/kk_query_table.c index 1ab205de0c2..8a0833e4019 100644 --- a/src/kosmickrisp/vulkan/kk_query_table.c +++ b/src/kosmickrisp/vulkan/kk_query_table.c @@ -33,7 +33,7 @@ kk_query_table_grow_locked(struct kk_device *dev, struct kk_query_table *table, table->bo = bo; assert((new_alloc % BITSET_WORDBITS) == 0); - const size_t new_in_use_size = BITSET_WORDS(new_alloc) * sizeof(BITSET_WORD); + const size_t new_in_use_size = BITSET_BYTES(new_alloc); new_in_use = vk_realloc(&dev->vk.alloc, table->in_use, new_in_use_size, sizeof(BITSET_WORD), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); diff --git a/src/mesa/main/performance_monitor.c b/src/mesa/main/performance_monitor.c index efe524ea85b..e1d0f88d336 100644 --- a/src/mesa/main/performance_monitor.c +++ b/src/mesa/main/performance_monitor.c @@ -467,8 +467,7 @@ new_performance_monitor(struct gl_context *ctx, GLuint index) for (i = 0; i < ctx->PerfMonitor.NumGroups; i++) { const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[i]; - m->ActiveCounters[i] = rzalloc_array(m->ActiveCounters, BITSET_WORD, - BITSET_WORDS(g->NumCounters)); + m->ActiveCounters[i] = BITSET_RZALLOC(m->ActiveCounters, g->NumCounters); if (m->ActiveCounters[i] == NULL) goto fail; } diff --git a/src/nouveau/vulkan/nvk_descriptor_table.c b/src/nouveau/vulkan/nvk_descriptor_table.c index 77e5fc19ea8..4bb5e1d8942 100644 --- a/src/nouveau/vulkan/nvk_descriptor_table.c +++ b/src/nouveau/vulkan/nvk_descriptor_table.c @@ -27,10 +27,8 @@ nvk_descriptor_table_grow_locked(struct nvk_device *dev, assert((table->alloc % BITSET_WORDBITS) == 0); assert((new_alloc % BITSET_WORDBITS) == 0); - const size_t old_in_use_size = - BITSET_WORDS(table->alloc) * sizeof(BITSET_WORD); - const size_t new_in_use_size = - BITSET_WORDS(new_alloc) * sizeof(BITSET_WORD); + const size_t old_in_use_size = BITSET_BYTES(table->alloc); + const size_t new_in_use_size = BITSET_BYTES(new_alloc); new_in_use = vk_realloc(&dev->vk.alloc, table->in_use, new_in_use_size, sizeof(BITSET_WORD), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); diff --git a/src/panfrost/compiler/bi_pressure_schedule.c b/src/panfrost/compiler/bi_pressure_schedule.c index dc56d2879de..1ee5b9f3ee6 100644 --- a/src/panfrost/compiler/bi_pressure_schedule.c +++ b/src/panfrost/compiler/bi_pressure_schedule.c @@ -246,8 +246,7 @@ pressure_schedule_block(bi_context *ctx, bi_block *block, struct sched_ctx *s) signed orig_max_pressure = 0; unsigned nr_ins = 0; - memcpy(s->live, block->ssa_live_out, - BITSET_WORDS(ctx->ssa_alloc) * sizeof(BITSET_WORD)); + memcpy(s->live, block->ssa_live_out, BITSET_BYTES(ctx->ssa_alloc)); bi_foreach_instr_in_block_rev(block, I) { pressure += calculate_pressure_delta(I, s->live); @@ -256,8 +255,7 @@ pressure_schedule_block(bi_context *ctx, bi_block *block, struct sched_ctx *s) nr_ins++; } - memcpy(s->live, block->ssa_live_out, - BITSET_WORDS(ctx->ssa_alloc) * sizeof(BITSET_WORD)); + memcpy(s->live, block->ssa_live_out, BITSET_BYTES(ctx->ssa_alloc)); /* off by a constant, that's ok */ signed max_pressure = 0; diff --git a/src/panfrost/compiler/bi_spill_ssa.c b/src/panfrost/compiler/bi_spill_ssa.c index c787f42dc94..59503dc1e80 100644 --- a/src/panfrost/compiler/bi_spill_ssa.c +++ b/src/panfrost/compiler/bi_spill_ssa.c @@ -1422,8 +1422,8 @@ bi_spill_ssa(bi_context *ctx, unsigned k, unsigned spill_base) memset(mem_map, 0xff, sizeof(uint32_t) * n); bi_foreach_block(ctx, block) { - memset(W, 0, BITSET_WORDS(n) * sizeof(BITSET_WORD)); - memset(S, 0, BITSET_WORDS(n) * sizeof(BITSET_WORD)); + memset(W, 0, BITSET_BYTES(n)); + memset(S, 0, BITSET_BYTES(n)); struct spill_ctx sctx = { .memctx = memctx, diff --git a/src/panfrost/compiler/valhall/va_optimize.c b/src/panfrost/compiler/valhall/va_optimize.c index c55c99e352f..2051a721d65 100644 --- a/src/panfrost/compiler/valhall/va_optimize.c +++ b/src/panfrost/compiler/valhall/va_optimize.c @@ -366,8 +366,7 @@ va_optimize_forward(bi_context *ctx) unsigned count = ctx->ssa_alloc; bi_instr **lut = rzalloc_array(ctx, bi_instr *, count); bi_instr **uses = rzalloc_array(ctx, bi_instr *, count); - BITSET_WORD *multiple = - rzalloc_array(ctx, BITSET_WORD, BITSET_WORDS(count)); + BITSET_WORD *multiple = BITSET_RZALLOC(ctx, count); if (!lut || !uses || !multiple) goto out; diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 3b7eebb5cf7..f70127428c5 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -1460,7 +1460,7 @@ schedule_block(compiler_context *ctx, midgard_block *block) mir_create_dependency_graph(instructions, len, node_count); /* Allocate the worklist */ - size_t sz = BITSET_WORDS(len) * sizeof(BITSET_WORD); + size_t sz = BITSET_BYTES(len); BITSET_WORD *worklist = calloc(sz, 1); uint16_t *liveness = calloc(node_count, 2); mir_initialize_worklist(worklist, instructions, len); diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c index 8c3296c342e..daba52a48a2 100644 --- a/src/util/register_allocate.c +++ b/src/util/register_allocate.c @@ -901,7 +901,7 @@ ra_compute_available_regs(struct ra_graph *g, unsigned int n, BITSET_WORD *regs) struct ra_class *c = g->regs->classes[g->nodes[n].class]; /* Populate with the set of regs that are in the node's class. */ - memcpy(regs, c->regs, BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD)); + memcpy(regs, c->regs, BITSET_BYTES(g->regs->count)); /* Remove any regs that conflict with nodes that we're adjacent to and have * already colored. @@ -946,7 +946,7 @@ ra_select(struct ra_graph *g) BITSET_WORD *select_regs = NULL; if (g->select_reg_callback) - select_regs = malloc(BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD)); + select_regs = malloc(BITSET_BYTES(g->regs->count)); while (g->tmp.stack_count != 0) { unsigned int ri;