nir: Drop nir_instr_rewrite_src()
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Thu, 17 Aug 2023 21:44:38 +0000 (16:44 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 18 Aug 2023 01:00:15 +0000 (01:00 +0000)
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>

src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_deref.c
src/compiler/nir/nir_opt_load_store_vectorize.c
src/gallium/drivers/etnaviv/etnaviv_nir_lower_source_mods.c
src/gallium/drivers/r600/sfn/sfn_nir.cpp
src/gallium/drivers/r600/sfn/sfn_nir_lower_64bit.cpp
src/imagination/rogue/nir/rogue_nir_pfo.c

index d9e8e84..4a10e2f 100644 (file)
@@ -1466,16 +1466,6 @@ src_add_all_uses(nir_src *src, nir_instr *parent_instr, nir_if *parent_if)
 }
 
 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);
index 30c8e12..11b1668 100644 (file)
@@ -4410,8 +4410,6 @@ nir_src_rewrite(nir_src *src, nir_def *new_ssa)
    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
index 15d3cd3..60f9270 100644 (file)
@@ -1206,7 +1206,7 @@ opt_deref_cast(nir_builder *b, nir_deref_instr *cast)
           !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;
    }
 
@@ -1255,7 +1255,7 @@ opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref)
                                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;
 }
index 5afef28..73e6ff6 100644 (file)
@@ -823,21 +823,20 @@ vectorize_stores(nir_builder *b, struct vectorize_ctx *ctx,
 
    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 */
index 570be29..27cc0ca 100644 (file)
@@ -76,7 +76,7 @@ nir_lower_to_source_mods_instr(nir_builder *b, nir_instr *instr,
       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)
index e73686a..91b01b8 100644 (file)
@@ -334,7 +334,7 @@ private:
       }
 
       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;
    }
 };
index e5b64ff..d59e8bb 100644 (file)
@@ -614,8 +614,7 @@ LowerSplit64BitVar::split_double_load_ssbo(nir_intrinsic_instr *intr)
    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);
 
@@ -1241,9 +1240,7 @@ StoreMerger::combine_one_slot(vector<nir_intrinsic_instr *>& stores)
 
    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);
index 4120bf4..2de9ad4 100644 (file)
@@ -41,11 +41,10 @@ static void insert_pfo(nir_builder *b,
    /* 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);