[Mesa-dev] [PATCH 01/11] nir: Add helper functions to get the instruction that generated a nir_src
Thomas Helland
thomashelland90 at gmail.com
Mon Oct 8 20:08:23 UTC 2018
Den tir. 11. sep. 2018 kl. 01:30 skrev Ian Romanick <idr at freedesktop.org>:
>
> From: Ian Romanick <ian.d.romanick at intel.com>
>
Reviewed-by: Thomas Helland<thomashelland90 at gmail.com>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/compiler/nir/nir.h | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index bf4bd916d27..69ca1215644 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2490,6 +2490,29 @@ bool nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state);
> bool nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state);
>
> nir_const_value *nir_src_as_const_value(nir_src src);
> +
> +static inline struct nir_instr *
> +nir_src_instr(const struct nir_src *src)
> +{
> + return src->is_ssa ? src->ssa->parent_instr : NULL;
> +}
> +
> +#define NIR_SRC_AS_(name, c_type, type_enum, cast_macro) \
> +static inline c_type * \
> +nir_src_as_ ## name (struct nir_src *src) \
> +{ \
> + return src->is_ssa && src->ssa->parent_instr->type == type_enum \
> + ? cast_macro(src->ssa->parent_instr) : NULL; \
> +} \
> +static inline const c_type * \
> +nir_src_as_ ## name ## _const(const struct nir_src *src) \
> +{ \
> + return src->is_ssa && src->ssa->parent_instr->type == type_enum \
> + ? cast_macro(src->ssa->parent_instr) : NULL; \
> +}
> +
> +NIR_SRC_AS_(alu_instr, nir_alu_instr, nir_instr_type_alu, nir_instr_as_alu)
> +
> bool nir_src_is_dynamically_uniform(nir_src src);
> bool nir_srcs_equal(nir_src src1, nir_src src2);
> void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
> --
> 2.14.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list