glsl: Put `sample`-qualified varyings in their own packing classes
[mesa.git] / src / glsl / loop_analysis.h
index f5c5a04be81d3463dbb48bb6d1a9deebe6edd1eb..98414b3c6149dc4e78c5b907138ef2f59b6f1ed4 100644 (file)
@@ -56,6 +56,10 @@ extern bool
 set_loop_controls(exec_list *instructions, loop_state *ls);
 
 
+extern bool
+unroll_loops(exec_list *instructions, loop_state *ls, unsigned max_iterations);
+
+
 /**
  * Tracking for all variables used in a loop
  */
@@ -66,11 +70,6 @@ public:
    class loop_terminator *insert(ir_if *);
 
 
-   /**
-    * Loop whose variable state is being tracked by this structure
-    */
-   ir_loop *loop;
-
    /**
     * Variables that have not yet been classified
     */
@@ -104,14 +103,30 @@ public:
     */
    hash_table *var_hash;
 
+   /**
+    * Maximum number of loop iterations.
+    *
+    * If this value is negative, then the loop may be infinite.  This actually
+    * means that analysis was unable to determine an upper bound on the number
+    * of loop iterations.
+    */
+   int max_iterations;
+
    /**
     * Number of ir_loop_jump instructions that operate on this loop
     */
    unsigned num_loop_jumps;
 
+   /**
+    * Whether this loop contains any function calls.
+    */
+   bool contains_calls;
+
    loop_variable_state()
    {
+      this->max_iterations = -1;
       this->num_loop_jumps = 0;
+      this->contains_calls = false;
       this->var_hash = hash_table_ctor(0, hash_table_pointer_hash,
                                       hash_table_pointer_compare);
    }
@@ -120,6 +135,23 @@ public:
    {
       hash_table_dtor(this->var_hash);
    }
+
+   static void* operator new(size_t size, void *ctx)
+   {
+      void *lvs = ralloc_size(ctx, size);
+      assert(lvs != NULL);
+
+      ralloc_set_destructor(lvs, (void (*)(void*)) destructor);
+
+      return lvs;
+   }
+
+private:
+   static void
+   destructor(loop_variable_state *lvs)
+   {
+      lvs->~loop_variable_state();
+   }
 };
 
 
@@ -200,6 +232,8 @@ public:
 
    loop_variable_state *insert(ir_loop *ir);
 
+   bool loop_found;
+
 private:
    loop_state();
 
@@ -210,7 +244,7 @@ private:
 
    void *mem_ctx;
 
-   friend class loop_analysis;
+   friend loop_state *analyze_loop_variables(exec_list *instructions);
 };
 
 #endif /* LOOP_ANALYSIS_H */