+void be_do_stat_reg_pressure(ir_graph *irg, const arch_register_class_t *cls)
+{
+ pressure_walker_env_t env;
+ double average_pressure;
+
+ env.irg = irg;
+ env.insn_count = 0;
+ env.max_pressure = 0;
+ env.regpressure = 0;
+ be_liveness_assure_sets(be_assure_liveness(irg));
+ env.lv = be_get_irg_liveness(irg);
+ env.cls = cls;
+
+ /* Collect register pressure information for each block */
+ irg_block_walk_graph(irg, stat_reg_pressure_block, NULL, &env);
+
+ average_pressure = env.regpressure / env.insn_count;
+ stat_ev_emit("bechordal_average_register_pressure", average_pressure);
+ stat_ev_emit("bechordal_maximum_register_pressure", env.max_pressure);
+}
+
+
+
+
+typedef struct estimate_irg_costs_env_t {
+ ir_exec_freq *execfreqs;
+ double costs;
+} estimate_irg_costs_env_t;
+
+static void estimate_block_costs(ir_node *block, void *data)
+{
+ estimate_irg_costs_env_t *env = (estimate_irg_costs_env_t*)data;
+ ir_node *node;
+ double costs = 0.0;
+
+ sched_foreach(block, node) {
+ costs += arch_get_op_estimated_cost(node);
+ }
+
+ env->costs += costs * get_block_execfreq(env->execfreqs, block);
+}
+
+double be_estimate_irg_costs(ir_graph *irg, ir_exec_freq *execfreqs)
+{
+ estimate_irg_costs_env_t env;
+
+ env.execfreqs = execfreqs;
+ env.costs = 0.0;
+
+ irg_block_walk_graph(irg, estimate_block_costs, NULL, &env);
+
+ return env.costs;
+}
+
+
+
+static void node_stat_walker(ir_node *irn, void *data)
+{
+ be_node_stats_t *const stats = (be_node_stats_t*)data;
+
+ /* if the node is a normal phi */
+ if (is_Phi(irn)) {
+ if (get_irn_mode(irn) == mode_M) {
+ (*stats)[BE_STAT_MEM_PHIS]++;
+ } else {
+ (*stats)[BE_STAT_PHIS]++;