--- src/compiler/glsl/opt_constant_propagation.cpp | 47 ++++++++++++-------------- 1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/src/compiler/glsl/opt_constant_propagation.cpp b/src/compiler/glsl/opt_constant_propagation.cpp index 05dc71efb7..8072bf4811 100644 --- a/src/compiler/glsl/opt_constant_propagation.cpp +++ b/src/compiler/glsl/opt_constant_propagation.cpp @@ -41,6 +41,7 @@ #include "ir_optimization.h" #include "compiler/glsl_types.h" #include "util/hash_table.h" +#include "util/pointer_map.h" namespace { @@ -103,8 +104,7 @@ public: mem_ctx = ralloc_context(0); this->lin_ctx = linear_alloc_parent(this->mem_ctx, 0); this->acp = new(mem_ctx) exec_list; - this->kills = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, - _mesa_key_pointer_equal); + this->kills = _mesa_pointer_map_create(mem_ctx); } ~ir_constant_propagation_visitor() { @@ -129,10 +129,10 @@ public: exec_list *acp; /** - * Hash table of kill_entry: The masks of variables whose values were + * Pointer map of kill_entry: The masks of variables whose values were * killed in this block. */ - hash_table *kills; + pointer_map *kills; bool progress; @@ -269,12 +269,11 @@ ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir) * main() at link time, so they're irrelevant to us. */ exec_list *orig_acp = this->acp; - hash_table *orig_kills = this->kills; + pointer_map *orig_kills = this->kills; bool orig_killed_all = this->killed_all; this->acp = new(mem_ctx) exec_list; - this->kills = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, - _mesa_key_pointer_equal); + this->kills = _mesa_pointer_map_create(mem_ctx); this->killed_all = false; visit_list_elements(this, &ir->body); @@ -359,12 +358,11 @@ void ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) { exec_list *orig_acp = this->acp; - hash_table *orig_kills = this->kills; + pointer_map *orig_kills = this->kills; bool orig_killed_all = this->killed_all; this->acp = new(mem_ctx) exec_list; - this->kills = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, - _mesa_key_pointer_equal); + this->kills = _mesa_pointer_map_create(mem_ctx); this->killed_all = false; /* Populate the initial acp with a constant of the original */ @@ -378,14 +376,14 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) orig_acp->make_empty(); } - hash_table *new_kills = this->kills; + pointer_map *new_kills = this->kills; this->kills = orig_kills; this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - hash_entry *htk; - hash_table_foreach(new_kills, htk) { - kill_entry *k = (kill_entry *) htk->data; + map_entry *me; + _mesa_pointer_map_foreach(new_kills, me) { + kill_entry *k = (kill_entry *) me->data; kill(k->var, k->write_mask); } } @@ -407,7 +405,7 @@ ir_visitor_status ir_constant_propagation_visitor::visit_enter(ir_loop *ir) { exec_list *orig_acp = this->acp; - hash_table *orig_kills = this->kills; + pointer_map *orig_kills = this->kills; bool orig_killed_all = this->killed_all; /* FINISHME: For now, the initial acp for loops is totally empty. @@ -415,8 +413,7 @@ ir_constant_propagation_visitor::visit_enter(ir_loop *ir) * cloned minus the killed entries after the first run through. */ this->acp = new(mem_ctx) exec_list; - this->kills = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, - _mesa_key_pointer_equal); + this->kills = _mesa_pointer_map_create(mem_ctx); this->killed_all = false; visit_list_elements(this, &ir->body_instructions); @@ -425,14 +422,14 @@ ir_constant_propagation_visitor::visit_enter(ir_loop *ir) orig_acp->make_empty(); } - hash_table *new_kills = this->kills; + pointer_map *new_kills = this->kills; this->kills = orig_kills; this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - hash_entry *htk; - hash_table_foreach(new_kills, htk) { - kill_entry *k = (kill_entry *) htk->data; + map_entry *me; + _mesa_pointer_map_foreach(new_kills, me) { + kill_entry *k = (kill_entry *) me->data; kill(k->var, k->write_mask); } @@ -461,14 +458,14 @@ ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask) /* Add this writemask of the variable to the hash table of killed * variables in this block. */ - hash_entry *kill_hash_entry = _mesa_hash_table_search(this->kills, var); - if (kill_hash_entry) { - kill_entry *entry = (kill_entry *) kill_hash_entry->data; + map_entry *kill_map_entry = _mesa_pointer_map_search(this->kills, var); + if (kill_map_entry) { + kill_entry *entry = (kill_entry *) kill_map_entry->data; entry->write_mask |= write_mask; return; } /* Not already in the hash table. Make new entry. */ - _mesa_hash_table_insert(this->kills, var, + _mesa_pointer_map_insert(this->kills, var, new(this->lin_ctx) kill_entry(var, write_mask)); } -- 2.16.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev