src/compiler: use new hash table and set creation helpers
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 11 Jan 2019 19:50:53 +0000 (11:50 -0800)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 14 Jan 2019 18:49:28 +0000 (10:49 -0800)
Replace calls to create hash tables and sets that use
_mesa_hash_pointer/_mesa_key_pointer_equal with the helpers
_mesa_pointer_hash_table_create() and _mesa_pointer_set_create().

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Eric Engestrom <eric@engestrom.ch>
42 files changed:
src/compiler/glsl/gl_nir_linker.c
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir_array_refcount.cpp
src/compiler/glsl/ir_builder_print_visitor.cpp
src/compiler/glsl/ir_clone.cpp
src/compiler/glsl/ir_constant_expression.cpp
src/compiler/glsl/ir_function_detect_recursion.cpp
src/compiler/glsl/ir_print_visitor.cpp
src/compiler/glsl/ir_validate.cpp
src/compiler/glsl/ir_variable_refcount.cpp
src/compiler/glsl/link_functions.cpp
src/compiler/glsl/linker.cpp
src/compiler/glsl/loop_analysis.cpp
src/compiler/glsl/loop_analysis.h
src/compiler/glsl/lower_if_to_cond_assign.cpp
src/compiler/glsl/opt_constant_propagation.cpp
src/compiler/glsl/opt_constant_variable.cpp
src/compiler/glsl/opt_copy_propagation_elements.cpp
src/compiler/glsl/opt_function_inlining.cpp
src/compiler/glsl/standalone.cpp
src/compiler/nir/nir.c
src/compiler/nir/nir_clone.c
src/compiler/nir/nir_deref.c
src/compiler/nir/nir_from_ssa.c
src/compiler/nir/nir_inline_functions.c
src/compiler/nir/nir_linking_helpers.c
src/compiler/nir/nir_lower_global_vars_to_local.c
src/compiler/nir/nir_lower_io_arrays_to_elements.c
src/compiler/nir/nir_lower_io_to_scalar.c
src/compiler/nir/nir_lower_phis_to_scalar.c
src/compiler/nir/nir_lower_vars_to_ssa.c
src/compiler/nir/nir_opt_copy_prop_vars.c
src/compiler/nir/nir_opt_loop_unroll.c
src/compiler/nir/nir_print.c
src/compiler/nir/nir_propagate_invariant.c
src/compiler/nir/nir_remove_dead_variables.c
src/compiler/nir/nir_serialize.c
src/compiler/nir/nir_split_per_member_structs.c
src/compiler/nir/nir_split_vars.c
src/compiler/nir/nir_validate.c
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_cfg.c

index 547549bc4e072ed2553eef139a920c68b0734baf..92e90714e10bf6561070bea7ebad032f2c4f8b9a 100644 (file)
@@ -44,9 +44,7 @@ nir_build_program_resource_list(struct gl_context *ctx,
       prog->data->NumProgramResourceList = 0;
    }
 
