diff --git a/src/amd/common/ac_nir.c b/src/amd/common/ac_nir.c index 118a4ca0e37..cdb609c05fb 100644 --- a/src/amd/common/ac_nir.c +++ b/src/amd/common/ac_nir.c @@ -1080,11 +1080,8 @@ ac_nir_lower_legacy_gs(nir_shader *nir, nir_function_impl *impl = nir_shader_get_entrypoint(nir); - nir_builder builder; + nir_builder builder = nir_builder_at(nir_after_cf_list(&impl->body)); nir_builder *b = &builder; - nir_builder_init(b, impl); - - b->cursor = nir_after_cf_list(&impl->body); /* Emit shader query for mix use legacy/NGG GS */ bool progress = ac_nir_gs_shader_query(b, diff --git a/src/amd/common/ac_nir_lower_ngg.c b/src/amd/common/ac_nir_lower_ngg.c index 12c25e038f0..d32dae39e90 100644 --- a/src/amd/common/ac_nir_lower_ngg.c +++ b/src/amd/common/ac_nir_lower_ngg.c @@ -2363,9 +2363,8 @@ ac_nir_lower_ngg_nogs(nir_shader *shader, const ac_nir_lower_ngg_options *option shader->info.outputs_written |= VARYING_BIT_PRIMITIVE_ID; } - nir_builder builder; + nir_builder builder = nir_builder_create(impl); nir_builder *b = &builder; /* This is to avoid the & */ - nir_builder_init(b, impl); if (options->can_cull) { analyze_shader_before_culling(shader, &state); @@ -3440,10 +3439,8 @@ ac_nir_lower_ngg_gs(nir_shader *shader, const ac_nir_lower_ngg_options *options) nir_cf_list extracted; nir_cf_extract(&extracted, nir_before_cf_list(&impl->body), nir_after_cf_list(&impl->body)); - nir_builder builder; + nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body)); nir_builder *b = &builder; /* This is to avoid the & */ - nir_builder_init(b, impl); - b->cursor = nir_before_cf_list(&impl->body); /* Workgroup barrier: wait for ES threads */ nir_scoped_barrier(b, .execution_scope=SCOPE_WORKGROUP, .memory_scope=SCOPE_WORKGROUP, @@ -4767,10 +4764,8 @@ ac_nir_lower_ngg_ms(nir_shader *shader, state.primitive_count_var = nir_local_variable_create(impl, glsl_uint_type(), "primitive_count_var"); - nir_builder builder; + nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body)); nir_builder *b = &builder; /* This is to avoid the & */ - nir_builder_init(b, impl); - b->cursor = nir_before_cf_list(&impl->body); handle_smaller_ms_api_workgroup(b, &state); ms_emit_legacy_workgroup_index(b, &state); diff --git a/src/amd/common/ac_nir_lower_ps.c b/src/amd/common/ac_nir_lower_ps.c index 84425ec3449..670e5ab8776 100644 --- a/src/amd/common/ac_nir_lower_ps.c +++ b/src/amd/common/ac_nir_lower_ps.c @@ -853,9 +853,8 @@ ac_nir_lower_ps(nir_shader *nir, const ac_nir_lower_ps_options *options) { nir_function_impl *impl = nir_shader_get_entrypoint(nir); - nir_builder builder; + nir_builder builder = nir_builder_create(impl); nir_builder *b = &builder; - nir_builder_init(b, impl); lower_ps_state state = { .options = options, diff --git a/src/amd/common/ac_nir_lower_tess_io_to_mem.c b/src/amd/common/ac_nir_lower_tess_io_to_mem.c index 086e2170305..8035af4a1fc 100644 --- a/src/amd/common/ac_nir_lower_tess_io_to_mem.c +++ b/src/amd/common/ac_nir_lower_tess_io_to_mem.c @@ -559,10 +559,8 @@ hs_emit_write_tess_factors(nir_shader *shader, /* We assume there is always a single end block in the shader. */ - nir_builder builder; + nir_builder builder = nir_builder_at(nir_after_block(last_block)); nir_builder *b = &builder; /* This is to avoid the & */ - nir_builder_init(b, impl); - b->cursor = nir_after_block(last_block); /* If tess factors are load from LDS, wait previous LDS stores done. */ if (!st->tcs_pass_tessfactors_by_reg) { diff --git a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c index 773d26ebee4..2404882d862 100644 --- a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c +++ b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c @@ -495,9 +495,7 @@ gl_nir_lower_blend_equation_advanced(nir_shader *sh, bool coherent) sh->info.fs.uses_sample_shading = true; - nir_builder b; - nir_builder_init(&b, impl); - b.cursor = nir_after_block(nir_impl_last_block(impl)); + nir_builder b = nir_builder_at(nir_after_block(nir_impl_last_block(impl))); nir_variable *fb = nir_variable_create(sh, nir_var_shader_out, glsl_vec4_type(), diff --git a/src/compiler/nir/nir_opt_preamble.c b/src/compiler/nir/nir_opt_preamble.c index 80af6230873..5962f43bd22 100644 --- a/src/compiler/nir/nir_opt_preamble.c +++ b/src/compiler/nir/nir_opt_preamble.c @@ -524,10 +524,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, _mesa_pointer_hash_table_create(NULL); nir_function_impl *preamble = nir_shader_get_preamble(impl->function->shader); - nir_builder _b; - nir_builder *b = &_b; - nir_builder_init(b, preamble); - b->cursor = nir_before_cf_list(&preamble->body); + nir_builder preamble_builder = nir_builder_at(nir_before_cf_list(&preamble->body)); + nir_builder *b = &preamble_builder; nir_foreach_block (block, impl) { nir_foreach_instr (instr, block) { @@ -570,7 +568,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options, } } - nir_builder_init(b, impl); + nir_builder builder = nir_builder_create(impl); + b = &builder; nir_foreach_block (block, impl) { nir_foreach_instr_safe (instr, block) { diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c index 3c2c104614e..89f9d170e7f 100644 --- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c +++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c @@ -350,9 +350,8 @@ copy_ubo_to_uniform(nir_shader *nir, const struct ir3_const_state *const_state) return false; nir_function_impl *preamble = nir_shader_get_preamble(nir); - nir_builder _b, *b = &_b; - nir_builder_init(b, preamble); - b->cursor = nir_after_cf_list(&preamble->body); + nir_builder _b = nir_builder_at(nir_after_cf_list(&preamble->body)); + nir_builder *b = &_b; for (unsigned i = 0; i < state->num_enabled; i++) { const struct ir3_ubo_range *range = &state->range[i]; diff --git a/src/freedreno/ir3/ir3_nir_opt_preamble.c b/src/freedreno/ir3/ir3_nir_opt_preamble.c index 59ad228bb7c..6db45b9fdf6 100644 --- a/src/freedreno/ir3/ir3_nir_opt_preamble.c +++ b/src/freedreno/ir3/ir3_nir_opt_preamble.c @@ -310,9 +310,8 @@ ir3_nir_lower_preamble(nir_shader *nir, struct ir3_shader_variant *v) BITSET_DECLARE(promoted_to_float, preamble_size); memset(promoted_to_float, 0, sizeof(promoted_to_float)); - nir_builder _b; - nir_builder *b = &_b; - nir_builder_init(b, main); + nir_builder builder_main = nir_builder_create(main); + nir_builder *b = &builder_main; nir_foreach_block (block, main) { nir_foreach_instr_safe (instr, block) { @@ -350,7 +349,8 @@ ir3_nir_lower_preamble(nir_shader *nir, struct ir3_shader_variant *v) } } - nir_builder_init(b, preamble); + nir_builder builder_preamble = nir_builder_create(preamble); + b = &builder_preamble; nir_foreach_block (block, preamble) { nir_foreach_instr_safe (instr, block) { diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c index 9020406cc0e..16a4694bf3d 100644 --- a/src/gallium/auxiliary/nir/nir_draw_helpers.c +++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c @@ -104,9 +104,7 @@ static void nir_lower_pstipple_impl(nir_function_impl *impl, lower_pstipple *state) { - nir_builder *b = &state->b; - - nir_builder_init(b, impl); + state->b = nir_builder_create(impl); nir_block *start = nir_start_block(impl); nir_lower_pstipple_block(start, state); @@ -313,13 +311,10 @@ static void nir_lower_aapoint_impl(nir_function_impl *impl, lower_aapoint *state, nir_alu_type bool_type) { - nir_builder *b = &state->b; - - nir_builder_init(b, impl); - nir_block *block = nir_start_block(impl); - b->cursor = nir_before_block(block); + state->b = nir_builder_at(nir_before_block(block)); + nir_builder *b = &state->b; nir_ssa_def *aainput = nir_load_var(b, state->input); nir_ssa_def *dist = nir_fadd(b, nir_fmul(b, nir_channel(b, aainput, 0), nir_channel(b, aainput, 0)), diff --git a/src/gallium/drivers/r600/sfn/sfn_nir_lower_tess_io.cpp b/src/gallium/drivers/r600/sfn/sfn_nir_lower_tess_io.cpp index 5c7c3e77bda..27a5714eae3 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir_lower_tess_io.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir_lower_tess_io.cpp @@ -530,12 +530,11 @@ r600_append_tcs_TF_emission(nir_shader *shader, enum mesa_prim prim_type) } } } - nir_builder builder; - nir_builder *b = &builder; assert(exec_list_length(&shader->functions) == 1); nir_function *f = (nir_function *)shader->functions.get_head(); - nir_builder_init(b, f->impl); + nir_builder builder = nir_builder_create(f->impl); + nir_builder *b = &builder; auto outer_comps = outer_tf_components(prim_type); if (!outer_comps) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index ad5990ceb63..45387d0b359 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1931,11 +1931,8 @@ static void si_nir_lower_ps_color_input(nir_shader *nir, struct si_shader *shade { nir_function_impl *impl = nir_shader_get_entrypoint(nir); - nir_builder builder; + nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body)); nir_builder *b = &builder; - nir_builder_init(b, impl); - - b->cursor = nir_before_cf_list(&impl->body); const struct si_shader_selector *sel = shader->selector; const union si_shader_key *key = &shader->key; @@ -2015,11 +2012,8 @@ static void si_nir_emit_polygon_stipple(nir_shader *nir, struct si_shader_args * { nir_function_impl *impl = nir_shader_get_entrypoint(nir); - nir_builder builder; + nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body)); nir_builder *b = &builder; - nir_builder_init(b, impl); - - b->cursor = nir_before_cf_list(&impl->body); /* Load the buffer descriptor. */ nir_ssa_def *desc = diff --git a/src/intel/compiler/brw_kernel.c b/src/intel/compiler/brw_kernel.c index 67f004e10aa..c920bb5c269 100644 --- a/src/intel/compiler/brw_kernel.c +++ b/src/intel/compiler/brw_kernel.c @@ -56,12 +56,11 @@ load_clc_shader(struct brw_compiler *compiler, struct disk_cache *disk_cache, } } -static void -builder_init_new_impl(nir_builder *b, nir_function *func) +static nir_builder +builder_init_new_impl(nir_function *func) { nir_function_impl *impl = nir_function_impl_create(func); - nir_builder_init(b, impl); - b->cursor = nir_before_cf_list(&impl->body); + return nir_builder_at(nir_before_cf_list(&impl->body)); } static void @@ -69,9 +68,7 @@ implement_atomic_builtin(nir_function *func, nir_atomic_op atomic_op, enum glsl_base_type data_base_type, nir_variable_mode mode) { - nir_builder b; - builder_init_new_impl(&b, func); - + nir_builder b = builder_init_new_impl(func); const struct glsl_type *data_type = glsl_scalar_type(data_base_type); unsigned p = 0; @@ -103,9 +100,7 @@ implement_atomic_builtin(nir_function *func, nir_atomic_op atomic_op, static void implement_sub_group_ballot_builtin(nir_function *func) { - nir_builder b; - builder_init_new_impl(&b, func); - + nir_builder b = builder_init_new_impl(func); nir_deref_instr *ret = nir_build_deref_cast(&b, nir_load_param(&b, 0), nir_var_function_temp, glsl_uint_type(), 0); diff --git a/src/intel/vulkan/anv_nir_compute_push_layout.c b/src/intel/vulkan/anv_nir_compute_push_layout.c index 18fcd879df8..b1ef69ec0e1 100644 --- a/src/intel/vulkan/anv_nir_compute_push_layout.c +++ b/src/intel/vulkan/anv_nir_compute_push_layout.c @@ -144,8 +144,8 @@ anv_nir_compute_push_layout(nir_shader *nir, if (has_push_intrinsic) { nir_foreach_function_impl(impl, nir) { - nir_builder build, *b = &build; - nir_builder_init(b, impl); + nir_builder build = nir_builder_create(impl); + nir_builder *b = &build; nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) {