+ ir_nodeset_destroy(&be.cands);
+ ir_nodeset_destroy(&be.live);
+}
+
+/* List schedule a graph. */
+void list_sched(ir_graph *irg)
+{
+ int num_nodes;
+ sched_env_t env;
+ mris_env_t *mris = NULL;
+ list_sched_selector_t sel;
+
+ /* Select a scheduler based on backend options */
+ switch (list_sched_options.select) {
+ case BE_SCHED_SELECT_TRIVIAL: sel = trivial_selector; break;
+ case BE_SCHED_SELECT_RANDOM: sel = random_selector; break;
+ case BE_SCHED_SELECT_REGPRESS: sel = reg_pressure_selector; break;
+ case BE_SCHED_SELECT_MUCHNIK: sel = muchnik_selector; break;
+ case BE_SCHED_SELECT_HEUR: sel = heuristic_selector; break;
+ case BE_SCHED_SELECT_NORMAL: sel = normal_selector; break;
+ default:
+ case BE_SCHED_SELECT_HMUCHNIK: sel = heuristic_selector; break;
+ }
+
+#if 1
+ /* Matze: This is very slow, we should avoid it to improve backend speed,
+ * we just have to make sure that we have no dangling out-edges at this
+ * point...
+ */
+
+ /* Assure, that we have no dangling out-edges to deleted stuff */
+ edges_deactivate(irg);
+ edges_activate(irg);
+#endif
+
+ switch (list_sched_options.prep) {
+ case BE_SCHED_PREP_MRIS:
+ mris = be_sched_mris_preprocess(irg);
+ break;
+ case BE_SCHED_PREP_RSS:
+ rss_schedule_preparation(irg);
+ break;
+ default:
+ break;
+ }
+
+ num_nodes = get_irg_last_idx(irg);
+
+ /* initialize environment for list scheduler */
+ memset(&env, 0, sizeof(env));
+ env.selector = arch_env_get_list_sched_selector(be_get_irg_arch_env(irg), &sel);
+ env.sched_info = NEW_ARR_F(sched_irn_t, num_nodes);
+
+ memset(env.sched_info, 0, num_nodes * sizeof(env.sched_info[0]));
+
+ if (env.selector->init_graph)
+ env.selector_env = env.selector->init_graph(env.selector, irg);
+
+ /* Schedule each single block. */
+ irg_block_walk_graph(irg, list_sched_block, NULL, &env);
+
+ if (env.selector->finish_graph)
+ env.selector->finish_graph(env.selector_env);
+
+ if (list_sched_options.prep == BE_SCHED_PREP_MRIS)
+ be_sched_mris_free(mris);
+
+ DEL_ARR_F(env.sched_info);
+}
+
+/* List schedule a block. */
+void list_sched_single_block(ir_graph *irg, ir_node *block)
+{
+ int num_nodes;
+ sched_env_t env;
+ list_sched_selector_t sel;
+
+ /* Select a scheduler based on backend options */
+ switch (list_sched_options.select) {
+ case BE_SCHED_SELECT_TRIVIAL: sel = trivial_selector; break;
+ case BE_SCHED_SELECT_RANDOM: sel = random_selector; break;
+ case BE_SCHED_SELECT_REGPRESS: sel = reg_pressure_selector; break;
+ case BE_SCHED_SELECT_MUCHNIK: sel = muchnik_selector; break;
+ case BE_SCHED_SELECT_HEUR: sel = heuristic_selector; break;
+ case BE_SCHED_SELECT_NORMAL: sel = normal_selector; break;
+ default:
+ case BE_SCHED_SELECT_HMUCHNIK: sel = trivial_selector; break;
+ }
+
+ /* Assure, that the out edges are computed */
+ edges_deactivate(irg);
+ edges_activate(irg);
+
+ num_nodes = get_irg_last_idx(irg);
+
+ /* initialize environment for list scheduler */
+ memset(&env, 0, sizeof(env));
+ env.selector = arch_env_get_list_sched_selector(be_get_irg_arch_env(irg), &sel);
+ env.sched_info = NEW_ARR_F(sched_irn_t, num_nodes);
+
+ memset(env.sched_info, 0, num_nodes * sizeof(env.sched_info[0]));
+
+ if (env.selector->init_graph)
+ env.selector_env = env.selector->init_graph(env.selector, irg);
+
+ /* Schedule block. */
+ list_sched_block(block, &env);
+
+ if (env.selector->finish_graph)
+ env.selector->finish_graph(env.selector_env);
+
+ DEL_ARR_F(env.sched_info);
+}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_listsched);
+void be_init_listsched(void)
+{
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *sched_grp = lc_opt_get_grp(be_grp, "listsched");
+
+ lc_opt_add_table(sched_grp, list_sched_option_table);