nir: add a nir_instr_def_is_register helper
This returns true if the instruction has a dest that is not an SSA value. Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15056>
This commit is contained in:

committed by
Marge Bot

parent
0a04468704
commit
fe2249eac5
@@ -1476,6 +1476,43 @@ nir_instr_ssa_def(nir_instr *instr)
|
||||
unreachable("Invalid instruction type");
|
||||
}
|
||||
|
||||
bool
|
||||
nir_instr_def_is_register(nir_instr *instr)
|
||||
{
|
||||
switch (instr->type) {
|
||||
case nir_instr_type_alu:
|
||||
return !nir_instr_as_alu(instr)->dest.dest.is_ssa;
|
||||
|
||||
case nir_instr_type_deref:
|
||||
return !nir_instr_as_deref(instr)->dest.is_ssa;
|
||||
|
||||
case nir_instr_type_tex:
|
||||
return !nir_instr_as_tex(instr)->dest.is_ssa;
|
||||
|
||||
case nir_instr_type_intrinsic: {
|
||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||
return nir_intrinsic_infos[intrin->intrinsic].has_dest &&
|
||||
!intrin->dest.is_ssa;
|
||||
}
|
||||
|
||||
case nir_instr_type_phi:
|
||||
return !nir_instr_as_phi(instr)->dest.is_ssa;
|
||||
|
||||
case nir_instr_type_parallel_copy:
|
||||
unreachable("Parallel copies are unsupported by this function");
|
||||
|
||||
case nir_instr_type_load_const:
|
||||
case nir_instr_type_ssa_undef:
|
||||
return false;
|
||||
|
||||
case nir_instr_type_call:
|
||||
case nir_instr_type_jump:
|
||||
return false;
|
||||
}
|
||||
|
||||
unreachable("Invalid instruction type");
|
||||
}
|
||||
|
||||
bool
|
||||
nir_foreach_phi_src_leaving_block(nir_block *block,
|
||||
nir_foreach_src_cb cb,
|
||||
|
@@ -3947,6 +3947,7 @@ nir_cursor nir_instr_free_and_dce(nir_instr *instr);
|
||||
/** @} */
|
||||
|
||||
nir_ssa_def *nir_instr_ssa_def(nir_instr *instr);
|
||||
bool nir_instr_def_is_register(nir_instr *instr);
|
||||
|
||||
typedef bool (*nir_foreach_ssa_def_cb)(nir_ssa_def *def, void *state);
|
||||
typedef bool (*nir_foreach_dest_cb)(nir_dest *dest, void *state);
|
||||
|
Reference in New Issue
Block a user