* @brief Functions for traversing ir graphs
* @author Boris Boesler, Goetz Lindenmaier, Michael Beck
* @version $Id$
- * @summary
+ * @brief
* traverse an ir graph
* - execute the pre function before recursion
* - execute the post function after recursion
current_ir_graph = rem;
}
-#endif
/**
* Insert all ir_graphs in irg_set, that are (transitive) reachable.
*/
-static void collect_irgs(ir_node * node, pset_new_t *irg_set) {
+static void collect_irgs(ir_node * node, pset_new_t *irg_set)
+{
if (is_Call(node)) {
int i;
for (i = get_Call_n_callees(node) - 1; i >= 0; --i) {
}
}
}
+#endif
/**
* specialized version of irg_walk_2, called if only pre callback exists
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env) {
+static unsigned irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env) {
+static unsigned irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) {
+static unsigned irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
+unsigned irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
+ void *env)
{
if (node->visited < current_ir_graph->visited) {
if (!post) return irg_walk_2_pre (node, pre, env);
/*
* walk over a graph
*/
-void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
+void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
+{
ir_graph * rem = current_ir_graph;
hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post);
/* Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
Sets current_ir_graph properly for each walk. Conserves current
current_ir_graph. */
-void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) {
+void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env)
+{
int i, n;
ir_graph *irg;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_in_or_dep_2_pre(ir_node *node, irg_walk_func *pre, void *env) {
+static unsigned irg_walk_in_or_dep_2_pre(ir_node *node, irg_walk_func *pre, void *env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_in_or_dep_2_post(ir_node *node, irg_walk_func *post, void *env) {
+static unsigned irg_walk_in_or_dep_2_post(ir_node *node, irg_walk_func *post, void *env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_in_or_dep_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) {
+static unsigned irg_walk_in_or_dep_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
+{
int i;
unsigned cnt = 1;
ir_graph *irg = current_ir_graph;
*
* @return number of visited nodes
*/
-static unsigned
-irg_walk_in_or_dep_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
+static unsigned irg_walk_in_or_dep_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
{
if (node->visited < current_ir_graph->visited) {
if (! post) return irg_walk_in_or_dep_2_pre (node, pre, env);
/*
* Walk over a graph. Follow all edges (including dependencies)
*/
-void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
+void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
+{
ir_graph * rem = current_ir_graph;
hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post);
* Returns current_ir_graph and sets it to the irg of predecessor index
* of node n.
*/
-static inline ir_graph *
-switch_irg(ir_node *n, int index) {
+static inline ir_graph * switch_irg(ir_node *n, int index)
+{
ir_graph *old_current = current_ir_graph;
if (get_interprocedural_view()) {
}
#ifdef INTERPROCEDURAL_VIEW
-static void
-cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
+static void cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
{
int i;
ir_graph *rem = NULL;
}
/* Walks all irgs in interprocedural view. Visits each node only once. */
-void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) {
+void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env)
+{
int i;
ir_graph *rem = current_ir_graph;
int rem_view = get_interprocedural_view();
/***************************************************************************/
/* Walks back from n until it finds a real cf op. */
-static ir_node *get_cf_op(ir_node *n) {
+static ir_node *get_cf_op(ir_node *n)
+{
while (!is_cfop(n) && !is_fragile_op(n) && !is_Bad(n)) {
n = skip_Id(n);
n = skip_Tuple(n);
if (pre) pre(node, env);
- for(i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
+ for (i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
/* find the corresponding predecessor block. */
ir_node *pred = get_cf_op(get_Block_cfgpred(node, i));
pred = get_nodes_block(pred);
* walk over a graph block wise
*/
void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre,
- irg_walk_func *post, void *env) {
+ irg_walk_func *post, void *env)
+{
ir_graph * rem = current_ir_graph;
current_ir_graph = irg;
irg_block_walk(get_irg_end(irg), pre, post, env);
/*
* 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) {
+void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
+{
ir_graph * rem = current_ir_graph;
current_ir_graph = irg;
static void walk_initializer(ir_initializer_t *initializer, walk_env *env)
{
- switch(initializer->kind) {
+ switch (initializer->kind) {
case IR_INITIALIZER_CONST:
irg_walk(initializer->consti.value, env->pre, env->post, env->env);
return;
case IR_INITIALIZER_COMPOUND: {
size_t i;
- for(i = 0; i < initializer->compound.n_initializers; ++i) {
+ for (i = 0; i < initializer->compound.n_initializers; ++i) {
ir_initializer_t *subinitializer
= initializer->compound.initializers[i];
walk_initializer(subinitializer, env);
{
walk_env *my_env = (walk_env *)env;
- if (get_entity_variability(ent) != variability_uninitialized) {
- if (ent->has_initializer) {
- walk_initializer(ent->attr.initializer, my_env);
- } else if (is_atomic_entity(ent)) {
- irg_walk(get_atomic_ent_value(ent), my_env->pre, my_env->post, my_env->env);
- } else {
- int i, n_vals = get_compound_ent_n_values(ent);
+ if (ent->initializer != NULL) {
+ walk_initializer(ent->initializer, my_env);
+ } else if (entity_has_compound_ent_values(ent)) {
+ int i, n_vals = get_compound_ent_n_values(ent);
- for (i = 0; i < n_vals; i++)
- irg_walk(get_compound_ent_value(ent, i), my_env->pre, my_env->post, my_env->env);
- }
+ for (i = 0; i < n_vals; i++)
+ irg_walk(get_compound_ent_value(ent, i), my_env->pre, my_env->post, my_env->env);
}
}
/* Walks over all code in const_code_irg. */
-void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env) {
+void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env)
+{
int i, j, n_types;
walk_env my_env;
+ ir_segment_t s;
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
my_env.env = env;
/* Walk all types that can contain constant entities. */
- for (i = 0; i < IR_SEGMENT_COUNT; i++)
- walk_types_entities(get_segment_type((ir_segment_t) i), &walk_entity, &my_env);
+ for (s = IR_SEGMENT_FIRST; s <= IR_SEGMENT_LAST; s++)
+ walk_types_entities(get_segment_type(s), &walk_entity, &my_env);
n_types = get_irp_n_types();
for (i = 0; i < n_types; i++)
walk_types_entities(get_irp_type(i), &walk_entity, &my_env);