Commit 43b545e3 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Let list_for_each_entry(), list_for_each_entry_reverse() and...

Let list_for_each_entry(), list_for_each_entry_reverse() and list_for_each_entry_safe() declare their iterator variables.
parent 337762ab
......@@ -254,7 +254,7 @@ static inline void list_splice_init(struct list_head *list,
* @param member the name of the list_struct within the struct.
*/
#define list_for_each_entry(type, pos, head, member) \
for (pos = list_entry((head)->next, type, member); \
for (type *pos = list_entry((head)->next, type, member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, type, member))
......@@ -266,7 +266,7 @@ static inline void list_splice_init(struct list_head *list,
* @param member the name of the list_struct within the struct.
*/
#define list_for_each_entry_reverse(type, pos, head, member) \
for (pos = list_entry((head)->prev, type, member); \
for (type *pos = list_entry((head)->prev, type, member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, type, member))
......@@ -280,8 +280,8 @@ static inline void list_splice_init(struct list_head *list,
* @param member the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(type, pos, n, head, member) \
for (pos = list_entry((head)->next, type, member), \
n = list_entry(pos->member.next, type, member); \
for (type *pos = list_entry((head)->next, type, member), \
*n = list_entry(pos->member.next, type, member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, type, member))
......
......@@ -404,8 +404,6 @@ static void assign(ir_node *block, void *env_ptr)
struct list_head *head = get_block_border_head(env, block);
be_lv_t *lv = be_get_irg_liveness(env->irg);
border_t *b;
bitset_clear_all(colors);
bitset_clear_all(live);
bitset_clear_all(in_colors);
......
......@@ -209,7 +209,6 @@ static void block_dims_walker(ir_node *block, void *data)
struct list_head *head = get_block_border_head(env->chordal_env, block);
const draw_chordal_opts_t *opts = env->opts;
struct block_dims *dims = OALLOCZ(&env->obst, struct block_dims);
border_t *b;
dims->min_step = INT_MAX;
......@@ -323,7 +322,6 @@ static void draw_block(ir_node *bl, void *data)
const draw_chordal_opts_t *opts = env->opts;
struct block_dims *dims = pmap_get(struct block_dims, env->block_dims, bl);
char buf[64];
border_t *b;
ir_snprintf(buf, sizeof(buf), "%F", bl);
......
......@@ -549,13 +549,12 @@ static inline void ou_insert_qnode(unit_t *ou, qnode_t *qn)
*/
static void ou_optimize(unit_t *ou)
{
qnode_t *curr = NULL;
qnode_t *tmp;
const arch_register_req_t *req;
bitset_t const* allocatable_regs;
unsigned n_regs;
unsigned idx;
int i;
qnode_t *curr = NULL;
const arch_register_req_t *req;
bitset_t const* allocatable_regs;
unsigned n_regs;
unsigned idx;
int i;
DBG((dbg, LEVEL_1, "\tOptimizing unit:\n"));
for (i=0; i<ou->node_count; ++i)
......@@ -640,8 +639,6 @@ static void ou_optimize(unit_t *ou)
*/
int co_solve_heuristic(copy_opt_t *co)
{
unit_t *curr;
ASSERT_OU_AVAIL(co);
pinned_global = pset_new_ptr(SLOTS_PINNED_GLOBAL);
......
......@@ -399,16 +399,12 @@ static void single_color_cost(co2_t *env, co2_irn_t *ci, col_t col, col_cost_pai
static void reject_coloring(struct list_head *h)
{
co2_irn_t *pos;
list_for_each_entry(co2_irn_t, pos, h, changed_list)
pos->tmp_fixed = 0;
}
static void materialize_coloring(struct list_head *h)
{
co2_irn_t *pos;
list_for_each_entry(co2_irn_t, pos, h, changed_list) {
pos->orig_col = pos->tmp_col;
pos->tmp_fixed = 0;
......@@ -819,7 +815,6 @@ static void populate_cloud(co2_t *env, co2_cloud_t *cloud, affinity_node_t *a, i
static co2_cloud_t *new_cloud(co2_t *env, affinity_node_t *a)
{
co2_cloud_t *cloud = OALLOC(&env->obst, co2_cloud_t);
co2_cloud_irn_t *ci;
int i;
DBG((env->dbg, LEVEL_2, "new cloud with %+F\n", a->irn));
......@@ -1029,7 +1024,6 @@ static void writeback_colors(co2_t *env)
static void process(co2_t *env)
{
co2_cloud_t *pos;
co2_cloud_t **clouds;
int n_clouds;
int i;
......
......@@ -648,7 +648,6 @@ static void build_affinity_chunks(co_mst_env_t *env)
aff_edge_t *edges = NEW_ARR_F(aff_edge_t, 0);
ir_node *n;
int i, len;
aff_chunk_t *curr_chunk;
size_t pn;
/* at first we create the affinity edge objects */
......@@ -924,7 +923,6 @@ static aff_chunk_t *fragment_chunk(co_mst_env_t *env, int col, aff_chunk_t *c, w
*/
static inline void reject_coloring(struct list_head *nodes)
{
co_mst_irn_t *n, *temp;
DB((dbg, LEVEL_4, "\treject coloring for"));
list_for_each_entry_safe(co_mst_irn_t, n, temp, nodes, list) {
DB((dbg, LEVEL_4, " %+F", n->irn));
......@@ -937,7 +935,6 @@ static inline void reject_coloring(struct list_head *nodes)
static inline void materialize_coloring(struct list_head *nodes)
{
co_mst_irn_t *n, *temp;
list_for_each_entry_safe(co_mst_irn_t, n, temp, nodes, list) {
assert(n->tmp_col >= 0);
n->col = n->tmp_col;
......
......@@ -240,7 +240,6 @@ static void make_affinity_var_name(char *buf, size_t buf_size,
static void build_affinity_cstr(ilp_env_t *ienv)
{
unsigned n_colors = arch_register_class_n_regs(ienv->co->cls);
unit_t *curr;
/* for all optimization units */
list_for_each_entry(unit_t, curr, &ienv->co->units, units) {
......
......@@ -86,8 +86,7 @@ void free_size_red(size_red_t *sr);
* Is this necessary?
*/
static inline int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
int i;
unit_t *curr;
int i;
/* search optimization unit for phi */
list_for_each_entry(unit_t, curr, &co->units, units)
......
......@@ -604,7 +604,7 @@ static int compare_ous(const void *k1, const void *k2)
static void co_sort_units(copy_opt_t *co)
{
int i, count = 0, costs;
unit_t *ou, **ous;
unit_t **ous;
/* get the number of ous, remove them form the list and fill the array */
list_for_each_entry(unit_t, ou, &co->units, units)
......@@ -650,7 +650,6 @@ void co_build_ou_structure(copy_opt_t *co)
void co_free_ou_structure(copy_opt_t *co)
{
unit_t *curr, *tmp;
ASSERT_OU_AVAIL(co);
list_for_each_entry_safe(unit_t, curr, tmp, &co->units, units) {
xfree(curr->nodes);
......@@ -665,7 +664,6 @@ void co_free_ou_structure(copy_opt_t *co)
int co_get_max_copy_costs(const copy_opt_t *co)
{
int i, res = 0;
unit_t *curr;
ASSERT_OU_AVAIL(co);
......@@ -680,7 +678,6 @@ int co_get_max_copy_costs(const copy_opt_t *co)
int co_get_inevit_copy_costs(const copy_opt_t *co)
{
int res = 0;
unit_t *curr;
ASSERT_OU_AVAIL(co);
......@@ -692,7 +689,6 @@ int co_get_inevit_copy_costs(const copy_opt_t *co)
int co_get_copy_costs(const copy_opt_t *co)
{
int i, res = 0;
unit_t *curr;
ASSERT_OU_AVAIL(co);
......@@ -714,7 +710,6 @@ int co_get_copy_costs(const copy_opt_t *co)
int co_get_lower_bound(const copy_opt_t *co)
{
int res = 0;
unit_t *curr;
ASSERT_OU_AVAIL(co);
......
......@@ -61,7 +61,6 @@ static void nodes_walker(ir_node *bl, void *data)
{
nodes_iter_t *it = (nodes_iter_t*)data;
struct list_head *head = get_block_border_head(it->env, bl);
border_t *b;
foreach_border_head(head, b) {
if (b->is_def && b->is_real) {
......@@ -125,7 +124,6 @@ static void find_neighbour_walker(ir_node *block, void *data)
struct list_head *head = get_block_border_head(it->env, block);
be_lv_t *lv = be_get_irg_liveness(it->env->irg);
border_t *b;
int has_started = 0;
if (!be_is_live_in(lv, block, it->irn) && block != get_nodes_block(it->irn))
......
......@@ -163,10 +163,9 @@ static void create_suffix(char *suffix, size_t n, const char *pass_name)
int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
{
ir_graph_pass_t *pass;
size_t i;
int res = 0;
ir_graph *rem = current_ir_graph;
size_t i;
int res = 0;
ir_graph *rem = current_ir_graph;
/* on all graphs: beware: number of irgs might be changed */
for (i = 0; i < get_irp_n_irgs(); ++i) {
......@@ -218,8 +217,7 @@ static int irp_verify_irgs(void)
int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
{
ir_prog_pass_t *pass;
int res = 0;
int res = 0;
/* run every pass on every graph */
unsigned idx = mgr->run_idx;
......@@ -286,8 +284,6 @@ ir_prog_pass_manager_t *new_prog_pass_mgr(
void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr)
{
ir_graph_pass_t *pass, *next;
list_for_each_entry_safe(ir_graph_pass_t, pass, next, &mgr->passes, list) {
if (pass->rem_from_mgr)
pass->rem_from_mgr(pass->context);
......@@ -300,8 +296,6 @@ void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr)
void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr)
{
ir_prog_pass_t *pass, *next;
list_for_each_entry_safe(ir_prog_pass_t, pass, next, &mgr->passes, list) {
if (pass->rem_from_mgr)
pass->rem_from_mgr(pass->context);
......
......@@ -75,7 +75,6 @@ static void resize(HashSet *self, size_t new_size)
HashSetEntry *old_entries = self->entries;
HashSetEntry *new_entries;
list_head list = self->elem_list;
ValueType *entry;
int res = 1;
/* allocate a new array with double size */
......
......@@ -232,7 +232,7 @@ lc_opt_entry_t *lc_opt_add_opt(lc_opt_entry_t *parent,
static lc_opt_entry_t *lc_opt_find_ent(const struct list_head *head, const char *name,
int error_to_use, lc_opt_err_info_t *err)
{
lc_opt_entry_t *ent, *found = NULL;
lc_opt_entry_t *found = NULL;
int error = error_to_use;
unsigned hash = hash_str(name);
......@@ -611,7 +611,6 @@ static void lc_opt_print_help_rec(lc_opt_entry_t *ent, char separator, lc_opt_en
char grp_name[512];
char value[256];
char values[512];
lc_opt_entry_t *e;
if (!list_empty(&s->opts)) {
lc_opt_print_grp_path(grp_name, sizeof(grp_name), ent, separator, stop_ent);
......@@ -669,8 +668,6 @@ static void lc_opt_print_tree_grp_indent(lc_opt_entry_t *ent, FILE *f, int level
lc_grp_special_t *s;
if (ent->is_grp) {
lc_opt_entry_t *e;
s = lc_get_grp_special(ent);
indent(f, level);
fprintf(f, "/%s\n", ent->name);
......
......@@ -276,7 +276,6 @@ void lower_CopyB(ir_graph *irg, unsigned max_small_sz, unsigned min_large_sz,
{
const backend_params *bparams = be_get_backend_param();
walk_env_t env;
entry_t *entry;
assert(max_small_sz < min_large_sz && "CopyB size ranges must not overlap");
......
......@@ -267,7 +267,6 @@ static int cmp_irn_opcode(const ir_node *a, const ir_node *b)
*/
static void check_partition(const partition_t *T)
{
node_t *node;
unsigned n = 0;
list_for_each_entry(node_t, node, &T->Leader, node_list) {
......@@ -290,7 +289,6 @@ static void check_partition(const partition_t *T)
*/
static void check_opcode(const partition_t *Z)
{
node_t *node;
const ir_node *repr = NULL;
list_for_each_entry(node_t, node, &Z->Leader, node_list) {
......@@ -308,7 +306,6 @@ static void check_all_partitions(environment_t *env)
{
#ifdef DEBUG_libfirm
partition_t *P;
node_t *node;
for (P = env->dbg_list; P != NULL; P = P->dbg_next) {
check_partition(P);
......@@ -367,7 +364,6 @@ static inline lattice_elem_t get_partition_type(const partition_t *X);
*/
static void dump_partition(const char *msg, const partition_t *part)
{
const node_t *node;
int first = 1;
lattice_elem_t type = get_partition_type(part);
......@@ -1177,7 +1173,7 @@ static partition_t *split(partition_t **pX, node_t *gg, environment_t *env)
partition_t *X_prime;
list_head tmp;
step_env senv[2];
node_t *g, *h, *node, *t;
node_t *g, *h;
int max_input, transitions, winner, shf;
unsigned n;
DEBUG_ONLY(static int run = 0;)
......@@ -1197,7 +1193,7 @@ static partition_t *split(partition_t **pX, node_t *gg, environment_t *env)
/* Remove gg from X.Leader and put into g */
g = NULL;
for (node = gg; node != NULL; node = node->next) {
for (node_t *node = gg; node != NULL; node = node->next) {
assert(node->part == X);
assert(node->is_follower == 0);
......@@ -1268,7 +1264,7 @@ static partition_t *split(partition_t **pX, node_t *gg, environment_t *env)
X_prime = new_partition(env);
max_input = 0;
n = 0;
for (node = senv[winner].walked; node != NULL; node = node->race_next) {
for (node_t *node = senv[winner].walked; node != NULL; node = node->race_next) {
list_del(&node->node_list);
node->part = X_prime;
if (node->is_follower) {
......@@ -1397,7 +1393,7 @@ static int type_is_neither_top_nor_const(const lattice_elem_t type)
*/
static void collect_touched(list_head *list, int idx, environment_t *env)
{
node_t *x, *y;
node_t *y;
int end_idx = env->end_idx;
list_for_each_entry(node_t, x, list, node_list) {
......@@ -1463,7 +1459,7 @@ static void collect_touched(list_head *list, int idx, environment_t *env)
*/
static void collect_commutative_touched(list_head *list, environment_t *env)
{
node_t *x, *y;
node_t *y;
list_for_each_entry(node_t, x, list, node_list) {
int num_edges;
......@@ -1644,7 +1640,7 @@ static void cause_splits(environment_t *env)
static partition_t *split_by_what(partition_t *X, what_func What,
partition_t **P, environment_t *env)
{
node_t *x, *S;
node_t *S;
listmap_t map;
listmap_entry_t *iter;
partition_t *R;
......@@ -2911,8 +2907,6 @@ static void propagate(environment_t *env)
x->on_fallen = 0;
if (old_type_was_T_or_C) {
node_t *y, *tmp;
/* check if some nodes will make the leader -> follower transition */
list_for_each_entry_safe(node_t, y, tmp, &Y->Leader, node_list) {
if (y->type.tv != tarval_top && ! is_con(y->type)) {
......
......@@ -162,8 +162,7 @@ DEBUG_ONLY(static unsigned part_nr = 0;)
*/
static void dump_partition(const char *msg, const partition_t *part)
{
const block_t *block;
int first = 1;
int first = 1;
DB((dbg, LEVEL_2, " %s part%u (%u blocks) {\n ", msg, part->nr, part->n_blocks));
list_for_each_entry(block_t, block, &part->blocks, block_list) {
......@@ -507,7 +506,6 @@ static void propagate_blocks(partition_t *part, environment_t *env)
{
block_t *ready_blocks = NULL;
unsigned n_ready = 0;
block_t *bl, *next;
listmap_t map;
listmap_entry_t *iter;
......@@ -617,8 +615,6 @@ static void propagate_blocks(partition_t *part, environment_t *env)
*/
static void propagate(environment_t *env)
{
partition_t *part, *next;
list_for_each_entry_safe(partition_t, part, next, &env->partitions, part_list) {
if (part->n_blocks < 2) {
/* zero or one block left, kill this partition */
......@@ -654,7 +650,6 @@ static void *live_throughs(const block_t *bl, const ir_node *phi)
static void propagate_blocks_live_troughs(partition_t *part, environment_t *env)
{
const ir_node *meet_block = part->meet_block;
block_t *bl, *next;
listmap_t map;
listmap_entry_t *iter;
const ir_node *phi;
......@@ -708,8 +703,6 @@ static void propagate_blocks_live_troughs(partition_t *part, environment_t *env)
*/
static void propagate_live_troughs(environment_t *env)
{
partition_t *part, *next;
list_for_each_entry_safe(partition_t, part, next, &env->partitions, part_list) {
propagate_blocks_live_troughs(part, env);
}
......@@ -729,7 +722,6 @@ static void propagate_live_troughs(environment_t *env)
static void apply(ir_graph *irg, partition_t *part)
{
block_t *repr = list_entry(part->blocks.next, block_t, block_list);
block_t *bl;
ir_node *block, *end, *meet_block, *p, *next;
ir_node **ins, **phi_ins;
phi_t *repr_phi, *phi;
......@@ -1195,7 +1187,6 @@ static void add_roots(ir_graph *irg, environment_t *env)
void shape_blocks(ir_graph *irg)
{
environment_t env;
partition_t *part;
block_t *bl;
int res, n;
......
......@@ -714,7 +714,6 @@ void inline_small_irgs(ir_graph *irg, int size)
{
ir_graph *rem = current_ir_graph;
inline_env_t env;
call_entry *entry;
current_ir_graph = irg;
/* Handle graph state */
......@@ -939,7 +938,7 @@ static call_entry *duplicate_call_entry(const call_entry *entry,
*/
static void append_call_list(inline_irg_env *dst, inline_irg_env *src, int loop_depth)
{
call_entry *entry, *nentry;
call_entry *nentry;
/* Note that the src list points to Call nodes in the inlined graph, but
we need Call nodes in our graph. Luckily the inliner leaves this information
......@@ -969,8 +968,6 @@ void inline_leaf_functions(unsigned maxsize, unsigned leafsize,
ir_graph *rem;
int did_inline;
wenv_t wenv;
call_entry *entry, *next;
const call_entry *centry;
pmap *copied_graphs;
pmap_entry *pm_entry;
......@@ -1566,7 +1563,6 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
{
int phiproj_computed = 0;
inline_irg_env *env = (inline_irg_env*)get_irg_link(irg);
call_entry *curr_call;
wenv_t wenv;
pqueue_t *pqueue;
......@@ -1599,7 +1595,6 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
irg_inline_property prop = get_irg_inline_property(callee);
ir_graph *calleee;
int loop_depth;
const call_entry *centry;
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,
......
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