[Mesa-dev] [PATCH] nir: Add a nir_foreach_phi_src helper macro
Jason Ekstrand
jason at jlekstrand.net
Tue Jan 20 16:55:44 PST 2015
On Tue, Jan 20, 2015 at 4:37 PM, Connor Abbott <cwabbott0 at gmail.com> wrote:
> Assuming you grepped for uses of foreach_list* with nir_phi_src and
> made sure there were no more,
>
I did
> Reviewed-by: Connor Abbott <cwabbott02gmail.com>
>
thanks
--Jason
>
> On Tue, Jan 20, 2015 at 7:34 PM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> > ---
> > src/glsl/nir/nir.c | 4 ++--
> > src/glsl/nir/nir.h | 3 +++
> > src/glsl/nir/nir_from_ssa.c | 4 ++--
> > src/glsl/nir/nir_live_variables.c | 2 +-
> > src/glsl/nir/nir_opt_cse.c | 4 ++--
> > src/glsl/nir/nir_opt_peephole_select.c | 2 +-
> > src/glsl/nir/nir_print.c | 2 +-
> > src/glsl/nir/nir_to_ssa.c | 2 +-
> > src/glsl/nir/nir_validate.c | 2 +-
> > 9 files changed, 14 insertions(+), 11 deletions(-)
> >
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> > index 81dec1c..89e21fd 100644
> > --- a/src/glsl/nir/nir.c
> > +++ b/src/glsl/nir/nir.c
> > @@ -731,7 +731,7 @@ rewrite_phi_preds(nir_block *block, nir_block
> *old_pred, nir_block *new_pred)
> > 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;
> > @@ -1585,7 +1585,7 @@ visit_load_const_src(nir_load_const_instr *instr,
> nir_foreach_src_cb cb,
> > 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;
> > }
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index 8861809..f31d0e0 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -990,6 +990,9 @@ typedef struct {
> > 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;
> >
> > diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> > index 0258699..9728b99 100644
> > --- a/src/glsl/nir/nir_from_ssa.c
> > +++ b/src/glsl/nir/nir_from_ssa.c
> > @@ -343,7 +343,7 @@ isolate_phi_nodes_block(nir_block *block, void
> *void_state)
> >
> > 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);
> > @@ -412,7 +412,7 @@ coalesce_phi_nodes_block(nir_block *block, void
> *void_state)
> > 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)
> > diff --git a/src/glsl/nir/nir_live_variables.c
> b/src/glsl/nir/nir_live_variables.c
> > index f110c5e..7402dc0 100644
> > --- a/src/glsl/nir/nir_live_variables.c
> > +++ b/src/glsl/nir/nir_live_variables.c
> > @@ -147,7 +147,7 @@ propagate_across_edge(nir_block *pred, nir_block
> *succ,
> > 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;
> > diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
> > index e7dba1d..89d78c8 100644
> > --- a/src/glsl/nir/nir_opt_cse.c
> > +++ b/src/glsl/nir/nir_opt_cse.c
> > @@ -99,8 +99,8 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
> > 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;
> > diff --git a/src/glsl/nir/nir_opt_peephole_select.c
> b/src/glsl/nir/nir_opt_peephole_select.c
> > index 3e8c938..5d2f5d6 100644
> > --- a/src/glsl/nir/nir_opt_peephole_select.c
> > +++ b/src/glsl/nir/nir_opt_peephole_select.c
> > @@ -140,7 +140,7 @@ nir_opt_peephole_select_block(nir_block *block, void
> *void_state)
> > 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);
> >
> > diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
> > index 84bb979..1a50ae9 100644
> > --- a/src/glsl/nir/nir_print.c
> > +++ b/src/glsl/nir/nir_print.c
> > @@ -543,7 +543,7 @@ print_phi_instr(nir_phi_instr *instr, FILE *fp)
> > {
> > 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, ", ");
> >
> > diff --git a/src/glsl/nir/nir_to_ssa.c b/src/glsl/nir/nir_to_ssa.c
> > index 3e75211..b9b1cff 100644
> > --- a/src/glsl/nir/nir_to_ssa.c
> > +++ b/src/glsl/nir/nir_to_ssa.c
> > @@ -386,7 +386,7 @@ rewrite_phi_sources(nir_block *block, nir_block
> *pred, rewrite_state *state)
> >
> > 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;
> > diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
> > index 228dce2..7c801b2 100644
> > --- a/src/glsl/nir/nir_validate.c
> > +++ b/src/glsl/nir/nir_validate.c
> > @@ -486,7 +486,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block
> *pred, validate_state *state)
> > 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)
> > --
> > 2.2.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150120/aaf6b4f9/attachment-0001.html>
More information about the mesa-dev
mailing list