[Mesa-dev] [PATCH 21/23] glsl: Convert loop analysis to the util hash table

Thomas Helland thomashelland90 at gmail.com
Tue Aug 16 20:10:34 UTC 2016


Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/compiler/glsl/loop_analysis.cpp | 25 ++++++++++++++-----------
 src/compiler/glsl/loop_analysis.h   |  8 ++++----
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/compiler/glsl/loop_analysis.cpp b/src/compiler/glsl/loop_analysis.cpp
index 096a80a..b9bae43 100644
--- a/src/compiler/glsl/loop_analysis.cpp
+++ b/src/compiler/glsl/loop_analysis.cpp
@@ -75,8 +75,8 @@ loop_variable::record_reference(bool in_assignee,
 
 loop_state::loop_state()
 {
-   this->ht = hash_table_ctor(0, hash_table_pointer_hash,
-			      hash_table_pointer_compare);
+   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+                                      _mesa_key_pointer_equal);
    this->mem_ctx = ralloc_context(NULL);
    this->loop_found = false;
 }
@@ -84,7 +84,7 @@ loop_state::loop_state()
 
 loop_state::~loop_state()
 {
-   hash_table_dtor(this->ht);
+   _mesa_hash_table_destroy(this->ht, NULL);
    ralloc_free(this->mem_ctx);
 }
 
@@ -94,7 +94,7 @@ loop_state::insert(ir_loop *ir)
 {
    loop_variable_state *ls = new(this->mem_ctx) loop_variable_state;
 
-   hash_table_insert(this->ht, ls, ir);
+   _mesa_hash_table_insert(this->ht, ir, ls);
    this->loop_found = true;
 
    return ls;
@@ -104,14 +104,16 @@ loop_state::insert(ir_loop *ir)
 loop_variable_state *
 loop_state::get(const ir_loop *ir)
 {
-   return (loop_variable_state *) hash_table_find(this->ht, ir);
+   hash_entry *entry = _mesa_hash_table_search(this->ht, ir);
+   return entry ? (loop_variable_state *) entry->data : NULL;
 }
 
 
 loop_variable *
 loop_variable_state::get(const ir_variable *ir)
 {
-   return (loop_variable *) hash_table_find(this->var_hash, ir);
+   hash_entry *entry = _mesa_hash_table_search(this->var_hash, ir);
+   return entry ? (loop_variable *) entry->data : NULL;
 }
 
 
@@ -123,7 +125,7 @@ loop_variable_state::insert(ir_variable *var)
 
    lv->var = var;
 
-   hash_table_insert(this->var_hash, lv, lv->var);
+   _mesa_hash_table_insert(this->var_hash, lv->var, lv);
    this->variables.push_tail(lv);
 
    return lv;
@@ -518,8 +520,9 @@ public:
 
    virtual ir_visitor_status visit(ir_dereference_variable *ir)
    {
-      loop_variable *lv =
-	 (loop_variable *) hash_table_find(this->loop_variables, ir->var);
+      hash_entry *entry = _mesa_hash_table_search(this->loop_variables,
+                                                  ir->var);
+      loop_variable *lv = entry ? (loop_variable *) entry->data : NULL;
 
       assert(lv != NULL);
 
@@ -576,8 +579,8 @@ get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash)
    if (inc->as_constant() == NULL) {
       ir_variable *const inc_var = inc->variable_referenced();
       if (inc_var != NULL) {
-	 loop_variable *lv =
-	    (loop_variable *) hash_table_find(var_hash, inc_var);
+         hash_entry *entry = _mesa_hash_table_search(var_hash, inc_var);
+         loop_variable *lv = entry ? (loop_variable *) entry->data : NULL;
 
          if (lv == NULL || !lv->is_loop_constant()) {
             assert(lv != NULL);
diff --git a/src/compiler/glsl/loop_analysis.h b/src/compiler/glsl/loop_analysis.h
index 3b1971d..727a91c 100644
--- a/src/compiler/glsl/loop_analysis.h
+++ b/src/compiler/glsl/loop_analysis.h
@@ -27,7 +27,7 @@
 #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
@@ -130,14 +130,14 @@ 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_hash_table_create(NULL, _mesa_hash_pointer,
+                                               _mesa_key_pointer_equal);
       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)
-- 
2.9.2



More information about the mesa-dev mailing list