X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyilp2.c;h=95e6b42d6f7e8b46f614f1977e4e0a2dbc983c6a;hb=fef8dc3eff6468d7d65485af8e1ac9884c504e1a;hp=17b9262486012978a42870cf8d7ade76a718424e;hpb=31d36dd3e8a2b7b513958f005cc555e01b9c3d5b;p=libfirm diff --git a/ir/be/becopyilp2.c b/ir/be/becopyilp2.c index 17b926248..95e6b42d6 100644 --- a/ir/be/becopyilp2.c +++ b/ir/be/becopyilp2.c @@ -45,7 +45,9 @@ */ #include "config.h" +#include "be_t.h" #include "bitset.h" +#include "error.h" #include "raw_bitset.h" #include "pdeq.h" @@ -68,11 +70,8 @@ static unsigned check_alignment_constraints(ir_node *node) { const arch_register_req_t *req = arch_get_irn_register_req(node); // For larger than 1 variables, support only aligned constraints - assert(((!(req->type & arch_register_req_type_aligned) - && req->width == 1) - || (req->type & arch_register_req_type_aligned)) - && "Unaligned large (width > 1) variables not supported"); - return (req->type & arch_register_req_type_aligned) && req->width > 1; + assert((arch_register_req_is(req, aligned) || req->width == 1) && "Unaligned large (width > 1) variables not supported"); + return arch_register_req_is(req, aligned) && req->width > 1; } static void make_color_var_name(char *buf, size_t buf_size, @@ -89,12 +88,10 @@ static void build_coloring_cstr(ilp_env_t *ienv) unsigned n_regs = arch_register_class_n_regs(ienv->co->cls); const unsigned *allocatable_colors = lenv->allocatable_colors; nodes_iter_t iter; - unsigned *colors; ir_node *irn; char buf[32]; - rbitset_alloca(colors, n_regs); - + unsigned *const colors = rbitset_alloca(n_regs); be_ifg_foreach_node(ifg, &iter, irn) { const arch_register_req_t *req; unsigned col; @@ -240,7 +237,6 @@ static void make_affinity_var_name(char *buf, size_t buf_size, static void build_affinity_cstr(ilp_env_t *ienv) { unsigned n_colors = arch_register_class_n_regs(ienv->co->cls); - unit_t *curr; /* for all optimization units */ list_for_each_entry(unit_t, curr, &ienv->co->units, units) { @@ -312,7 +308,7 @@ static inline edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou new_edge.n2 = n1; } (*counter)++; - return (edge_t*)set_insert(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); + return set_insert(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); } static inline edge_t *find_edge(set *edges, ir_node *n1, ir_node *n2) @@ -326,7 +322,7 @@ static inline edge_t *find_edge(set *edges, ir_node *n1, ir_node *n2) new_edge.n1 = n2; new_edge.n2 = n1; } - return (edge_t*)set_find(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); + return set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); } static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *counter) @@ -340,7 +336,7 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou new_edge.n1 = n2; new_edge.n2 = n1; } - e = (edge_t*)set_find(edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); + e = set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge)); if (e) { e->n1 = NULL; e->n2 = NULL; @@ -348,7 +344,7 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou } } -#define pset_foreach(pset, irn) for (irn=(ir_node*)pset_first(pset); irn; irn=(ir_node*)pset_next(pset)) +#define pset_foreach(pset, irn) foreach_pset((pset), ir_node, (irn)) /** * Search for an interference clique and an external node @@ -357,12 +353,9 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou */ static void build_clique_star_cstr(ilp_env_t *ienv) { - affinity_node_t *aff; - /* for each node with affinity edges */ co_gs_foreach_aff_node(ienv->co, aff) { struct obstack ob; - neighb_t *nbr; const ir_node *center = aff->irn; ir_node **nodes; set *edges; @@ -401,8 +394,7 @@ static void build_clique_star_cstr(ilp_env_t *ienv) bool growed; /* get 2 starting nodes to form a clique */ - for (e=(edge_t*)set_first(edges); !e->n1; e=(edge_t*)set_next(edges)) { - } + for (e = set_first(edge_t, edges); !e->n1; e = set_next(edge_t, edges)) {} /* we could be stepped out of the loop before the set iterated to the end */ set_break(edges); @@ -418,7 +410,6 @@ static void build_clique_star_cstr(ilp_env_t *ienv) /* search for a candidate to extend the clique */ for (i=0; ilp, NULL, lpp_greater_equal, pset_count(clique)-1); @@ -479,7 +469,6 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn) int i, len; ir_node **curr_path; affinity_node_t *aff; - neighb_t *nbr; /* do not walk backwards or in circles */ if (pdeq_contains(path, irn)) @@ -541,8 +530,6 @@ end: */ static void build_path_cstr(ilp_env_t *ienv) { - affinity_node_t *aff_info; - /* for each node with affinity edges */ co_gs_foreach_aff_node(ienv->co, aff_info) { pdeq *path = new_pdeq(); @@ -625,7 +612,6 @@ static void ilp2_apply(ilp_env_t *ienv) */ static int co_solve_ilp2(copy_opt_t *co) { - unsigned *allocatable_colors; unsigned n_regs = arch_register_class_n_regs(co->cls); lpp_sol_state_t sol_state; ilp_env_t *ienv; @@ -638,7 +624,7 @@ static int co_solve_ilp2(copy_opt_t *co) my.last_x_var = -1; FIRM_DBG_REGISTER(dbg, "firm.be.coilp2"); - rbitset_alloca(allocatable_colors, n_regs); + unsigned *const allocatable_colors = rbitset_alloca(n_regs); be_set_allocatable_regs(co->irg, co->cls, allocatable_colors); my.allocatable_colors = allocatable_colors;