Commit ca8347e7 authored by Matthias Braun's avatar Matthias Braun
Browse files

replace pamp_find with pmap_get where possible

parent 89ecd499
......@@ -1257,14 +1257,12 @@ static pmap *mtp_map;
*/
static ir_type *clone_type_and_cache(ir_type *tp)
{
ir_type *res;
pmap_entry *e = pmap_find(mtp_map, tp);
ir_type *res = (ir_type*)pmap_get(mtp_map, tp);
if (e != NULL)
return (ir_type*) e->value;
res = clone_type_method(tp);
pmap_insert(mtp_map, tp, res);
if (res == NULL) {
res = clone_type_method(tp);
pmap_insert(mtp_map, tp, res);
}
return res;
}
......
......@@ -119,14 +119,13 @@ void set_irp_typeinfo_inconsistent(void)
ir_type *get_irn_typeinfo_type(const ir_node *n)
{
ir_type *res = initial_type;
pmap_entry *entry;
ir_type *res;
assert(get_irg_typeinfo_state(get_irn_irg(n)) != ir_typeinfo_none);
entry = pmap_find(type_node_map, n);
if (entry != NULL)
res = (ir_type*) entry->value;
res = pmap_get(type_node_map, n);
if (res == NULL) {
res = initial_type;
}
return res;
}
......
......@@ -130,19 +130,19 @@ typedef struct stabs_handle {
*/
static unsigned get_type_number(stabs_handle *h, ir_type *tp)
{
pmap_entry *entry;
void *entry;
unsigned num;
if (tp == NULL) {
/* map to the void type */
return 0;
}
entry = pmap_find(h->type_map, tp);
if (! entry) {
entry = pmap_get(h->type_map, tp);
if (entry == NULL) {
num = h->next_type_nr++;
pmap_insert(h->type_map, tp, INT_TO_PTR(num));
pmap_insert(h->type_map, tp, INT_TO_PTR(num+1));
} else {
num = (unsigned)PTR_TO_INT(entry->value);
num = ((unsigned)PTR_TO_INT(entry))-1;
}
return num;
}
......@@ -152,7 +152,7 @@ static unsigned get_type_number(stabs_handle *h, ir_type *tp)
*/
static void map_to_void(stabs_handle *h, ir_type *tp)
{
pmap_insert(h->type_map, tp, INT_TO_PTR(0));
pmap_insert(h->type_map, tp, INT_TO_PTR(1));
}
/**
......
......@@ -125,8 +125,6 @@ typedef struct blk_state {
x87_state *end; /**< state at the end or NULL if not assigned */
} blk_state;
#define PTR_TO_BLKSTATE(p) ((blk_state *)(p))
/** liveness bitset for vfp registers. */
typedef unsigned char vfp_liveness;
......@@ -339,18 +337,17 @@ static void x87_emms(x87_state *state)
*/
static blk_state *x87_get_bl_state(x87_simulator *sim, ir_node *block)
{
pmap_entry *entry = pmap_find(sim->blk_states, block);
blk_state *res = pmap_get(sim->blk_states, block);
if (! entry) {
blk_state *bl_state = OALLOC(&sim->obst, blk_state);
bl_state->begin = NULL;
bl_state->end = NULL;
if (res == NULL) {
res = OALLOC(&sim->obst, blk_state);
res->begin = NULL;
res->end = NULL;
pmap_insert(sim->blk_states, block, bl_state);
return bl_state;
pmap_insert(sim->blk_states, block, res);
}
return PTR_TO_BLKSTATE(entry->value);
return res;
}
/**
......
......@@ -507,14 +507,9 @@ static void do_copy_return_opt(ir_node *n, void *ctx)
static ir_node *get_dummy_sel(ir_graph *irg, ir_node *block, ir_type *tp,
wlk_env *env)
{
ir_entity *ent;
pmap_entry *e;
/* use a map the check if we already create such an entity */
e = pmap_find(env->dummy_map, tp);
if (e) {
ent = (ir_entity*)e->value;
} else {
ir_entity *ent = pmap_get(env->dummy_map, tp);
if (ent == NULL) {
ir_type *ft = get_irg_frame_type(irg);
ident *dummy_id = id_unique("dummy.%u");
ent = new_entity(ft, dummy_id, tp);
......
......@@ -62,7 +62,6 @@ static void call_mapper(ir_node *node, void *env)
if (op == op_Call) {
ir_node *symconst;
pmap_entry *p;
const i_call_record *r;
ir_entity *ent;
......@@ -71,10 +70,9 @@ static void call_mapper(ir_node *node, void *env)
return;
ent = get_SymConst_entity(symconst);
p = pmap_find(wenv->c_map, ent);
r = (const i_call_record*)pmap_get(wenv->c_map, ent);
if (p) {
r = (const i_call_record*)p->value;
if (r != NULL) {
wenv->nr_of_intrinsics += r->i_mapper(node, r->ctx) ? 1 : 0;
}
} else {
......
......@@ -1073,7 +1073,7 @@ void inline_leave_functions(unsigned maxsize, unsigned leavesize,
list_for_each_entry_safe(call_entry, entry, next, &env->calls, list) {
irg_inline_property prop;
ir_graph *callee;
pmap_entry *e;
ir_graph *calleee;
call = entry->call;
callee = entry->callee;
......@@ -1083,13 +1083,13 @@ void inline_leave_functions(unsigned maxsize, unsigned leavesize,
continue;
}
e = pmap_find(copied_graphs, callee);
if (e != NULL) {
calleee = (ir_graph*)pmap_get(copied_graphs, callee);
if (calleee != NULL) {
/*
* Remap callee if we have a copy.
* FIXME: Should we do this only for recursive Calls ?
*/
callee = (ir_graph*)e->value;
callee = calleee;
}
if (prop >= irg_inline_forced ||
......@@ -1593,9 +1593,9 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
ir_node *call_node = curr_call->call;
inline_irg_env *callee_env = (inline_irg_env*)get_irg_link(callee);
irg_inline_property prop = get_irg_inline_property(callee);
ir_graph *calleee;
int loop_depth;
const call_entry *centry;
pmap_entry *e;
if ((prop < irg_inline_forced) && env->n_nodes + callee_env->n_nodes > maxsize) {
DB((dbg, LEVEL_2, "%+F: too big (%d) + %+F (%d)\n", irg,
......@@ -1603,8 +1603,8 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
continue;
}
e = pmap_find(copied_graphs, callee);
if (e != NULL) {
calleee = (ir_graph*)pmap_get(copied_graphs, callee);
if (calleee != NULL) {
int benefice = curr_call->benefice;
/*
* Reduce the weight for recursive function IFF not all arguments are const.
......@@ -1618,7 +1618,7 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
/*
* Remap callee if we have a copy.
*/
callee = (ir_graph*)e->value;
callee = calleee;
callee_env = (inline_irg_env*)get_irg_link(callee);
}
......
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