glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / loop_analysis.h
index e2eff9dbaed6c1baaf6b2ef283abca55f0879c29..d6fdb908e0d668c88f063bdec92c42b5fd36998e 100644 (file)
 extern class loop_state *
 analyze_loop_variables(exec_list *instructions);
 
-
-/**
- * Fill in loop control fields
- *
- * Based on analysis of loop variables, this function tries to remove
- * redundant sequences in the loop of the form
- *
- *  (if (expression bool ...) (break))
- *
- * For example, if it is provable that one loop exit condition will
- * always be satisfied before another, the unnecessary exit condition will be
- * removed.
- */
-extern bool
-set_loop_controls(exec_list *instructions, loop_state *ls);
+static inline bool
+is_break(ir_instruction *ir)
+{
+   return ir != NULL && ir->ir_type == ir_type_loop_jump &&
+      ((ir_loop_jump *) ir)->is_break();
+}
 
 
 extern bool
@@ -64,7 +55,7 @@ public:
    class loop_variable *get(const ir_variable *);
    class loop_variable *insert(ir_variable *);
    class loop_variable *get_or_insert(ir_variable *, bool in_assignee);
-   class loop_terminator *insert(ir_if *);
+   class loop_terminator *insert(ir_if *, bool continue_from_then);
 
 
    /**
@@ -122,8 +113,7 @@ public:
    {
       this->num_loop_jumps = 0;
       this->contains_calls = false;
-      this->var_hash = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                               _mesa_key_pointer_equal);
+      this->var_hash = _mesa_pointer_hash_table_create(NULL);
       this->limiting_terminator = NULL;
    }
 
@@ -219,6 +209,9 @@ public:
     * terminate the loop (if that is a fixed value).  Otherwise -1.
     */
    int iterations;
+
+   /* Does the if continue from the then branch or the else branch */
+   bool continue_from_then;
 };