From 69ba1c4d596a453530553b8b004a157d8c7292d7 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 8 Sep 2021 16:41:00 +0100 Subject: [PATCH] nir: adjust nir_src_copy signature to take a nir_instr * This is almost always a nir_instr and updating the src of a nir_if will have to work slightly differently in the future. Signed-off-by: Rhys Perry Acked-by: Alyssa Rosenzweig Reviewed-by: Jason Ekstrand Reviewed-by: Emma Anholt Part-of: --- src/amd/vulkan/radv_nir_lower_ycbcr_textures.c | 2 +- src/compiler/glsl/glsl_to_nir.cpp | 2 +- src/compiler/nir/nir.c | 20 +++++++++++++------- src/compiler/nir/nir.h | 2 +- src/compiler/nir/nir_builtin_builder.c | 4 ++-- src/compiler/nir/nir_deref.c | 4 ++-- src/compiler/nir/nir_from_ssa.c | 2 +- src/compiler/nir/nir_lower_atomics_to_ssbo.c | 12 ++++++------ src/compiler/nir/nir_lower_indirect_derefs.c | 2 +- src/compiler/nir/nir_lower_io.c | 2 +- src/compiler/nir/nir_lower_locals_to_regs.c | 2 +- src/compiler/nir/nir_lower_ssbo.c | 8 ++++---- src/compiler/nir/nir_lower_subgroups.c | 10 +++++----- src/compiler/nir/nir_lower_tex.c | 8 ++++---- src/compiler/nir/nir_opt_peephole_select.c | 4 ++-- src/compiler/nir/nir_search.c | 3 +-- .../drivers/lima/ir/lima_nir_split_load_input.c | 2 +- .../drivers/r600/sfn/tests/sfn_valuefactory_test.cpp | 2 +- src/gallium/drivers/zink/zink_compiler.c | 2 +- .../drivers/zink/zink_lower_cubemap_to_array.c | 4 ++-- src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 2 +- src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c | 2 +- src/microsoft/compiler/dxil_nir_lower_int_samplers.c | 6 +++--- src/panfrost/midgard/midgard_errata_lod.c | 2 +- 24 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c index 4cc322a..ce7fb83 100644 --- a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c +++ b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c @@ -134,7 +134,7 @@ create_plane_tex_instr_implicit(struct ycbcr_state *state, uint32_t plane) } FALLTHROUGH; default: - nir_src_copy(&tex->src[i].src, &old_tex->src[i].src, tex); + nir_src_copy(&tex->src[i].src, &old_tex->src[i].src, &tex->instr); break; } } diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index f38df40..a3035ab 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -1704,7 +1704,7 @@ nir_visitor::visit(ir_call *ir) nir_ssa_def *val = evaluate_rvalue(param_rvalue); nir_src src = nir_src_for_ssa(val); - nir_src_copy(&call->params[i], &src, call); + nir_src_copy(&call->params[i], &src, &call->instr); } else if (sig_param->data.mode == ir_var_function_inout) { unreachable("unimplemented: inout parameters"); } diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 03ac7b0..934081f 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -451,10 +451,8 @@ static void dest_free_indirects(nir_dest *dest) } } -/* NOTE: if the instruction you are copying a src to is already added - * to the IR, use nir_instr_rewrite_src() instead. - */ -void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx) +static void +src_copy(nir_src *dest, const nir_src *src) { src_free_indirects(dest); @@ -466,13 +464,21 @@ void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx) dest->reg.reg = src->reg.reg; if (src->reg.indirect) { dest->reg.indirect = calloc(1, sizeof(nir_src)); - nir_src_copy(dest->reg.indirect, src->reg.indirect, mem_ctx); + src_copy(dest->reg.indirect, src->reg.indirect); } else { dest->reg.indirect = NULL; } } } +/* NOTE: if the instruction you are copying a src to is already added + * to the IR, use nir_instr_rewrite_src() instead. + */ +void nir_src_copy(nir_src *dest, const nir_src *src, nir_instr *instr) +{ + src_copy(dest, src); +} + void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr) { /* Copying an SSA definition makes no sense whatsoever. */ @@ -496,7 +502,7 @@ void nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, nir_alu_instr *instr) { - nir_src_copy(&dest->src, &src->src, &instr->instr); + nir_src_copy(&dest->src, &src->src, instr ? &instr->instr : NULL); dest->abs = src->abs; dest->negate = src->negate; for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) @@ -1706,7 +1712,7 @@ nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src) assert(!src_is_valid(src) || src->parent_if == if_stmt); src_remove_all_uses(src); - nir_src_copy(src, &new_src, if_stmt); + src_copy(src, &new_src); src_add_all_uses(src, NULL, if_stmt); } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 4219123..403b12b 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1137,7 +1137,7 @@ nir_is_sequential_comp_swizzle(uint8_t *swiz, unsigned nr_comp) return true; } -void nir_src_copy(nir_src *dest, const nir_src *src, void *instr_or_if); +void nir_src_copy(nir_src *dest, const nir_src *src, nir_instr *instr); void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr); typedef struct { diff --git a/src/compiler/nir/nir_builtin_builder.c b/src/compiler/nir/nir_builtin_builder.c index 26b5241..bd11159 100644 --- a/src/compiler/nir/nir_builtin_builder.c +++ b/src/compiler/nir/nir_builtin_builder.c @@ -366,7 +366,7 @@ nir_get_texture_size(nir_builder *b, nir_tex_instr *tex) tex->src[i].src_type == nir_tex_src_sampler_offset || tex->src[i].src_type == nir_tex_src_texture_handle || tex->src[i].src_type == nir_tex_src_sampler_handle) { - nir_src_copy(&txs->src[idx].src, &tex->src[i].src, txs); + nir_src_copy(&txs->src[idx].src, &tex->src[i].src, &txs->instr); txs->src[idx].src_type = tex->src[i].src_type; idx++; } @@ -421,7 +421,7 @@ nir_get_texture_lod(nir_builder *b, nir_tex_instr *tex) tex->src[i].src_type == nir_tex_src_sampler_offset || tex->src[i].src_type == nir_tex_src_texture_handle || tex->src[i].src_type == nir_tex_src_sampler_handle) { - nir_src_copy(&tql->src[idx].src, &tex->src[i].src, tql); + nir_src_copy(&tql->src[idx].src, &tex->src[i].src, &tql->instr); tql->src[idx].src_type = tex->src[i].src_type; idx++; } diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index 7427835..e03be3a 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -757,7 +757,7 @@ rematerialize_deref_in_block(nir_deref_instr *deref, parent = rematerialize_deref_in_block(parent, state); new_deref->parent = nir_src_for_ssa(&parent->dest.ssa); } else { - nir_src_copy(&new_deref->parent, &deref->parent, new_deref); + nir_src_copy(&new_deref->parent, &deref->parent, &new_deref->instr); } } @@ -774,7 +774,7 @@ rematerialize_deref_in_block(nir_deref_instr *deref, case nir_deref_type_array: case nir_deref_type_ptr_as_array: assert(!nir_src_as_deref(deref->arr.index)); - nir_src_copy(&new_deref->arr.index, &deref->arr.index, new_deref); + nir_src_copy(&new_deref->arr.index, &deref->arr.index, &new_deref->instr); break; case nir_deref_type_struct: diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index 3292c1f..32ce928 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -644,7 +644,7 @@ emit_copy(nir_builder *b, nir_src src, nir_src dest_src) assert(src.reg.reg->num_components >= dest_src.reg.reg->num_components); nir_alu_instr *mov = nir_alu_instr_create(b->shader, nir_op_mov); - nir_src_copy(&mov->src[0].src, &src, mov); + nir_src_copy(&mov->src[0].src, &src, &mov->instr); mov->dest.dest = nir_dest_for_reg(dest_src.reg.reg); mov->dest.write_mask = (1 << dest_src.reg.reg->num_components) - 1; diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c index 4abf83f..fe8a673 100644 --- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c +++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c @@ -122,7 +122,7 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b, un /* remapped to ssbo_atomic_add: { buffer_idx, offset, +1 } */ temp = nir_imm_int(b, +1); new_instr->src[0] = nir_src_for_ssa(buffer); - nir_src_copy(&new_instr->src[1], &instr->src[0], new_instr); + nir_src_copy(&new_instr->src[1], &instr->src[0], &new_instr->instr); new_instr->src[2] = nir_src_for_ssa(temp); break; case nir_intrinsic_atomic_counter_pre_dec: @@ -131,22 +131,22 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b, un /* NOTE semantic difference so we adjust the return value below */ temp = nir_imm_int(b, -1); new_instr->src[0] = nir_src_for_ssa(buffer); - nir_src_copy(&new_instr->src[1], &instr->src[0], new_instr); + nir_src_copy(&new_instr->src[1], &instr->src[0], &new_instr->instr); new_instr->src[2] = nir_src_for_ssa(temp); break; case nir_intrinsic_atomic_counter_read: /* remapped to load_ssbo: { buffer_idx, offset } */ new_instr->src[0] = nir_src_for_ssa(buffer); - nir_src_copy(&new_instr->src[1], &instr->src[0], new_instr); + nir_src_copy(&new_instr->src[1], &instr->src[0], &new_instr->instr); break; default: /* remapped to ssbo_atomic_x: { buffer_idx, offset, data, (compare)? } */ new_instr->src[0] = nir_src_for_ssa(buffer); - nir_src_copy(&new_instr->src[1], &instr->src[0], new_instr); - nir_src_copy(&new_instr->src[2], &instr->src[1], new_instr); + nir_src_copy(&new_instr->src[1], &instr->src[0], &new_instr->instr); + nir_src_copy(&new_instr->src[2], &instr->src[1], &new_instr->instr); if (op == nir_intrinsic_ssbo_atomic_comp_swap || op == nir_intrinsic_ssbo_atomic_fcomp_swap) - nir_src_copy(&new_instr->src[3], &instr->src[2], new_instr); + nir_src_copy(&new_instr->src[3], &instr->src[2], &new_instr->instr); break; } diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c b/src/compiler/nir/nir_lower_indirect_derefs.c index e30ccad..1ffb990 100644 --- a/src/compiler/nir/nir_lower_indirect_derefs.c +++ b/src/compiler/nir/nir_lower_indirect_derefs.c @@ -98,7 +98,7 @@ emit_load_store_deref(nir_builder *b, nir_intrinsic_instr *orig_instr, /* Copy over any other sources. This is needed for interp_deref_at */ for (unsigned i = 1; i < nir_intrinsic_infos[orig_instr->intrinsic].num_srcs; i++) - nir_src_copy(&load->src[i], &orig_instr->src[i], load); + nir_src_copy(&load->src[i], &orig_instr->src[i], &load->instr); nir_ssa_dest_init(&load->instr, &load->dest, orig_instr->dest.ssa.num_components, diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 7ff8d43..768c031 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -611,7 +611,7 @@ lower_interpolate_at(nir_intrinsic_instr *intrin, struct lower_io_state *state, if (intrin->intrinsic == nir_intrinsic_interp_deref_at_sample || intrin->intrinsic == nir_intrinsic_interp_deref_at_offset || intrin->intrinsic == nir_intrinsic_interp_deref_at_vertex) - nir_src_copy(&bary_setup->src[0], &intrin->src[1], bary_setup); + nir_src_copy(&bary_setup->src[0], &intrin->src[1], &bary_setup->instr); nir_builder_instr_insert(b, &bary_setup->instr); diff --git a/src/compiler/nir/nir_lower_locals_to_regs.c b/src/compiler/nir/nir_lower_locals_to_regs.c index d4d4c88..9860d5f 100644 --- a/src/compiler/nir/nir_lower_locals_to_regs.c +++ b/src/compiler/nir/nir_lower_locals_to_regs.c @@ -246,7 +246,7 @@ lower_locals_to_regs_block(nir_block *block, nir_alu_instr *mov = nir_alu_instr_create(b->shader, nir_op_mov); - nir_src_copy(&mov->src[0].src, &intrin->src[1], mov); + nir_src_copy(&mov->src[0].src, &intrin->src[1], &mov->instr); /* The normal NIR SSA copy propagate pass can't happen after this pass, * so do an ad-hoc copy propagate since this ALU op can do swizzles diff --git a/src/compiler/nir/nir_lower_ssbo.c b/src/compiler/nir/nir_lower_ssbo.c index 19a040a..7535717 100644 --- a/src/compiler/nir/nir_lower_ssbo.c +++ b/src/compiler/nir/nir_lower_ssbo.c @@ -90,7 +90,7 @@ nir_load_ssbo_prop(nir_builder *b, nir_intrinsic_op op, { nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, op); load->num_components = 1; - nir_src_copy(&load->src[0], idx, load); + nir_src_copy(&load->src[0], idx, &load->instr); nir_ssa_dest_init(&load->instr, &load->dest, 1, bitsize, NULL); nir_builder_instr_insert(b, &load->instr); return &load->dest.ssa; @@ -134,7 +134,7 @@ lower_ssbo_instr(nir_builder *b, nir_intrinsic_instr *intr) } if (is_store) { - nir_src_copy(&global->src[0], &intr->src[0], global); + nir_src_copy(&global->src[0], &intr->src[0], &global->instr); nir_intrinsic_set_write_mask(global, nir_intrinsic_write_mask(intr)); } else { nir_ssa_dest_init(&global->instr, &global->dest, @@ -142,9 +142,9 @@ lower_ssbo_instr(nir_builder *b, nir_intrinsic_instr *intr) intr->dest.ssa.bit_size, NULL); if (is_atomic) { - nir_src_copy(&global->src[1], &intr->src[2], global); + nir_src_copy(&global->src[1], &intr->src[2], &global->instr); if (nir_intrinsic_infos[op].num_srcs > 2) - nir_src_copy(&global->src[2], &intr->src[3], global); + nir_src_copy(&global->src[2], &intr->src[3], &global->instr); } } diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index a2e2e11..f54a80a 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -45,7 +45,7 @@ lower_subgroups_64bit_split_intrinsic(nir_builder *b, nir_intrinsic_instr *intri intr->const_index[1] = intrin->const_index[1]; intr->src[0] = nir_src_for_ssa(comp); if (nir_intrinsic_infos[intrin->intrinsic].num_srcs == 2) - nir_src_copy(&intr->src[1], &intrin->src[1], intr); + nir_src_copy(&intr->src[1], &intrin->src[1], &intr->instr); intr->num_components = 1; nir_builder_instr_insert(b, &intr->instr); @@ -126,7 +126,7 @@ lower_subgroup_op_to_scalar(nir_builder *b, nir_intrinsic_instr *intrin, /* invocation */ if (nir_intrinsic_infos[intrin->intrinsic].num_srcs > 1) { assert(nir_intrinsic_infos[intrin->intrinsic].num_srcs == 2); - nir_src_copy(&chan_intrin->src[1], &intrin->src[1], chan_intrin); + nir_src_copy(&chan_intrin->src[1], &intrin->src[1], &chan_intrin->instr); } chan_intrin->const_index[0] = intrin->const_index[0]; @@ -209,7 +209,7 @@ lower_shuffle_to_swizzle(nir_builder *b, nir_intrinsic_instr *intrin, nir_intrinsic_instr *swizzle = nir_intrinsic_instr_create( b->shader, nir_intrinsic_masked_swizzle_amd); swizzle->num_components = intrin->num_components; - nir_src_copy(&swizzle->src[0], &intrin->src[0], swizzle); + nir_src_copy(&swizzle->src[0], &intrin->src[0], &swizzle->instr); nir_intrinsic_set_swizzle_mask(swizzle, (mask << 10) | 0x1f); nir_ssa_dest_init(&swizzle->instr, &swizzle->dest, intrin->dest.ssa.num_components, @@ -288,7 +288,7 @@ lower_to_shuffle(nir_builder *b, nir_intrinsic_instr *intrin, nir_intrinsic_instr *shuffle = nir_intrinsic_instr_create(b->shader, nir_intrinsic_shuffle); shuffle->num_components = intrin->num_components; - nir_src_copy(&shuffle->src[0], &intrin->src[0], shuffle); + nir_src_copy(&shuffle->src[0], &intrin->src[0], &shuffle->instr); shuffle->src[1] = nir_src_for_ssa(index); nir_ssa_dest_init(&shuffle->instr, &shuffle->dest, intrin->dest.ssa.num_components, @@ -568,7 +568,7 @@ lower_dynamic_quad_broadcast(nir_builder *b, nir_intrinsic_instr *intrin, qbcst->num_components = intrin->num_components; qbcst->src[1] = nir_src_for_ssa(nir_imm_int(b, i)); - nir_src_copy(&qbcst->src[0], &intrin->src[0], qbcst); + nir_src_copy(&qbcst->src[0], &intrin->src[0], &qbcst->instr); nir_ssa_dest_init(&qbcst->instr, &qbcst->dest, intrin->dest.ssa.num_components, intrin->dest.ssa.bit_size, NULL); diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index 14f83c9..b6ff776 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -315,7 +315,7 @@ sample_plane(nir_builder *b, nir_tex_instr *tex, int plane, nir_tex_instr *plane_tex = nir_tex_instr_create(b->shader, tex->num_srcs + 1); for (unsigned i = 0; i < tex->num_srcs; i++) { - nir_src_copy(&plane_tex->src[i].src, &tex->src[i].src, plane_tex); + nir_src_copy(&plane_tex->src[i].src, &tex->src[i].src, &plane_tex->instr); plane_tex->src[i].src_type = tex->src[i].src_type; } plane_tex->src[tex->num_srcs].src = nir_src_for_ssa(nir_imm_int(b, plane)); @@ -812,7 +812,7 @@ lower_tex_to_txd(nir_builder *b, nir_tex_instr *tex) /* reuse existing srcs */ for (unsigned i = 0; i < tex->num_srcs; i++) { - nir_src_copy(&txd->src[i].src, &tex->src[i].src, txd); + nir_src_copy(&txd->src[i].src, &tex->src[i].src, &txd->instr); txd->src[i].src_type = tex->src[i].src_type; } int coord = nir_tex_instr_src_index(tex, nir_tex_src_coord); @@ -852,7 +852,7 @@ lower_txb_to_txl(nir_builder *b, nir_tex_instr *tex) /* reuse all but bias src */ for (int i = 0; i < 2; i++) { if (tex->src[i].src_type != nir_tex_src_bias) { - nir_src_copy(&txl->src[i].src, &tex->src[i].src, txl); + nir_src_copy(&txl->src[i].src, &tex->src[i].src, &txl->instr); txl->src[i].src_type = tex->src[i].src_type; } } @@ -1164,7 +1164,7 @@ lower_tg4_offsets(nir_builder *b, nir_tex_instr *tex) tex_copy->dest_type = tex->dest_type; for (unsigned j = 0; j < tex->num_srcs; ++j) { - nir_src_copy(&tex_copy->src[j].src, &tex->src[j].src, tex_copy); + nir_src_copy(&tex_copy->src[j].src, &tex->src[j].src, &tex_copy->instr); tex_copy->src[j].src_type = tex->src[j].src_type; } diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c index cc5fb54..03d656d 100644 --- a/src/compiler/nir/nir_opt_peephole_select.c +++ b/src/compiler/nir/nir_opt_peephole_select.c @@ -457,7 +457,7 @@ nir_opt_peephole_select_block(nir_block *block, nir_shader *shader, nir_phi_instr *phi = nir_instr_as_phi(instr); nir_alu_instr *sel = nir_alu_instr_create(shader, nir_op_bcsel); - nir_src_copy(&sel->src[0].src, &if_stmt->condition, sel); + nir_src_copy(&sel->src[0].src, &if_stmt->condition, &sel->instr); /* Splat the condition to all channels */ memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle); @@ -467,7 +467,7 @@ nir_opt_peephole_select_block(nir_block *block, nir_shader *shader, assert(src->src.is_ssa); unsigned idx = src->pred == then_block ? 1 : 2; - nir_src_copy(&sel->src[idx].src, &src->src, sel); + nir_src_copy(&sel->src[idx].src, &src->src, &sel->instr); } nir_ssa_dest_init(&sel->instr, &sel->dest.dest, diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 596db69..8ac17a7 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -526,8 +526,7 @@ construct_value(nir_builder *build, assert(state->variables_seen & (1 << var->variable)); nir_alu_src val = { NIR_SRC_INIT }; - nir_alu_src_copy(&val, &state->variables[var->variable], - (void *)build->shader); + nir_alu_src_copy(&val, &state->variables[var->variable], NULL); assert(!var->is_constant); for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) diff --git a/src/gallium/drivers/lima/ir/lima_nir_split_load_input.c b/src/gallium/drivers/lima/ir/lima_nir_split_load_input.c index 7506c0f..802a083 100644 --- a/src/gallium/drivers/lima/ir/lima_nir_split_load_input.c +++ b/src/gallium/drivers/lima/ir/lima_nir_split_load_input.c @@ -85,7 +85,7 @@ lima_nir_split_load_input_instr(nir_builder *b, nir_intrinsic_set_dest_type(new_intrin, nir_intrinsic_dest_type(intrin)); /* offset */ - nir_src_copy(&new_intrin->src[0], &intrin->src[0], new_intrin); + nir_src_copy(&new_intrin->src[0], &intrin->src[0], &new_intrin->instr); nir_builder_instr_insert(b, &new_intrin->instr); nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, diff --git a/src/gallium/drivers/r600/sfn/tests/sfn_valuefactory_test.cpp b/src/gallium/drivers/r600/sfn/tests/sfn_valuefactory_test.cpp index f0527f7..77ff836 100644 --- a/src/gallium/drivers/r600/sfn/tests/sfn_valuefactory_test.cpp +++ b/src/gallium/drivers/r600/sfn/tests/sfn_valuefactory_test.cpp @@ -150,7 +150,7 @@ TEST_F(ValuefactoryTest, test_create_register_array_indirect_access) mov->dest.dest.reg.base_offset = 0; mov->dest.dest.reg.indirect = (nir_src *)calloc(1, sizeof(nir_src)); nir_src addr = nir_src_for_ssa(c2); - nir_src_copy(mov->dest.dest.reg.indirect, &addr, mov); + nir_src_copy(mov->dest.dest.reg.indirect, &addr, &mov->instr); nir_builder_instr_insert(&b, &mov->instr); auto addr_reg = factory->src(addr, 0); diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 5417bfd..cc73c71 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1273,7 +1273,7 @@ rewrite_atomic_ssbo_instr(nir_builder *b, nir_instr *instr, struct bo_vars *bo) new_instr->src[0] = nir_src_for_ssa(&deref_arr->dest.ssa); /* deref ops have no offset src, so copy the srcs after it */ for (unsigned i = 2; i < nir_intrinsic_infos[intr->intrinsic].num_srcs; i++) - nir_src_copy(&new_instr->src[i - 1], &intr->src[i], new_instr); + nir_src_copy(&new_instr->src[i - 1], &intr->src[i], &new_instr->instr); nir_builder_instr_insert(b, &new_instr->instr); result[i] = &new_instr->dest.ssa; diff --git a/src/gallium/drivers/zink/zink_lower_cubemap_to_array.c b/src/gallium/drivers/zink/zink_lower_cubemap_to_array.c index 217fc4b..4dcc995 100644 --- a/src/gallium/drivers/zink/zink_lower_cubemap_to_array.c +++ b/src/gallium/drivers/zink/zink_lower_cubemap_to_array.c @@ -171,7 +171,7 @@ create_array_tex_from_cube_tex(nir_builder *b, nir_tex_instr *tex, nir_ssa_def * nir_ssa_def *c = nir_channels(b, psrc->ssa, BITFIELD_MASK(nir_tex_instr_src_size(array_tex, s))); array_tex->src[s].src = nir_src_for_ssa(c); } else - nir_src_copy(&array_tex->src[s].src, psrc, array_tex); + nir_src_copy(&array_tex->src[s].src, psrc, &array_tex->instr); s++; } @@ -432,7 +432,7 @@ lower_tex_to_txl(nir_builder *b, nir_tex_instr *tex) for (int i = 0; i < tex->num_srcs; i++) { if (i == bias_idx) continue; - nir_src_copy(&txl->src[s].src, &tex->src[i].src, txl); + nir_src_copy(&txl->src[s].src, &tex->src[i].src, &txl->instr); txl->src[s].src_type = tex->src[i].src_type; s++; } diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c index 58f81c2..e82cd03 100644 --- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c +++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c @@ -135,7 +135,7 @@ create_plane_tex_instr_implicit(struct ycbcr_state *state, } FALLTHROUGH; default: - nir_src_copy(&tex->src[i].src, &old_tex->src[i].src, tex); + nir_src_copy(&tex->src[i].src, &old_tex->src[i].src, &tex->instr); break; } } diff --git a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c index 936875b..46c719b 100644 --- a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c +++ b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c @@ -210,7 +210,7 @@ create_array_tex_from_cube_tex(nir_builder *b, nir_tex_instr *tex, nir_ssa_def * nir_src *psrc = (tex->src[i].src_type == nir_tex_src_coord) ? &coord_src : &tex->src[i].src; - nir_src_copy(&array_tex->src[i].src, psrc, array_tex); + nir_src_copy(&array_tex->src[i].src, psrc, &array_tex->instr); array_tex->src[i].src_type = tex->src[i].src_type; } diff --git a/src/microsoft/compiler/dxil_nir_lower_int_samplers.c b/src/microsoft/compiler/dxil_nir_lower_int_samplers.c index 4546a79..2faae5a 100644 --- a/src/microsoft/compiler/dxil_nir_lower_int_samplers.c +++ b/src/microsoft/compiler/dxil_nir_lower_int_samplers.c @@ -81,7 +81,7 @@ dx_get_texture_lod(nir_builder *b, nir_tex_instr *tex) nir_ssa_def *ssa_src = nir_channels(b, tex->src[coord_index].src.ssa, (1 << coord_components) - 1); nir_src src = nir_src_for_ssa(ssa_src); - nir_src_copy(&tql->src[0].src, &src, tql); + nir_src_copy(&tql->src[0].src, &src, &tql->instr); tql->src[0].src_type = nir_tex_src_coord; unsigned idx = 1; @@ -92,7 +92,7 @@ dx_get_texture_lod(nir_builder *b, nir_tex_instr *tex) tex->src[i].src_type == nir_tex_src_sampler_offset || tex->src[i].src_type == nir_tex_src_texture_handle || tex->src[i].src_type == nir_tex_src_sampler_handle) { - nir_src_copy(&tql->src[idx].src, &tex->src[i].src, tql); + nir_src_copy(&tql->src[idx].src, &tex->src[i].src, &tql->instr); tql->src[idx].src_type = tex->src[i].src_type; idx++; } @@ -278,7 +278,7 @@ create_txf_from_tex(nir_builder *b, nir_tex_instr *tex) if (tex->src[i].src_type == nir_tex_src_texture_deref || tex->src[i].src_type == nir_tex_src_texture_offset || tex->src[i].src_type == nir_tex_src_texture_handle) { - nir_src_copy(&txf->src[idx].src, &tex->src[i].src, txf); + nir_src_copy(&txf->src[idx].src, &tex->src[i].src, &txf->instr); txf->src[idx].src_type = tex->src[i].src_type; idx++; } diff --git a/src/panfrost/midgard/midgard_errata_lod.c b/src/panfrost/midgard/midgard_errata_lod.c index 7ceea1c..395d8c1 100644 --- a/src/panfrost/midgard/midgard_errata_lod.c +++ b/src/panfrost/midgard/midgard_errata_lod.c @@ -53,7 +53,7 @@ nir_lod_errata_instr(nir_builder *b, nir_instr *instr, void *data) /* TODO: Indirect samplers, separate sampler objects XXX */ nir_src idx = nir_src_for_ssa(nir_imm_int(b, tex->texture_index)); - nir_src_copy(&l->src[0], &idx, l); + nir_src_copy(&l->src[0], &idx, &l->instr); nir_builder_instr_insert(b, &l->instr); nir_ssa_def *params = &l->dest.ssa; -- 2.7.4