break;
nir_phi_instr *phi = nir_instr_as_phi(instr);
- foreach_list_typed_safe(nir_phi_src, src, node, &phi->srcs) {
+ nir_foreach_phi_src(phi, src) {
if (src->pred == old_pred) {
src->pred = new_pred;
break;
static bool
visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb cb, void *state)
{
- foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
+ nir_foreach_phi_src(instr, src) {
if (!visit_src(&src->src, cb, state))
return false;
}
nir_src src;
} nir_phi_src;
+#define nir_foreach_phi_src(phi, entry) \
+ foreach_list_typed(nir_phi_src, entry, node, &(phi)->srcs)
+
typedef struct {
nir_instr instr;
nir_phi_instr *phi = nir_instr_as_phi(instr);
assert(phi->dest.is_ssa);
- foreach_list_typed(nir_phi_src, src, node, &phi->srcs) {
+ nir_foreach_phi_src(phi, src) {
nir_parallel_copy_instr *pcopy =
get_parallel_copy_at_end_of_block(src->pred);
assert(pcopy);
assert(phi->dest.is_ssa);
merge_node *dest_node = get_merge_node(&phi->dest.ssa, state);
- foreach_list_typed(nir_phi_src, src, node, &phi->srcs) {
+ nir_foreach_phi_src(phi, src) {
assert(src->src.is_ssa);
merge_node *src_node = get_merge_node(src->src.ssa, state);
if (src_node->set != dest_node->set)
break;
nir_phi_instr *phi = nir_instr_as_phi(instr);
- foreach_list_typed(nir_phi_src, src, node, &phi->srcs) {
+ nir_foreach_phi_src(phi, src) {
if (src->pred == pred) {
set_src_live(&src->src, live);
break;
if (phi1->instr.block != phi2->instr.block)
return false;
- foreach_list_typed(nir_phi_src, src1, node, &phi1->srcs) {
- foreach_list_typed(nir_phi_src, src2, node, &phi2->srcs) {
+ nir_foreach_phi_src(phi1, src1) {
+ nir_foreach_phi_src(phi2, src2) {
if (src1->pred == src2->pred) {
if (!nir_srcs_equal(src1->src, src2->src))
return false;
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
assert(exec_list_length(&phi->srcs) == 2);
- foreach_list_typed(nir_phi_src, src, node, &phi->srcs) {
+ nir_foreach_phi_src(phi, src) {
assert(src->pred == then_block || src->pred == else_block);
assert(src->src.is_ssa);
{
print_dest(&instr->dest, fp);
fprintf(fp, " = phi ");
- foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
+ nir_foreach_phi_src(instr, src) {
if (&src->node != exec_list_get_head(&instr->srcs))
fprintf(fp, ", ");
state->parent_instr = instr;
- foreach_list_typed(nir_phi_src, src, node, &phi_instr->srcs) {
+ nir_foreach_phi_src(phi_instr, src) {
if (src->pred == pred) {
rewrite_use(&src->src, state);
break;
assert(instr->dest.is_ssa);
exec_list_validate(&instr->srcs);
- foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
+ nir_foreach_phi_src(instr, src) {
if (src->pred == pred) {
unsigned num_components;
if (src->src.is_ssa)