+ env->node_factory = obstack_alloc(&env->obst, sizeof(*env->node_factory));
+ be_node_factory_init(env->node_factory, isa);
+
+ arch_env_add_irn_handler(env->arch_env, &firm_irn_handler);
+ arch_env_add_irn_handler(env->arch_env,
+ be_node_get_irn_handler(env->node_factory));
+
+ return env;
+}
+
+static be_main_session_env_t *
+be_init_session_env(be_main_session_env_t *env,
+ be_main_env_t *main_env, ir_graph *irg)
+{
+ env->main_env = main_env;
+ env->irg = irg;
+
+ return env;
+}
+
+static void prepare_graph(be_main_session_env_t *s)
+{
+ /* set the current graph (this is important for several firm functions) */
+ current_ir_graph = s->irg;
+
+ /* Let the isa prepare the graph. */
+ s->main_env->arch_env->isa->prepare_graph(s->irg);
+
+ /* Normalize proj nodes. */
+ normalize_proj_nodes(s->irg);
+
+ /* Remove critical edges */
+ remove_critical_cf_edges(s->irg);
+
+ /* Compute the dominance information. */
+ free_dom_and_peace(s->irg);
+ compute_doms(s->irg);
+
+ /* Compute the dominance frontiers */
+ s->dom_front = be_compute_dominance_frontiers(s->irg);
+
+ /* Ensure, that the ir_edges are computed. */
+ edges_activate(s->irg);
+
+ /* Compute loop nesting information (for weighting copies) */
+ if (get_irg_loopinfo_state(s->irg) != (loopinfo_valid & loopinfo_cf_consistent))
+ construct_cf_backedges(s->irg);
+
+ be_check_dominance(s->irg);