Commit 6153d219 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Let sched_foreach_from() and sched_foreach_reverse_from() declare their iterator variables.

parent 5619c912
......@@ -212,8 +212,6 @@ static void TEMPLATE_emit_node(const ir_node *node)
*/
static void TEMPLATE_emit_block(ir_node *block)
{
ir_node *node;
be_gas_begin_block(block, true);
sched_foreach(block, node) {
......
......@@ -533,7 +533,6 @@ static void amd64_emit_node(const ir_node *node)
*/
static void amd64_gen_block(ir_node *block, void *data)
{
ir_node *node;
(void) data;
if (! is_Block(block))
......
......@@ -875,8 +875,6 @@ static void arm_emit_block_header(ir_node *block, ir_node *prev)
*/
static void arm_gen_block(ir_node *block, ir_node *prev_block)
{
ir_node *irn;
arm_emit_block_header(block, prev_block);
be_dwarf_location(get_irn_dbg_info(block));
sched_foreach(block, irn) {
......
......@@ -112,10 +112,9 @@ void create_borders(ir_node *block, void *env_ptr)
#define border_use(irn, step, real) \
border_add(env, head, irn, step, ++pressure, 0, real)
be_chordal_env_t *env = (be_chordal_env_t*)env_ptr;
bitset_t *live = bitset_malloc(get_irg_last_idx(env->irg));
ir_node *irn;
be_lv_t *lv = be_get_irg_liveness(env->irg);
be_chordal_env_t *env = (be_chordal_env_t*)env_ptr;
bitset_t *live = bitset_malloc(get_irg_last_idx(env->irg));
be_lv_t *lv = be_get_irg_liveness(env->irg);
int i, n;
size_t elm;
......
......@@ -203,19 +203,21 @@ static void rematerialize_or_move(ir_node *flags_needed, ir_node *node,
*/
static void fix_flags_walker(ir_node *block, void *env)
{
ir_node *node;
ir_node *flags_needed = NULL;
ir_node *flag_consumers = NULL;
int pn = -1;
(void) env;
ir_node *place = block;
sched_foreach_reverse(block, node) {
int i, arity;
ir_node *new_flags_needed = NULL;
ir_node *test;
if (is_Phi(node))
if (is_Phi(node)) {
place = node;
break;
}
if (node == flags_needed) {
/* all ok */
......@@ -278,7 +280,7 @@ static void fix_flags_walker(ir_node *block, void *env)
if (flags_needed != NULL) {
assert(get_nodes_block(flags_needed) != block);
rematerialize_or_move(flags_needed, node, flag_consumers, pn);
rematerialize_or_move(flags_needed, place, flag_consumers, pn);
flags_needed = NULL;
flag_consumers = NULL;
}
......
......@@ -158,7 +158,6 @@ static void remove_empty_block(ir_node *block)
{
int i;
int arity;
ir_node *node;
ir_node *pred;
ir_node *succ_block;
ir_node *jump = NULL;
......@@ -212,7 +211,7 @@ static void remove_empty_block(ir_node *block)
/* there can be some non-scheduled Pin nodes left in the block, move them
* to the succ block (Pin) or pred block (Sync) */
foreach_out_edge_safe(block, edge) {
node = get_edge_src_irn(edge);
ir_node *const node = get_edge_src_irn(edge);
if (node == jump)
continue;
......
......@@ -561,7 +561,6 @@ void be_liveness_nodes_live_at(const be_lv_t *lv,
const ir_node *pos, ir_nodeset_t *live)
{
const ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_node *irn;
be_liveness_end_of_block(lv, cls, bl, live);
sched_foreach_reverse(bl, irn) {
......
......@@ -74,10 +74,9 @@ static unsigned be_compute_block_pressure(const ir_graph *irg,
ir_node *block,
const arch_register_class_t *cls)
{
be_lv_t *lv = be_get_irg_liveness(irg);
ir_nodeset_t live_nodes;
ir_node *irn;
size_t max_live;
be_lv_t *lv = be_get_irg_liveness(irg);
ir_nodeset_t live_nodes;
size_t max_live;
DBG((dbg, LEVEL_1, "Processing Block %+F\n", block));
......
......@@ -619,7 +619,6 @@ static void assure_different_constraints(ir_node *irn, ir_node *skipped_irn, con
*/
static void assure_constraints_walker(ir_node *block, void *walk_env)
{
ir_node *irn;
constraint_env_t *env = (constraint_env_t*)walk_env;
sched_foreach_reverse(block, irn) {
......@@ -856,7 +855,6 @@ static int push_through_perm(ir_node *perm)
int n_moved;
int new_size;
ir_node *frontier = bl;
ir_node *irn;
int i, n;
/* get some Proj and find out the register class of that Proj. */
......
......@@ -319,7 +319,6 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
pbqp_t *pbqp_inst = pbqp_alloc_env->pbqp_inst;
plist_t *temp_list = plist_new();
plist_element_t *el;
ir_node *irn;
ir_nodeset_t live_nodes;
#if USE_BIPARTIT_MATCHING
int *assignment = ALLOCAN(int, cls->n_regs);
......
......@@ -316,9 +316,8 @@ static void check_defs(const ir_nodeset_t *live_nodes, float weight,
*/
static void analyze_block(ir_node *block, void *data)
{
float weight = (float)get_block_execfreq(execfreqs, block);
ir_nodeset_t live_nodes;
ir_node *node;
float weight = (float)get_block_execfreq(execfreqs, block);
ir_nodeset_t live_nodes;
(void) data;
ir_nodeset_init(&live_nodes);
......@@ -439,8 +438,7 @@ static void congruence_def(ir_nodeset_t *live_nodes, const ir_node *node)
static void create_congruence_class(ir_node *block, void *data)
{
ir_nodeset_t live_nodes;
ir_node *node;
ir_nodeset_t live_nodes;
(void) data;
ir_nodeset_init(&live_nodes);
......@@ -478,7 +476,6 @@ static void create_congruence_class(ir_node *block, void *data)
unsigned r;
int old_node_idx;
ir_node *live;
ir_node *phi;
allocation_info_t *head_info;
allocation_info_t *other_info;
ir_node *op = get_Phi_pred(node, i);
......@@ -1604,7 +1601,6 @@ static void assign_phi_registers(ir_node *block)
int n;
int res;
unsigned *assignment;
ir_node *node;
hungarian_problem_t *bp;
/* count phi nodes */
......@@ -1692,7 +1688,6 @@ static void allocate_coalesce_block(ir_node *block, void *data)
{
int i;
ir_nodeset_t live_nodes;
ir_node *node;
int n_preds;
block_info_t *block_info;
block_info_t **pred_block_infos;
......@@ -1727,7 +1722,7 @@ static void allocate_coalesce_block(ir_node *block, void *data)
const arch_register_t *reg;
int p;
node = be_lv_get_irn(lv, block, i);
ir_node *node = be_lv_get_irn(lv, block, i);
req = arch_get_irn_register_req(node);
if (req->cls != cls)
continue;
......@@ -1812,7 +1807,8 @@ 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_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);
......
......@@ -50,7 +50,6 @@
static void sched_renumber(const ir_node *block)
{
ir_node *irn;
sched_info_t *inf;
sched_timestep_t step = SCHED_INITIAL_GRANULARITY;
......
......@@ -199,10 +199,10 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
}
#define sched_foreach_from(from, irn) \
for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
for (ir_node *irn = from; !sched_is_end(irn); irn = sched_next(irn))
#define sched_foreach_reverse_from(from, irn) \
for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
for (ir_node *irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
/**
* A shorthand macro for iterating over a schedule.
......
......@@ -174,7 +174,6 @@ static void *reg_pressure_graph_init(ir_graph *irg)
static void *reg_pressure_block_init(void *graph_env, ir_node *bl)
{
ir_node *irn;
reg_pressure_selector_env_t *env = XMALLOC(reg_pressure_selector_env_t);
(void) graph_env;
......
......@@ -221,7 +221,6 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node)
static void pre_spill_prepare_constr_walker(ir_node *block, void *data)
{
be_pre_spill_env_t *env = (be_pre_spill_env_t*)data;
ir_node *node;
sched_foreach(block, node) {
prepare_constr_insn(env, node);
}
......
......@@ -540,7 +540,6 @@ static void decide_start_workset(const ir_node *block)
{
ir_loop *loop = get_irn_loop(block);
ir_node *first;
ir_node *node;
loc_t loc;
loc_t *starters;
loc_t *delayed;
......@@ -761,7 +760,6 @@ static void decide_start_workset(const ir_node *block)
static void process_block(ir_node *block)
{
workset_t *new_vals;
ir_node *irn;
unsigned iter;
block_info_t *block_info;
int arity;
......@@ -793,9 +791,11 @@ static void process_block(ir_node *block)
set_block_info(block, block_info);
DB((dbg, DBG_WSETS, "Start workset for %+F:\n", block));
workset_foreach(ws, irn, iter) {
DB((dbg, DBG_WSETS, " %+F (%u)\n", irn,
workset_get_time(ws, iter)));
{
ir_node *irn;
workset_foreach(ws, irn, iter) {
DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter)));
}
}
block_info->start_workset = workset_clone(ws);
......@@ -843,8 +843,11 @@ static void process_block(ir_node *block)
/* Remember end-workset for this block */
block_info->end_workset = workset_clone(ws);
DB((dbg, DBG_WSETS, "End workset for %+F:\n", block));
workset_foreach(ws, irn, iter)
DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter)));
{
ir_node *irn;
workset_foreach(ws, irn, iter)
DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter)));
}
}
/**
......
......@@ -278,13 +278,12 @@ 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;
ir_node *node;
int n_phi_values_spilled;
int regpressure;
int live_nodes_pressure;
int phi_spills_needed;
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;
(void) data;
DBG((dbg, LEVEL_1, "spilling block %+F\n", block));
......@@ -294,13 +293,16 @@ 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 */
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"));
{
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"));
}
}
}
......@@ -329,8 +331,11 @@ static void spill_block(ir_node *block, void *data)
}
live_nodes_pressure = 0;
foreach_ir_nodeset(&live_nodes, node, iter) {
live_nodes_pressure += get_value_width(node);
{
ir_node *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 */
......
......@@ -297,7 +297,6 @@ static void set_operands(be_ssa_construction_env_t *env, ir_node *use, ir_node *
*/
static void process_block(be_ssa_construction_env_t *env, ir_node *block)
{
ir_node *node;
ir_node *def = NULL;
constr_info *block_info = get_or_set_info(env, block);
......@@ -353,22 +352,17 @@ static ir_node *search_def_end_of_block(be_ssa_construction_env_t *env,
}
}
else {
ir_node *def = NULL;
/* Search the last definition of the block. */
sched_foreach_reverse(block, def) {
if (is_definition(env, def)) {
constr_info *info = get_info(env, def);
def = info->u.definition;
DBG((dbg, LEVEL_3, "\t...found definition %+F\n", def));
DBG((dbg, LEVEL_3, "\t...found definition %+F\n", info->u.definition));
block_info->u.last_definition = info->u.definition;
break;
}
}
assert(def && "No definition found");
block_info->u.last_definition = def;
assert(block_info->u.last_definition && "No definition found");
}
return block_info->u.last_definition;
......
......@@ -160,7 +160,6 @@ static int process_stack_bias(ir_node *bl, int real_bias)
be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
bool sp_relative = layout->sp_relative;
const arch_env_t *arch_env = be_get_irg_arch_env(irg);
ir_node *irn;
sched_foreach(bl, irn) {
int ofs;
......
......@@ -59,10 +59,9 @@ static void check_reg_pressure_class(pressure_walker_env_t *env,
ir_node *block,
const arch_register_class_t *cls)
{
ir_graph *irg = env->irg;
ir_node *irn;
ir_nodeset_t live_nodes;
size_t max_live;
ir_graph *irg = env->irg;
ir_nodeset_t live_nodes;
size_t max_live;
ir_nodeset_init(&live_nodes);
be_liveness_end_of_block(env->lv, cls, block, &live_nodes);
......@@ -128,8 +127,7 @@ typedef struct estimate_irg_costs_env_t {
static void estimate_block_costs(ir_node *block, void *data)
{
estimate_irg_costs_env_t *env = (estimate_irg_costs_env_t*)data;
ir_node *node;
double costs = 0.0;
double costs = 0.0;
sched_foreach(block, node) {
costs += arch_get_op_estimated_cost(node);
......
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