glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / loop_analysis.h
index 3b1971d7edce2ca3283ac5ae820c1b75224ac67b..d6fdb908e0d668c88f063bdec92c42b5fd36998e 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef LOOP_ANALYSIS_H
 #define LOOP_ANALYSIS_H
 
 #include "ir.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
 
 /**
  * Analyze and classify all variables used in all loops in the instruction list
 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
 unroll_loops(exec_list *instructions, loop_state *ls,
              const struct gl_shader_compiler_options *options);
 
-ir_rvalue *
-find_initial_value(ir_loop *loop, ir_variable *var);
-
-int
-calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
-                    enum ir_expression_operation op);
-
 
 /**
  * Tracking for all variables used in a loop
@@ -72,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);
 
 
    /**
@@ -130,14 +113,13 @@ public:
    {
       this->num_loop_jumps = 0;
       this->contains_calls = false;
-      this->var_hash = hash_table_ctor(0, hash_table_pointer_hash,
-                                      hash_table_pointer_compare);
+      this->var_hash = _mesa_pointer_hash_table_create(NULL);
       this->limiting_terminator = NULL;
    }
 
    ~loop_variable_state()
    {
-      hash_table_dtor(this->var_hash);
+      _mesa_hash_table_destroy(this->var_hash, NULL);
    }
 
    DECLARE_RALLOC_CXX_OPERATORS(loop_variable_state)
@@ -227,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;
 };