/*@}*/
-struct foreach_def_state {
- nir_foreach_def_cb cb;
- void *client_state;
-};
-
-static inline bool
-nir_def_visitor(nir_dest *dest, void *void_state)
-{
- struct foreach_def_state *state = void_state;
-
- return state->cb(&dest->ssa, state->client_state);
-}
-
-bool
-nir_foreach_def(nir_instr *instr, nir_foreach_def_cb cb, void *state)
-{
- switch (instr->type) {
- case nir_instr_type_alu:
- case nir_instr_type_deref:
- case nir_instr_type_tex:
- case nir_instr_type_intrinsic:
- case nir_instr_type_phi:
- case nir_instr_type_parallel_copy: {
- struct foreach_def_state foreach_state = { cb, state };
- return nir_foreach_dest(instr, nir_def_visitor, &foreach_state);
- }
-
- case nir_instr_type_load_const:
- return cb(&nir_instr_as_load_const(instr)->def, state);
- case nir_instr_type_ssa_undef:
- return cb(&nir_instr_as_ssa_undef(instr)->def, state);
- case nir_instr_type_call:
- case nir_instr_type_jump:
- return true;
- default:
- unreachable("Invalid instruction type");
- }
-}
-
nir_def *
nir_instr_ssa_def(nir_instr *instr)
{
nir_def *nir_instr_ssa_def(nir_instr *instr);
typedef bool (*nir_foreach_def_cb)(nir_def *def, void *state);
-typedef bool (*nir_foreach_dest_cb)(nir_dest *dest, void *state);
typedef bool (*nir_foreach_src_cb)(nir_src *src, void *state);
-bool nir_foreach_def(nir_instr *instr, nir_foreach_def_cb cb,
- void *state);
-static inline bool nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state);
static inline bool nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state);
bool nir_foreach_phi_src_leaving_block(nir_block *instr,
nir_foreach_src_cb cb,
-/* _nir_foreach_dest() needs to be ALWAYS_INLINE so that it can inline the
+/* _nir_foreach_def() needs to be ALWAYS_INLINE so that it can inline the
* callback if it was declared with ALWAYS_INLINE.
*/
static ALWAYS_INLINE bool
-_nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)
+_nir_foreach_def(nir_instr *instr, nir_foreach_def_cb cb, void *state)
{
switch (instr->type) {
case nir_instr_type_alu:
- return cb(&nir_instr_as_alu(instr)->dest.dest, state);
+ return cb(&nir_instr_as_alu(instr)->dest.dest.ssa, state);
case nir_instr_type_deref:
- return cb(&nir_instr_as_deref(instr)->dest, state);
+ return cb(&nir_instr_as_deref(instr)->dest.ssa, state);
case nir_instr_type_intrinsic: {
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
if (nir_intrinsic_infos[intrin->intrinsic].has_dest)
- return cb(&intrin->dest, state);
+ return cb(&intrin->dest.ssa, state);
return true;
}
case nir_instr_type_tex:
- return cb(&nir_instr_as_tex(instr)->dest, state);
+ return cb(&nir_instr_as_tex(instr)->dest.ssa, state);
case nir_instr_type_phi:
- return cb(&nir_instr_as_phi(instr)->dest, state);
+ return cb(&nir_instr_as_phi(instr)->dest.ssa, state);
case nir_instr_type_parallel_copy: {
nir_foreach_parallel_copy_entry(entry, nir_instr_as_parallel_copy(instr)) {
- if (!entry->dest_is_reg && !cb(&entry->dest.dest, state))
+ if (!entry->dest_is_reg && !cb(&entry->dest.dest.ssa, state))
return false;
}
return true;
}
case nir_instr_type_load_const:
+ return cb(&nir_instr_as_load_const(instr)->def, state);
case nir_instr_type_ssa_undef:
+ return cb(&nir_instr_as_ssa_undef(instr)->def, state);
+
case nir_instr_type_call:
case nir_instr_type_jump:
- break;
+ return true;
default:
unreachable("Invalid instruction type");
- break;
}
-
- return true;
}
static ALWAYS_INLINE bool
}
static inline bool
-nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)
+nir_foreach_def(nir_instr *instr, nir_foreach_def_cb cb, void *state)
{
- return _nir_foreach_dest(instr, cb, state);
+ return _nir_foreach_def(instr, cb, state);
}
static inline bool