From: Jason Ekstrand Date: Fri, 19 Apr 2019 20:09:04 +0000 (-0500) Subject: nir: Use the NIR_SRC_AS_ macro to define nir_src_as_deref X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ccb25aaeafa4d5bc82da76774a3776e83638f211;p=mesa.git nir: Use the NIR_SRC_AS_ macro to define nir_src_as_deref We have a macro for this now; no reason to hand-roll it for derefs. While we're here, move the NIR_DEFINE_CAST for derefs down to where all the other ones are. Reviewed-by: Eric Anholt --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index f4bd85f9255..7d2062d3691 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1041,20 +1041,7 @@ typedef struct { nir_dest dest; } nir_deref_instr; -NIR_DEFINE_CAST(nir_instr_as_deref, nir_instr, nir_deref_instr, instr, - type, nir_instr_type_deref) - -static inline nir_deref_instr * -nir_src_as_deref(nir_src src) -{ - if (!src.is_ssa) - return NULL; - - if (src.ssa->parent_instr->type != nir_instr_type_deref) - return NULL; - - return nir_instr_as_deref(src.ssa->parent_instr); -} +static inline nir_deref_instr *nir_src_as_deref(nir_src src); static inline nir_deref_instr * nir_deref_instr_parent(const nir_deref_instr *instr) @@ -1793,6 +1780,8 @@ typedef struct { NIR_DEFINE_CAST(nir_instr_as_alu, nir_instr, nir_alu_instr, instr, type, nir_instr_type_alu) +NIR_DEFINE_CAST(nir_instr_as_deref, nir_instr, nir_deref_instr, instr, + type, nir_instr_type_deref) NIR_DEFINE_CAST(nir_instr_as_call, nir_instr, nir_call_instr, instr, type, nir_instr_type_call) NIR_DEFINE_CAST(nir_instr_as_jump, nir_instr, nir_jump_instr, instr, @@ -2762,6 +2751,7 @@ nir_src_as_ ## name (nir_src src) \ NIR_SRC_AS_(alu_instr, nir_alu_instr, nir_instr_type_alu, nir_instr_as_alu) NIR_SRC_AS_(intrinsic, nir_intrinsic_instr, nir_instr_type_intrinsic, nir_instr_as_intrinsic) +NIR_SRC_AS_(deref, nir_deref_instr, nir_instr_type_deref, nir_instr_as_deref) bool nir_src_is_dynamically_uniform(nir_src src); bool nir_srcs_equal(nir_src src1, nir_src src2);