[Mesa-dev] [PATCH 3/5] nir: constify instruction comparison functions

Pohjolainen, Topi topi.pohjolainen at intel.com
Mon Jun 1 03:20:15 PDT 2015


On Fri, May 22, 2015 at 02:24:50PM -0400, Connor Abbott wrote:
> Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
> ---
>  src/glsl/nir/nir.h               | 4 ++--
>  src/glsl/nir/nir_instr_compare.c | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index e3b7b17..19b1e18 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1578,8 +1578,8 @@ 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);
> -bool nir_srcs_equal(nir_src src1, nir_src src2);
> -bool nir_instrs_equal(nir_instr *instr1, nir_instr *instr2);
> +bool nir_srcs_equal(const nir_src src1, const nir_src src2);
> +bool nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2);
>  void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
>  void nir_instr_move_src(nir_instr *dest_instr, nir_src *dest, nir_src *src);
>  void nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src);
> diff --git a/src/glsl/nir/nir_instr_compare.c b/src/glsl/nir/nir_instr_compare.c
> index 89b576c..07d0031 100644
> --- a/src/glsl/nir/nir_instr_compare.c
> +++ b/src/glsl/nir/nir_instr_compare.c
> @@ -30,7 +30,7 @@
>  #include "nir.h"
>  
>  bool
> -nir_srcs_equal(nir_src src1, nir_src src2)
> +nir_srcs_equal(const nir_src src1, const nir_src src2)

You could even make them constant references and avoid the automatic
copy. With that:

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

>  {
>     if (src1.is_ssa) {
>        if (src2.is_ssa) {
> @@ -58,8 +58,8 @@ nir_srcs_equal(nir_src src1, nir_src src2)
>  
>  
>  static bool
> -nir_alu_srcs_equal(nir_alu_instr *alu1, nir_alu_instr *alu2, unsigned src1,
> -                   unsigned src2)
> +nir_alu_srcs_equal(const nir_alu_instr *alu1, const nir_alu_instr *alu2,
> +                   unsigned src1, unsigned src2)
>  {
>     if (alu1->src[src1].abs != alu2->src[src2].abs ||
>         alu1->src[src1].negate != alu2->src[src2].negate)
> @@ -74,7 +74,7 @@ nir_alu_srcs_equal(nir_alu_instr *alu1, nir_alu_instr *alu2, unsigned src1,
>  }
>  
>  bool
> -nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
> +nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
>  {
>     if (instr1->type != instr2->type)
>        return false;
> -- 
> 2.1.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list