summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_from_ssa.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-01-15 09:31:18 -0800
committerJason Ekstrand <[email protected]>2015-01-15 13:21:27 -0800
commit153b8b35257fb5d68735b5e43e48b0cdb8b15170 (patch)
tree05db6c87edc7a57a0b7b3457a35448962b4c1c76 /src/glsl/nir/nir_from_ssa.c
parent4c99e3ae78ed3524d188f00b558f803a943aaa00 (diff)
util/hash_set: Rework the API to know about hashing
Previously, the set API required the user to do all of the hashing of keys as it passed them in. Since the hashing function is intrinsically tied to the comparison function, it makes sense for the hash set to know about it. Also, it makes for a somewhat clumsy API as the user is constantly calling hashing functions many of which have long names. This is especially bad when the standard call looks something like _mesa_set_add(ht, _mesa_pointer_hash(key), key); In the above case, there is no reason why the hash set shouldn't do the hashing for you. We leave the option for you to do your own hashing if it's more efficient, but it's no longer needed. Also, if you do do your own hashing, the hash set will assert that your hash matches what it expects out of the hashing function. This should make it harder to mess up your hashing. This is analygous to 94303a0750 where we did this for hash_table Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_from_ssa.c')
-rw-r--r--src/glsl/nir/nir_from_ssa.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 97c09b3b880..025869921f7 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -353,16 +353,14 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
exec_list_push_tail(&pcopy->entries, &entry->node);
entry->src = nir_src_copy(src->src, state->dead_ctx);
- _mesa_set_add(src->src.ssa->uses,
- _mesa_hash_pointer(&pcopy->instr), &pcopy->instr);
+ _mesa_set_add(src->src.ssa->uses, &pcopy->instr);
entry->dest.is_ssa = true;
nir_ssa_def_init(&pcopy->instr, &entry->dest.ssa,
phi->dest.ssa.num_components, src->src.ssa->name);
struct set_entry *use_entry =
- _mesa_set_search(src->src.ssa->uses,
- _mesa_hash_pointer(instr), instr);
+ _mesa_set_search(src->src.ssa->uses, instr);
if (use_entry)
/* It is possible that a phi node can use the same source twice
* but for different basic blocks. If that happens, entry will
@@ -374,7 +372,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
_mesa_set_remove(src->src.ssa->uses, use_entry);
src->src.ssa = &entry->dest.ssa;
- _mesa_set_add(entry->dest.ssa.uses, _mesa_hash_pointer(instr), instr);
+ _mesa_set_add(entry->dest.ssa.uses, instr);
}
nir_parallel_copy_entry *entry = ralloc(state->dead_ctx,
@@ -393,9 +391,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
entry->src.is_ssa = true;
entry->src.ssa = &phi->dest.ssa;
- _mesa_set_add(phi->dest.ssa.uses,
- _mesa_hash_pointer(&block_pcopy->instr),
- &block_pcopy->instr);
+ _mesa_set_add(phi->dest.ssa.uses, &block_pcopy->instr);
}
return true;
@@ -545,7 +541,7 @@ rewrite_ssa_src(nir_src *src, void *void_state)
/* We don't need to remove it from the uses set because that is going
* away. We just need to add it to the one for the register. */
- _mesa_set_add(reg->uses, _mesa_hash_pointer(state->instr), state->instr);
+ _mesa_set_add(reg->uses, state->instr);
}
return true;
@@ -570,7 +566,7 @@ rewrite_ssa_dest(nir_dest *dest, void *void_state)
memset(dest, 0, sizeof *dest);
dest->reg.reg = reg;
- _mesa_set_add(reg->defs, _mesa_hash_pointer(state->instr), state->instr);
+ _mesa_set_add(reg->defs, state->instr);
}
return true;
@@ -605,8 +601,7 @@ resolve_registers_block(nir_block *block, void *void_state)
memset(&following_if->condition, 0, sizeof following_if->condition);
following_if->condition.reg.reg = reg;
- _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
- following_if);
+ _mesa_set_add(reg->if_uses, following_if);
} else {
/* FIXME: We really shouldn't hit this. We should be doing
* constant control flow propagation.