-   struct set *resource_set = _mesa_set_create(NULL,
-                                               _mesa_hash_pointer,
-                                               _mesa_key_pointer_equal);
+   struct set *resource_set = _mesa_pointer_set_create(NULL);
 
    /* Add uniforms
     *
index 424298ad952e9062cf85f1a9c5f58c6242f4bd1f..8f786575fcebade5e2ac0a80caab880b01233525 100644 (file)
@@ -176,10 +176,8 @@ nir_visitor::nir_visitor(nir_shader *shader)
    this->supports_ints = shader->options->native_integers;
    this->shader = shader;
    this->is_global = true;
-   this->var_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
-   this->overload_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                  _mesa_key_pointer_equal);
+   this->var_table = _mesa_pointer_hash_table_create(NULL);
+   this->overload_table = _mesa_pointer_hash_table_create(NULL);
    this->result = NULL;
    this->impl = NULL;
    memset(&this->b, 0, sizeof(this->b));
index 1a46b2185d4b875ad083ac9ec1cd8a0c53cfbdf3..c2295c96ca9e80288f60a77bd26c2a1636a8dc31 100644 (file)
@@ -37,8 +37,7 @@ ir_array_refcount_visitor::ir_array_refcount_visitor()
    : last_array_deref(0), derefs(0), num_derefs(0), derefs_size(0)
 {
    this->mem_ctx = ralloc_context(NULL);
-   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+   this->ht = _mesa_pointer_hash_table_create(NULL);
 }
 
 static void
index da04868652a402ce855c0d553c4d2b9e4b15b061..57424699d00aae388ebaca17c591606c49cda1f2 100644 (file)
@@ -141,8 +141,7 @@ _mesa_print_builder_for_ir(FILE *f, exec_list *instructions)
 ir_builder_print_visitor::ir_builder_print_visitor(FILE *f)
    : next_ir_index(1), f(f), indentation(0)
 {
-   index_map =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+   index_map = _mesa_pointer_hash_table_create(NULL);
 }
 
 ir_builder_print_visitor::~ir_builder_print_visitor()
index e1f4f3b2903dd30697a44afb6301abbe956f9b14..c492fdbb3d0254d8a228d1132db31f3a986f6a12 100644 (file)
@@ -419,8 +419,7 @@ fixup_function_calls(struct hash_table *ht, exec_list *instructions)
 void
 clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in)
 {
-   struct hash_table *ht =
-         _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+   struct hash_table *ht = _mesa_pointer_hash_table_create(NULL);
 
    foreach_in_list(const ir_instruction, original, in) {
       ir_instruction *copy = original->clone(mem_ctx, ht);
index bfc22c0011adc09a887db00df3173e2eaf8d4404..cb8558eb00dae3873d192b695356cacb66c71ee0 100644 (file)
@@ -1024,8 +1024,7 @@ ir_function_signature::constant_expression_value(void *mem_ctx,
     * We expect the correctness of the number of parameters to have
     * been checked earlier.
     */
-   hash_table *deref_hash = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                    _mesa_key_pointer_equal);
+   hash_table *deref_hash = _mesa_pointer_hash_table_create(NULL);
 
    /* If "origin" is non-NULL, then the function body is there.  So we
     * have to use the variable objects from the object with the body,
index 5b05274d0015ac64efa8c4b2dc207265f996d6cc..4a774f666c9a6e39919cc735c053e0cb789c4398 100644 (file)
@@ -158,8 +158,7 @@ public:
    {
       progress = false;
       this->mem_ctx = ralloc_context(NULL);
-      this->function_hash = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                    _mesa_key_pointer_equal);
+      this->function_hash = _mesa_pointer_hash_table_create(NULL);
    }
 
    ~has_recursion_visitor()
index 1626657081ea36bbaf1351bca4745403c87f92bc..ef6bca1229ebc4136bb295d4f6ee085e9c417a0d 100644 (file)
@@ -90,8 +90,7 @@ ir_print_visitor::ir_print_visitor(FILE *f)
    : f(f)
 {
    indentation = 0;
-   printable_names =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+   printable_names = _mesa_pointer_hash_table_create(NULL);
    symbols = _mesa_symbol_table_ctor();
    mem_ctx = ralloc_context(NULL);
 }
index aa07f8aea642151bec41e9336aebb4cd469a7180..819e8aa60dd3e5a6e0dc8b1a60f777fb01fd7c9a 100644 (file)
@@ -46,8 +46,7 @@ class ir_validate : public ir_hierarchical_visitor {
 public:
    ir_validate()
    {
-      this->ir_set = _mesa_set_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+      this->ir_set = _mesa_pointer_set_create(NULL);
 
       this->current_function = NULL;
 
index 8306be10b9c5a3eebe28e6070d26c7c32c3d77bb..47e9d0c897c709323ddfac19292a7f89191a47d5 100644 (file)
@@ -38,8 +38,7 @@
 ir_variable_refcount_visitor::ir_variable_refcount_visitor()
 {
    this->mem_ctx = ralloc_context(NULL);
-   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+   this->ht = _mesa_pointer_hash_table_create(NULL);
 }
 
 static void
index e73a72c86c9bf6255fdf63239aa9368215473e4c..4998d39dc597a16e99f411fc28566c83a52ef836 100644 (file)
@@ -47,8 +47,7 @@ public:
       this->success = true;
       this->linked = linked;
 
-      this->locals = _mesa_set_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+      this->locals = _mesa_pointer_set_create(NULL);
    }
 
    ~call_link_visitor()
@@ -148,8 +147,7 @@ public:
        * replace signature stored in a function.  One could easily be added,
        * but this avoids the need.
        */
