treewide: Use nir_builder_create more
perl -p0e 's/nir_builder_init\(&([^,]*), /\1 = nir_builder_create(/g' -i $(git grep -l nir_builder_init) Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23860>
This commit is contained in:

committed by
Marge Bot

parent
815efcdf7e
commit
173b9ee69a
@@ -523,7 +523,7 @@ ac_nir_lower_tex(nir_shader *nir, const ac_nir_lower_tex_options *options)
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
|
||||
struct move_tex_coords_state state;
|
||||
nir_builder_init(&state.toplevel_b, impl);
|
||||
state.toplevel_b = nir_builder_create(impl);
|
||||
state.options = options;
|
||||
state.num_wqm_vgprs = 0;
|
||||
|
||||
|
@@ -518,7 +518,7 @@ radv_nir_apply_pipeline_layout(nir_shader *shader, struct radv_device *device,
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_builder_init(&b, function->impl);
|
||||
b = nir_builder_create(function->impl);
|
||||
|
||||
/* Iterate in reverse so load_ubo lowering can look at
|
||||
* the vulkan_resource_index to tell if it's an inline
|
||||
|
@@ -274,7 +274,7 @@ radv_nir_lower_fs_barycentric(nir_shader *shader, const struct radv_pipeline_key
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_builder_init(&b, function->impl);
|
||||
b = nir_builder_create(function->impl);
|
||||
|
||||
nir_foreach_block (block, impl) {
|
||||
nir_foreach_instr_safe (instr, block) {
|
||||
|
@@ -1534,7 +1534,7 @@ radv_nir_lower_rt_abi(nir_shader *shader, const VkRayTracingPipelineCreateInfoKH
|
||||
{
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
struct rt_variables vars = create_rt_variables(shader, pCreateInfo->flags);
|
||||
lower_rt_instructions(shader, &vars, 0);
|
||||
|
@@ -167,7 +167,7 @@ insert_sample_mask_write(nir_shader *s)
|
||||
{
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(s);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
b.cursor = nir_before_block(nir_start_block(impl));
|
||||
|
||||
/* Kill samples that are NOT covered by the mask */
|
||||
|
@@ -1010,7 +1010,7 @@ gl_nir_lower_packed_varyings(const struct gl_constants *consts,
|
||||
assert(f->impl == impl);
|
||||
}
|
||||
|
||||
nir_builder_init(&state.b, impl);
|
||||
state.b = nir_builder_create(impl);
|
||||
state.consts = consts;
|
||||
state.prog = prog;
|
||||
state.mem_ctx = mem_ctx;
|
||||
|
@@ -805,7 +805,7 @@ nir_visitor::visit(ir_function_signature *ir)
|
||||
|
||||
this->is_global = false;
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
b.cursor = nir_after_cf_list(&impl->body);
|
||||
|
||||
unsigned i = (ir->return_type != glsl_type::void_type) ? 1 : 0;
|
||||
|
@@ -833,7 +833,7 @@ bool
|
||||
nir_rematerialize_derefs_in_use_blocks_impl(nir_function_impl *impl)
|
||||
{
|
||||
struct rematerialize_deref_state state = { 0 };
|
||||
nir_builder_init(&state.builder, impl);
|
||||
state.builder = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block_unstructured(block, impl) {
|
||||
state.block = block;
|
||||
|
@@ -856,7 +856,7 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only)
|
||||
|
||||
struct from_ssa_state state;
|
||||
|
||||
nir_builder_init(&state.builder, impl);
|
||||
state.builder = nir_builder_create(impl);
|
||||
state.dead_ctx = ralloc_context(NULL);
|
||||
state.phi_webs_only = phi_webs_only;
|
||||
state.merge_node_table = _mesa_pointer_hash_table_create(NULL);
|
||||
|
@@ -328,7 +328,7 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars,
|
||||
if (!ucp_enables)
|
||||
return false;
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
/* NIR should ensure that, even in case of loops/if-else, there
|
||||
* should be only a single predecessor block to end_block, which
|
||||
@@ -409,7 +409,7 @@ nir_lower_clip_gs(nir_shader *shader, unsigned ucp_enables,
|
||||
create_clipdist_vars(shader, out, ucp_enables, true,
|
||||
use_clipdist_array);
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl)
|
||||
lower_clip_in_gs_block(&b, block, position, clipvertex, out,
|
||||
|
@@ -718,7 +718,7 @@ nir_lower_io_impl(nir_function_impl *impl,
|
||||
struct lower_io_state state;
|
||||
bool progress = false;
|
||||
|
||||
nir_builder_init(&state.builder, impl);
|
||||
state.builder = nir_builder_create(impl);
|
||||
state.dead_ctx = ralloc_context(NULL);
|
||||
state.modes = modes;
|
||||
state.type_size = type_size;
|
||||
|
@@ -298,7 +298,7 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl, uint8_t bool_bitsize)
|
||||
{
|
||||
struct locals_to_regs_state state;
|
||||
|
||||
nir_builder_init(&state.builder, impl);
|
||||
state.builder = nir_builder_create(impl);
|
||||
state.progress = false;
|
||||
state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal);
|
||||
state.bool_bitsize = bool_bitsize;
|
||||
|
@@ -32,7 +32,7 @@ lower_impl(nir_function_impl *impl)
|
||||
nir_variable *in, *out;
|
||||
nir_ssa_def *def;
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
b.cursor = nir_before_cf_list(&impl->body);
|
||||
|
||||
/* The edge flag is the last input in st/mesa. This code is also called by
|
||||
|
@@ -116,7 +116,7 @@ nir_lower_pntc_ytransform(nir_shader *shader,
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(&state.b, function->impl);
|
||||
state.b = nir_builder_create(function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
lower_pntc_ytransform_block(&state, block);
|
||||
|
@@ -40,7 +40,7 @@ lower_impl(nir_function_impl *impl,
|
||||
nir_builder b;
|
||||
nir_variable *in, *new_out = NULL;
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
in = nir_state_variable_create(shader, glsl_vec4_type(),
|
||||
"gl_PointSizeClampedMESA",
|
||||
|
@@ -280,7 +280,7 @@ nir_lower_returns_impl(nir_function_impl *impl)
|
||||
state.return_flag = NULL;
|
||||
state.has_predicated_return = false;
|
||||
state.removed_unreachable_code = false;
|
||||
nir_builder_init(&state.builder, impl);
|
||||
state.builder = nir_builder_create(impl);
|
||||
|
||||
bool progress = lower_returns_in_cf_list(&impl->body, &state);
|
||||
progress = progress || state.removed_unreachable_code;
|
||||
|
@@ -560,8 +560,8 @@ spill_ssa_defs_and_lower_shader_calls(nir_shader *shader, uint32_t num_calls,
|
||||
}
|
||||
|
||||
nir_builder before, after;
|
||||
nir_builder_init(&before, impl);
|
||||
nir_builder_init(&after, impl);
|
||||
before = nir_builder_create(impl);
|
||||
after = nir_builder_create(impl);
|
||||
|
||||
call_idx = 0;
|
||||
unsigned max_scratch_size = shader->scratch_size;
|
||||
|
@@ -400,7 +400,7 @@ static bool
|
||||
combine_stores_impl(struct combine_stores_state *state, nir_function_impl *impl)
|
||||
{
|
||||
state->progress = false;
|
||||
nir_builder_init(&state->b, impl);
|
||||
state->b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl)
|
||||
combine_stores_block(state, block);
|
||||
|
@@ -379,7 +379,7 @@ nir_opt_comparison_pre_impl(nir_function_impl *impl)
|
||||
nir_builder bld;
|
||||
|
||||
block_queue_init(&bq);
|
||||
nir_builder_init(&bld, impl);
|
||||
bld = nir_builder_create(impl);
|
||||
|
||||
nir_metadata_require(impl, nir_metadata_dominance);
|
||||
|
||||
|
@@ -124,7 +124,7 @@ nir_opt_conditional_discard(nir_shader *shader)
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(&builder, function->impl);
|
||||
builder = nir_builder_create(function->impl);
|
||||
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block_safe(block, function->impl) {
|
||||
|
@@ -640,7 +640,7 @@ opt_find_array_copies_impl(nir_function_impl *impl)
|
||||
s.dead_ctx = ralloc_context(NULL);
|
||||
s.var_nodes = _mesa_pointer_hash_table_create(s.dead_ctx);
|
||||
s.cast_nodes = _mesa_pointer_hash_table_create(s.dead_ctx);
|
||||
nir_builder_init(&s.builder, impl);
|
||||
s.builder = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
if (opt_find_array_copies_block(&b, block, &s))
|
||||
|
@@ -6629,7 +6629,7 @@ vtn_emit_kernel_entry_point_wrapper(struct vtn_builder *b,
|
||||
|
||||
nir_function *main_entry_point = nir_function_create(b->shader, func_name);
|
||||
nir_function_impl *impl = nir_function_impl_create(main_entry_point);
|
||||
nir_builder_init(&b->nb, impl);
|
||||
b->nb = nir_builder_create(impl);
|
||||
b->nb.cursor = nir_after_cf_list(&impl->body);
|
||||
b->func_param_idx = 0;
|
||||
|
||||
|
@@ -225,7 +225,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
|
||||
* directly in our OpFunctionParameter handler.
|
||||
*/
|
||||
nir_function_impl *impl = nir_function_impl_create(func);
|
||||
nir_builder_init(&b->nb, impl);
|
||||
b->nb = nir_builder_create(impl);
|
||||
b->nb.cursor = nir_before_cf_list(&impl->body);
|
||||
b->nb.exact = b->exact;
|
||||
|
||||
@@ -627,7 +627,7 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
|
||||
}
|
||||
|
||||
nir_function_impl *impl = func->nir_func->impl;
|
||||
nir_builder_init(&b->nb, impl);
|
||||
b->nb = nir_builder_create(impl);
|
||||
b->func = func;
|
||||
b->nb.cursor = nir_after_cf_list(&impl->body);
|
||||
b->nb.exact = b->exact;
|
||||
|
@@ -600,7 +600,7 @@ d3d12_add_missing_dual_src_target(struct nir_shader *s,
|
||||
assert(missing_mask != 0);
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(s);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
b.cursor = nir_before_cf_list(&impl->body);
|
||||
|
||||
nir_ssa_def *zero = nir_imm_zero(&b, 4, 32);
|
||||
@@ -629,7 +629,7 @@ d3d12_lower_primitive_id(nir_shader *shader)
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
nir_ssa_def *primitive_id;
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
nir_variable *primitive_id_var = nir_variable_create(shader, nir_var_shader_out,
|
||||
glsl_uint_type(), "primitive_id");
|
||||
@@ -745,7 +745,7 @@ d3d12_lower_triangle_strip(nir_shader *shader)
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
nir_variable *tmp_vars[VARYING_SLOT_MAX] = {0};
|
||||
nir_variable *out_vars[VARYING_SLOT_MAX] = {0};
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
shader->info.gs.vertices_out = (shader->info.gs.vertices_out - 2) * 3;
|
||||
|
||||
|
@@ -398,7 +398,7 @@ lower_gl_point_gs(nir_shader *shader)
|
||||
return false;
|
||||
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
b.cursor = nir_before_cf_list(&entry->body);
|
||||
|
||||
return nir_shader_instructions_pass(shader, lower_gl_point_gs_instr,
|
||||
@@ -640,7 +640,7 @@ lower_pv_mode_gs(nir_shader *shader, unsigned prim)
|
||||
memset(state.varyings, 0, sizeof(state.varyings));
|
||||
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
b.cursor = nir_before_cf_list(&entry->body);
|
||||
|
||||
state.primitive_vert_count =
|
||||
@@ -793,7 +793,7 @@ lower_line_stipple_gs(nir_shader *shader, bool line_rectangular)
|
||||
state.line_rectangular = line_rectangular;
|
||||
// initialize pos_counter and stipple_counter
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
b.cursor = nir_before_cf_list(&entry->body);
|
||||
nir_store_var(&b, state.pos_counter, nir_imm_int(&b, 0), 1);
|
||||
nir_store_var(&b, state.stipple_counter, nir_imm_float(&b, 0), 1);
|
||||
@@ -807,7 +807,7 @@ lower_line_stipple_fs(nir_shader *shader)
|
||||
{
|
||||
nir_builder b;
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
|
||||
// create stipple counter
|
||||
nir_variable *stipple = nir_variable_create(shader, nir_var_shader_in,
|
||||
@@ -1122,7 +1122,7 @@ lower_line_smooth_gs(nir_shader *shader)
|
||||
|
||||
// initialize pos_counter
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
b.cursor = nir_before_cf_list(&entry->body);
|
||||
nir_store_var(&b, state.pos_counter, nir_imm_int(&b, 0), 1);
|
||||
|
||||
@@ -1156,7 +1156,7 @@ lower_line_smooth_fs(nir_shader *shader, bool lower_stipple)
|
||||
|
||||
// initialize stipple_pattern
|
||||
nir_function_impl *entry = nir_shader_get_entrypoint(shader);
|
||||
nir_builder_init(&b, entry);
|
||||
b = nir_builder_create(entry);
|
||||
b.cursor = nir_before_cf_list(&entry->body);
|
||||
nir_ssa_def *pattern = nir_load_push_constant(&b, 1, 32,
|
||||
nir_imm_int(&b, ZINK_GFX_PUSHCONST_LINE_STIPPLE_PATTERN),
|
||||
@@ -2540,7 +2540,7 @@ clamp_layer_output(nir_shader *vs, nir_shader *fs, unsigned *next_location)
|
||||
} else {
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(vs);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
assert(impl->end_block->predecessors->entries == 1);
|
||||
b.cursor = nir_after_cf_list(&impl->body);
|
||||
clamp_layer_output_emit(&b, &state);
|
||||
|
@@ -61,7 +61,7 @@ void rogue_nir_pfo(nir_shader *shader)
|
||||
if (shader->info.stage != MESA_SHADER_FRAGMENT)
|
||||
return;
|
||||
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block (block, impl) {
|
||||
nir_foreach_instr_safe (instr, block) {
|
||||
|
@@ -639,7 +639,7 @@ brw_nir_initialize_mue(nir_shader *nir,
|
||||
|
||||
nir_builder b;
|
||||
nir_function_impl *entrypoint = nir_shader_get_entrypoint(nir);
|
||||
nir_builder_init(&b, entrypoint);
|
||||
b = nir_builder_create(entrypoint);
|
||||
b.cursor = nir_before_block(nir_start_block(entrypoint));
|
||||
|
||||
nir_ssa_def *dw_off = nir_imm_int(&b, 0);
|
||||
|
@@ -277,7 +277,7 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
|
||||
static void
|
||||
lower_cs_intrinsics_convert_impl(struct lower_intrinsics_state *state)
|
||||
{
|
||||
nir_builder_init(&state->builder, state->impl);
|
||||
state->builder = nir_builder_create(state->impl);
|
||||
|
||||
nir_foreach_block(block, state->impl) {
|
||||
lower_cs_intrinsics_convert_block(state, block);
|
||||
|
@@ -503,7 +503,7 @@ static void
|
||||
lower_ray_query_impl(nir_function_impl *impl, struct lowering_state *state)
|
||||
{
|
||||
nir_builder _b, *b = &_b;
|
||||
nir_builder_init(&_b, impl);
|
||||
_b = nir_builder_create(impl);
|
||||
|
||||
b->cursor = nir_before_block(nir_start_block(b->impl));
|
||||
|
||||
|
@@ -505,7 +505,7 @@ brw_nir_create_raygen_trampoline(const struct brw_compiler *compiler,
|
||||
|
||||
NIR_PASS_V(nir, brw_nir_lower_rt_intrinsics, devinfo);
|
||||
|
||||
nir_builder_init(&b, nir_shader_get_entrypoint(b.shader));
|
||||
b = nir_builder_create(nir_shader_get_entrypoint(b.shader));
|
||||
/* brw_nir_lower_rt_intrinsics will leave us with a btd_global_arg_addr
|
||||
* intrinsic which doesn't exist in compute shaders. We also created one
|
||||
* above when we generated the BTD spawn intrinsic. Now we go through and
|
||||
|
@@ -224,7 +224,7 @@ anv_nir_lower_multiview(nir_shader *shader, uint32_t view_mask,
|
||||
.view_mask = view_mask,
|
||||
};
|
||||
|
||||
nir_builder_init(&state.builder, entrypoint);
|
||||
state.builder = nir_builder_create(entrypoint);
|
||||
|
||||
nir_foreach_block(block, entrypoint) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
|
@@ -122,7 +122,7 @@ anv_nir_lower_set_vtx_and_prim_count(nir_shader *nir)
|
||||
if (state.primitive_count == NULL) {
|
||||
nir_builder b;
|
||||
nir_function_impl *entrypoint = nir_shader_get_entrypoint(nir);
|
||||
nir_builder_init(&b, entrypoint);
|
||||
b = nir_builder_create(entrypoint);
|
||||
b.cursor = nir_before_block(nir_start_block(entrypoint));
|
||||
nir_ssa_def *zero = nir_imm_int(&b, 0);
|
||||
state.primitive_count = anv_nir_prim_count_store(&b, zero);
|
||||
|
@@ -198,7 +198,7 @@ anv_nir_lower_multiview(nir_shader *shader, uint32_t view_mask)
|
||||
.view_mask = view_mask,
|
||||
};
|
||||
|
||||
nir_builder_init(&state.builder, entrypoint);
|
||||
state.builder = nir_builder_create(entrypoint);
|
||||
|
||||
nir_foreach_block(block, entrypoint) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
|
@@ -241,7 +241,7 @@ st_nir_add_point_size(nir_shader *nir)
|
||||
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
bool found = false;
|
||||
nir_foreach_block_safe(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
@@ -315,7 +315,7 @@ st_nir_zero_initialize_clip_distance(nir_shader *nir)
|
||||
return false;
|
||||
nir_builder b;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_builder_init(&b, impl);
|
||||
b = nir_builder_create(impl);
|
||||
b.cursor = nir_before_block(nir_start_block(impl));
|
||||
if (clip_dist0)
|
||||
zero_array_members(&b, clip_dist0);
|
||||
|
Reference in New Issue
Block a user