nir: Stop using apostrophes to pluralize.
[mesa.git] / src / compiler / nir / nir_search_helpers.h
index 20fdae66e2cc999f530618a992df9ed1b3fe6b69..faa3bdfd12b390abc27fb98567183324ca3bea55 100644 (file)
@@ -41,7 +41,7 @@ is_pos_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components,
 {
    nir_const_value *val = nir_src_as_const_value(instr->src[src].src);
 
-   /* only constant src's: */
+   /* only constant srcs: */
    if (!val)
       return false;
 
@@ -71,7 +71,7 @@ is_neg_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components,
 {
    nir_const_value *val = nir_src_as_const_value(instr->src[src].src);
 
-   /* only constant src's: */
+   /* only constant srcs: */
    if (!val)
       return false;
 
@@ -114,4 +114,48 @@ is_zero_to_one(nir_alu_instr *instr, unsigned src, unsigned num_components,
    return true;
 }
 
+static inline bool
+is_used_more_than_once(nir_alu_instr *instr)
+{
+   bool zero_if_use = list_empty(&instr->dest.dest.ssa.if_uses);
+   bool zero_use = list_empty(&instr->dest.dest.ssa.uses);
+
+   if (zero_use && zero_if_use)
+      return false;
+   else if (zero_use && list_is_singular(&instr->dest.dest.ssa.if_uses))
+      return false;
+   else if (zero_if_use && list_is_singular(&instr->dest.dest.ssa.uses))
+      return false;
+
+   return true;
+}
+
+static inline bool
+is_used_once(nir_alu_instr *instr)
+{
+   bool zero_if_use = list_empty(&instr->dest.dest.ssa.if_uses);
+   bool zero_use = list_empty(&instr->dest.dest.ssa.uses);
+
+   if (zero_if_use && zero_use)
+      return false;
+
+   if (!zero_if_use && list_is_singular(&instr->dest.dest.ssa.uses))
+     return false;
+
+   if (!zero_use && list_is_singular(&instr->dest.dest.ssa.if_uses))
+     return false;
+
+   if (!list_is_singular(&instr->dest.dest.ssa.if_uses) &&
+       !list_is_singular(&instr->dest.dest.ssa.uses))
+      return false;
+
+   return true;
+}
+
+static inline bool
+is_not_used_by_if(nir_alu_instr *instr)
+{
+   return list_empty(&instr->dest.dest.ssa.if_uses);
+}
+
 #endif /* _NIR_SEARCH_ */