+static void insert_afe_edge(be_pbqp_alloc_env_t *pbqp_alloc_env, ir_node *src_node, ir_node *trg_node, int pos)
+{
+ pbqp_t *pbqp = pbqp_alloc_env->pbqp_inst;
+ const arch_register_class_t *cls = pbqp_alloc_env->cls;
+ unsigned *restr_nodes = pbqp_alloc_env->restr_nodes;
+ pbqp_matrix_t *afe_matrix = pbqp_matrix_alloc(pbqp, arch_register_class_n_regs(cls), arch_register_class_n_regs(cls));
+ unsigned colors_n = arch_register_class_n_regs(cls);
+
+ if (get_edge(pbqp, get_irn_idx(src_node), get_irn_idx(trg_node)) == NULL) {
+ if (use_exec_freq) {
+ /* get exec_freq for copy_block */
+ ir_node *root_bl = get_nodes_block(src_node);
+ ir_node *copy_bl = is_Phi(src_node) ? get_Block_cfgpred_block(root_bl, pos) : root_bl;
+ ir_exec_freq *exec_freq = be_get_irg_exec_freq(pbqp_alloc_env->irg);
+ unsigned long res = get_block_execfreq_ulong(exec_freq, copy_bl);
+
+ /* create afe-matrix */
+ unsigned row, col;
+ for (row = 0; row < colors_n; row++) {
+ for (col = 0; col < colors_n; col++) {
+ if (row != col)
+ pbqp_matrix_set(afe_matrix, row, col, (num)res);
+ }
+ }
+ }
+ else {
+ afe_matrix = pbqp_alloc_env->aff_matrix_template;
+ }
+#if DO_USEFUL_OPT || USE_BIPARTIT_MATCHING
+ /* do useful optimization to speed up pbqp solving */
+ if (get_free_regs(restr_nodes, cls, src_node) == 1 && get_free_regs(restr_nodes, cls, trg_node) == 1) {
+ return;
+ }
+ if (get_free_regs(restr_nodes, cls, src_node) == 1 || get_free_regs(restr_nodes, cls, trg_node) == 1) {
+ if (get_free_regs(restr_nodes, cls, src_node) == 1) {
+ unsigned regIdx = vector_get_min_index(get_node(pbqp, get_irn_idx(src_node))->costs);
+ vector_add_matrix_col(get_node(pbqp, get_irn_idx(trg_node))->costs, afe_matrix, regIdx);
+ }
+ else {
+ unsigned regIdx = vector_get_min_index(get_node(pbqp, get_irn_idx(trg_node))->costs);
+ vector_add_matrix_col(get_node(pbqp, get_irn_idx(src_node))->costs, afe_matrix, regIdx);
+ }
+ return;
+ }
+#endif
+ /* insert interference edge */
+ insert_edge(pbqp, src_node, trg_node, afe_matrix);
+ }
+}