X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeschedrss.c;h=633e89776e2a1b72f5967003efd4cbcd03a52965;hb=e7ba741cdd9599ce05d7989bff60a1c6137ee0b5;hp=350a7dff7d59b6cf53b9816db6d0798de0a273a8;hpb=863d31d7a5c8210432fef88b30fc3e8353131538;p=libfirm diff --git a/ir/be/beschedrss.c b/ir/be/beschedrss.c index 350a7dff7..633e89776 100644 --- a/ir/be/beschedrss.c +++ b/ir/be/beschedrss.c @@ -1,12 +1,32 @@ +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /** + * @file + * @brief Implementation of a register saturating list scheduler. + * @author Christian Wuerdig + * @date 29.08.2006 + * @version $Id$ + * * Implementation of a register saturating list scheduler * as described in: Sid-Ahmed-Ali Touati * Register Saturation in Superscalar and VLIW Codes - * - * @license This file protected by GPL - GNU GENERAL PUBLIC LICENSE. - * @author Christian Wuerdig - * @date 29.08.2006 - * @cvs-id $Id$ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -37,6 +57,7 @@ #include "bemodule.h" #include "benode_t.h" #include "besched_t.h" +#include "beirg_t.h" #include #include @@ -124,7 +145,7 @@ typedef struct _serialization { } serialization_t; typedef struct _rss { - phase_t ph; /**< Phase to hold some data */ + ir_phase ph; /**< Phase to hold some data */ heights_t *h; /**< The current height object */ ir_graph *irg; /**< The irg to preprocess */ plist_t *nodes; /**< The list of interesting nodes */ @@ -136,7 +157,7 @@ typedef struct _rss { unsigned max_height; /**< maximum height in the current block */ rss_opts_t *opts; /**< The options */ be_lv_t *liveness; /**< The liveness information for this irg */ - pset *live_block; /**< Values alive at end of block */ + ir_nodeset_t live_block; /**< Values alive at end of block */ const arch_register_class_t *cls; /**< The current register class */ DEBUG_ONLY(firm_dbg_module_t *dbg); } rss_t; @@ -197,7 +218,7 @@ static lc_opt_enum_int_var_t dump_var = { static const lc_opt_table_entry_t rss_option_table[] = { LC_OPT_ENT_ENUM_MASK("dump", "dump phases", &dump_var), - { NULL } + LC_OPT_LAST }; /****************************************************************************** @@ -558,7 +579,7 @@ static void debug_vcg_dump_dvg_pkiller(rss_t *rss, dvg_t *dvg) { /** * In case there is no rss information for irn, initialize it. */ -static void *init_rss_irn(phase_t *ph, ir_node *irn, void *old) { +static void *init_rss_irn(ir_phase *ph, ir_node *irn, void *old) { rss_irn_t *res = old ? old : phase_alloc(ph, sizeof(res[0])); res->descendant_list = plist_obstack_new(phase_obst(ph)); @@ -752,6 +773,7 @@ static int is_potential_killer(rss_t *rss, rss_irn_t *v, rss_irn_t *u) { plist_t *list; ir_node **arr; plist_element_t *el; + (void) rss; assert(is_Sink(v->irn) || ((plist_count(v->descendant_list) > 0 && v->descendants) || 1)); assert(is_Sink(u->irn) || ((plist_count(u->consumer_list) > 0 && u->consumer) || 1)); @@ -1824,8 +1846,9 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod */ if (add_edge) { - int vv_height = get_irn_height(rss->h, vv_irn); - int mu1, mu2, critical_path_cost; + unsigned vv_height = get_irn_height(rss->h, vv_irn); + unsigned critical_path_cost; + unsigned mu1, mu2; /* mu1 = | descendants(v) cut sat_vals | @@ -1929,7 +1952,7 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod static void perform_value_serialization_heuristic(rss_t *rss) { bitset_t *arch_nonign_bs = bitset_alloca(arch_register_class_n_regs(rss->cls)); bitset_t *abi_ign_bs = bitset_alloca(arch_register_class_n_regs(rss->cls)); - int available_regs, iteration; + unsigned available_regs, iteration; dvg_t dvg; ir_nodeset_t *sat_vals; pset *ser_set = new_pset(cmp_rss_edges, 20); @@ -2021,7 +2044,7 @@ static void process_block(ir_node *block, void *env) { int i, n; const ir_edge_t *edge; - phase_init(&rss->ph, "rss block preprocessor", rss->irg, PHASE_DEFAULT_GROWTH, init_rss_irn); + phase_init(&rss->ph, "rss block preprocessor", rss->irg, PHASE_DEFAULT_GROWTH, init_rss_irn, NULL); DBG((rss->dbg, LEVEL_1, "preprocessing block %+F\n", block)); rss->block = block; @@ -2045,8 +2068,8 @@ static void process_block(ir_node *block, void *env) { DBG((rss->dbg, LEVEL_1, "register class %s\n", arch_register_class_name(cls))); /* Get all live value at end of Block having current register class */ - rss->live_block = pset_new_ptr(10); - be_liveness_end_of_block(rss->liveness, rss->arch_env, rss->cls, rss->block, rss->live_block); + ir_nodeset_init(&rss->live_block); + be_liveness_end_of_block(rss->liveness, rss->arch_env, rss->cls, rss->block, &rss->live_block); /* reset the list of interesting nodes */ plist_clear(rss->nodes); @@ -2103,7 +2126,7 @@ static void process_block(ir_node *block, void *env) { */ perform_value_serialization_heuristic(rss); - del_pset(rss->live_block); + ir_nodeset_destroy(&rss->live_block); } phase_free(&rss->ph); @@ -2126,22 +2149,23 @@ BE_REGISTER_MODULE_CONSTRUCTOR(be_init_schedrss); * Preprocess the irg for scheduling. */ void rss_schedule_preparation(const be_irg_t *birg) { + ir_graph *irg = be_get_birg_irg(birg); rss_t rss; FIRM_DBG_REGISTER(rss.dbg, "firm.be.sched.rss"); //firm_dbg_set_mask(rss.dbg, LEVEL_1 | LEVEL_2 | LEVEL_3); - init_rss_special_nodes(birg->irg); + init_rss_special_nodes(irg); - rss.irg = birg->irg; - rss.arch_env = birg->main_env->arch_env; + rss.irg = irg; + rss.arch_env = be_get_birg_arch_env(birg); rss.abi = birg->abi; - rss.h = heights_new(birg->irg); + rss.h = heights_new(irg); rss.nodes = plist_new(); rss.opts = &rss_options; - rss.liveness = be_liveness(birg->irg); - irg_block_walk_graph(birg->irg, NULL, process_block, &rss); + rss.liveness = be_liveness(irg); + irg_block_walk_graph(irg, NULL, process_block, &rss); heights_free(rss.h); plist_free(rss.nodes); be_liveness_free(rss.liveness);