/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Author: Boris Boesler
-**
-** traverse an ir graph
-** - execute the pre function before recursion
-** - execute the post function after recursion
+* All rights reserved.
+*
+* Author: Boris Boesler
+*
+* traverse an ir graph
+* - execute the pre function before recursion
+* - execute the post function after recursion
*/
/* $Id$ */
# include <stdlib.h>
-# include "irnode.h"
+# include "irnode_t.h"
# include "irgraph.h" /* visited flag */
# include "irprog.h"
# include "irgwalk.h"
+# include "typewalk.h"
# include "eset.h"
# include "array.h"
/* walk over an interprocedural graph (callgraph). Visits only graphs in irg_set. */
static void irg_walk_cg(ir_node * node, int visited, eset * irg_set,
- irg_walk_func pre, irg_walk_func post, void * env) {
+ irg_walk_func *pre, irg_walk_func *post, void * env) {
int i;
ir_graph * rem = current_ir_graph;
ir_node * pred;
- assert(node);
+ assert(node && node->kind==k_ir_node);
if (get_irn_visited(node) >= visited) return;
set_irn_visited(node, visited);
ir_graph * irg = ent ? get_entity_irg(ent) : NULL;
if (irg && !eset_contains(irg_set, irg)) {
eset_insert(irg_set, irg);
- irg_walk_graph(irg, (irg_walk_func) collect_irgs, NULL, irg_set);
+ irg_walk_graph(irg, (irg_walk_func *) collect_irgs, NULL, irg_set);
}
}
}
}
-void irg_walk_2(ir_node *node, irg_walk_func pre, irg_walk_func post, void * env)
+static void
+irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
{
int i;
- assert(node);
+ assert(node && node->kind==k_ir_node);
if (get_irn_visited(node) < get_irg_visited(current_ir_graph)) {
set_irn_visited(node, get_irg_visited(current_ir_graph));
}
-void irg_walk(ir_node *node, irg_walk_func pre, irg_walk_func post, void *env)
+void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
{
- assert(node);
+ assert(node && node->kind==k_ir_node);
if (interprocedural_view) {
eset * irg_set = eset_create();
int visited;
ir_graph * irg;
interprocedural_view = false;
eset_insert(irg_set, current_ir_graph);
- irg_walk(node, (irg_walk_func) collect_irgs, NULL, irg_set);
+ irg_walk(node, (irg_walk_func *) collect_irgs, NULL, irg_set);
interprocedural_view = true;
visited = get_max_irg_visited() + 1;
irg_walk_cg(node, visited, irg_set, pre, post, env);
}
-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;
current_ir_graph = irg;
irg_walk(get_irg_end(irg), pre, post, env);
/* 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;
ir_graph *irg, *rem;
return old_current;
}
-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 = interprocedural_view;
/***************************************************************************/
/* Walks back from n until it finds a real cf op. */
-ir_node *get_cf_op(ir_node *n) {
+static ir_node *get_cf_op(ir_node *n) {
ir_node *pred;
n = skip_nop(n);
return skip_Proj(n);
}
-void irg_block_walk_2(ir_node *node, irg_walk_func pre, irg_walk_func post, void *env)
+static void irg_block_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
{
int i;
assert(get_irn_opcode(node) == iro_Block);
/* walks only over Block nodes in the graph. Has it's own visited
flag, so that it can be interleaved with the other walker. */
-void irg_block_walk(ir_node *node, irg_walk_func pre, irg_walk_func post, void *env)
+void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_node *block, *pred;
int i;
}
-void irg_block_walk_graph(ir_graph *irg, irg_walk_func pre,
- irg_walk_func post, void *env) {
+void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre,
+ 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);
/********************************************************************/
typedef struct walk_env {
- void *pre;
- void *post;
+ irg_walk_func *pre;
+ irg_walk_func *post;
void *env;
} walk_env;
/* Walk to all constant expressions in this entity. */
-void walk_entity(entity *ent, void *env) {
+static void walk_entity(entity *ent, void *env) {
walk_env *my_env = (walk_env *)env;
if (get_entity_variability(ent) != uninitialized) {
if (is_atomic_entity(ent)) {
}
/* 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;
walk_env my_env;
/** } **/
/********************************************************************/
-/* Allocates some necessary datastructures. */
-void init_ip_walk ();
-/* Frees some necessary datastructures. */
-void finish_ip_walk();
-
/* Call for i in {0|-1 ... get_irn_arity(n)}.
If n is a conventional node returns the same node as get_irn_n(n, i).
If the predecessors of n are in the callee of the procedure n belongs
/* Initialization routines ******************************************/
-void init_ip_walk () {
+void init_ip_walk (void) {
int i;
for (i = 0; i < get_irp_n_irgs(); i++)
new_callsite_stack(get_irp_irg(i));
}
-void finish_ip_walk() {
+void finish_ip_walk(void) {
int i;
for (i = 0; i < get_irp_n_irgs(); i++)
free_callsite_stack(get_irp_irg(i));