Commit 7d61ad5f authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add the return type as parameter to the macros set_find() and set_insert().

parent c6571686
......@@ -203,10 +203,10 @@ FIRM_API void set_break(set *set);
/* implementation specific */
#define new_set(cmp, slots) ((new_set) ((cmp), (slots)))
#define set_find(set, key, size, hash) \
_set_search ((set), (key), (size), (hash), _set_find)
#define set_insert(set, key, size, hash) \
_set_search ((set), (key), (size), (hash), _set_insert)
#define set_find(type, set, key, size, hash) \
((type*)_set_search((set), 1 ? (key) : (type*)0 /* type check */, (size), (hash), _set_find))
#define set_insert(type, set, key, size, hash) \
((type*)_set_search((set), 1 ? (key) : (type*)0 /* type check */, (size), (hash), _set_insert))
#define set_hinsert(set, key, size, hash) \
((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert))
#define set_hinsert0(set, key, size, hash) \
......
......@@ -75,19 +75,19 @@ void pmap_insert(pmap *map, const void *key, void *value)
pmap_entry entry, *p;
entry.key = key;
p = (pmap_entry*) set_insert(M2S(map), &entry, sizeof(pmap_entry), hash_ptr(key));
p = set_insert(pmap_entry, M2S(map), &entry, sizeof(pmap_entry), hash_ptr(key));
p->value = value;
}
int pmap_contains(pmap *map, const void *key)
{
return set_find(M2S(map), &key, sizeof(pmap_entry), hash_ptr(key)) != NULL;
return pmap_find(map, key) != NULL;
}
pmap_entry * pmap_find(pmap *map, const void *key)
{
pmap_entry const entry = { key, 0 };
return (pmap_entry*)set_find(M2S(map), &entry, sizeof(entry), hash_ptr(key));
return set_find(pmap_entry, M2S(map), &entry, sizeof(entry), hash_ptr(key));
}
......
......@@ -447,13 +447,13 @@ void pset_insert_pset_ptr(pset *target, pset *src)
void *(set_find) (set *se, const void *key, size_t size, unsigned hash)
{
return set_find (se, key, size, hash);
return set_find(void, se, key, size, hash);
}
void *(set_insert) (set *se, const void *key, size_t size, unsigned hash)
{
return set_insert (se, key, size, hash);
return set_insert(void, se, key, size, hash);
}
......
......@@ -68,7 +68,7 @@ static dfs_edge_t *get_edge(const dfs_t *self, const void *src, const void *tgt)
templ.tgt = tgt;
templ.kind = (dfs_edge_kind_t) -1;
return (dfs_edge_t*) set_insert(self->edges, &templ, sizeof(templ), hash);
return set_insert(dfs_edge_t, self->edges, &templ, sizeof(templ), hash);
}
static void dfs_perform(dfs_t *dfs, void *n, void *anc, int level)
......
......@@ -70,7 +70,7 @@ static dfs_node_t *_dfs_get_node(const dfs_t *self, const void *node)
dfs_node_t templ;
memset(&templ, 0, sizeof(templ));
templ.node = node;
return (dfs_node_t*) set_insert(self->nodes, &templ, sizeof(templ), hash_ptr(node));
return set_insert(dfs_node_t, self->nodes, &templ, sizeof(templ), hash_ptr(node));
}
#define _dfs_int_is_ancestor(n, m) ((m)->pre_num >= (n)->pre_num && (m)->pre_num <= (n)->max_pre_num)
......
......@@ -94,7 +94,7 @@ static freq_t *set_find_freq(set *freqs, const ir_node *irn)
{
freq_t query;
query.irn = irn;
return (freq_t*) set_find(freqs, &query, sizeof(query), hash_ptr(irn));
return set_find(freq_t, freqs, &query, sizeof(query), hash_ptr(irn));
}
static freq_t *set_insert_freq(set *freqs, const ir_node *irn)
......@@ -104,7 +104,7 @@ static freq_t *set_insert_freq(set *freqs, const ir_node *irn)
query.irn = irn;
query.freq = 0.0;
query.idx = -1;
return (freq_t*) set_insert(freqs, &query, sizeof(query), hash_ptr(irn));
return set_insert(freq_t, freqs, &query, sizeof(query), hash_ptr(irn));
}
double get_block_execfreq(const ir_exec_freq *ef, const ir_node *irn)
......
......@@ -758,13 +758,13 @@ ir_alias_relation get_alias_relation_ex(
key.adr2 = adr2;
key.mode1 = mode1;
key.mode2 = mode2;
entry = (mem_disambig_entry*) set_find(result_cache, &key, sizeof(key), HASH_ENTRY(adr1, adr2));
entry = set_find(mem_disambig_entry, result_cache, &key, sizeof(key), HASH_ENTRY(adr1, adr2));
if (entry != NULL)
return entry->result;
key.result = get_alias_relation(adr1, mode1, adr2, mode2);
set_insert(result_cache, &key, sizeof(key), HASH_ENTRY(adr1, adr2));
set_insert(mem_disambig_entry, result_cache, &key, sizeof(key), HASH_ENTRY(adr1, adr2));
return key.result;
}
......
......@@ -131,7 +131,7 @@ static void emit_amd64_SymConst(const ir_node *irn)
key.u.id = get_entity_ld_ident(attr->entity);
key.is_ident = 1;
key.label = 0;
entry = (sym_or_tv_t *)set_insert(sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
entry = set_insert(sym_or_tv_t, sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
if (entry->label == 0) {
/* allocate a label */
entry->label = get_unique_label();
......
......@@ -261,7 +261,7 @@ static void emit_arm_SymConst(const ir_node *irn)
key.u.entity = attr->entity;
key.is_entity = true;
key.label = 0;
entry = (sym_or_tv_t *)set_insert(sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
entry = set_insert(sym_or_tv_t, sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
if (entry->label == 0) {
/* allocate a label */
entry->label = get_unique_label();
......@@ -299,7 +299,7 @@ static void emit_arm_fConst(const ir_node *irn)
key.u.tv = get_fConst_value(irn);
key.is_entity = false;
key.label = 0;
entry = (sym_or_tv_t *)set_insert(sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
entry = set_insert(sym_or_tv_t, sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic));
if (entry->label == 0) {
/* allocate a label */
entry->label = get_unique_label();
......
......@@ -70,7 +70,7 @@ static arm_irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn, set *reg_set)
templ.reg = NULL;
hash = hash_ptr(irn);
return (arm_irn_reg_assoc*)set_insert(reg_set, &templ, sizeof(templ), hash);
return set_insert(arm_irn_reg_assoc, reg_set, &templ, sizeof(templ), hash);
}
void arm_set_firm_reg(ir_node *irn, const arch_register_t *reg, set *reg_set)
......
......@@ -185,7 +185,7 @@ static be_abi_call_arg_t *get_call_arg(be_abi_call_t *call, int is_res, int pos,
hash = is_res * 128 + pos;
return (be_abi_call_arg_t*)set_find(call->params, &arg, sizeof(arg), hash);
return set_find(be_abi_call_arg_t, call->params, &arg, sizeof(arg), hash);
}
/**
......@@ -196,11 +196,11 @@ static void remember_call_arg(be_abi_call_arg_t *arg, be_abi_call_t *call, be_ab
unsigned hash = arg->is_res * 128 + arg->pos;
if (context & ABI_CONTEXT_CALLEE) {
arg->callee = 1;
set_insert(call->params, arg, sizeof(*arg), hash);
set_insert(be_abi_call_arg_t, call->params, arg, sizeof(*arg), hash);
}
if (context & ABI_CONTEXT_CALLER) {
arg->callee = 0;
set_insert(call->params, arg, sizeof(*arg), hash);
set_insert(be_abi_call_arg_t, call->params, arg, sizeof(*arg), hash);
}
}
......
......@@ -126,7 +126,7 @@ static inline void qnode_add_conflict(const qnode_t *qn, const ir_node *n1, cons
c.n1 = n2;
c.n2 = n1;
}
set_insert(qn->conflicts, &c, sizeof(c), HASH_CONFLICT(c));
set_insert(conflict_t, qn->conflicts, &c, sizeof(c), HASH_CONFLICT(c));
}
/**
......@@ -146,7 +146,7 @@ static inline int qnode_are_conflicting(const qnode_t *qn, const ir_node *n1, co
c.n1 = n2;
c.n2 = n1;
}
return set_find(qn->conflicts, &c, sizeof(c), HASH_CONFLICT(c)) != 0;
return set_find(conflict_t, qn->conflicts, &c, sizeof(c), HASH_CONFLICT(c)) != 0;
}
static int set_cmp_node_stat_t(const void *x, const void *y, size_t size)
......@@ -162,7 +162,7 @@ static inline const node_stat_t *qnode_find_node(const qnode_t *qn, ir_node *irn
{
node_stat_t find;
find.irn = irn;
return (const node_stat_t*)set_find(qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
return set_find(node_stat_t, qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
}
/**
......@@ -175,7 +175,7 @@ static inline node_stat_t *qnode_find_or_insert_node(const qnode_t *qn, ir_node
find.irn = irn;
find.new_color = NO_COLOR;
find.pinned_local = 0;
return (node_stat_t*)set_insert(qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
return set_insert(node_stat_t, qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
}
/**
......
......@@ -312,7 +312,7 @@ static inline edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou
new_edge.n2 = n1;
}
(*counter)++;
return (edge_t*)set_insert(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
return set_insert(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
}
static inline edge_t *find_edge(set *edges, ir_node *n1, ir_node *n2)
......@@ -326,7 +326,7 @@ static inline edge_t *find_edge(set *edges, ir_node *n1, ir_node *n2)
new_edge.n1 = n2;
new_edge.n2 = n1;
}
return (edge_t*)set_find(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
return set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
}
static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *counter)
......@@ -340,7 +340,7 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou
new_edge.n1 = n2;
new_edge.n2 = n1;
}
e = (edge_t*)set_find(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
e = set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
if (e) {
e->n1 = NULL;
e->n2 = NULL;
......
......@@ -787,7 +787,7 @@ static void add_edge(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs)
new_node.irn = n1;
new_node.degree = 0;
new_node.neighbours = NULL;
node = (affinity_node_t*)set_insert(co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
node = set_insert(affinity_node_t, co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
for (nbr = node->neighbours; nbr; nbr = nbr->next)
if (nbr->irn == n2) {
......@@ -878,7 +878,7 @@ int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn)
ASSERT_GS_AVAIL(co);
new_node.irn = irn;
n = (affinity_node_t*)set_find(co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
n = set_find(affinity_node_t, co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
if (n) {
return (n->degree > 0);
} else
......
......@@ -146,7 +146,7 @@ static inline affinity_node_t *get_affinity_info(const copy_opt_t *co, const ir_
ASSERT_GS_AVAIL(co);
find.irn = irn;
return (affinity_node_t*)set_find(co->nodes, &find, sizeof(find), hash_irn(irn));
return set_find(affinity_node_t, co->nodes, &find, sizeof(find), hash_irn(irn));
}
#define co_gs_foreach_aff_node(co, aff_node) foreach_set((co)->nodes, affinity_node_t, (aff_node))
......
......@@ -141,7 +141,7 @@ static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop,
key.loop = loop;
key.cls = cls;
key.max_pressure = 0;
entry = (be_loop_info_t*)set_insert(loop_ana->data, &key, sizeof(key), HASH_LOOP_INFO(&key));
entry = set_insert(be_loop_info_t, loop_ana->data, &key, sizeof(key), HASH_LOOP_INFO(&key));
entry->max_pressure = MAX(entry->max_pressure, pressure);
return pressure;
......@@ -218,7 +218,7 @@ unsigned be_get_loop_pressure(be_loopana_t *loop_ana, const arch_register_class_
key.loop = loop;
key.cls = cls;
entry = (be_loop_info_t*)set_find(loop_ana->data, &key, sizeof(key), HASH_LOOP_INFO(&key));
entry = set_find(be_loop_info_t, loop_ana->data, &key, sizeof(key), HASH_LOOP_INFO(&key));
if (entry)
pressure = entry->max_pressure;
......
......@@ -460,12 +460,12 @@ static memperm_t *get_memperm(be_fec_env_t *env, ir_node *block)
entry.block = block;
hash = hash_irn(block);
res = (memperm_t*)set_find(env->memperms, &entry, sizeof(entry), hash);
res = set_find(memperm_t, env->memperms, &entry, sizeof(entry), hash);
if (res == NULL) {
entry.entrycount = 0;
entry.entries = NULL;
res = (memperm_t*)set_insert(env->memperms, &entry, sizeof(entry), hash);
res = set_insert(memperm_t, env->memperms, &entry, sizeof(entry), hash);
}
return res;
......
......@@ -135,7 +135,7 @@ static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
int hash = hash_irn(value);
info.to_spill = value;
res = (spill_info_t*)set_find(env->spills, &info, sizeof(info), hash);
res = set_find(spill_info_t, env->spills, &info, sizeof(info), hash);
if (res == NULL) {
info.reloaders = NULL;
......@@ -143,7 +143,7 @@ static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
info.spill_costs = -1;
info.reload_cls = NULL;
info.spilled_phi = false;
res = (spill_info_t*)set_insert(env->spills, &info, sizeof(info), hash);
res = set_insert(spill_info_t, env->spills, &info, sizeof(info), hash);
}
return res;
......
......@@ -130,7 +130,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
hash = hash_irn(arg);
templ.arg = arg;
pp = (perm_proj_t*)set_find(arg_set, &templ, sizeof(templ), hash);
pp = set_find(perm_proj_t, arg_set, &templ, sizeof(templ), hash);
/*
* If a proj_perm_t entry has not been made in the argument set,
......@@ -141,7 +141,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
*/
if (!pp && !be_is_live_in(lv, bl, arg)) {
templ.pos = n_projs++;
set_insert(arg_set, &templ, sizeof(templ), hash);
set_insert(perm_proj_t, arg_set, &templ, sizeof(templ), hash);
}
}
......@@ -188,7 +188,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
perm_proj_t templ;
templ.arg = get_irn_n(phi, i);
pp = (perm_proj_t*)set_find(arg_set, &templ, sizeof(templ), hash_irn(templ.arg));
pp = set_find(perm_proj_t, arg_set, &templ, sizeof(templ), hash_irn(templ.arg));
/* If not found, it was an interfering argument */
if (pp) {
......
......@@ -104,7 +104,7 @@ static const be_use_t *get_or_set_use_block(be_uses_t *env,
temp.block = block;
temp.node = def;
result = (be_use_t*)set_find(env->uses, &temp, sizeof(temp), hash);
result = set_find(be_use_t, env->uses, &temp, sizeof(temp), hash);
if (result == NULL) {
// insert templ first as we might end in a loop in the get_next_use
......@@ -112,7 +112,7 @@ static const be_use_t *get_or_set_use_block(be_uses_t *env,
temp.next_use = USES_INFINITY;
temp.outermost_loop = UNKNOWN_OUTERMOST_LOOP;
temp.visited = 0;
result = (be_use_t*)set_insert(env->uses, &temp, sizeof(temp), hash);
result = set_insert(be_use_t, env->uses, &temp, sizeof(temp), hash);
}
if (result->outermost_loop == UNKNOWN_OUTERMOST_LOOP && result->visited < env->visited_counter) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment