Commit 5619c912 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Let foreach_out_edge_kind() and foreach_out_edge_kind_safe() declare their iterator variables.

parent 3aeb68ad
......@@ -64,7 +64,7 @@ FIRM_API const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
* edge.
*/
#define foreach_out_edge_kind(irn, edge, kind) \
for(edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge))
for (ir_edge_t const *edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge))
/**
* A convenience iteration macro over all out edges of a node, which is safe
......@@ -72,27 +72,27 @@ FIRM_API const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
*
* @param irn The node.
* @param edge An ir_edge_t pointer which shall be set to the current edge.
* @param ne The next edge, enables alteration safe edge processing.
* @param kind The kind of the edge.
*/
#define foreach_out_edge_kind_safe(irn, edge, ne, kind) \
for((edge) = (get_irn_out_edge_first_kind(irn, kind)), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL); \
edge; (edge) = (ne), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL))
#define foreach_out_edge_kind_safe(irn, edge, kind) \
for (ir_edge_t const *edge = get_irn_out_edge_first_kind((irn), (kind)), *edge##__next; \
edge ? edge##__next = get_irn_out_edge_next((irn), edge), 1 : 0; \
edge = edge##__next)
/**
* Convenience macro for normal out edges.
*/
#define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
#define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
/**
* Convenience macro for normal out edges.
*/
#define foreach_out_edge_safe(irn, edge, tmp) foreach_out_edge_kind_safe(irn, edge, tmp, EDGE_KIND_NORMAL)
#define foreach_out_edge_safe(irn, edge) foreach_out_edge_kind_safe(irn, edge, EDGE_KIND_NORMAL)
/**
* A convenience iteration macro for all control flow edges.
*/
#define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
#define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
/**
* Returns the source node of an edge.
......
......@@ -47,7 +47,6 @@ static void *irg_cfg_succ_get_end(void *self)
static void irg_cfg_succ_grow_succs(void *self, void *node, struct obstack *obst)
{
ir_node *bl = (ir_node*) node;
const ir_edge_t *edge;
(void) self;
foreach_block_succ(bl, edge) {
......
......@@ -58,7 +58,6 @@ static inline ir_node *get_idom(ir_node *bl)
static ir_node **compute_df(ir_node *blk, ir_dom_front_info_t *info)
{
ir_node *c;
const ir_edge_t *edge;
ir_node **df_list = NEW_ARR_F(ir_node *, 0);
ir_node **df;
size_t len;
......
......@@ -174,16 +174,15 @@ static double *solve_lgs(gs_matrix_t *mat, double *x, int size)
*/
static double get_cf_probability(ir_node *bb, int pos, double loop_weight)
{
double sum = 0.0;
double cur = 1.0;
double inv_loop_weight = 1./loop_weight;
const ir_node *pred = get_Block_cfgpred_block(bb, pos);
const ir_loop *pred_loop;
int pred_depth;
const ir_edge_t *edge;
const ir_loop *loop;
int depth;
int d;
double sum = 0.0;
double cur = 1.0;
double inv_loop_weight = 1./loop_weight;
const ir_node *pred = get_Block_cfgpred_block(bb, pos);
const ir_loop *pred_loop;
int pred_depth;
const ir_loop *loop;
int depth;
int d;
if (is_Bad(pred))
return 0;
......
......@@ -149,8 +149,6 @@ static unsigned compute_height(ir_heights_t *h, ir_node *irn, const ir_node *bl)
{
irn_height_t *ih = get_height_data(h, irn);
const ir_edge_t *edge;
/* bail out if we already visited that node. */
if (ih->visited >= h->visited)
return ih->height;
......@@ -186,8 +184,7 @@ static unsigned compute_height(ir_heights_t *h, ir_node *irn, const ir_node *bl)
static unsigned compute_heights_in_block(ir_node *bl, ir_heights_t *h)
{
int max_height = -1;
const ir_edge_t *edge;
int max_height = -1;
h->visited++;
......@@ -224,7 +221,6 @@ unsigned get_irn_height(const ir_heights_t *heights, const ir_node *irn)
unsigned heights_recompute_block(ir_heights_t *h, ir_node *block)
{
ir_graph *irg = get_irn_irg(block);
const ir_edge_t *edge;
assure_edges(irg);
......
......@@ -108,16 +108,14 @@ static ir_node *get_case_value(ir_node *switchn, long pn)
*/
static void handle_case(ir_node *block, ir_node *switchn, long pn, env_t *env)
{
ir_node *c = NULL;
ir_node *selector = get_Switch_selector(switchn);
const ir_edge_t *edge;
const ir_edge_t *next;
ir_node *c = NULL;
ir_node *selector = get_Switch_selector(switchn);
/* we can't do usefull things with the default label */
if (pn == pn_Switch_default)
return;
foreach_out_edge_safe(selector, edge, next) {
foreach_out_edge_safe(selector, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(succ, pos);
......@@ -153,9 +151,8 @@ static void handle_modeb(ir_node *block, ir_node *selector, pn_Cond pnc, env_t *
{
ir_node *cond, *old, *other_blk = NULL, *con = NULL;
ir_node *c_b = NULL, *c_o = NULL;
const ir_edge_t *edge, *next;
foreach_out_edge_safe(selector, edge, next) {
foreach_out_edge_safe(selector, edge) {
ir_node *user = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *user_blk = get_effective_use_block(user, pos);
......@@ -270,7 +267,6 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
ir_node *right = get_Cmp_right(cmp);
ir_node *cond_block;
ir_op *op;
const ir_edge_t *edge, *next;
/* Beware of Bads */
if (is_Bad(left) || is_Bad(right))
......@@ -299,7 +295,7 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
*/
if (rel == ir_relation_equal) {
cond_block = get_Block_cfgpred_block(block, 0);
foreach_out_edge_safe(left, edge, next) {
foreach_out_edge_safe(left, edge) {
ir_node *user = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(user, pos);
......@@ -323,9 +319,7 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
* left == Const and we found a movable user of left in a
* dominator of the Cond block
*/
const ir_edge_t *user_edge;
const ir_edge_t *user_next;
foreach_out_edge_safe(user, user_edge, user_next) {
foreach_out_edge_safe(user, user_edge) {
ir_node *usr_of_usr = get_edge_src_irn(user_edge);
int npos = get_edge_src_pos(user_edge);
ir_node *user_blk = get_effective_use_block(usr_of_usr, npos);
......@@ -357,7 +351,7 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
} else { /* not ir_relation_equal cases */
ir_node *c = NULL;
foreach_out_edge_safe(left, edge, next) {
foreach_out_edge_safe(left, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
ir_node *blk = get_effective_use_block(succ, pos);
......@@ -384,7 +378,7 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
ir_node *rc = NULL;
rel = get_inversed_relation(rel);
foreach_out_edge_safe(right, edge, next) {
foreach_out_edge_safe(right, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos;
ir_node *blk;
......@@ -495,10 +489,9 @@ static int is_non_null_Confirm(const ir_node *ptr)
*/
static void insert_non_null(ir_node *ptr, ir_node *block, env_t *env)
{
const ir_edge_t *edge, *next;
ir_node *c = NULL;
ir_node *c = NULL;
foreach_out_edge_safe(ptr, edge, next) {
foreach_out_edge_safe(ptr, edge) {
ir_node *succ = get_edge_src_irn(edge);
int pos;
ir_node *blk;
......
......@@ -135,8 +135,6 @@ static void red_trans_closure(lv_chk_t *lv)
const ir_node *bl = (const ir_node*) dfs_get_post_num_node(lv->dfs, i);
bl_info_t *bi = get_block_info(lv, bl);
const ir_edge_t *edge;
bitset_set(bi->red_reachable, bi->id);
foreach_block_succ (bl, edge) {
ir_node *succ = get_edge_src_irn(edge);
......@@ -183,7 +181,6 @@ static void compute_back_edge_chain(lv_chk_t *lv, const ir_node *bl)
/* iterate over them ... */
bitset_foreach(tmp, elm) {
bl_info_t *si = lv->map[elm];
const ir_edge_t *edge;
/* and find back edge targets which are not reduced reachable from bl */
foreach_block_succ (si->block, edge) {
......@@ -217,8 +214,6 @@ static inline void compute_back_edge_chains(lv_chk_t *lv)
const ir_node *bl = (const ir_node*) dfs_get_post_num_node(lv->dfs, i);
bl_info_t *bi = get_block_info(lv, bl);
const ir_edge_t *edge;
if (!bitset_is_set(lv->back_edge_tgt, bi->id)) {
foreach_block_succ (bl, edge) {
ir_node *succ = get_edge_src_irn(edge);
......@@ -328,8 +323,6 @@ unsigned lv_chk_bl_xxx(lv_chk_t *lv, const ir_node *bl, const ir_node *var)
* the algorithm is simple. Just check for uses not inside this block.
*/
if (def_bl == bl) {
const ir_edge_t *edge;
stat_ev("lv_chk_def_block");
DBG((lv->dbg, LEVEL_2, "lv check same block %+F in %+F\n", var, bl));
foreach_out_edge (var, edge) {
......@@ -376,7 +369,6 @@ unsigned lv_chk_bl_xxx(lv_chk_t *lv, const ir_node *bl, const ir_node *var)
size_t i;
unsigned min_dom, max_dom;
const ir_edge_t *edge;
/* if the block has no DFS info, it cannot be reached.
* This can happen in functions with endless loops.
......
......@@ -215,17 +215,16 @@ static void emit_amd64_Jmp(const ir_node *node)
*/
static void emit_amd64_Jcc(const ir_node *irn)
{
const ir_edge_t *edge;
const ir_node *proj_true = NULL;
const ir_node *proj_false = NULL;
const ir_node *block;
const ir_node *next_block;
const char *suffix;
const amd64_attr_t *attr = get_amd64_attr_const(irn);
ir_relation relation = attr->ext.relation;
ir_node *op1 = get_irn_n(irn, 0);
const amd64_attr_t *cmp_attr = get_amd64_attr_const(op1);
bool is_signed = !cmp_attr->data.cmp_unsigned;
const ir_node *proj_true = NULL;
const ir_node *proj_false = NULL;
const ir_node *block;
const ir_node *next_block;
const char *suffix;
const amd64_attr_t *attr = get_amd64_attr_const(irn);
ir_relation relation = attr->ext.relation;
ir_node *op1 = get_irn_n(irn, 0);
const amd64_attr_t *cmp_attr = get_amd64_attr_const(op1);
bool is_signed = !cmp_attr->data.cmp_unsigned;
assert(is_amd64_Cmp(op1));
......
......@@ -348,7 +348,6 @@ static void arm_emit_cfop_target(const ir_node *irn)
*/
static void emit_arm_B(const ir_node *irn)
{
const ir_edge_t *edge;
const ir_node *proj_true = NULL;
const ir_node *proj_false = NULL;
const ir_node *block;
......
......@@ -99,8 +99,6 @@ static void peephole_be_IncSP(ir_node *node)
int cnt;
int sign = 1;
arm_vals v;
const ir_edge_t *edge;
const ir_edge_t *next;
/* first optimize incsp->incsp combinations */
node = be_peephole_IncSP_IncSP(node);
......@@ -129,7 +127,7 @@ static void peephole_be_IncSP(ir_node *node)
/* reattach IncSP users */
last = node;
node = sched_next(first);
foreach_out_edge_safe(first, edge, next) {
foreach_out_edge_safe(first, edge) {
ir_node *user = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
if (user == node)
......
......@@ -378,7 +378,6 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
ir_node **in;
ir_node **res_projs;
int n_reg_results = 0;
const ir_edge_t *edge;
int *reg_param_idxs;
int *stack_param_idx;
int i, n;
......@@ -524,8 +523,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
res_projs = ALLOCANZ(ir_node*, n_res);
foreach_out_edge(irn, edge) {
const ir_edge_t *res_edge;
ir_node *irn = get_edge_src_irn(edge);
ir_node *irn = get_edge_src_irn(edge);
if (!is_Proj(irn) || get_Proj_proj(irn) != pn_Call_T_result)
continue;
......@@ -794,7 +792,6 @@ static ir_node *adjust_alloc(be_abi_irg_t *env, ir_node *alloc, ir_node *curr_sp
ir_type *type = get_Alloc_type(alloc);
dbg_info *dbg;
const ir_edge_t *edge;
ir_node *new_alloc;
ir_node *count;
ir_node *size;
......@@ -1377,7 +1374,6 @@ static void fix_start_block(ir_graph *irg)
/* merge start block with successor if possible */
{
const ir_edge_t *edge;
foreach_out_edge(jmp, edge) {
ir_node *succ = get_edge_src_irn(edge);
if (!is_Block(succ))
......@@ -1420,7 +1416,6 @@ static void modify_irg(ir_graph *irg)
ir_node *start_bl;
ir_node **args;
ir_node *arg_tuple;
const ir_edge_t *edge;
ir_type *arg_type, *bet_type;
lower_frame_sels_env_t ctx;
......
......@@ -383,7 +383,6 @@ ir_node *be_epilog_create_return(beabi_helper_env_t *env, dbg_info *dbgi,
*/
static bool has_real_user(const ir_node *node)
{
const ir_edge_t *edge;
foreach_out_edge(node, edge) {
ir_node *user = get_edge_src_irn(edge);
if (!is_End(user) && !is_Anchor(user))
......@@ -413,12 +412,11 @@ static ir_node *add_to_keep(ir_node *last_keep,
void be_add_missing_keeps_node(ir_node *node)
{
int n_outs, i;
unsigned *found_projs;
const ir_edge_t *edge;
ir_mode *mode = get_irn_mode(node);
ir_node *last_keep;
ir_node **existing_projs;
int n_outs, i;
unsigned *found_projs;
ir_mode *mode = get_irn_mode(node);
ir_node *last_keep;
ir_node **existing_projs;
if (mode != mode_T) {
if (!has_real_user(node)) {
......
......@@ -624,7 +624,6 @@ static inline bool arch_irn_consider_in_reg_alloc(
#define be_foreach_definition_(node, cls, value, code) \
do { \
if (get_irn_mode(node) == mode_T) { \
const ir_edge_t *edge_; \
foreach_out_edge(node, edge_) { \
const arch_register_req_t *req_; \
value = get_edge_src_irn(edge_); \
......
......@@ -395,8 +395,7 @@ static void pick_block_successor(blocksched_entry_t *entry, blocksched_env_t *en
ir_node *block = entry->block;
ir_node *succ = NULL;
blocksched_entry_t *succ_entry;
const ir_edge_t *edge;
double best_succ_execfreq;
double best_succ_execfreq;
if (irn_visited_else_mark(block))
return;
......
......@@ -177,7 +177,6 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
pmap *partners;
int i, n_alloc;
size_t col;
const ir_edge_t *edge;
ir_node *perm = NULL;
//int match_res, cost;
be_chordal_env_t *env = alloc_env->chordal_env;
......
......@@ -154,8 +154,6 @@ void create_borders(ir_node *block, void *env_ptr)
DBG((dbg, LEVEL_2, "\tlive: %B\n", live));
if (get_irn_mode(irn) == mode_T) {
const ir_edge_t *edge;
foreach_out_edge(irn, edge) {
ir_node *proj = get_edge_src_irn(edge);
......@@ -229,11 +227,10 @@ be_insn_t *chordal_scan_insn(be_chordal_env_t *env, ir_node *irn)
ir_node *pre_process_constraints(be_chordal_env_t *env, be_insn_t **the_insn)
{
be_insn_t *insn = *the_insn;
ir_node *perm = NULL;
bitset_t *out_constr = bitset_alloca(env->cls->n_regs);
const ir_edge_t *edge;
int i;
be_insn_t *insn = *the_insn;
ir_node *perm = NULL;
bitset_t *out_constr = bitset_alloca(env->cls->n_regs);
int i;
assert(insn->has_constraints && "only do this for constrained nodes");
......
......@@ -288,8 +288,7 @@ static void set_y(const draw_chordal_env_t *env, ir_node *bl, int up)
static color_t *reg_to_color(const draw_chordal_env_t *env,
ir_node *rel_bl, ir_node *irn, color_t *color)
{
int phi_arg = 0;
const ir_edge_t *edge;
int phi_arg = 0;
(void) env;
(void) rel_bl;
......
......@@ -185,9 +185,8 @@ static void dump(unsigned mask, ir_graph *irg,
*/
static void memory_operand_walker(ir_node *irn, void *env)
{
const ir_edge_t *edge, *ne;
ir_node *block;
ir_node *spill;
ir_node *block;
ir_node *spill;
(void)env;
......@@ -201,7 +200,7 @@ static void memory_operand_walker(ir_node *irn, void *env)
spill = be_get_Reload_mem(irn);
block = get_nodes_block(irn);
foreach_out_edge_safe(irn, edge, ne) {
foreach_out_edge_safe(irn, edge) {
ir_node *src = get_edge_src_irn(edge);
int pos = get_edge_src_pos(edge);
......
......@@ -87,7 +87,6 @@ static bool default_check_modifies(const ir_node *node)
*/
static bool can_move(ir_node *node, ir_node *after)
{
const ir_edge_t *edge;
ir_node *node_block = get_nodes_block(node);
assert(node_block == get_nodes_block(after));
......@@ -98,7 +97,6 @@ static bool can_move(ir_node *node, ir_node *after)
foreach_out_edge(node, edge) {
ir_node *out = get_edge_src_irn(edge);
if (is_Proj(out)) {
const ir_edge_t *edge2;
assert(get_irn_n_edges_kind(out, EDGE_KIND_DEP) == 0);
foreach_out_edge(out, edge2) {
ir_node *out2 = get_edge_src_irn(edge2);
......@@ -108,7 +106,6 @@ static bool can_move(ir_node *node, ir_node *after)
if (is_Phi(out2) || is_End(out2))
continue;
if (is_Sync(out2)) {
const ir_edge_t *edge3;
foreach_out_edge(out2, edge3) {
ir_node *out3 = get_edge_src_irn(edge3);
/* Phi or End represents a usage at block end. */
......
......@@ -1530,14 +1530,13 @@ static void emit_global_decls(const be_main_env_t *main_env)
void be_emit_jump_table(const ir_node *node, const ir_switch_table *table,
ir_entity *entity, get_cfop_target_func get_cfop_target)
{
unsigned n_outs = arch_get_irn_n_outs(node);
const ir_node **targets = XMALLOCNZ(const ir_node*, n_outs);
size_t n_entries = ir_switch_table_get_n_entries(table);
unsigned long length = 0;
size_t e;
const ir_edge_t *edge;
unsigned i;
const ir_node **labels;
unsigned n_outs = arch_get_irn_n_outs(node);
const ir_node **targets = XMALLOCNZ(const ir_node*, n_outs);
size_t n_entries = ir_switch_table_get_n_entries(table);
unsigned long length = 0;
size_t e;
unsigned i;
const ir_node **labels;
/* go over all proj's and collect their jump targets */
foreach_out_edge(node, edge) {
......
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