X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fnir%2Fnir_phi_builder.h;h=c663d04183f02c51f3e0ebee8e50f6b62bc2096a;hb=60097cc840e33af8506d7d4d621fefdca1a77695;hp=50251bf1ba39fc770d9c5836afb4fbce5f28aa64;hpb=7f6a0cb29c89a03441be744680a2145445be3a3c;p=mesa.git diff --git a/src/compiler/nir/nir_phi_builder.h b/src/compiler/nir/nir_phi_builder.h index 50251bf1ba3..c663d04183f 100644 --- a/src/compiler/nir/nir_phi_builder.h +++ b/src/compiler/nir/nir_phi_builder.h @@ -21,11 +21,44 @@ * IN THE SOFTWARE. */ -#pragma once +#ifndef NIR_PHI_BUILDER_H +#define NIR_PHI_BUILDER_H #include "nir.h" +/** A helper for placing phi nodes in a NIR shader + * + * Basic usage goes something like this: + * + * each variable, var, has: + * a bitset var.defs of blocks where the variable is defined + * a struct nir_phi_builder_value *pb_val + * + * // initialize bitsets + * foreach block: + * foreach def of variable var: + * var.defs[def.block] = true; + * + * // initialize phi builder + * pb = nir_phi_builder_create() + * foreach var: + * var.pb_val = nir_phi_builder_add_value(pb, var.defs) + * + * // Visit each block. This needs to visit dominators first; + * // nir_foreach_block() will be ok. + * + * foreach block: + * foreach instruction: + * foreach use of variable var: + * replace use with nir_phi_builder_get_block_def(var.pb_val) + * foreach def of variable var: + * create ssa def, register with + * nir_phi_builder_set_block_def(var.pb_val) + * + * nir_phi_builder_finish(pb) + */ struct nir_phi_builder; + struct nir_phi_builder_value; /* Create a new phi builder. @@ -43,7 +76,7 @@ struct nir_phi_builder *nir_phi_builder_create(nir_function_impl *impl); */ struct nir_phi_builder_value * nir_phi_builder_add_value(struct nir_phi_builder *pb, unsigned num_components, - const BITSET_WORD *defs); + unsigned bit_size, const BITSET_WORD *defs); /* Register a definition for the given value and block. * @@ -82,3 +115,5 @@ nir_phi_builder_value_get_block_def(struct nir_phi_builder_value *val, * adds the phi nodes to the program. */ void nir_phi_builder_finish(struct nir_phi_builder *pb); + +#endif /* NIR_PHI_BUILDER_H */