nir: Add a deref_instr_has_indirect helper
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -987,6 +987,8 @@ nir_deref_instr_get_variable(const nir_deref_instr *instr)
|
|||||||
return instr->var;
|
return instr->var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nir_deref_instr_has_indirect(nir_deref_instr *instr);
|
||||||
|
|
||||||
bool nir_deref_instr_remove_if_unused(nir_deref_instr *instr);
|
bool nir_deref_instr_remove_if_unused(nir_deref_instr *instr);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@@ -102,6 +102,24 @@ nir_deref_instr_remove_if_unused(nir_deref_instr *instr)
|
|||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nir_deref_instr_has_indirect(nir_deref_instr *instr)
|
||||||
|
{
|
||||||
|
while (instr->deref_type != nir_deref_type_var) {
|
||||||
|
/* Consider casts to be indirects */
|
||||||
|
if (instr->deref_type == nir_deref_type_cast)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (instr->deref_type == nir_deref_type_array &&
|
||||||
|
!nir_src_as_const_value(instr->arr.index))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
instr = nir_deref_instr_parent(instr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nir_remove_dead_derefs_impl(nir_function_impl *impl)
|
nir_remove_dead_derefs_impl(nir_function_impl *impl)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user