-void copystat_reset(void) {
- int i;
- for (i = 0; i < ASIZE; ++i)
- curr_vals[i] = 0;
- del_pset(all_phi_nodes);
- del_pset(all_phi_classes);
- del_pset(all_copy_nodes);
- all_phi_nodes = pset_new_ptr_default();
- all_phi_classes = pset_new_ptr_default();
- all_copy_nodes = pset_new_ptr_default();
-}
-
-/**
- * Collect general data
- */
-static void irg_stat_walker(ir_node *node, void *env) {
- arch_env_t *arch_env = env;
- curr_vals[I_ALL_NODES]++; /* count all nodes */
-
- if (is_Block(node)) /* count all blocks */
- curr_vals[I_BLOCKS]++;
-
- if (is_Phi(node) && mode_is_datab(get_irn_mode(node))) /* collect phis */
- pset_insert_ptr(all_phi_nodes, node);
-
- if (is_Copy(arch_env, node))
- pset_insert_ptr(all_copy_nodes, node);
-}
-
-void copystat_collect_irg(ir_graph *irg, arch_env_t *arch_env) {
- irg_walk_graph(irg, irg_stat_walker, NULL, arch_env);
- curr_vals[I_BLOCKS] -= 2; /* substract 2 for start and end block */
- all_phi_classes = phi_class_compute_by_phis(all_phi_nodes);
-}
-
-/**
- * Collect phi node data
- */
-static void stat_phi_node(be_chordal_env_t *chordal_env, ir_node *phi) {
- int arity, i;
- assert(is_Phi(phi));
-
- /* count all phi phis */
- curr_vals[I_PHI_CNT]++;
-
- /* argument count */
- arity = get_irn_arity(phi);
- curr_vals[I_PHI_ARG_CNT] += arity;
- if (arity > MAX_ARITY)
- curr_vals[I_PHI_ARITY_E]++;
- else
- curr_vals[I_PHI_ARITY_S + arity]++;
-
- /* type of argument {self, const, pred, glob} */
- for (i = 0; i < arity; i++) {
- ir_node *block_of_arg, *block_ith_pred;
- ir_node *cfg_node, *arg = get_irn_n(phi, i);
-
- if (arg == phi) {
- curr_vals[I_PHI_ARG_SELF]++;
- continue;
- }
-
- if (iro_Const == get_irn_opcode(arg)) {
- curr_vals[I_PHI_ARG_CONST]++;
- continue;
- }
-
- block_of_arg = get_nodes_block(arg);
-
- /* get the pred block skipping blocks on critical edges */
- cfg_node = get_irn_n(get_nodes_block(phi), i);
- block_ith_pred = get_nodes_block(cfg_node);
- if (get_irn_opcode(cfg_node) == iro_Jmp && get_irn_arity(block_ith_pred) == 1) {
- /* Then cfg_node_block has exactly 1 pred and 1 succ block,
- * thus it must have been inserted during remove_critical_edges */
- block_ith_pred = get_Block_cfgpred_block(block_ith_pred, 0);
- }
-
- if (block_of_arg == block_ith_pred) {
- curr_vals[I_PHI_ARG_PRED]++;
- continue;
- }
-
- curr_vals[I_PHI_ARG_GLOB]++;