-/**
- * Collect phi node data
- */
-static void stat_phi_node(be_chordal_env_t *chordal_env, ir_node *phi) {
- int arity, i;
- ir_node *phi_bl;
- 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]++;
-
- phi_bl = get_nodes_block(phi);
- /* type of argument {self, const, pred, glob} */
- for (i = 0; i < arity; i++) {
- ir_node *block_of_arg, *block_ith_pred;
- ir_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;
- }
-
- /* get the pred block skipping blocks on critical edges */
- block_ith_pred = get_Block_cfgpred_block(phi_bl, i);
- if (was_edge_critical(phi_bl, i))
- block_ith_pred = get_Block_cfgpred_block(block_ith_pred, 0);
-
- block_of_arg = get_nodes_block(arg);
- if (block_of_arg == block_ith_pred) {
- curr_vals[I_PHI_ARG_PRED]++;
- continue;
- }
-
- curr_vals[I_PHI_ARG_GLOB]++;
- }
-}
-
-/**
- * Collect register-constrained node data
- */
-static void stat_copy_node(be_chordal_env_t *chordal_env, ir_node *root) {
- curr_vals[I_CPY_CNT]++;
- curr_vals[I_COPIES_MAX]++;
- if (nodes_interfere(chordal_env, root, get_Perm_src(root))) {
- curr_vals[I_COPIES_IF]++;
- assert(0 && "A Perm pair (in/out) should never interfere!");
- }
-}
-
-/**
- * Collect phi class data
- */
-static void stat_phi_class(be_chordal_env_t *chordal_env, pset *pc) {
- int i, o, size, if_free, phis;
- ir_node **members, *p;
-
- /* phi class count */
- curr_vals[I_CLS_CNT]++;
-
- /* phi class size */
- size = pset_count(pc);
- if (size > MAX_CLS_SIZE)
- curr_vals[I_CLS_SIZE_E]++;
- else
- curr_vals[I_CLS_SIZE_S + size]++;
-
- /* get an array of all members for double iterating */
- members = xmalloc(size * sizeof(*members));
- DBG((dbg, LEVEL_2, "Phi-class:\n"));
- for (i = 0, p = pset_first(pc); p; p = pset_next(pc)) {
- DBG((dbg, LEVEL_2, " %+F\n", p));
- members[i++] = p;
- }
- assert(i == size);
-
- /* determine number of phis on this class */
- phis = 0;
- for (i = 0; i < size; ++i)
- if (is_Phi(members[i]))
- phis++;
- if (phis > MAX_CLS_PHIS)
- curr_vals[I_CLS_PHIS_E]++;
- else
- curr_vals[I_CLS_PHIS_S + phis]++;
-
- /* determine interference of phi class members */
- curr_vals[I_CLS_IF_MAX] += size*(size-1)/2;
- if_free = 1;
- for (i = 0; i < size-1; ++i)
- for (o = i+1; o < size; ++o)
- if (nodes_interfere(chordal_env, members[i], members[o])) {
- if_free = 0;
- curr_vals[I_CLS_IF_CNT]++;
- }
-
- /* Does this phi class have an inner interference? */
- curr_vals[I_CLS_IF_FREE] += if_free;
-
- xfree(members);
-}
-
-void copystat_collect_cls(be_chordal_env_t *cenv) {
- ir_node *n;
- pset *pc;
- ir_graph *irg = cenv->irg;
- arch_env_t *aenv = cenv->birg->main_env->arch_env;
-
- if (last_irg != irg) {
- copystat_reset();
- copystat_collect_irg(irg, aenv);
- }
-
- for (n = pset_first(all_phi_nodes); n; n = pset_next(all_phi_nodes))
- if (arch_get_irn_reg_class(aenv, n, -1) == cenv->cls)
- stat_phi_node(cenv, n);
-
- for (n = pset_first(all_copy_nodes); n; n = pset_next(all_copy_nodes))
- if (arch_get_irn_reg_class(aenv, n, -1) == cenv->cls)
- stat_copy_node(cenv, n);
-
- for (pc = pset_first(all_phi_classes); pc; pc = pset_next(all_phi_classes)) {
- ir_node *member = pset_first(pc);
- pset_break(pc);
- if (arch_get_irn_reg_class(aenv, member, -1) == cenv->cls)
- stat_phi_class(cenv, pc);
- }
-}
-
-void copystat_add_max_costs(int costs) {