nir: Add a "deep" instruction clone

For the shader preamble, we need to add support for cloning one
instruction at a time into the preamble, but we also need to rewrite
sources.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
This commit is contained in:
Connor Abbott
2021-09-24 18:38:27 +02:00
committed by Marge Bot
parent d1b017d479
commit 31221ee556
2 changed files with 16 additions and 0 deletions

View File

@@ -4205,6 +4205,10 @@ char *nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotation
/** Shallow clone of a single instruction. */
nir_instr *nir_instr_clone(nir_shader *s, const nir_instr *orig);
/** Clone a single instruction, including a remap table to rewrite sources. */
nir_instr *nir_instr_clone_deep(nir_shader *s, const nir_instr *orig,
struct hash_table *remap_table);
/** Shallow clone of a single ALU instruction. */
nir_alu_instr *nir_alu_instr_clone(nir_shader *s, const nir_alu_instr *orig);

View File

@@ -522,6 +522,18 @@ nir_instr_clone(nir_shader *shader, const nir_instr *orig)
return clone_instr(&state, orig);
}
nir_instr *
nir_instr_clone_deep(nir_shader *shader, const nir_instr *orig,
struct hash_table *remap_table)
{
clone_state state = {
.allow_remap_fallback = true,
.ns = shader,
.remap_table = remap_table,
};
return clone_instr(&state, orig);
}
static nir_block *
clone_block(clone_state *state, struct exec_list *cf_list, const nir_block *blk)
{