-      struct hash_table *ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                      _mesa_key_pointer_equal);
+      struct hash_table *ht = _mesa_pointer_hash_table_create(NULL);
 
       exec_list formal_parameters;
       foreach_in_list(const ir_instruction, original, &sig->parameters) {
index d9b9f60067f591699c8ccf5b53fbb6e0bdd998d1..2d76e852f47490b31dd4736213a89b2a03a41db8 100644 (file)
@@ -1460,8 +1460,7 @@ move_non_declarations(exec_list *instructions, exec_node *last,
    hash_table *temps = NULL;
 
    if (make_copies)
-      temps = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+      temps = _mesa_pointer_hash_table_create(NULL);
 
    foreach_in_list_safe(ir_instruction, inst, instructions) {
       if (inst->as_function())
@@ -1507,8 +1506,7 @@ class array_sizing_visitor : public deref_type_updater {
 public:
    array_sizing_visitor()
       : mem_ctx(ralloc_context(NULL)),
-        unnamed_interfaces(_mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                   _mesa_key_pointer_equal))
+        unnamed_interfaces(_mesa_pointer_hash_table_create(NULL))
    {
    }
 
@@ -4412,9 +4410,7 @@ build_program_resource_list(struct gl_context *ctx,
    if (input_stage == MESA_SHADER_STAGES && output_stage == 0)
       return;
 
-   struct set *resource_set = _mesa_set_create(NULL,
-                                               _mesa_hash_pointer,
-                                               _mesa_key_pointer_equal);
+   struct set *resource_set = _mesa_pointer_set_create(NULL);
 
    /* Program interface needs to expose varyings in case of SSO. */
    if (shProg->SeparateShader) {
index 0fb6e9feb743dda471603af491555c7a13926ce6..e90eb1ccde5a028bb07c8b285f7f41bae7ca8316 100644 (file)
@@ -252,8 +252,7 @@ loop_variable::record_reference(bool in_assignee,
 
 loop_state::loop_state()
 {
-   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+   this->ht = _mesa_pointer_hash_table_create(NULL);
    this->mem_ctx = ralloc_context(NULL);
    this->loop_found = false;
 }
index 4e1100184611f5dbec7399b01d0db4e78609d904..d6fdb908e0d668c88f063bdec92c42b5fd36998e 100644 (file)
@@ -113,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;
    }
 
index 0d6aa0049d43e25dce10423ecc543ae45a772eaf..ca61f1d52739f9eace58a5a25a2392cbebccd4c6 100644 (file)
@@ -71,9 +71,7 @@ public:
       this->min_branch_cost = min_branch_cost;
       this->depth = 0;
 
-      this->condition_variables =
-            _mesa_set_create(NULL, _mesa_hash_pointer,
-                                    _mesa_key_pointer_equal);
+      this->condition_variables = _mesa_pointer_set_create(NULL);
    }
 
    ~ir_if_to_cond_assign_visitor()
index 642bd641ed62459c97a26fa7ab27f36bc533c53b..cc57c48c83aaab34857d86c20061b898e917f1de 100644 (file)
@@ -86,8 +86,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_hash_table_create(mem_ctx);
    }
    ~ir_constant_propagation_visitor()
    {
@@ -256,8 +255,7 @@ ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir)
    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_hash_table_create(mem_ctx);
    this->killed_all = false;
 
    visit_list_elements(this, &ir->body);
@@ -368,8 +366,7 @@ ir_constant_propagation_visitor::visit_enter(ir_if *ir)
    ir->condition->accept(this);
    handle_rvalue(&ir->condition);
 
-   hash_table *new_kills = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
-                                                   _mesa_key_pointer_equal);
+   hash_table *new_kills = _mesa_pointer_hash_table_create(mem_ctx);
    bool then_killed_all = false;
    bool else_killed_all = false;
 
@@ -398,8 +395,7 @@ ir_constant_propagation_visitor::handle_loop(ir_loop *ir, bool keep_acp)
    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_hash_table_create(mem_ctx);
    this->killed_all = false;
 
    if (keep_acp) {
index 15d8cf7cdfd1a2dccb2ac2351910caf48e9920e1..a1fffd4a5f124072b2f5c97001d4d0246c11cd9a 100644 (file)
@@ -186,8 +186,7 @@ do_constant_variable(exec_list *instructions)
    bool progress = false;
    ir_constant_variable_visitor v;
 
-   v.ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                  _mesa_key_pointer_equal);
+   v.ht = _mesa_pointer_hash_table_create(NULL);
    v.run(instructions);
 
    hash_table_foreach(v.ht, hte) {
index 78126ca3870a34f1b92b0d71933b5a59754121d2..081909903e547aa159bd3a7c7061de4fe9153dcf 100644 (file)
@@ -203,8 +203,7 @@ private:
       /* Use 'this' as context for the table, no explicit destruction
        * needed later.
        */
-      acp = _mesa_hash_table_create(this, _mesa_hash_pointer,
-                                    _mesa_key_pointer_equal);
+      acp = _mesa_pointer_hash_table_create(this);
       lin_ctx = linear_alloc_parent(this, 0);
    }
 
@@ -231,8 +230,7 @@ private:
       }
 
       if (!found) {
-         entry->dsts = _mesa_set_create(this, _mesa_hash_pointer,
-                                        _mesa_key_pointer_equal);
+         entry->dsts = _mesa_pointer_set_create(this);
       }
 
       return entry;
index 52f57da936df0147aa079c41fb7dc6b48745dbfa..590bd707bee22de592bee6cf8ccc6d899abd204f 100644 (file)
@@ -152,7 +152,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
    int i;
    struct hash_table *ht;
 
-   ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+   ht = _mesa_pointer_hash_table_create(NULL);
 
    num_parameters = this->callee->parameters.length();
    parameters = new ir_variable *[num_parameters];
index 96ea18f1303822b099a70afff0519218386b9a38..add4e4ea478d86bfaf7160858fb792ba91f56b98 100644 (file)
@@ -49,9 +49,7 @@ class dead_variable_visitor : public ir_hierarchical_visitor {
 public:
    dead_variable_visitor()
    {
-      variables = _mesa_set_create(NULL,
-                                   _mesa_hash_pointer,
-                                   _mesa_key_pointer_equal);
+      variables = _mesa_pointer_set_create(NULL);
    }
 
    virtual ~dead_variable_visitor()
index 3345266fa69e4dcd1fa94445ff98c5e58cac018d..1fc09d9c250c157b6aee165263cc5142fa2a8b39 100644 (file)
@@ -330,8 +330,7 @@ nir_block_create(nir_shader *shader)
    cf_init(&block->cf_node, nir_cf_node_block);
 
    block->successors[0] = block->successors[1] = NULL;
-   block->predecessors = _mesa_set_create(block, _mesa_hash_pointer,
-                                          _mesa_key_pointer_equal);
+   block->predecessors = _mesa_pointer_set_create(block);
    block->imm_dom = NULL;
    /* XXX maybe it would be worth it to defer allocation?  This
     * way it doesn't get allocated for shader refs that never run
@@ -341,8 +340,7 @@ nir_block_create(nir_shader *shader)
     * which is later used to do state specific lowering and futher
     * opt.  Do any of the references not need dominance metadata?
     */
-   block->dom_frontier = _mesa_set_create(block, _mesa_hash_pointer,
-                                          _mesa_key_pointer_equal);
+   block->dom_frontier = _mesa_pointer_set_create(block);
 
    exec_list_make_empty(&block->instr_list);
 
index c7c41ef5c6bf2b3ede779fad99964bd03c5a2bde..557c7d29f53c90cc523aad839fca5372c170963b 100644 (file)
@@ -62,8 +62,7 @@ init_clone_state(clone_state *state, struct hash_table *remap_table,
    if (remap_table) {
       state->remap_table = remap_table;
    } else {
-      state->remap_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                   _mesa_key_pointer_equal);
+      state->remap_table = _mesa_pointer_hash_table_create(NULL);
    }
 
    list_inithead(&state->phi_srcs);
index 26de64c5140d47e1d9dfaea22611106237905fa9..513e8242d7c21222ef792d6478ef995f9927a6af 100644 (file)
@@ -474,8 +474,7 @@ rematerialize_deref_in_block(nir_deref_instr *deref,
       return deref;
 
    if (!state->cache) {
-      state->cache = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+      state->cache = _mesa_pointer_hash_table_create(NULL);
    }
 
    struct hash_entry *cached = _mesa_hash_table_search(state->cache, deref);
index 8419b28576badc16edb10de9e148187868992253..99cfe75747763c119fd8443f7ab4a8e43e3fc732 100644 (file)
@@ -768,8 +768,7 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only)
    nir_builder_init(&state.builder, impl);
    state.dead_ctx = ralloc_context(NULL);
    state.phi_webs_only = phi_webs_only;
-   state.merge_node_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                    _mesa_key_pointer_equal);
+   state.merge_node_table = _mesa_pointer_hash_table_create(NULL);
    state.progress = false;
 
    nir_foreach_block(block, impl) {
index 74d39db7ab26cb3b7cc353aba838ebb06caf2c48..4e0bb8fcba138a6ece15a58c2b60980cab21b368 100644 (file)
@@ -209,8 +209,7 @@ inline_function_impl(nir_function_impl *impl, struct set *inlined)
 bool
 nir_inline_functions(nir_shader *shader)
 {
-   struct set *inlined = _mesa_set_create(NULL, _mesa_hash_pointer,
-                                          _mesa_key_pointer_equal);
+   struct set *inlined = _mesa_pointer_set_create(NULL);
    bool progress = false;
 
    nir_foreach_function(function, shader) {
index 2e89aa7dd19bf6895470c842238bc169aa63589b..b85e1295da3dfaf5b728d2183bdae94173980f7a 100644 (file)
@@ -712,9 +712,7 @@ nir_link_opt_varyings(nir_shader *producer, nir_shader *consumer)
 
    nir_function_impl *impl = nir_shader_get_entrypoint(producer);
 
-   struct hash_table *varying_values =
-      _mesa_hash_table_create(NULL,  _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *varying_values = _mesa_pointer_hash_table_create(NULL);
 
    /* If we find a store in the last block of the producer we can be sure this
     * is the only possible value for this output.
index 1ca7c1996a358630a8a8ec7f9976157f5dc3cd91..9eb76c7ed6c69b07612ec493d9bb19964d111deb 100644 (file)
@@ -74,9 +74,7 @@ nir_lower_global_vars_to_local(nir_shader *shader)
     * nir_function_impl that uses the given variable.  If a variable is
     * used in multiple functions, the data for the given key will be NULL.
     */
-   struct hash_table *var_func_table =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *var_func_table = _mesa_pointer_hash_table_create(NULL);
 
    nir_foreach_function(function, shader) {
       if (function->impl) {
index 3402024919957576329916e6be710ab769336fd9..9051d397fbcf48a4ce5e3d1a4e550e99e4aa1494 100644 (file)
@@ -343,12 +343,8 @@ void
 nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
                                              bool outputs_only)
 {
-   struct hash_table *split_inputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
-   struct hash_table *split_outputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL);
+   struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL);
 
    uint64_t indirects[4] = {0}, patch_indirects[4] = {0};
 
@@ -385,12 +381,8 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
 void
 nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer)
 {
-   struct hash_table *split_inputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
-   struct hash_table *split_outputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL);
+   struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL);
 
    uint64_t indirects[4] = {0}, patch_indirects[4] = {0};
    create_indirects_mask(producer, indirects, patch_indirects,
index d58805294b5fa908426f5c0905fff083cd3889e7..e9135b56ffdedd79b1f8dae93fec144807945729 100644 (file)
@@ -279,12 +279,8 @@ lower_store_output_to_scalar_early(nir_builder *b, nir_intrinsic_instr *intr,
 void
 nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask)
 {
-   struct hash_table *split_inputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
-   struct hash_table *split_outputs =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL);
+   struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL);
 
    nir_foreach_function(function, shader) {
       if (function->impl) {
index 904eff0d828055c3dfd36ca822d2d3e1be128d8d..3d7155c04f65dc886cb137f7d279ac63ddce1864 100644 (file)
@@ -275,8 +275,7 @@ lower_phis_to_scalar_impl(nir_function_impl *impl)
 
    state.mem_ctx = ralloc_parent(impl);
    state.dead_ctx = ralloc_context(NULL);
-   state.phi_table = _mesa_hash_table_create(state.dead_ctx, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+   state.phi_table = _mesa_pointer_hash_table_create(state.dead_ctx);
 
    nir_foreach_block(block, impl) {
       progress = lower_phis_to_scalar_block(block, &state) || progress;
index 9c8f75f1083a251a1aedc28795f0f882770631ef..62f9ad8bccac9e8f843852d7d504bff6cee3ea53 100644 (file)
@@ -376,8 +376,7 @@ register_load_instr(nir_intrinsic_instr *load_instr,
       return;
 
    if (node->loads == NULL)
-      node->loads = _mesa_set_create(state->dead_ctx, _mesa_hash_pointer,
-                                     _mesa_key_pointer_equal);
+      node->loads = _mesa_pointer_set_create(state->dead_ctx);
 
    _mesa_set_add(node->loads, load_instr);
 }
@@ -392,8 +391,7 @@ register_store_instr(nir_intrinsic_instr *store_instr,
       return;
 
    if (node->stores == NULL)
-      node->stores = _mesa_set_create(state->dead_ctx, _mesa_hash_pointer,
-                                     _mesa_key_pointer_equal);
+      node->stores = _mesa_pointer_set_create(state->dead_ctx);
 
    _mesa_set_add(node->stores, store_instr);
 }
@@ -409,8 +407,7 @@ register_copy_instr(nir_intrinsic_instr *copy_instr,
          continue;
 
       if (node->copies == NULL)
-         node->copies = _mesa_set_create(state->dead_ctx, _mesa_hash_pointer,
-                                         _mesa_key_pointer_equal);
+         node->copies = _mesa_pointer_set_create(state->dead_ctx);
 
       _mesa_set_add(node->copies, copy_instr);
    }
@@ -661,9 +658,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
    state.dead_ctx = ralloc_context(state.shader);
    state.impl = impl;
 
-   state.deref_var_nodes = _mesa_hash_table_create(state.dead_ctx,
-                                                   _mesa_hash_pointer,
-                                                   _mesa_key_pointer_equal);
+   state.deref_var_nodes = _mesa_pointer_hash_table_create(state.dead_ctx);
    exec_list_make_empty(&state.direct_deref_nodes);
 
    /* Build the initial deref structures and direct_deref_nodes table */
index 069fcad71998bd60d3bfa374edbe8f75d000e226..3dc0ad805738381506b7c3117bfc4a2a59ec188f 100644 (file)
@@ -106,8 +106,7 @@ create_vars_written(struct copy_prop_var_state *state)
 {
    struct vars_written *written =
       linear_zalloc_child(state->lin_ctx, sizeof(struct vars_written));
-   written->derefs = _mesa_hash_table_create(state->mem_ctx, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+   written->derefs = _mesa_pointer_hash_table_create(state->mem_ctx);
    return written;
 }
 
@@ -865,8 +864,7 @@ nir_copy_prop_vars_impl(nir_function_impl *impl)
       .mem_ctx = mem_ctx,
       .lin_ctx = linear_zalloc_parent(mem_ctx, 0),
 
-      .vars_written_map = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
-                                                  _mesa_key_pointer_equal),
+      .vars_written_map = _mesa_pointer_hash_table_create(mem_ctx),
    };
 
    gather_vars_written(&state, NULL, &impl->cf_node);
index 8406880204a017eb2a92905c8d2166ddc1e572b9..e599005083b1de16650c0b484db11a4566ad1ec1 100644 (file)
@@ -165,9 +165,7 @@ simple_unroll(nir_loop *loop)
    nir_cf_extract(&loop_body, nir_after_cf_node(&limiting_term->nif->cf_node),
                   nir_after_block(nir_loop_last_block(loop)));
 
-   struct hash_table *remap_table =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *remap_table = _mesa_pointer_hash_table_create(NULL);
 
    /* Clone the loop header and insert before the loop */
    nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,
@@ -417,9 +415,7 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,
       num_times_to_clone = loop->info->max_trip_count;
    }
 
-   struct hash_table *remap_table =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *remap_table = _mesa_pointer_hash_table_create(NULL);
 
    nir_cf_list lp_body;
    nir_cf_node *unroll_loc =
index cfbc8be7a2c23b92a01296b837c64fe083e6f0e5..88a82b1ef17ca50f7a2cebcc7a82e80fa59dae05 100644 (file)
@@ -1318,8 +1318,7 @@ init_print_state(print_state *state, nir_shader *shader, FILE *fp)
 {
    state->fp = fp;
    state->shader = shader;
-   state->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                       _mesa_key_pointer_equal);
+   state->ht = _mesa_pointer_hash_table_create(NULL);
    state->syms = _mesa_set_create(NULL, _mesa_key_hash_string,
                                   _mesa_key_string_equal);
    state->index = 0;
index 7e253492ba853d229da1369e13fde5b70c197c3d..103b2422b8354714c2b4543996a7ba031ed3ad15 100644 (file)
@@ -182,8 +182,7 @@ bool
 nir_propagate_invariant(nir_shader *shader)
 {
    /* Hash set of invariant things */
-   struct set *invariants = _mesa_set_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+   struct set *invariants = _mesa_pointer_set_create(NULL);
 
    bool progress = false;
    nir_foreach_function(function, shader) {
index a8a347b6a67b223324b707f57254f746cefafaf7..5c345bdb8542a1cf73861aa90608d4644fb08f49 100644 (file)
@@ -164,8 +164,7 @@ bool
 nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)
 {
    bool progress = false;
-   struct set *live =
-      _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+   struct set *live = _mesa_pointer_set_create(NULL);
 
    add_var_use_shader(shader, live, modes);
 
index 808df193754d041175f65d0554788f5951ff6bd0..743eeaed3d5b4d2507cc308c90594f216437aa45 100644 (file)
@@ -1082,8 +1082,7 @@ void
 nir_serialize(struct blob *blob, const nir_shader *nir)
 {
    write_ctx ctx;
-   ctx.remap_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+   ctx.remap_table = _mesa_pointer_hash_table_create(NULL);
    ctx.next_idx = 0;
    ctx.blob = blob;
    ctx.nir = nir;
index c1234c2e92a676d916b6ff26adea8f51ac29fcba..1c148d3d63e5aa65b85835a4ac1f23fc36ff41d0 100644 (file)
@@ -175,8 +175,7 @@ nir_split_per_member_structs(nir_shader *shader)
    bool progress = false;
    void *dead_ctx = ralloc_context(NULL);
    struct hash_table *var_to_member_map =
-      _mesa_hash_table_create(dead_ctx, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+      _mesa_pointer_hash_table_create(dead_ctx);
 
    progress |= split_variables_in_list(&shader->inputs, shader,
                                        var_to_member_map, dead_ctx);
index 5044d29f146e5f63165f94578dff7a425d4d89a1..0cf3e517f85d8ed1909f2802f5ce5c24d8d18d4e 100644 (file)
@@ -257,8 +257,7 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)
 {
    void *mem_ctx = ralloc_context(NULL);
    struct hash_table *var_field_map =
-      _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+      _mesa_pointer_hash_table_create(mem_ctx);
 
    assert((modes & (nir_var_private | nir_var_function)) == modes);
 
@@ -793,9 +792,7 @@ bool
 nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
 {
    void *mem_ctx = ralloc_context(NULL);
-   struct hash_table *var_info_map =
-      _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+   struct hash_table *var_info_map = _mesa_pointer_hash_table_create(mem_ctx);
 
    assert((modes & (nir_var_private | nir_var_function)) == modes);
 
@@ -973,8 +970,7 @@ mark_deref_used(nir_deref_instr *deref,
                                        true, mem_ctx);
       if (copy_usage) {
          if (usage->vars_copied == NULL) {
-            usage->vars_copied = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
-                                                  _mesa_key_pointer_equal);
+            usage->vars_copied = _mesa_pointer_set_create(mem_ctx);
          }
          _mesa_set_add(usage->vars_copied, copy_usage);
       } else {
@@ -1016,9 +1012,7 @@ mark_deref_used(nir_deref_instr *deref,
                &copy_usage->levels[copy_i++];
 
             if (level->levels_copied == NULL) {
-               level->levels_copied =
-                  _mesa_set_create(mem_ctx, _mesa_hash_pointer,
-                                   _mesa_key_pointer_equal);
+               level->levels_copied = _mesa_pointer_set_create(mem_ctx);
             }
             _mesa_set_add(level->levels_copied, copy_level);
          } else {
@@ -1523,8 +1517,7 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
    void *mem_ctx = ralloc_context(NULL);
 
    struct hash_table *var_usage_map =
-      _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
+      _mesa_pointer_hash_table_create(mem_ctx);
 
    bool has_vars_to_shrink = false;
    nir_foreach_function(function, shader) {
index f506b54d3b5eb7d80c5b9c3ad4d48e47df355568..c9732edda14c37cc7d047ae074fd11f2489278f3 100644 (file)
@@ -300,10 +300,8 @@ validate_ssa_def(nir_ssa_def *def, validate_state *state)
    ssa_def_validate_state *def_state = ralloc(state->ssa_defs,
                                               ssa_def_validate_state);
    def_state->where_defined = state->impl;
-   def_state->uses = _mesa_set_create(def_state, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
-   def_state->if_uses = _mesa_set_create(def_state, _mesa_hash_pointer,
-                                         _mesa_key_pointer_equal);
+   def_state->uses = _mesa_pointer_set_create(def_state);
+   def_state->if_uses = _mesa_pointer_set_create(def_state);
    _mesa_hash_table_insert(state->ssa_defs, def, def_state);
 }
 
@@ -927,12 +925,9 @@ prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)
    list_validate(&reg->if_uses);
 
    reg_validate_state *reg_state = ralloc(state->regs, reg_validate_state);
-   reg_state->uses = _mesa_set_create(reg_state, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
-   reg_state->if_uses = _mesa_set_create(reg_state, _mesa_hash_pointer,
-                                         _mesa_key_pointer_equal);
-   reg_state->defs = _mesa_set_create(reg_state, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+   reg_state->uses = _mesa_pointer_set_create(reg_state);
+   reg_state->if_uses = _mesa_pointer_set_create(reg_state);
+   reg_state->defs = _mesa_pointer_set_create(reg_state);
 
    reg_state->where_defined = is_global ? NULL : state->impl;
 
@@ -1132,16 +1127,12 @@ validate_function(nir_function *func, validate_state *state)
 static void
 init_validate_state(validate_state *state)
 {
-   state->regs = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                         _mesa_key_pointer_equal);
-   state->ssa_defs = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+   state->regs = _mesa_pointer_hash_table_create(NULL);
+   state->ssa_defs = _mesa_pointer_hash_table_create(NULL);
    state->ssa_defs_found = NULL;
    state->regs_found = NULL;
-   state->var_defs = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
-   state->errors = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                           _mesa_key_pointer_equal);
+   state->var_defs = _mesa_pointer_hash_table_create(NULL);
+   state->errors = _mesa_pointer_hash_table_create(NULL);
 
    state->loop = NULL;
    state->instr = NULL;
index 76a997ee34196f011f23efe4d5dbf2e7ae1202cc..0ca1ee48b5eee060a34359c324e48d960b03be6c 100644 (file)
@@ -4406,8 +4406,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
       progress = false;
       foreach_list_typed(struct vtn_function, func, node, &b->functions) {
          if (func->referenced && !func->emitted) {
-            b->const_table = _mesa_hash_table_create(b, _mesa_hash_pointer,
-                                                     _mesa_key_pointer_equal);
+            b->const_table = _mesa_pointer_hash_table_create(b);
 
             vtn_function_emit(b, func, vtn_handle_body_instruction);
             progress = true;
index dc57e41feb0af17a6dd3cb1e29653fc5e732c668..dde5b972a297ba65acb4abc53ac0f38a122b5b72 100644 (file)
@@ -1039,8 +1039,7 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
    b->func = func;
    b->nb.cursor = nir_after_cf_list(&func->impl->body);
    b->has_loop_continue = false;
-   b->phi_table = _mesa_hash_table_create(b, _mesa_hash_pointer,
-                                          _mesa_key_pointer_equal);
+   b->phi_table = _mesa_pointer_hash_table_create(b);
 
    vtn_emit_cf_list(b, &func->body, NULL, NULL, instruction_handler);