Replace all its remaining users with nir_src_rewrite().
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24729>
}
void
-nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src)
-{
- assert(!src_is_valid(src) || src->parent_instr == instr);
-
- src_remove_all_uses(src);
- nir_src_copy(src, &new_src, instr);
- src_add_all_uses(src, instr, NULL);
-}
-
-void
nir_instr_init_src(nir_instr *instr, nir_src *src, nir_def *def)
{
*src = nir_src_for_ssa(def);
list_addtail(&src->use_link, &new_ssa->uses);
}
-void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
-
/** Initialize a nir_src
*
* This is almost never the helper you want to use. This helper assumes that
!trivial_array_cast)
continue;
- nir_instr_rewrite_src(use_src->parent_instr, use_src, cast->parent);
+ nir_src_rewrite(use_src, cast->parent.ssa);
progress = true;
}
deref->arr.index.ssa);
deref->deref_type = parent->deref_type;
- nir_instr_rewrite_src(&deref->instr, &deref->parent, parent->parent);
+ nir_src_rewrite(&deref->parent, parent->parent.ssa);
nir_src_rewrite(&deref->arr.index, new_idx);
return true;
}
const struct intrinsic_info *info = second->info;
assert(info->value_src >= 0);
- nir_instr_rewrite_src(second->instr, &second->intrin->src[info->value_src],
- nir_src_for_ssa(data));
+ nir_src_rewrite(&second->intrin->src[info->value_src], data);
/* update the offset */
if (second != low && info->base_src >= 0)
- nir_instr_rewrite_src(second->instr, &second->intrin->src[info->base_src],
- low->intrin->src[info->base_src]);
+ nir_src_rewrite(&second->intrin->src[info->base_src],
+ low->intrin->src[info->base_src].ssa);
/* update the deref */
if (info->deref_src >= 0) {
b->cursor = nir_before_instr(second->instr);
second->deref = cast_deref(b, new_num_components, new_bit_size,
nir_src_as_deref(low->intrin->src[info->deref_src]));
- nir_instr_rewrite_src(second->instr, &second->intrin->src[info->deref_src],
- nir_src_for_ssa(&second->deref->def));
+ nir_src_rewrite(&second->intrin->src[info->deref_src],
+ &second->deref->def);
}
/* update base/align */
if (i >= 3)
continue;
- nir_instr_rewrite_src(instr, &alu->src[i].src, parent->src[0].src);
+ nir_src_rewrite(&alu->src[i].src, parent->src[0].src.ssa);
/* Apply any modifiers that come from the parent opcode */
if (parent->op == nir_op_fneg)
}
nir_intrinsic_set_base(intr, new_base);
- nir_instr_rewrite_src(instr, &intr->src[0], nir_src_for_ssa(new_bufid->ssa));
+ nir_src_rewrite(&intr->src[0], new_bufid->ssa);
return &intr->def;
}
};
nir_intrinsic_instr *load2 =
nir_instr_as_intrinsic(nir_instr_clone(b->shader, &intr->instr));
- auto new_src0 = nir_src_for_ssa(nir_iadd_imm(b, intr->src[0].ssa, 1));
- nir_instr_rewrite_src(&load2->instr, &load2->src[0], new_src0);
+ nir_src_rewrite(&load2->src[0], nir_iadd_imm(b, intr->src[0].ssa, 1));
load2->num_components = second_components;
nir_def_init(&load2->instr, &load2->def, second_components, 64);
auto new_src = nir_vec(&b, srcs, comps);
- nir_instr_rewrite_src(&last_store->instr,
- &last_store->src[0],
- nir_src_for_ssa(new_src));
+ nir_src_rewrite(&last_store->src[0], new_src);
last_store->num_components = comps;
nir_intrinsic_set_component(last_store, first_comp);
nir_intrinsic_set_write_mask(last_store, writemask);
/* TODO: Verify type is vec4. */
/* Pack the output color components into U8888 format. */
- nir_def *new_output_src_ssa = nir_pack_unorm_4x8(b, output_src->ssa);
- nir_src new_output_src = nir_src_for_ssa(new_output_src_ssa);
+ nir_def *new_output_src = nir_pack_unorm_4x8(b, output_src->ssa);
/* Update the store_output intrinsic. */
- nir_instr_rewrite_src(&store_output->instr, output_src, new_output_src);
+ nir_src_rewrite(output_src, new_output_src);
nir_intrinsic_set_write_mask(store_output, 1);
store_output->num_components = 1;
nir_intrinsic_set_src_type(store_output, nir_type_uint32);