From 95683bdce347cb706453479b660b05cda738ade4 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 4 Apr 2018 20:40:33 -0400 Subject: [PATCH] nir: promote intrinsic_get_var() to helper Useful in a few other places.. let's not copy-pasta Signed-off-by: Rob Clark Acked-by: Rob Clark Acked-by: Bas Nieuwenhuizen Acked-by: Dave Airlie Reviewed-by: Kenneth Graunke --- src/compiler/nir/nir.h | 6 ++++++ src/compiler/nir/nir_propagate_invariant.c | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 6f2f65848f2..80210945c9b 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1111,6 +1111,12 @@ typedef struct { nir_src src[]; } nir_intrinsic_instr; +static inline nir_variable * +nir_intrinsic_get_var(nir_intrinsic_instr *intrin, unsigned i) +{ + return nir_deref_instr_get_variable(nir_src_as_deref(intrin->src[i])); +} + /** * \name NIR intrinsics semantic flags * diff --git a/src/compiler/nir/nir_propagate_invariant.c b/src/compiler/nir/nir_propagate_invariant.c index 9d17bdbc667..b95313d4c1e 100644 --- a/src/compiler/nir/nir_propagate_invariant.c +++ b/src/compiler/nir/nir_propagate_invariant.c @@ -74,12 +74,6 @@ var_is_invariant(nir_variable *var, struct set * invariants) return var->data.invariant || _mesa_set_search(invariants, var); } -static nir_variable * -intrinsic_get_var(nir_intrinsic_instr *intrin, unsigned i) -{ - return nir_deref_instr_get_variable(nir_src_as_deref(intrin->src[i])); -} - static void propagate_invariant_instr(nir_instr *instr, struct set *invariants) { @@ -106,17 +100,17 @@ propagate_invariant_instr(nir_instr *instr, struct set *invariants) switch (intrin->intrinsic) { case nir_intrinsic_copy_deref: /* If the destination is invariant then so is the source */ - if (var_is_invariant(intrinsic_get_var(intrin, 0), invariants)) - add_var(intrinsic_get_var(intrin, 1), invariants); + if (var_is_invariant(nir_intrinsic_get_var(intrin, 0), invariants)) + add_var(nir_intrinsic_get_var(intrin, 1), invariants); break; case nir_intrinsic_load_deref: if (dest_is_invariant(&intrin->dest, invariants)) - add_var(intrinsic_get_var(intrin, 0), invariants); + add_var(nir_intrinsic_get_var(intrin, 0), invariants); break; case nir_intrinsic_store_deref: - if (var_is_invariant(intrinsic_get_var(intrin, 0), invariants)) + if (var_is_invariant(nir_intrinsic_get_var(intrin, 0), invariants)) add_src(&intrin->src[1], invariants); break; -- 2.30.2