Commit 443730f3 authored by Michael Beck's avatar Michael Beck
Browse files

use the new Anchor node instead of old anchors

[r15053]
parent ae7ae8f3
......@@ -1515,7 +1515,7 @@ static ir_node *gen_Proj(ir_node *node) {
ir_fprintf(stderr, "created jump: %+F\n", jump);
return jump;
}
if (node == be_get_old_anchor(anchor_tls)) {
if (node == get_irg_anchor(irg, anchor_tls)) {
return gen_Proj_tls(node);
}
} else {
......
......@@ -1815,9 +1815,11 @@ static void modify_irg(be_abi_irg_t *env)
arg_tuple = get_irg_args(irg);
foreach_out_edge(arg_tuple, edge) {
ir_node *irn = get_edge_src_irn(edge);
int nr = get_Proj_proj(irn);
args[nr] = irn;
DBG((dbg, LEVEL_2, "\treading arg: %d -> %+F\n", nr, irn));
if (! is_Anchor(irn)) {
int nr = get_Proj_proj(irn);
args[nr] = irn;
DBG((dbg, LEVEL_2, "\treading arg: %d -> %+F\n", nr, irn));
}
}
arg_type = compute_arg_type(env, call, method_type, &param_map);
......@@ -1975,8 +1977,8 @@ static void modify_irg(be_abi_irg_t *env)
}
}
/* the arg proj is not needed anymore now */
assert(get_irn_n_edges(arg_tuple) == 0);
/* the arg proj is not needed anymore now and should be only used by the anchor */
assert(get_irn_n_edges(arg_tuple) == 1);
be_kill_node(arg_tuple);
set_irg_args(irg, new_rd_Bad(irg));
......
......@@ -391,6 +391,8 @@ static void trace_preprocess_block(trace_env_t *env, ir_node *block) {
foreach_out_edge(block, edge) {
ir_node *succ = get_edge_src_irn(edge);
if (is_Anchor(succ))
continue;
if (is_root(succ, block)) {
mark_root_node(env, succ);
set_irn_link(succ, root);
......
......@@ -33,7 +33,7 @@
#include "iropt_t.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "ircons.h"
#include "ircons_t.h"
#include "irhooks.h"
#include "iredges.h"
#include "irouts.h"
......@@ -50,7 +50,7 @@ typedef struct be_transform_env_t {
node is already transformed */
waitq *worklist; /**< worklist of nodes that still need to be
transformed */
ir_node **old_anchors;/**< the list of anchors nodes in the old irg */
ir_node *old_anchor; /**< the old anchor node in the old irg */
} be_transform_env_t;
......@@ -65,10 +65,6 @@ static INLINE ir_node *be_get_transformed_node(ir_node *old_node) {
return (ir_node*) get_irn_link(old_node);
}
ir_node *be_get_old_anchor(unsigned anchor) {
return env.old_anchors[anchor];
}
void be_duplicate_deps(ir_node *old_node, ir_node *new_node) {
int i;
int deps = get_irn_deps(old_node);
......@@ -228,7 +224,7 @@ ir_node *be_pre_transform_node(ir_node *place) {
*/
static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, void *cg) {
int i;
ir_node *old_end;
ir_node *old_end, *new_anchor;
hook_dead_node_elim(irg, 1);
......@@ -237,31 +233,28 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, v
env.irg = irg;
env.visited = get_irg_visited(irg);
env.worklist = new_waitq();
env.old_anchors = alloca(anchor_max * sizeof(env.old_anchors[0]));
env.old_anchor = irg->anchor;
old_end = get_irg_end(irg);
/* put all anchor nodes in the worklist */
for (i = 0; i < anchor_max; ++i) {
ir_node *anchor = irg->anchors[i];
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *anchor = get_irg_anchor(irg, i);
if (anchor == NULL)
continue;
waitq_put(env.worklist, anchor);
/* remember anchor */
env.old_anchors[i] = anchor;
/* and set it to NULL to make sure we don't accidently use it */
irg->anchors[i] = NULL;
}
new_anchor = new_Anchor(irg);
/* pre transform some anchors (so they are available in the other transform
* functions) */
set_irg_bad(irg, be_transform_node(env.old_anchors[anchor_bad]));
set_irg_no_mem(irg, be_transform_node(env.old_anchors[anchor_no_mem]));
set_irg_start_block(irg, be_transform_node(env.old_anchors[anchor_start_block]));
set_irg_start(irg, be_transform_node(env.old_anchors[anchor_start]));
set_irg_frame(irg, be_transform_node(env.old_anchors[anchor_frame]));
set_irn_n(new_anchor, anchor_bad, be_transform_node(get_irg_anchor(irg, anchor_bad)));
set_irn_n(new_anchor, anchor_no_mem, be_transform_node(get_irg_anchor(irg, anchor_no_mem)));
set_irn_n(new_anchor, anchor_start_block, be_transform_node(get_irg_anchor(irg, anchor_start_block)));
set_irn_n(new_anchor, anchor_start, be_transform_node(get_irg_anchor(irg, anchor_start)));
set_irn_n(new_anchor, anchor_frame, be_transform_node(get_irg_anchor(irg, anchor_frame)));
if (pre_transform)
(*pre_transform)(cg);
......@@ -274,17 +267,18 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, v
/* fix loops and set new anchors*/
inc_irg_visited(irg);
for (i = 0; i < anchor_max; ++i) {
ir_node *anchor = env.old_anchors[i];
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *anchor = get_irg_anchor(irg, i);
if (anchor == NULL)
continue;
anchor = get_irn_link(anchor);
fix_loops(anchor);
assert(irg->anchors[i] == NULL || irg->anchors[i] == anchor);
irg->anchors[i] = anchor;
set_irn_n(new_anchor, i, anchor);
}
irg->anchor = new_anchor;
set_irn_n(new_anchor, -1, get_irn_intra_n(new_anchor, anchor_end_block));
del_waitq(env.worklist);
free_End(old_end);
......@@ -297,7 +291,7 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, v
static ir_node *gen_Block(ir_node *node) {
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *start_block = be_get_old_anchor(anchor_start_block);
ir_node *start_block = get_irg_anchor(irg, anchor_start_block);
ir_node *block;
/*
......
......@@ -40,11 +40,6 @@ typedef void (arch_pretrans_nodes)(void *arch_cg);
*/
typedef ir_node *(be_transform_func)(ir_node *node);
/**
* Returns an old (saved) anchor of the currently transforming graph.
*/
ir_node *be_get_old_anchor(unsigned anchor);
/** pre-transform a node */
ir_node *be_pre_transform_node(ir_node *place);
......
......@@ -3927,7 +3927,7 @@ static ir_node *gen_Proj(ir_node *node) {
jump = new_rd_Jmp(dbgi, irg, block);
return jump;
}
if (node == be_get_old_anchor(anchor_tls)) {
if (node == get_irg_anchor(irg, anchor_tls)) {
return gen_Proj_tls(node);
}
} else {
......
......@@ -519,7 +519,7 @@ static ir_node *gen_Proj_Start(ir_node *node)
ir_node *jump = new_rd_Jmp(dbgi, irg, block);
return jump;
}
if(node == be_get_old_anchor(anchor_tls)) {
if(node == get_irg_anchor(irg, anchor_tls)) {
/* TODO... */
return be_duplicate_node(node);
}
......
......@@ -3357,3 +3357,10 @@ ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_clobber, ident *clobber[], ident *asm_text) {
return new_d_ASM(NULL, arity, in, inputs, n_outs, outputs, n_clobber, clobber, asm_text);
}
/* create a new anchor node */
ir_node *new_Anchor(ir_graph *irg) {
ir_node *in[anchor_last];
memset(in, 0, sizeof(in));
return new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last, in);
}
......@@ -40,16 +40,21 @@
*/
void init_cons(uninitialized_local_variable_func_t *func);
/**
* Creates a new Anchor node.
*/
ir_node *new_Anchor(ir_graph *irg);
/* inline functions */
static INLINE ir_node *
_new_d_Bad(void) {
return current_ir_graph->anchors[anchor_bad];
return get_irg_bad(current_ir_graph);
}
static INLINE ir_node *
_new_d_NoMem(void) {
return current_ir_graph->anchors[anchor_no_mem];
return get_irg_no_mem(current_ir_graph);
}
......
......@@ -536,13 +536,14 @@ static int node_floats(ir_node *n) {
* Walker that visits the anchors
*/
static void ird_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
irg_walk_graph(irg, pre, post, env);
if (dump_anchors) {
int i;
for (i = anchor_max - 1; i >= 0; --i) {
ir_node *n = irg->anchors[i];
if (pre)
pre(irg->anchor, env);
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *n = get_irg_anchor(irg, i);
if (n) {
/* reset the visit flag: will be increase in the walker */
......@@ -550,6 +551,10 @@ static void ird_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *pos
irg_walk(n, pre, post, env);
}
}
if (post)
post(irg->anchor, env);
} else {
irg_walk_graph(irg, pre, post, env);
}
}
......
......@@ -498,8 +498,6 @@ void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
info->activated = 1;
edges_init_graph_kind(irg, kind);
//irg_walk_graph(irg, init_lh_walker, build_edges_walker, &w);
inc_irg_visited(irg);
irg_walk_anchors(irg, init_lh_walker, build_edges_walker, &w);
visit_all_identities(irg, visitor, &w);
}
......@@ -758,9 +756,7 @@ int edges_verify(ir_graph *irg) {
w.problem_found = 0;
/* verify counter */
inc_irg_visited(irg);
irg_walk_anchors(irg, clear_links, count_user, &w);
inc_irg_visited(irg);
irg_walk_anchors(irg, NULL, verify_edge_counter, &w);
return problem_found ? 1 : w.problem_found;
......
......@@ -35,7 +35,7 @@
#include "irprog_t.h"
#include "iroptimize.h"
#include "ircons.h"
#include "ircons_t.h"
#include "iropt_t.h"
#include "irgopt.h"
#include "irgmod.h"
......@@ -363,8 +363,7 @@ static void copy_node(ir_node *n, void *env) {
* Copies new predecessors of old node to new node remembered in link.
* Spare the Bad predecessors of Phi and Block nodes.
*/
void
copy_preds(ir_node *n, void *env) {
static void copy_preds(ir_node *n, void *env) {
ir_node *nn, *block;
int i, j, irn_arity;
(void) env;
......@@ -497,8 +496,8 @@ static void copy_graph(ir_graph *irg, int copy_node_nr) {
/* Note: from yet, the visited flag of the graph is equal to vfl + 1 */
/* visit the anchors as well */
for (i = anchor_max - 1; i >= 0; --i) {
ir_node *n = irg->anchors[i];
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *n = get_irg_anchor(irg, i);
if (n && (get_irn_visited(n) <= vfl)) {
set_irg_visited(irg, vfl);
......@@ -555,7 +554,7 @@ static void copy_graph(ir_graph *irg, int copy_node_nr) {
static void
copy_graph_env(int copy_node_nr) {
ir_graph *irg = current_ir_graph;
ir_node *old_end, *n;
ir_node *old_end, *new_anchor;
int i;
/* remove end_except and end_reg nodes */
......@@ -566,9 +565,10 @@ copy_graph_env(int copy_node_nr) {
/* Not all nodes remembered in irg might be reachable
from the end node. Assure their link is set to NULL, so that
we can test whether new nodes have been computed. */
for (i = anchor_max - 1; i >= 0; --i) {
if (irg->anchors[i])
set_new_node(irg->anchors[i], NULL);
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *n = get_irg_anchor(irg, i);
if (n != NULL)
set_new_node(n, NULL);
}
/* we use the block walk flag for removing Bads from Blocks ins. */
inc_irg_block_visited(irg);
......@@ -576,14 +576,20 @@ copy_graph_env(int copy_node_nr) {
/* copy the graph */
copy_graph(irg, copy_node_nr);
/* fix the fields in irg */
old_end = get_irg_end(irg);
for (i = anchor_max - 1; i >= 0; --i) {
n = irg->anchors[i];
/* fix the anchor */
old_end = get_irg_end(irg);
new_anchor = new_Anchor(irg);
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
ir_node *n = get_irg_anchor(irg, i);
if (n)
irg->anchors[i] = get_new_node(n);
set_irn_n(new_anchor, i, get_new_node(n));
}
free_End(old_end);
irg->anchor = new_anchor;
/* ensure the new anchor is placed in the endblock */
set_irn_n(new_anchor, -1, get_irg_end_block(irg));
}
/**
......
......@@ -25,8 +25,6 @@
#ifndef FIRM_IR_IRGOPT_T_H
#define FIRM_IR_IRGOPT_T_H
//void copy_node (ir_node *n, void *env);
void copy_preds(ir_node *n, void *env);
void firm_copy_node (ir_node *n, void *env);
#endif
This diff is collapsed.
......@@ -97,112 +97,123 @@ _is_ir_graph(const void *thing) {
/** Returns the start block of a graph. */
static INLINE ir_node *
_get_irg_start_block(const ir_graph *irg) {
return irg->anchors[anchor_start_block];
return get_irn_intra_n(irg->anchor, anchor_start_block);
}
static INLINE void
_set_irg_start_block(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_start_block] = node;
set_irn_n(irg->anchor, anchor_start_block, node);
}
static INLINE ir_node *
_get_irg_start(const ir_graph *irg) {
return irg->anchors[anchor_start];
return get_irn_intra_n(irg->anchor, anchor_start);
}
static INLINE void
_set_irg_start(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_start] = node;
set_irn_n(irg->anchor, anchor_start, node);
}
static INLINE ir_node *
_get_irg_end_block(const ir_graph *irg) {
return irg->anchors[anchor_end_block];
return get_irn_intra_n(irg->anchor, anchor_end_block);
}
static INLINE void
_set_irg_end_block(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_end_block] = node;
set_irn_n(irg->anchor, -1, node);
set_irn_n(irg->anchor, anchor_end_block, node);
}
static INLINE ir_node *
_get_irg_end(const ir_graph *irg) {
return irg->anchors[anchor_end];
return get_irn_intra_n(irg->anchor, anchor_end);
}
static INLINE void
_set_irg_end(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_end] = node;
set_irn_n(irg->anchor, anchor_end, node);
}
static INLINE ir_node *
_get_irg_end_reg(const ir_graph *irg) {
return irg->anchors[anchor_end_reg];
return get_irn_intra_n(irg->anchor, anchor_end_reg);
}
static INLINE void
_set_irg_end_reg(ir_graph *irg, ir_node *node) {
set_irn_n(irg->anchor, anchor_end_reg, node);
}
static INLINE ir_node *
_get_irg_end_except (const ir_graph *irg) {
return irg->anchors[anchor_end_except];
_get_irg_end_except(const ir_graph *irg) {
return get_irn_intra_n(irg->anchor, anchor_end_except);
}
static INLINE void
_set_irg_end_except(ir_graph *irg, ir_node *node) {
set_irn_n(irg->anchor, anchor_end_except, node);
}
static INLINE ir_node *
_get_irg_frame(const ir_graph *irg) {
return irg->anchors[anchor_frame];
return get_irn_intra_n(irg->anchor, anchor_frame);
}
static INLINE void
_set_irg_frame(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_frame] = node;
set_irn_n(irg->anchor, anchor_frame, node);
}
static INLINE ir_node *
_get_irg_globals(const ir_graph *irg) {
return irg->anchors[anchor_globals];
return get_irn_intra_n(irg->anchor, anchor_globals);
}
static INLINE void
_set_irg_globals(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_globals] = node;
set_irn_n(irg->anchor, anchor_globals, node);
}
static INLINE ir_node *
_get_irg_tls(const ir_graph *irg) {
return irg->anchors[anchor_tls];
return get_irn_intra_n(irg->anchor, anchor_tls);
}
static INLINE void
_set_irg_tls(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_tls] = node;
set_irn_n(irg->anchor, anchor_tls, node);
}
static INLINE ir_node *
_get_irg_initial_mem(const ir_graph *irg) {
return irg->anchors[anchor_initial_mem];
return get_irn_intra_n(irg->anchor, anchor_initial_mem);
}
static INLINE void
_set_irg_initial_mem(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_initial_mem] = node;
set_irn_n(irg->anchor, anchor_initial_mem, node);
}
static INLINE ir_node *
_get_irg_args(const ir_graph *irg) {
return irg->anchors[anchor_args];
return get_irn_intra_n(irg->anchor, anchor_args);
}
static INLINE void
_set_irg_args(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_args] = node;
set_irn_n(irg->anchor, anchor_args, node);
}
static INLINE ir_node *
_get_irg_value_param_base(const ir_graph *irg) {
return irg->anchors[anchor_value_param_base];
return get_irn_intra_n(irg->anchor, anchor_value_param_base);
}
static INLINE void
_set_irg_value_param_base(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_value_param_base] = node;
set_irn_n(irg->anchor, anchor_value_param_base, node);
}
static INLINE ir_node **
......@@ -217,23 +228,24 @@ _set_irg_proj_args(ir_graph *irg, ir_node **nodes) {
static INLINE ir_node *
_get_irg_bad(const ir_graph *irg) {
return irg->anchors[anchor_bad];
return get_irn_intra_n(irg->anchor, anchor_bad);
}
static INLINE void
_set_irg_bad(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_bad] = node;
set_irn_n(irg->anchor, anchor_bad, node);
}
static INLINE ir_node *
_get_irg_no_mem(const ir_graph *irg) {
return irg->anchors[anchor_no_mem];
return get_irn_intra_n(irg->anchor, anchor_no_mem);
}
static INLINE void
_set_irg_no_mem(ir_graph *irg, ir_node *node) {
irg->anchors[anchor_no_mem] = node;
set_irn_n(irg->anchor, anchor_no_mem, node);
}
static INLINE ir_node *
_get_irg_current_block(const ir_graph *irg) {
return irg->current_block;
......@@ -485,6 +497,31 @@ get_idx_irn(ir_graph *irg, unsigned idx) {
return irg->idx_irn_map[idx];
}
/**
* Return the number of anchors in this graph.
*/
static INLINE int
get_irg_n_anchors(const ir_graph *irg) {
return get_irn_arity(irg->anchor);
}
/**
* Return anchor for given index
*/
static INLINE ir_node *
get_irg_anchor(const ir_graph *irg, int idx) {
return get_irn_intra_n(irg->anchor, idx);
}
/**
* Set anchor for given index
*/
static INLINE void
set_irg_anchor(ir_graph *irg, int idx, ir_node *irn) {
set_irn_n(irg->anchor, idx, irn);
}
#define get_interprocedural_view() _get_interprocedural_view()
#define is_ir_graph(thing) _is_ir_graph(thing)
#define get_irg_start_block(irg) _get_irg_start_block(irg)
......@@ -496,7 +533,9 @@ get_idx_irn(ir_graph *irg, unsigned idx) {
#define get_irg_end(irg) _get_irg_end(irg)
#define set_irg_end(irg, node) _set_irg_end(irg, node)
#define get_irg_end_reg(irg) _get_irg_end_reg(irg)
#define set_irg_end_reg(irg, node) _set_irg_end_reg(irg, node)
#define get_irg_end_except(irg) _get_irg_end_except(irg)
#define set_irg_end_except(irg, node) _set_irg_end_except(irg, node)
#define get_irg_frame(irg) _get_irg_frame(irg)
#define set_irg_frame(irg, node) _set_irg_frame(irg, node)
#define get_irg_globals(irg) _get_irg_globals(irg)
......@@ -512,7 +551,7 @@ get_idx_irn(ir_graph *irg, unsigned idx) {
#define get_irg_bad(irg) _get_irg_bad(irg)
#define set_irg_bad(irg, node) _set_irg_bad(irg, node)
#define get_irg_no_mem(irg) _get_irg_no_mem(irg)
#define set_irg_no_mem(irg, node) _set_irg_no_mem(irg, node)
#define set_irn_no_mem(irg, node) _set_irn_no_mem(irg, node)
#define get_irg_current_block(irg) _get_irg_current_block(irg)
#define set_irg_current_block(irg, node) _set_irg_current_block(irg, node)
#define get_irg_entity(irg) _get_irg_entity(irg)
......
......@@ -653,15 +653,12 @@ void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre,
* Additionally walk over all anchors. Do NOT increase the visit flag.
*/
void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
int i;
ir_graph * rem = current_ir_graph;
current_ir_graph = irg;
for (i = 0; i < anchor_max; ++i) {
ir_node *anchor = irg->anchors[i];
inc_irg_visited(irg);
irg_walk_2(irg->anchor, pre, post, env);
irg_walk_2(anchor, pre, post, env);
}
current_ir_graph = rem;
}
......@@ -694,7 +691,7 @@ static void walk_entity(ir_entity *ent, void *env)
/* Walks over all code in const_code_irg. */
void walk_const_code(irg_walk_func *pre