projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
C99 feature removed.
[libfirm]
/
ir
/
be
/
becopyheur.c
diff --git
a/ir/be/becopyheur.c
b/ir/be/becopyheur.c
index
460363d
..
5e8805f
100644
(file)
--- a/
ir/be/becopyheur.c
+++ b/
ir/be/becopyheur.c
@@
-42,7
+42,8
@@
#include "becopyopt_t.h"
#include "becopystat.h"
#include "beintlive_t.h"
#include "becopyopt_t.h"
#include "becopystat.h"
#include "beintlive_t.h"
-#include "beirg_t.h"
+#include "beirg.h"
+#include "bemodule.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
@@
-93,7
+94,7
@@
static inline int nodes_interfere(const be_chordal_env_t *env, const ir_node *a,
if (env->ifg)
return be_ifg_connected(env->ifg, a, b);
else
if (env->ifg)
return be_ifg_connected(env->ifg, a, b);
else
- return
values_interfere(env->birg
, a, b);
+ return
be_values_interfere(env->birg->lv
, a, b);
}
static int set_cmp_conflict_t(const void *x, const void *y, size_t size) {
}
static int set_cmp_conflict_t(const void *x, const void *y, size_t size) {
@@
-299,7
+300,7
@@
static ir_node *qnode_color_irn(const qnode_t *qn, ir_node *irn, int col, const
#endif /* SEARCH_FREE_COLORS */
/* If target color is not allocatable changing color is impossible */
#endif /* SEARCH_FREE_COLORS */
/* If target color is not allocatable changing color is impossible */
- if (!arch_reg_
is_allocatable(irn, -1
, arch_register_for_index(cls, col))) {
+ if (!arch_reg_
out_is_allocatable(irn
, arch_register_for_index(cls, col))) {
DBG((dbg, LEVEL_3, "\t %+F impossible\n", irn));
return CHANGE_IMPOSSIBLE;
}
DBG((dbg, LEVEL_3, "\t %+F impossible\n", irn));
return CHANGE_IMPOSSIBLE;
}
@@
-384,17
+385,17
@@
static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) {
int i, o, safe_count, safe_costs, unsafe_count, *unsafe_costs;
bitset_t *curr, *best;
bitset_pos_t pos;
int i, o, safe_count, safe_costs, unsafe_count, *unsafe_costs;
bitset_t *curr, *best;
bitset_pos_t pos;
- int
max,
next, curr_weight, best_weight = 0;
+ int next, curr_weight, best_weight = 0;
/* assign the nodes into two groups.
* safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference
*/
/* assign the nodes into two groups.
* safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference
*/
- safe
= alloca((ou->node_count-1) * sizeof(*safe)
);
- safe_costs = 0;
- safe_count = 0;
- unsafe
= alloca((ou->node_count-1) * sizeof(*unsafe)
);
- unsafe_costs =
alloca((ou->node_count-1) * sizeof(*unsafe_costs)
);
+ safe
= ALLOCAN(ir_node*, ou->node_count - 1
);
+ safe_costs
= 0;
+ safe_count
= 0;
+ unsafe
= ALLOCAN(ir_node*, ou->node_count - 1
);
+ unsafe_costs =
ALLOCAN(int, ou->node_count - 1
);
unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) {
int is_safe = 1;
unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) {
int is_safe = 1;
@@
-438,7
+439,7
@@
static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) {
/* Exact Algorithm: Brute force */
curr = bitset_alloca(unsafe_count);
bitset_set_all(curr);
/* Exact Algorithm: Brute force */
curr = bitset_alloca(unsafe_count);
bitset_set_all(curr);
- while (
(max = bitset_popcnt(curr)) != 0
) {
+ while (
!bitset_is_empty(curr)
) {
/* check if curr is a stable set */
for (i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1))
for (o=bitset_next_set(curr, i); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to ou_max_ind_set_costs(): NOT (curr, i+1) */
/* check if curr is a stable set */
for (i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1))
for (o=bitset_next_set(curr, i); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to ou_max_ind_set_costs(): NOT (curr, i+1) */
@@
-530,11
+531,13
@@
static inline void ou_insert_qnode(unit_t *ou, qnode_t *qn) {
* nodes. (All other phi classes are reduced to this case.)
*/
static void ou_optimize(unit_t *ou) {
* nodes. (All other phi classes are reduced to this case.)
*/
static void ou_optimize(unit_t *ou) {
- int i;
- qnode_t *curr = NULL, *tmp;
- const arch_register_class_t *cls = ou->co->cls;
- bitset_pos_t idx;
- bitset_t *pos_regs = bitset_alloca(cls->n_regs);
+ qnode_t *curr = NULL;
+ qnode_t *tmp;
+ const arch_register_req_t *req;
+ bitset_t const* ignore;
+ bitset_pos_t n_regs;
+ bitset_pos_t idx;
+ int i;
DBG((dbg, LEVEL_1, "\tOptimizing unit:\n"));
for (i=0; i<ou->node_count; ++i)
DBG((dbg, LEVEL_1, "\tOptimizing unit:\n"));
for (i=0; i<ou->node_count; ++i)
@@
-543,16
+546,28
@@
static void ou_optimize(unit_t *ou) {
/* init queue */
INIT_LIST_HEAD(&ou->queue);
/* init queue */
INIT_LIST_HEAD(&ou->queue);
- arch_get_allocatable_regs(ou->nodes[0], -1, pos_regs);
+ req = arch_get_register_req_out(ou->nodes[0]);
+ ignore = ou->co->cenv->ignore_colors;
+ n_regs = req->cls->n_regs;
+ if (arch_register_req_is(req, limited)) {
+ rawbs_base_t const* limited = req->limited;
- /* exclude ignore colors */
- bitset_andnot(pos_regs, ou->co->cenv->ignore_colors);
+ for (idx = 0; idx != n_regs; ++idx) {
+ if (bitset_is_set(ignore, idx))
+ continue;
+ if (!rbitset_is_set(limited, idx))
+ continue;
- assert(bitset_popcnt(pos_regs) != 0 && "No register is allowed for this node !!?");
+ ou_insert_qnode(ou, new_qnode(ou, idx));
+ }
+ } else {
+ for (idx = 0; idx != n_regs; ++idx) {
+ if (bitset_is_set(ignore, idx))
+ continue;
- /* create new qnode */
- bitset_foreach(pos_regs, idx)
- ou_insert_qnode(ou, new_qnode(ou, idx));
+ ou_insert_qnode(ou, new_qnode(ou, idx));
+ }
+ }
/* search best */
for (;;) {
/* search best */
for (;;) {
@@
-602,9
+617,12
@@
static void ou_optimize(unit_t *ou) {
free_qnode(curr);
}
free_qnode(curr);
}
+/**
+ * Solves the problem using a heuristic approach
+ * Uses the OU data structure
+ */
int co_solve_heuristic(copy_opt_t *co) {
unit_t *curr;
int co_solve_heuristic(copy_opt_t *co) {
unit_t *curr;
- FIRM_DBG_REGISTER(dbg, "ir.be.copyoptheur");
ASSERT_OU_AVAIL(co);
ASSERT_OU_AVAIL(co);
@@
-616,3
+634,15
@@
int co_solve_heuristic(copy_opt_t *co) {
del_pset(pinned_global);
return 0;
}
del_pset(pinned_global);
return 0;
}
+
+void be_init_copyheur(void)
+{
+ static co_algo_info copyheur = {
+ co_solve_heuristic, 0
+ };
+
+ be_register_copyopt("heur1", ©heur);
+ FIRM_DBG_REGISTER(dbg, "ir.be.copyoptheur");
+}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyheur);