+
+/*
+ * walk over a graph block wise
+ */
+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);
+ current_ir_graph = rem;
+}
+
+/********************************************************************/
+
+typedef struct walk_env {
+ irg_walk_func *pre;
+ irg_walk_func *post;
+ void *env;
+} walk_env;
+
+/**
+ * Walk to all constant expressions in this entity.
+ */
+static void walk_entity(entity *ent, void *env)
+{
+ walk_env *my_env = (walk_env *)env;
+
+ if (get_entity_variability(ent) != variability_uninitialized) {
+ 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);
+
+ 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) {
+ int i, j;
+ walk_env my_env;
+
+ ir_graph *rem = current_ir_graph;
+ current_ir_graph = get_const_code_irg();
+ inc_irg_visited(current_ir_graph);
+
+ my_env.pre = pre;
+ my_env.post = post;
+ my_env.env = env;
+
+ /* Walk all types that can contain constant entities. */
+ walk_types_entities(get_glob_type(), &walk_entity, &my_env);
+ for (i = 0; i < get_irp_n_types(); i++)
+ walk_types_entities(get_irp_type(i), &walk_entity, &my_env);
+ for (i = 0; i < get_irp_n_irgs(); i++)
+ walk_types_entities(get_irg_frame_type(get_irp_irg(i)), &walk_entity, &my_env);
+
+ /* Walk constant array bounds. */
+ for (i = 0; i < get_irp_n_types(); i++) {
+ type *tp = get_irp_type(i);
+ if (is_array_type(tp)) {
+ for (j = 0; j < get_array_n_dimensions(tp); j++) {
+ ir_node *n = get_array_lower_bound(tp, j);
+ if (n) irg_walk(n, pre, post, env);
+ n = get_array_upper_bound(tp, j);
+ if (n) irg_walk(n, pre, post, env);
+ }
+ }
+ }
+
+ current_ir_graph = rem;
+}