nir: Pull the instr list free function out to a helper.

With the de-rallocing, we're going to have some more places that free a
list of instrs.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11776>
This commit is contained in:
Emma Anholt
2021-07-07 12:46:49 -07:00
committed by Marge Bot
parent 36d9bdca0b
commit b99efb8af0
2 changed files with 12 additions and 5 deletions
+11 -5
View File
@@ -1096,6 +1096,16 @@ void nir_instr_free(nir_instr *instr)
ralloc_free(instr);
}
void
nir_instr_free_list(struct exec_list *list)
{
struct exec_node *node;
while ((node = exec_list_pop_head(list))) {
nir_instr *removed_instr = exec_node_data(nir_instr, node, node);
nir_instr_free(removed_instr);
}
}
static bool nir_instr_free_and_dce_live_cb(nir_ssa_def *def, void *state)
{
bool *live = state;
@@ -1179,11 +1189,7 @@ nir_instr_free_and_dce(nir_instr *instr)
exec_list_push_tail(&to_free, &dce_instr->node);
}
struct exec_node *node;
while ((node = exec_list_pop_head(&to_free))) {
nir_instr *removed_instr = exec_node_data(nir_instr, node, node);
nir_instr_free(removed_instr);
}
nir_instr_free_list(&to_free);
nir_instr_worklist_destroy(worklist);
+1
View File
@@ -4226,6 +4226,7 @@ nir_instr_insert_after_cf_list(struct exec_list *list, nir_instr *after)
void nir_instr_remove_v(nir_instr *instr);
void nir_instr_free(nir_instr *instr);
void nir_instr_free_list(struct exec_list *list);
static inline nir_cursor
nir_instr_remove(nir_instr *instr)