static void insert_into_reverse_peo(ir_node *block, void *data) {
pqueue_t *queue = new_pqueue();
+ pqueue_t *constatQueue = new_pqueue();
pbqp_co_t *pbqp_co = data;
ir_node *irn;
assert(node && "No corresponding PBQP-Node found!");
// insert proj node into priority queue (descending by their degree in ifg)
- pqueue_put(queue,proj, be_ifg_degree(pbqp_co->ifg,proj));
+ if(bitset_is_set(pbqp_co->constatNodes, get_irn_idx(proj))) {
+ pqueue_put(constatQueue,proj, be_ifg_degree(pbqp_co->ifg,proj));
+ }
+ else {
+ pqueue_put(queue,proj, be_ifg_degree(pbqp_co->ifg,proj));
+ }
+ }
+
+ /* first insert all constat nodes */
+ while(!pqueue_empty(constatQueue)) {
+ plist_insert_back(pbqp_co->rpeo, get_node(pbqp_co->pbqp, get_irn_idx(pqueue_pop_front(constatQueue))));
}
/* insert proj nodes into reverse perfect elimination order (descending by their degree in ifg) */
while(!pqueue_empty(queue)) {
-
plist_insert_back(pbqp_co->rpeo, get_node(pbqp_co->pbqp, get_irn_idx(pqueue_pop_front(queue))));
}
+
} else {
if (!arch_irn_consider_in_reg_alloc(pbqp_co->cls, irn))
continue;
}
}
- /* free priority queue */
+ /* free priority queues */
del_pqueue(queue);
+ del_pqueue(constatQueue);
}
static int co_solve_heuristic_pbqp(copy_opt_t *co) {
pbqp_co.map = pmap_create_ex(number_nodes);
pbqp_co.pbqp = alloc_pbqp(number_nodes);
pbqp_co.ignore_reg = bitset_malloc(number_registers);
+ pbqp_co.constatNodes = bitset_malloc(number_nodes);
pbqp_co.ifg = co->cenv->ifg;
/* get ignored registers */
/* add costs vector to nodes */
be_ifg_foreach_node(co->cenv->ifg, nodes_it, ifg_node) {
+ int cntFreeChoosableRegs = 0;
+
/* create costs vector */
struct vector *costs_vector = vector_alloc(pbqp_co.pbqp, number_registers);
}
else {
vector_set(costs_vector, cnt, 0);
+ cntFreeChoosableRegs++;
}
}
#if KAPS_ENABLE_VECTOR_NAMES
/* insert ir_node and pbqp_node into map */
pmap_insert(pbqp_co.map, ifg_node, get_node(pbqp_co.pbqp, get_irn_idx(ifg_node)));
+
+ if(cntFreeChoosableRegs > 4) {
+ // node is constat
+ bitset_set(pbqp_co.constatNodes, get_irn_idx(ifg_node));
+ }
+ else
+ {
+ bitset_clear(pbqp_co.constatNodes, get_irn_idx(ifg_node));
+ }
+
}
/* add pbqp edges and cost matrix */
assert(solution != INF_COSTS && "No PBQP solution found");
-
#if KAPS_DUMP
/* dump graph after solving pbqp */
FILE *file_after = my_open(co->cenv, "", "-after.html");