X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeschedrss.c;h=45ac22a722929c2044ee7b2832feda70b0000dc4;hb=04bdfdfd695bd5d7e9c45f59074ac6bed4148ec7;hp=65498d2be3ecf43039b7e2fb1118a50fb301048f;hpb=cf9c1673146d1f45d46ceb77eccfaf10fedff25d;p=libfirm diff --git a/ir/be/beschedrss.c b/ir/be/beschedrss.c index 65498d2be..45ac22a72 100644 --- a/ir/be/beschedrss.c +++ b/ir/be/beschedrss.c @@ -28,9 +28,7 @@ * as described in: Sid-Ahmed-Ali Touati * Register Saturation in Superscalar and VLIW Codes */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include @@ -47,17 +45,20 @@ #include "irtools.h" #include "irbitset.h" #include "irprintf.h" +#include "irnodeset.h" #include "bipartite.h" #include "hungarian.h" #include "plist.h" +#include "array_t.h" #include "height.h" #include "beabi.h" #include "bemodule.h" -#include "benode_t.h" -#include "besched_t.h" -#include "beirg_t.h" +#include "benode.h" +#include "besched.h" +#include "beirg.h" +#include "belive.h" #include "lc_opts.h" #include "lc_opts_enum.h" @@ -434,19 +435,20 @@ static void debug_vcg_dump_kill(rss_t *rss) { } /* Dumps the potential killing DAG (PKG) as vcg. */ -static void debug_vcg_dump_pkg(rss_t *rss, ir_nodeset_t *max_ac, int iteration) { +static void debug_vcg_dump_pkg(rss_t *rss, ir_nodeset_t *max_ac, int iteration) +{ FILE *f; char file_name[256]; - char *suffix = alloca(32); + char suffix[32]; static const char suffix1[] = "-RSS-PKG.vcg"; static const char suffix2[] = "-RSS-PKG-MAXAC.vcg"; plist_element_t *el; if (! max_ac) { - snprintf(suffix, 32, "%s", suffix1); + snprintf(suffix, sizeof(suffix), "%s", suffix1); } else { - snprintf(suffix, 32, "-%02d%s", iteration, suffix2); + snprintf(suffix, sizeof(suffix), "-%02d%s", iteration, suffix2); } build_file_name(rss, suffix, strlen(suffix) + 1, file_name, sizeof(file_name)); @@ -632,7 +634,7 @@ static void collect_descendants(rss_t *rss, rss_irn_t *rirn, ir_node *irn, int * ir_node *user = get_edge_src_irn(edge); /* skip ignore nodes as they do not really contribute to register pressure */ - if (arch_irn_is(rss->arch_env, user, ignore)) + if (arch_irn_is_ignore(user)) continue; /* @@ -647,8 +649,7 @@ static void collect_descendants(rss_t *rss, rss_irn_t *rirn, ir_node *irn, int * } if (is_Proj(user)) { - - //if (arch_get_irn_reg_class(rss->arch_env, user, -1) == rss->cls) + //if (arch_get_irn_reg_class_out(user) == rss->cls) collect_descendants(rss, rirn, user, got_sink, cur_desc_walk); } else { @@ -681,7 +682,8 @@ static void collect_single_consumer(rss_t *rss, rss_irn_t *rss_irn, ir_node *con assert(! is_Proj(consumer) && "Cannot handle Projs"); if (! is_Phi(consumer) && ! is_Block(consumer) && get_nodes_block(consumer) == block) { - if (! arch_irn_is(rss->arch_env, consumer, ignore) && ! plist_has_value(rss_irn->consumer_list, consumer)) { + if (!arch_irn_is_ignore(consumer) && + !plist_has_value(rss_irn->consumer_list, consumer)) { plist_insert_back(rss_irn->consumer_list, consumer); DBG((rss->dbg, LEVEL_2, "\t\tconsumer %+F\n", consumer)); } @@ -716,7 +718,7 @@ static void collect_consumer(rss_t *rss, rss_irn_t *rss_irn, ir_node *irn, int * ir_node *consumer = get_edge_src_irn(edge); if (is_Proj(consumer)) { - //if (arch_get_irn_reg_class(rss->arch_env, consumer, -1) == rss->cls) + //if (arch_get_irn_reg_class_out(consumer) == rss->cls) collect_consumer(rss, rss_irn, consumer, got_sink); } else @@ -879,7 +881,7 @@ static void build_kill_edges(rss_t *rss, pset *epk) { foreach_plist(rirn->pkiller_list, k_el) { ir_node *pkiller = plist_element_get_value(k_el); - rss_edge_t *ke = obstack_alloc(phase_obst(&rss->ph), sizeof(*ke)); + rss_edge_t *ke = OALLOC(phase_obst(&rss->ph), rss_edge_t); ke->src = irn; ke->tgt = pkiller; @@ -948,7 +950,7 @@ static void compute_bipartite_decomposition(rss_t *rss) { DBG((rss->dbg, LEVEL_2, "\t\t%+F choosen:\n", u_irn)); - cbc = obstack_alloc(phase_obst(&rss->ph), sizeof(*cbc)); + cbc = OALLOC(phase_obst(&rss->ph), cbc_t); cbc->nr = cur_num++; /* initialize S_cb */ @@ -1182,8 +1184,7 @@ static void compute_killing_function(rss_t *rss) { /* while X not empty */ while (ir_nodeset_size(&x) > 0) { - child_t *t = obstack_alloc(&obst, sizeof(*t)); - memset(t, 0, sizeof(*t)); + child_t *t = OALLOCZ(&obst, child_t); t = select_child_max_cost(rss, &x, &y, t, cbc); @@ -1244,7 +1245,7 @@ static void compute_killing_function(rss_t *rss) { /** * Adds the edge src -> tgt to the dvg. Checks if reverse edge is already there (asserts). */ -static INLINE void add_dvg_edge(rss_t *rss, dvg_t *dvg, const ir_node *src, const ir_node *tgt, int have_source) { +static inline void add_dvg_edge(rss_t *rss, dvg_t *dvg, const ir_node *src, const ir_node *tgt, int have_source) { rss_edge_t *dvg_edge; rss_edge_t key; @@ -1263,7 +1264,7 @@ static INLINE void add_dvg_edge(rss_t *rss, dvg_t *dvg, const ir_node *src, cons key.tgt = (ir_node *) tgt; if (NULL != pset_find(dvg->edges, &key, HASH_RSS_EDGE(&key))) { /* add the edge to the DVG */ - dvg_edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*dvg_edge)); + dvg_edge = OALLOC(phase_obst(&rss->ph), rss_edge_t); dvg_edge->src = (ir_node *) src; dvg_edge->tgt = (ir_node *) tgt; @@ -1312,7 +1313,7 @@ static void compute_dvg(rss_t *rss, dvg_t *dvg) { There is an edge (u, v) in the DVG iff v is a descendant of the killer(u). */ if (BSEARCH_IRN_ARR(v_irn, u_kill->descendants)) { - rss_edge_t *dvg_edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*dvg_edge)); + rss_edge_t *dvg_edge = OALLOC(phase_obst(&rss->ph), rss_edge_t); rss_edge_t key; /* insert the user into the DVG and append it to the user list of u */ @@ -1347,7 +1348,7 @@ static void compute_dvg(rss_t *rss, dvg_t *dvg) { static void update_dvg(rss_t *rss, dvg_t *dvg, rss_irn_t *src, rss_irn_t *tgt) { int i, j, idx; rss_edge_t *edge; - rss_edge_t **arr = alloca(pset_count(dvg->edges) * sizeof(arr[0])); + rss_edge_t **arr = ALLOCAN(rss_edge_t*, pset_count(dvg->edges)); /* Add an edge from serialization target to serialization src: @@ -1454,9 +1455,9 @@ static void build_dvg_pkiller_list(rss_t *rss, dvg_t *dvg) { */ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int iteration) { int n = ir_nodeset_size(&dvg->nodes); - int *assignment = alloca(n * sizeof(assignment[0])); - int *assignment_rev = alloca(n * sizeof(assignment_rev[0])); - int *idx_map = alloca(n * sizeof(idx_map[0])); + int *assignment = ALLOCAN(int, n); + int *assignment_rev = ALLOCAN(int, n); + int *idx_map = ALLOCAN(int, n); hungarian_problem_t *bp; ir_nodeset_t *values, *temp; ir_nodeset_iterator_t iter; @@ -1469,7 +1470,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera if (pset_count(dvg->edges) == 0) return NULL; - bp = hungarian_new(n, n, 1, HUNGARIAN_MATCH_NORMAL); + bp = hungarian_new(n, n, HUNGARIAN_MATCH_NORMAL); /* At first, we build an index map for the nodes in the DVG, @@ -1567,7 +1568,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera DBG((rss->dbg, LEVEL_3, "\t\t\t%3d -> %3d %3d -> %3d\n", i, assignment[i], i, assignment_rev[i])); } - values = xmalloc(sizeof(values[0])); + values = XMALLOC(ir_nodeset_t); ir_nodeset_init_size(values, 10); cur_chain = 0; /* Construction of the minimal chain partition */ @@ -1577,7 +1578,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera int xj = idx_map[j]; ir_node *xj_irn = get_idx_irn(rss->irg, xj); rss_irn_t *xj_rss = get_rss_irn(rss, xj_irn); - chain_t *c = obstack_alloc(phase_obst(&rss->ph), sizeof(*c)); + chain_t *c = OALLOC(phase_obst(&rss->ph), chain_t); int source; /* there was no source for j -> we have a source of a new chain */ @@ -1645,7 +1646,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera free(temp); } - temp = xmalloc(sizeof(temp[0])); + temp = XMALLOC(ir_nodeset_t); ir_nodeset_init_size(temp, 10); /* Select all nodes from current value set, having another node in the set as descendant. */ @@ -1718,7 +1719,7 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod int n = ir_nodeset_size(sat_vals); int n_idx = ARR_LEN_SAFE(rss->idx_map); int i = 0; - ir_node **val_arr = alloca(n * sizeof(val_arr[0])); + ir_node **val_arr = ALLOCAN(ir_node*, n); bitset_t *bs_sv = bitset_alloca(n_idx); bitset_t *bs_vdesc = bitset_alloca(n_idx); bitset_t *bs_tmp = bitset_alloca(n_idx); @@ -1961,7 +1962,7 @@ static void perform_value_serialization_heuristic(rss_t *rss) { pset *ser_set = new_pset(cmp_rss_edges, 20); /* available_regs = R = |arch_non_ignore_regs cut ~abi_ignore_regs| */ - arch_put_non_ignore_regs(rss->arch_env, rss->cls, arch_nonign_bs); + arch_put_non_ignore_regs(rss->cls, arch_nonign_bs); be_abi_put_ignore_regs(rss->abi, rss->cls, abi_ign_bs); bitset_andnot(arch_nonign_bs, abi_ign_bs); available_regs = bitset_popcnt(arch_nonign_bs); @@ -1989,7 +1990,7 @@ static void perform_value_serialization_heuristic(rss_t *rss) { sat_vals = compute_maximal_antichain(rss, &dvg, iteration++); while (sat_vals && (ir_nodeset_size(sat_vals) > available_regs)) { serialization_t *ser, best_ser; - rss_edge_t *edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*edge)); + rss_edge_t *edge = OALLOC(phase_obst(&rss->ph), rss_edge_t); ir_node *dep_src, *dep_tgt; best_ser.edge = edge; @@ -2072,7 +2073,7 @@ static void process_block(ir_node *block, void *env) { /* Get all live value at end of Block having current register class */ ir_nodeset_init(&rss->live_block); - be_liveness_end_of_block(rss->liveness, rss->arch_env, rss->cls, rss->block, &rss->live_block); + be_liveness_end_of_block(rss->liveness, rss->cls, rss->block, &rss->live_block); /* reset the list of interesting nodes */ plist_clear(rss->nodes); @@ -2101,7 +2102,7 @@ static void process_block(ir_node *block, void *env) { */ if (is_Proj(irn)) { ir_node *pred = get_Proj_pred(irn); - if (be_is_Barrier(pred) || is_Start(pred)) + if (be_is_Barrier(pred) || be_is_Start(pred)) continue; } @@ -2111,7 +2112,8 @@ static void process_block(ir_node *block, void *env) { if (be_is_Keep(irn)) continue; - if (! arch_irn_is(rss->arch_env, irn, ignore) && arch_get_irn_reg_class(rss->arch_env, irn, -1) == cls) { + if (!arch_irn_is_ignore(irn) && + arch_get_irn_reg_class_out(irn) == cls) { plist_insert_back(rss->nodes, skip_Proj(irn)); } //} @@ -2167,7 +2169,7 @@ void rss_schedule_preparation(be_irg_t *birg) { rss.h = heights_new(irg); rss.nodes = plist_new(); rss.opts = &rss_options; - rss.liveness = be_liveness(birg); + rss.liveness = be_liveness(irg); be_liveness_assure_sets(rss.liveness); irg_block_walk_graph(irg, NULL, process_block, &rss); heights_free(rss.h);