Commit 8924d174 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Let foreach_ir_nodeset() declare its iterator variables.

parent 2b31fff4
......@@ -90,12 +90,11 @@ static int cmp_node_nr(const void *a, const void *b)
ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
ir_node *pos)
{
be_lv_t *lv = be_get_irg_liveness(irg);
ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_nodeset_t live;
ir_nodeset_iterator_t iter;
be_lv_t *lv = be_get_irg_liveness(irg);
ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_nodeset_t live;
ir_node *irn, *perm, **nodes;
ir_node *perm, **nodes;
size_t i, n;
DBG((dbg, LEVEL_1, "Insert Perm after: %+F\n", pos));
......
......@@ -651,9 +651,7 @@ static void melt_copykeeps(constraint_env_t *cenv)
foreach_ir_nodehashmap(&cenv->op_set, map_entry, map_iter) {
op_copy_assoc_t *entry = (op_copy_assoc_t*)map_entry.data;
int idx, num_ck;
ir_node *cp;
struct obstack obst;
ir_nodeset_iterator_t iter;
ir_node **ck_arr, **melt_arr;
obstack_init(&obst);
......@@ -783,8 +781,6 @@ void assure_constraints(ir_graph *irg)
op_copy_assoc_t *entry = (op_copy_assoc_t*)map_entry.data;
size_t n = ir_nodeset_size(&entry->copies);
ir_node **nodes = ALLOCAN(ir_node*, n);
ir_node *cp;
ir_nodeset_iterator_t iter;
be_ssa_construction_env_t senv;
/* put the node in an array */
......
......@@ -340,9 +340,6 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
/* create pbqp nodes, interference edges and reverse perfect elimination order */
sched_foreach_reverse(block, irn) {
ir_node *live;
ir_nodeset_iterator_t iter;
if (get_irn_mode(irn) == mode_T) {
foreach_out_edge(irn, edge) {
ir_node *proj = get_edge_src_irn(edge);
......
......@@ -218,11 +218,9 @@ static void give_penalties_for_limits(const ir_nodeset_t *live_nodes,
float penalty, const unsigned* limited,
ir_node *node)
{
ir_nodeset_iterator_t iter;
unsigned r;
size_t n_allowed;
allocation_info_t *info = get_allocation_info(node);
ir_node *neighbor;
unsigned r;
size_t n_allowed;
allocation_info_t *info = get_allocation_info(node);
/* give penalty for all forbidden regs */
for (r = 0; r < n_regs; ++r) {
......@@ -401,11 +399,9 @@ static void congruence_def(ir_nodeset_t *live_nodes, const ir_node *node)
node_idx = uf_find(congruence_classes, node_idx);
for (i = 0; i < arity; ++i) {
ir_node *live;
ir_node *op;
int op_idx;
ir_nodeset_iterator_t iter;
bool interferes = false;
ir_node *op;
int op_idx;
bool interferes = false;
if (!rbitset_is_set(&req->other_same, i))
continue;
......@@ -476,15 +472,13 @@ static void create_congruence_class(ir_node *block, void *data)
arity = get_irn_arity(phi);
for (i = 0; i < arity; ++i) {
bool interferes = false;
ir_nodeset_iterator_t iter;
unsigned r;
int old_node_idx;
ir_node *live;
allocation_info_t *head_info;
allocation_info_t *other_info;
ir_node *op = get_Phi_pred(phi, i);
int op_idx = get_irn_idx(op);
bool interferes = false;
unsigned r;
int old_node_idx;
allocation_info_t *head_info;
allocation_info_t *other_info;
ir_node *op = get_Phi_pred(phi, i);
int op_idx = get_irn_idx(op);
op_idx = uf_find(congruence_classes, op_idx);
/* do we interfere with the value */
......@@ -1809,13 +1803,9 @@ static void allocate_coalesce_block(ir_node *block, void *data)
/* all live-ins must have a register */
#ifdef DEBUG_libfirm
{
ir_nodeset_iterator_t iter;
ir_node *node;
foreach_ir_nodeset(&live_nodes, node, iter) {
const arch_register_t *reg = arch_get_irn_register(node);
assert(reg != NULL);
}
foreach_ir_nodeset(&live_nodes, node, iter) {
const arch_register_t *reg = arch_get_irn_register(node);
assert(reg != NULL);
}
#endif
......
......@@ -37,8 +37,6 @@
*/
static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
{
ir_nodeset_iterator_t iter;
ir_node *irn = NULL;
int only_branches_left = 1;
(void)block_env;
......@@ -50,6 +48,7 @@ static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
}
}
ir_node *irn;
if (only_branches_left) {
/* at last: schedule branches */
irn = ir_nodeset_first(ready_set);
......
......@@ -254,10 +254,9 @@ static inline int reg_pr_costs(reg_pressure_selector_env_t *env, ir_node *irn)
static ir_node *reg_pressure_select(void *block_env, ir_nodeset_t *ready_set)
{
ir_nodeset_iterator_t iter;
reg_pressure_selector_env_t *env = (reg_pressure_selector_env_t*)block_env;
ir_node *irn, *res = NULL;
int curr_cost = INT_MAX;
ir_node *res = NULL;
int curr_cost = INT_MAX;
assert(ir_nodeset_size(ready_set) > 0);
......
......@@ -541,9 +541,6 @@ static void trace_free(void *data)
*/
static ir_node *basic_selection(ir_nodeset_t *ready_set)
{
ir_node *irn = NULL;
ir_nodeset_iterator_t iter;
/* assure that branches and constants are executed last */
foreach_ir_nodeset(ready_set, irn, iter) {
if (!is_cfop(irn)) {
......@@ -552,9 +549,7 @@ static ir_node *basic_selection(ir_nodeset_t *ready_set)
}
/* at last: schedule branches */
irn = get_nodeset_node(ready_set);
return irn;
return get_nodeset_node(ready_set);
}
/**
......@@ -564,9 +559,7 @@ static ir_node *muchnik_select(void *block_env, ir_nodeset_t *ready_set)
{
trace_env_t *env = (trace_env_t*)block_env;
ir_nodeset_t mcands, ecands;
ir_nodeset_iterator_t iter;
sched_timestep_t max_delay = 0;
ir_node *irn;
/* calculate the max delay of all candidates */
foreach_ir_nodeset(ready_set, irn, iter) {
......@@ -588,6 +581,7 @@ static ir_node *muchnik_select(void *block_env, ir_nodeset_t *ready_set)
}
/* select a node */
ir_node *irn;
if (ir_nodeset_size(&mcands) == 1) {
irn = get_nodeset_node(&mcands);
DB((env->dbg, LEVEL_3, "\tirn = %+F, mcand = 1, max_delay = %u\n", irn, max_delay));
......@@ -650,11 +644,10 @@ static void sched_muchnik(ir_graph *irg)
static ir_node *heuristic_select(void *block_env, ir_nodeset_t *ns)
{
trace_env_t *trace_env = (trace_env_t*)block_env;
ir_node *irn, *cand = NULL;
ir_node *cand = NULL;
int max_prio = INT_MIN;
int cur_prio = INT_MIN;
int reg_fact;
ir_nodeset_iterator_t iter;
/* Note: register pressure calculation needs an overhaul, you need correct
* tracking for each register class indidually and weight by each class
int cur_pressure = ir_nodeset_size(lv); */
......
......@@ -43,8 +43,6 @@
*/
static ir_node *trivial_select(void *block_env, ir_nodeset_t *ready_set)
{
ir_node *irn;
ir_nodeset_iterator_t iter;
(void)block_env;
/* assure that branches and constants are executed last */
......
......@@ -140,17 +140,15 @@ static unsigned get_value_width(const ir_node *node)
*/
static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node)
{
size_t n_live_nodes = ir_nodeset_size(live_nodes);
size_t values_defined = 0;
size_t free_regs_needed = 0;
spill_candidate_t *candidates;
ir_nodeset_iterator_t iter;
int i, arity;
size_t c;
int spills_needed;
size_t cand_idx;
ir_node *n;
ir_node *value;
size_t n_live_nodes = ir_nodeset_size(live_nodes);
size_t values_defined = 0;
size_t free_regs_needed = 0;
spill_candidate_t *candidates;
int i, arity;
size_t c;
int spills_needed;
size_t cand_idx;
ir_node *value;
be_foreach_definition(node, cls, value,
assert(req_->width >= 1);
......@@ -263,9 +261,6 @@ static void add_uses(ir_node *node, ir_nodeset_t *nodeset)
static __attribute__((unused))
void print_nodeset(ir_nodeset_t *nodeset)
{
ir_nodeset_iterator_t iter;
ir_node *node;
foreach_ir_nodeset(nodeset, node, iter) {
ir_fprintf(stderr, "%+F ", node);
}
......@@ -278,12 +273,11 @@ void print_nodeset(ir_nodeset_t *nodeset)
*/
static void spill_block(ir_node *block, void *data)
{
ir_nodeset_t live_nodes;
ir_nodeset_iterator_t iter;
int n_phi_values_spilled;
int regpressure;
int live_nodes_pressure;
int phi_spills_needed;
ir_nodeset_t live_nodes;
int n_phi_values_spilled;
int regpressure;
int live_nodes_pressure;
int phi_spills_needed;
(void) data;
DBG((dbg, LEVEL_1, "spilling block %+F\n", block));
......@@ -293,16 +287,13 @@ static void spill_block(ir_node *block, void *data)
be_liveness_end_of_block(lv, cls, block, &live_nodes);
/* remove already spilled nodes from liveset */
{
ir_node *node;
foreach_ir_nodeset(&live_nodes, node, iter) {
DBG((dbg, LEVEL_2, "\t%+F is live-end... ", node));
if (bitset_is_set(spilled_nodes, get_irn_idx(node))) {
DBG((dbg, LEVEL_2, "but spilled; removing.\n"));
ir_nodeset_remove_iterator(&live_nodes, &iter);
} else {
DBG((dbg, LEVEL_2, "keeping.\n"));
}
foreach_ir_nodeset(&live_nodes, node, iter) {
DBG((dbg, LEVEL_2, "\t%+F is live-end... ", node));
if (bitset_is_set(spilled_nodes, get_irn_idx(node))) {
DBG((dbg, LEVEL_2, "but spilled; removing.\n"));
ir_nodeset_remove_iterator(&live_nodes, &iter);
} else {
DBG((dbg, LEVEL_2, "keeping.\n"));
}
}
......@@ -331,11 +322,8 @@ static void spill_block(ir_node *block, void *data)
}
live_nodes_pressure = 0;
{
ir_node *node;
foreach_ir_nodeset(&live_nodes, node, iter) {
live_nodes_pressure += get_value_width(node);
}
foreach_ir_nodeset(&live_nodes, node, iter) {
live_nodes_pressure += get_value_width(node);
}
/* calculate how many of the phis need to be spilled */
......
......@@ -62,9 +62,6 @@ typedef struct be_verify_register_pressure_env_t_ {
*/
static void print_living_values(FILE *F, const ir_nodeset_t *live_nodes)
{
ir_nodeset_iterator_t iter;
ir_node *node;
ir_fprintf(F, "\t");
foreach_ir_nodeset(live_nodes, node, iter) {
ir_fprintf(F, "%+F ", node);
......
......@@ -165,8 +165,9 @@ static inline ir_node *ir_nodeset_first(ir_nodeset_t const *const nodeset)
}
#define foreach_ir_nodeset(nodeset, irn, iter) \
for(ir_nodeset_iterator_init(&iter, nodeset), \
irn = ir_nodeset_iterator_next(&iter); \
irn != NULL; irn = ir_nodeset_iterator_next(&iter))
for (bool irn##__once = true; irn##__once;) \
for (ir_nodeset_iterator_t iter; irn##__once;) \
for (ir_node *irn; irn##__once; irn##__once = false) \
for (ir_nodeset_iterator_init(&iter, nodeset); (irn = ir_nodeset_iterator_next(&iter));)
#endif
......@@ -192,11 +192,9 @@ static void walker(ir_node *proj, void *env)
n = ir_nodeset_size(&pi.user_mem);
if (n > 0) { /* nothing happened otherwise */
ir_node *sync;
ir_node **in = XMALLOCN(ir_node*, n+1);
ir_node *node;
ir_nodeset_iterator_t iter;
size_t i;
ir_node *sync;
ir_node **in = XMALLOCN(ir_node*, n+1);
size_t i;
i = 0;
in[i++] = proj;
......
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