mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 08:40:11 +01:00
nir: Add a nir_instr_move helper
Removes an instruction from one place and inserts it at another while working around a weird cursor corner-case. v2: change return value to bool (Daniel Schürmann) Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> (v1) Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10522>
This commit is contained in:
parent
3701cb9439
commit
f97fb1fa55
2 changed files with 18 additions and 0 deletions
|
|
@ -958,6 +958,22 @@ nir_instr_insert(nir_cursor cursor, nir_instr *instr)
|
|||
impl->valid_metadata &= ~nir_metadata_instr_index;
|
||||
}
|
||||
|
||||
bool
|
||||
nir_instr_move(nir_cursor cursor, nir_instr *instr)
|
||||
{
|
||||
/* If the cursor happens to refer to this instruction (either before or
|
||||
* after), don't do anything.
|
||||
*/
|
||||
if ((cursor.option == nir_cursor_before_instr ||
|
||||
cursor.option == nir_cursor_after_instr) &&
|
||||
cursor.instr == instr)
|
||||
return false;
|
||||
|
||||
nir_instr_remove(instr);
|
||||
nir_instr_insert(cursor, instr);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
src_is_valid(const nir_src *src)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3826,6 +3826,8 @@ nir_after_cf_list(struct exec_list *cf_list)
|
|||
*/
|
||||
void nir_instr_insert(nir_cursor cursor, nir_instr *instr);
|
||||
|
||||
bool nir_instr_move(nir_cursor cursor, nir_instr *instr);
|
||||
|
||||
static inline void
|
||||
nir_instr_insert_before(nir_instr *instr, nir_instr *before)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue