Commit 634770b1 authored by Matthias Braun's avatar Matthias Braun
Browse files

pdeq: Remove unnecessary waitq aliases

parent 7ccf8903
......@@ -155,56 +155,6 @@ FIRM_API void *pdeq_getl(pdeq *dq);
*/
FIRM_API void *pdeq_getr(pdeq *dq);
/**
* The pdeq is often used as a wait queue. A helper
* type to support this.
*/
typedef pdeq waitq;
/**
* Creates a new pointer wait queue (fifo).
*
* @return A new queue.
*/
#define new_waitq() new_pdeq()
/**
* Delete a wait queue (fifo)
*
* @param wq The wait queue.
*/
#define del_waitq(wq) del_pdeq(wq)
/**
* Retrieve a pointer from the wait queue (fifo).
*
* @param wq The wait queue.
*
* @return The pointer element.
*
* @remark This function will fail if the queue is empty.
*/
#define waitq_get(wq) pdeq_getl(wq)
/**
* Add a pointer to the wait queue (fifo).
*
* @param wq The wait queue
* @param x The pointer element to be added
*
* @return The wait queue.
*/
#define waitq_put(wq, x) pdeq_putr((wq), (x))
/**
* Checks if a wait queue is empty.
*
* @param wq The wait queue.
*
* @return non-zero if the queue is empty.
*/
#define waitq_empty(wq) pdeq_empty(wq)
/**
* The pdeq can be used as a stack. A helper
* type to support this.
......
......@@ -28,7 +28,7 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
typedef struct vrp_env_t {
waitq *workqueue;
pdeq *workqueue;
bitset_t *visited;
ir_vrp_info *info;
} vrp_env_t;
......@@ -476,7 +476,7 @@ static void vrp_first_pass(ir_node *n, void *e)
foreach_irn_out_r(n, i, succ) {
if (bitset_is_set(env->visited, get_irn_idx(succ))) {
/* we found a loop*/
waitq_put(env->workqueue, succ);
pdeq_putr(env->workqueue, succ);
}
}
}
......@@ -520,7 +520,7 @@ void set_vrp_data(ir_graph *irg)
}
vrp_env_t *env = OALLOCZ(&irg->vrp.obst, vrp_env_t);
env->workqueue = new_waitq();
env->workqueue = new_pdeq();
env->info = info;
env->visited = bitset_malloc(get_irg_last_idx(irg));
......@@ -528,17 +528,17 @@ void set_vrp_data(ir_graph *irg)
free(env->visited);
/* while there are entries in the worklist, continue*/
while (!waitq_empty(env->workqueue)) {
ir_node *node = (ir_node*) waitq_get(env->workqueue);
while (!pdeq_empty(env->workqueue)) {
ir_node *node = (ir_node*) pdeq_getl(env->workqueue);
if (vrp_update_node(info, node)) {
/* if something changed, add successors to worklist*/
foreach_irn_out_r(node, i, succ) {
waitq_put(env->workqueue, succ);
pdeq_putr(env->workqueue, succ);
}
}
}
del_waitq(env->workqueue);
del_pdeq(env->workqueue);
}
void free_vrp_data(ir_graph *irg)
......
......@@ -674,20 +674,20 @@ static void expand_chunk_from(co_mst_env_t *env, co_mst_irn_t *node,
aff_chunk_t *orig_chunk, decide_func_t *decider,
unsigned col)
{
waitq *nodes = new_waitq();
pdeq *nodes = new_pdeq();
DBG((dbg, LEVEL_1, "\n\tExpanding new chunk (#%u) from %+F, color %d:",
chunk->id, node->irn, col));
/* init queue and chunk */
waitq_put(nodes, node);
pdeq_putr(nodes, node);
bitset_set(visited, get_irn_idx(node->irn));
aff_chunk_add_node(chunk, node);
DB((dbg, LEVEL_1, " %+F", node->irn));
/* as long as there are nodes in the queue */
while (!waitq_empty(nodes)) {
co_mst_irn_t *n = (co_mst_irn_t*)waitq_get(nodes);
while (!pdeq_empty(nodes)) {
co_mst_irn_t *n = (co_mst_irn_t*)pdeq_getl(nodes);
affinity_node_t *an = get_affinity_info(env->co, n->irn);
/* check all affinity neighbors */
......@@ -713,14 +713,14 @@ static void expand_chunk_from(co_mst_env_t *env, co_mst_irn_t *node,
aff_chunk_add_node(chunk, n2);
DB((dbg, LEVEL_1, " %+F", n2->irn));
/* enqueue for further search */
waitq_put(nodes, n2);
pdeq_putr(nodes, n2);
}
}
}
}
DB((dbg, LEVEL_1, "\n"));
del_waitq(nodes);
del_pdeq(nodes);
}
/**
......@@ -728,7 +728,7 @@ static void expand_chunk_from(co_mst_env_t *env, co_mst_irn_t *node,
* color.
*/
static aff_chunk_t *fragment_chunk(co_mst_env_t *env, unsigned col,
aff_chunk_t *c, waitq *tmp)
aff_chunk_t *c, pdeq *tmp)
{
bitset_t *visited = bitset_malloc(get_irg_last_idx(env->co->irg));
aff_chunk_t *best = NULL;
......@@ -752,7 +752,7 @@ static aff_chunk_t *fragment_chunk(co_mst_env_t *env, unsigned col,
/* create a new chunk starting at current node */
aff_chunk_t *tmp_chunk = new_aff_chunk(env);
waitq_put(tmp, tmp_chunk);
pdeq_putr(tmp, tmp_chunk);
expand_chunk_from(env, node, visited, tmp_chunk, c, decider, col);
assert(ARR_LEN(tmp_chunk->n) > 0 && "No nodes added to chunk");
......@@ -1068,8 +1068,8 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
* which one to take anyway.
* TODO Sebastian: Perhaps we should at all nodes and figure out
* a suitable color using costs as done above (determine_color_costs). */
waitq *tmp_chunks = new_waitq();
waitq *best_starts = NULL;
pdeq *tmp_chunks = new_pdeq();
pdeq *best_starts = NULL;
unsigned n_nodes = ARR_LEN(c->n);
aff_chunk_t *best_chunk = NULL;
int best_color = -1;
......@@ -1083,7 +1083,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
/* try to bring all nodes of given chunk to the current color. */
unsigned n_succeeded = 0;
waitq *good_starts = new_waitq();
pdeq *good_starts = new_pdeq();
for (size_t idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
const ir_node *irn = c->n[idx];
co_mst_irn_t *node = get_co_mst_irn(env, irn);
......@@ -1099,7 +1099,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
bool good = change_node_color(env, node, col, &changed);
stat_ev_tim_pop("heur4_recolor");
if (good) {
waitq_put(good_starts, node);
pdeq_putr(good_starts, node);
materialize_coloring(&changed);
node->fixed = 1;
} else {
......@@ -1118,7 +1118,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
/* try next color when failed */
if (n_succeeded == 0) {
del_waitq(good_starts);
del_pdeq(good_starts);
continue;
}
......@@ -1137,15 +1137,15 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
best_chunk = local_best;
best_color = col;
if (best_starts)
del_waitq(best_starts);
del_pdeq(best_starts);
best_starts = good_starts;
DB((dbg, LEVEL_3, "\n\t\t... setting global best chunk (id %u), color %d\n", best_chunk->id, best_color));
} else {
DB((dbg, LEVEL_3, "\n\t\t... omitting, global best is better\n"));
del_waitq(good_starts);
del_pdeq(good_starts);
}
} else {
del_waitq(good_starts);
del_pdeq(good_starts);
}
/* if all nodes were recolored, bail out */
......@@ -1156,17 +1156,17 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
stat_ev_int("heur4_colors_tried", i);
/* free all intermediate created chunks except best one */
while (!waitq_empty(tmp_chunks)) {
aff_chunk_t *tmp = (aff_chunk_t*)waitq_get(tmp_chunks);
while (!pdeq_empty(tmp_chunks)) {
aff_chunk_t *tmp = (aff_chunk_t*)pdeq_getl(tmp_chunks);
if (tmp != best_chunk)
delete_aff_chunk(tmp);
}
del_waitq(tmp_chunks);
del_pdeq(tmp_chunks);
/* return if coloring failed */
if (!best_chunk) {
if (best_starts)
del_waitq(best_starts);
del_pdeq(best_starts);
return;
}
......@@ -1243,7 +1243,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
delete_aff_chunk(best_chunk);
free(visited);
if (best_starts)
del_waitq(best_starts);
del_pdeq(best_starts);
stat_ev_ctx_pop("heur4_color_chunk");
}
......
......@@ -153,7 +153,7 @@ static void introduce_use(be_ssa_construction_env_t *env, ir_node *use)
info->is_use = true;
block_info->is_use = true;
waitq_put(env->worklist, use);
pdeq_putr(env->worklist, use);
}
/**
......@@ -166,8 +166,8 @@ static void mark_iterated_dominance_frontiers(
stat_ev_cnt_decl(blocks);
DBG((dbg, LEVEL_3, "Dominance Frontier:"));
stat_ev_tim_push();
while (!waitq_empty(env->worklist)) {
ir_node *block = (ir_node*)waitq_get(env->worklist);
while (!pdeq_empty(env->worklist)) {
ir_node *block = (ir_node*)pdeq_getl(env->worklist);
ir_node **domfront = ir_get_dominance_frontier(block);
for (size_t i = 0, len = ARR_LEN(domfront); i < len; ++i) {
ir_node *y = domfront[i];
......@@ -175,7 +175,7 @@ static void mark_iterated_dominance_frontiers(
continue;
if (!irn_visited(y))
waitq_put(env->worklist, y);
pdeq_putr(env->worklist, y);
DBG((dbg, LEVEL_3, " %+F", y));
mark_Block_block_visited(y);
......@@ -206,7 +206,7 @@ static ir_node *insert_dummy_phi(be_ssa_construction_env_t *env, ir_node *block)
DBG((dbg, LEVEL_2, "\tcreating phi %+F in %+F\n", phi, block));
introduce_definition(env, phi);
waitq_put(env->worklist, phi);
pdeq_putr(env->worklist, phi);
return phi;
}
......@@ -359,7 +359,7 @@ void be_ssa_construction_init(be_ssa_construction_env_t *env, ir_graph *irg)
memset(env, 0, sizeof(env[0]));
env->irg = irg;
env->new_phis = NEW_ARR_F(ir_node*, 0);
env->worklist = new_waitq();
env->worklist = new_pdeq();
ir_nodemap_init(&env->infos, irg);
obstack_init(&env->obst);
......@@ -382,7 +382,7 @@ void be_ssa_construction_destroy(be_ssa_construction_env_t *env)
stat_ev_int("bessaconstr_phis", ARR_LEN(env->new_phis));
obstack_free(&env->obst, NULL);
ir_nodemap_destroy(&env->infos);
del_waitq(env->worklist);
del_pdeq(env->worklist);
DEL_ARR_F(env->new_phis);
ir_free_resources(env->irg, IR_RESOURCE_IRN_VISITED
......@@ -422,7 +422,7 @@ void be_ssa_construction_add_copy(be_ssa_construction_env_t *env,
ir_node *block = get_nodes_block(copy);
if (!has_definition(block))
waitq_put(env->worklist, block);
pdeq_putr(env->worklist, block);
introduce_definition(env, copy);
}
......@@ -440,7 +440,7 @@ void be_ssa_construction_add_copies(be_ssa_construction_env_t *env,
assert(env->mode == get_irn_mode(copy));
if (!has_definition(block)) {
waitq_put(env->worklist, block);
pdeq_putr(env->worklist, block);
}
introduce_definition(env, copy);
}
......@@ -497,7 +497,7 @@ void be_ssa_construction_fix_users_array(be_ssa_construction_env_t *env,
DBG((dbg, LEVEL_1, "\tfixing users array\n"));
assert(waitq_empty(env->worklist));
assert(pdeq_empty(env->worklist));
stat_ev_tim_push();
......@@ -516,8 +516,8 @@ void be_ssa_construction_fix_users_array(be_ssa_construction_env_t *env,
}
stat_ev_cnt_decl(uses);
while (!waitq_empty(env->worklist)) {
ir_node *use = (ir_node *)waitq_get(env->worklist);
while (!pdeq_empty(env->worklist)) {
ir_node *use = (ir_node *)pdeq_getl(env->worklist);
constr_info *info = get_info(env, use);
if (info->already_processed)
......
......@@ -45,7 +45,7 @@ typedef struct be_ssa_construction_env_t {
ir_graph *irg;
ir_mode *mode;
const arch_register_req_t *phi_req;
waitq *worklist;
pdeq *worklist;
ir_node **new_phis;
bool iterated_domfront_calculated;
ir_nodemap infos;
......
......@@ -36,8 +36,7 @@
#include "util.h"
typedef struct be_transform_env_t {
waitq *worklist; /**< worklist of nodes that still need to be
transformed */
pdeq *worklist; /**< worklist of nodes that still need to be transformed */
} be_transform_env_t;
static be_transform_env_t env;
......@@ -254,7 +253,7 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
inc_irg_visited(irg);
env.worklist = new_waitq();
env.worklist = new_pdeq();
ir_node *const old_anchor = irg->anchor;
ir_node *const new_anchor = new_r_Anchor(irg);
......@@ -272,8 +271,8 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
pre_transform(irg);
/* process worklist (this should transform all nodes in the graph) */
while (! waitq_empty(env.worklist)) {
ir_node *node = (ir_node*)waitq_get(env.worklist);
while (!pdeq_empty(env.worklist)) {
ir_node *node = (ir_node*)pdeq_getl(env.worklist);
be_transform_node(node);
}
......@@ -283,7 +282,7 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
fix_loops(n);
}
del_waitq(env.worklist);
del_pdeq(env.worklist);
free_End(old_end);
hook_dead_node_elim(irg, 0);
}
......
......@@ -369,8 +369,8 @@ static void ia32_finish_irg_walker(ir_node *block, void *env)
*/
static void ia32_push_on_queue_walker(ir_node *block, void *env)
{
waitq *wq = (waitq*)env;
waitq_put(wq, block);
pdeq *wq = (pdeq*)env;
pdeq_putr(wq, block);
}
......@@ -379,17 +379,17 @@ static void ia32_push_on_queue_walker(ir_node *block, void *env)
*/
void ia32_finish_irg(ir_graph *irg)
{
waitq *wq = new_waitq();
pdeq *wq = new_pdeq();
/* Push the blocks on the waitq because ia32_finish_irg_walker starts more
/* Push the blocks on the pdeq because ia32_finish_irg_walker starts more
* walks ... */
irg_block_walk_graph(irg, NULL, ia32_push_on_queue_walker, wq);
while (! waitq_empty(wq)) {
ir_node *block = (ir_node*)waitq_get(wq);
while (!pdeq_empty(wq)) {
ir_node *block = (ir_node*)pdeq_getl(wq);
ia32_finish_irg_walker(block, NULL);
}
del_waitq(wq);
del_pdeq(wq);
}
void ia32_init_finish(void)
......
......@@ -103,7 +103,7 @@ struct x87_simulator {
be_lv_t *lv; /**< intrablock liveness. */
fp_liveness *live; /**< Liveness information. */
unsigned n_idx; /**< The cached get_irg_last_idx() result. */
waitq *worklist; /**< Worklist of blocks that must be processed. */
pdeq *worklist; /**< Worklist of blocks that must be processed. */
};
/**
......@@ -1399,7 +1399,7 @@ static void x87_simulate_block(x87_simulator *sim, ir_node *block)
DEBUG_ONLY(x87_dump_stack(state);)
succ_state->begin = state;
waitq_put(sim->worklist, succ);
pdeq_putr(sim->worklist, succ);
} else {
DB((dbg, LEVEL_2, "succ %+F already has a state, shuffling\n", succ));
/* There is already a begin state for the successor, bad.
......@@ -1516,8 +1516,8 @@ void ia32_x87_simulate_graph(ir_graph *irg)
x87_state const empty = { .sim = &sim };
bl_state->begin = &empty;
sim.worklist = new_waitq();
waitq_put(sim.worklist, start_block);
sim.worklist = new_pdeq();
pdeq_putr(sim.worklist, start_block);
be_assure_live_sets(irg);
sim.lv = be_get_irg_liveness(irg);
......@@ -1532,12 +1532,12 @@ void ia32_x87_simulate_graph(ir_graph *irg)
/* iterate */
do {
ir_node *block = (ir_node*)waitq_get(sim.worklist);
ir_node *block = (ir_node*)pdeq_getl(sim.worklist);
x87_simulate_block(&sim, block);
} while (! waitq_empty(sim.worklist));
} while (!pdeq_empty(sim.worklist));
/* kill it */
del_waitq(sim.worklist);
del_pdeq(sim.worklist);
x87_destroy_simulator(&sim);
}
......
......@@ -42,7 +42,7 @@ static bool is_block_reachable(ir_node *block)
* this may still be a dead block, but then there is no real use, as
* the control flow will be dead later.
*/
static void place_floats_early(ir_node *n, waitq *worklist)
static void place_floats_early(ir_node *n, pdeq *worklist)
{
/* we must not run into an infinite loop */
if (irn_visited_else_mark(n))
......@@ -101,7 +101,7 @@ static void place_floats_early(ir_node *n, waitq *worklist)
*
* @param worklist a worklist, used for the algorithm, empty on in/output
*/
static void place_early(ir_graph *irg, waitq *worklist)
static void place_early(ir_graph *irg, pdeq *worklist)
{
assert(worklist);
inc_irg_visited(irg);
......@@ -110,8 +110,8 @@ static void place_early(ir_graph *irg, waitq *worklist)
place_floats_early(get_irg_end(irg), worklist);
/* Work the content of the worklist. */
while (!waitq_empty(worklist)) {
ir_node *n = (ir_node*)waitq_get(worklist);
while (!pdeq_empty(worklist)) {
ir_node *n = (ir_node*)pdeq_getl(worklist);
if (!irn_visited(n))
place_floats_early(n, worklist);
}
......@@ -310,7 +310,7 @@ static void place_floats_late(ir_node *n, pdeq *worklist)
*
* @param worklist the worklist containing the nodes to place
*/
static void place_late(ir_graph *irg, waitq *worklist)
static void place_late(ir_graph *irg, pdeq *worklist)
{
assert(worklist);
inc_irg_visited(irg);
......@@ -319,8 +319,8 @@ static void place_late(ir_graph *irg, waitq *worklist)
place_floats_late(get_irg_start_block(irg), worklist);
/* And now empty the worklist again... */
while (!waitq_empty(worklist)) {
ir_node *n = (ir_node*)waitq_get(worklist);
while (!pdeq_empty(worklist)) {
ir_node *n = (ir_node*)pdeq_getl(worklist);
if (!irn_visited(n))
place_floats_late(n, worklist);
}
......@@ -339,7 +339,7 @@ void place_code(ir_graph *irg)
/* Place all floating nodes as early as possible. This guarantees
a legal code placement. */
waitq *worklist = new_waitq();
pdeq *worklist = new_pdeq();
place_early(irg, worklist);
/* While GCSE might place nodes in unreachable blocks,
......@@ -352,6 +352,6 @@ void place_code(ir_graph *irg)
unnecessary executions of the node. */
place_late(irg, worklist);
del_waitq(worklist);
del_pdeq(worklist);
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
}
......@@ -403,10 +403,10 @@ static void update_scc(ir_node *iv, node_entry *e, iv_env *env)
scc *pscc = e->pscc;
ir_node *header = e->header;
pscc->head = NULL;
waitq *wq = new_waitq();
waitq_put(wq, iv);
pdeq *wq = new_pdeq();
pdeq_putr(wq, iv);
do {
ir_node *irn = (ir_node*)waitq_get(wq);
ir_node *irn = (ir_node*)pdeq_getl(wq);
node_entry *ne = get_irn_ne(irn, env);
ne->pscc = pscc;
......@@ -420,11 +420,11 @@ static void update_scc(ir_node *iv, node_entry *e, iv_env *env)
if (pe->header == header && pe->pscc == NULL) {
/* set the pscc here to ensure that the node is NOT enqueued another time */
pe->pscc = pscc;
waitq_put(wq, pred);
pdeq_putr(wq, pred);
}
}
} while (!waitq_empty(wq));
del_waitq(wq);
} while (!pdeq_empty(wq));
del_pdeq(wq);
DB((dbg, LEVEL_2, "\n"));
}
......
......@@ -262,11 +262,11 @@ static int reassoc_commutative(ir_node **node)
*/
static void wq_walker(ir_node *n, void *env)
{
waitq *const wq = (waitq *)env;
pdeq *const wq = (pdeq*)env;
set_irn_link(n, NULL);
if (!is_Block(n)) {
waitq_put(wq, n);
pdeq_putr(wq, n);
set_irn_link(n, wq);
}
}
......@@ -274,10 +274,10 @@ static void wq_walker(ir_node *n, void *env)
/**
* The walker for the reassociation.
*/
static void do_reassociation(waitq *const wq)
static void do_reassociation(pdeq *const wq)
{
while (!waitq_empty(wq)) {
ir_node *n = (ir_node *)waitq_get(wq);
while (!pdeq_empty(wq)) {
ir_node *n = (ir_node *)pdeq_getl(wq);
set_irn_link(n, NULL);
hook_reassociate(1);
......@@ -305,7 +305,7 @@ static void do_reassociation(waitq *const wq)
if (changed) {
foreach_irn_in_r(n, i, pred) {
if (get_irn_link(pred) != wq) {
waitq_put(wq, pred);
pdeq_putr(wq, pred);
set_irn_link(pred, wq);
}
}
......@@ -2036,14 +2036,14 @@ static bool walk_chains(ir_node *node)
*/
static void do_chaining(ir_graph *irg)
{
waitq *const wq = new_waitq();
pdeq *const wq = new_pdeq();
/* now we have collected enough information, optimize */
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
irg_walk_graph(irg, NULL, wq_walker, wq);
while (!waitq_empty(wq)) {
ir_node *n = (ir_node *)waitq_get(wq);
while (!pdeq_empty(wq)) {
ir_node *n = (ir_node *)pdeq_getl(wq);
set_irn_link(n, NULL);
hook_reassociate(1);
......@@ -2066,7 +2066,7 @@ static void do_chaining(ir_graph *irg)
if (changed) {
foreach_irn_in_r(n, i, pred) {
if (get_irn_link(pred) != wq) {
waitq_put(wq, pred);
pdeq_putr(wq, pred);
set_irn_link(pred, wq);
}
}
......@@ -2074,7 +2074,7 @@ static void do_chaining(ir_graph *irg)
}
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
del_waitq(wq);
del_pdeq(wq);