nir: Add a src_get_parent_instr function
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 2 Apr 2015 18:07:48 +0000 (11:07 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 3 Apr 2015 21:04:12 +0000 (14:04 -0700)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/nir/nir.h
src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c

index 6e2aa97d49838e72e7e73249eec6759419a9b85b..0509e64e1e26e35c8860312a7a2f05daf135844b 100644 (file)
@@ -529,6 +529,16 @@ nir_src_for_reg(nir_register *reg)
    return src;
 }
 
+static inline nir_instr *
+nir_src_get_parent_instr(const nir_src *src)
+{
+   if (src->is_ssa) {
+      return src->ssa->parent_instr;
+   } else {
+      return src->reg.reg->parent_instr;
+   }
+}
+
 static inline nir_dest
 nir_dest_for_reg(nir_register *reg)
 {
index 3a27cf1a3d209138ed033a70eca89a0d6f1e5988..f0b018cf84a15a60d92e25ebd5721ab37dc7c2d6 100644 (file)
 static uint8_t
 get_resolve_status_for_src(nir_src *src)
 {
-   nir_instr *src_instr;
-   if (src->is_ssa) {
-      src_instr = src->ssa->parent_instr;
-   } else {
-      src_instr = src->reg.reg->parent_instr;
-   }
-
+   nir_instr *src_instr = nir_src_get_parent_instr(src);
    if (src_instr) {
       uint8_t resolve_status = src_instr->pass_flags & BRW_NIR_BOOLEAN_MASK;
 
@@ -72,13 +66,7 @@ get_resolve_status_for_src(nir_src *src)
 static bool
 src_mark_needs_resolve(nir_src *src, void *void_state)
 {
-   nir_instr *src_instr;
-   if (src->is_ssa) {
-      src_instr = src->ssa->parent_instr;
-   } else {
-      src_instr = src->reg.reg->parent_instr;
-   }
-
+   nir_instr *src_instr = nir_src_get_parent_instr(src);
    if (src_instr) {
       uint8_t resolve_status = src_instr->pass_flags & BRW_NIR_BOOLEAN_MASK;