BE_SCHED_SELECT_REGPRESS = 1,
BE_SCHED_SELECT_MUCHNIK = 2,
BE_SCHED_SELECT_HEUR = 3,
- BE_SCHED_SELECT_HMUCHNIK = 4
+ BE_SCHED_SELECT_HMUCHNIK = 4,
+ BE_SCHED_SELECT_RANDOM = 5
};
struct _be_options_t {
BE_TIMER_PUSH(ra_timer.t_spillslots);
- if(coalesce_spill_slots)
- be_coalesce_spillslots(&chordal_env);
+ be_coalesce_spillslots(&chordal_env, coalesce_spill_slots);
dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
BE_TIMER_POP(ra_timer.t_spillslots);
case BE_SCHED_SELECT_TRIVIAL:
memcpy(&sel, trivial_selector, sizeof(sel));
break;
+ case BE_SCHED_SELECT_RANDOM:
+ memcpy(&sel, random_selector, sizeof(sel));
+ break;
case BE_SCHED_SELECT_REGPRESS:
memcpy(&sel, reg_pressure_selector, sizeof(sel));
break;
*/
extern const list_sched_selector_t *trivial_selector;
+extern const list_sched_selector_t *random_selector;
+
/**
* A selector that tries to minimize the register pressure.
* @note Not really operational yet.
/* schedule selector options. */
static const lc_opt_enum_int_items_t sched_select_items[] = {
{ "trivial", BE_SCHED_SELECT_TRIVIAL },
+ { "random", BE_SCHED_SELECT_RANDOM },
{ "regpress", BE_SCHED_SELECT_REGPRESS },
{ "muchnik", BE_SCHED_SELECT_MUCHNIK },
{ "heur", BE_SCHED_SELECT_HEUR },
--- /dev/null
+/**
+ * Trivial node selector.
+ * @author Christian Wuerdig
+ * @date 29.08.2006
+ * @cvs-id $Id$
+ */
+
+#include <stdlib.h>
+
+#include "besched_t.h"
+#include "belistsched.h"
+
+/**
+ * The random selector:
+ * Just assure that branches are executed last, otherwise select a random node
+ */
+static ir_node *random_select(void *block_env, nodeset *ready_set, nodeset *live_set)
+{
+ const arch_env_t *arch_env = block_env;
+ ir_node *irn = NULL;
+ int only_branches_left = 1;
+
+ /* assure that branches and constants are executed last */
+ for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
+ if (! arch_irn_class_is(arch_env, irn, branch)) {
+ only_branches_left = 0;
+ nodeset_break(ready_set);
+ break;
+ }
+ }
+
+ if(only_branches_left) {
+ /* at last: schedule branches */
+ irn = nodeset_first(ready_set);
+ nodeset_break(ready_set);
+ } else {
+ do {
+ // take 1 random node
+ int n = rand() % pset_count(ready_set);
+ int i = 0;
+ for(irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
+ if(i == n) {
+ nodeset_break(ready_set);
+ break;
+ }
+ ++i;
+ }
+ } while(arch_irn_class_is(arch_env, irn, branch));
+ }
+
+ return irn;
+}
+
+static void *random_init_graph(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg)
+{
+ srand(time(0));
+ return (void *)arch_env;
+}
+
+static void *random_init_block(void *graph_env, ir_node *bl)
+{
+ return graph_env;
+}
+
+static const list_sched_selector_t random_selector_struct = {
+ random_init_graph,
+ random_init_block,
+ random_select,
+ NULL, /* to_appear_in_schedule */
+ NULL, /* node_ready */
+ NULL, /* node_selected */
+ NULL, /* exectime */
+ NULL, /* latency */
+ NULL, /* finish_block */
+ NULL /* finish_graph */
+};
+
+const list_sched_selector_t *random_selector = &random_selector_struct;
}
}
-void be_coalesce_spillslots(const be_chordal_env_t *chordal_env) {
+void be_coalesce_spillslots(const be_chordal_env_t *chordal_env, int coalesce_spillslots) {
ss_env_t env;
obstack_init(&env.obst);
/* Get initial spill slots */
irg_walk_graph(chordal_env->irg, NULL, collect_spills_walker, &env);
- do_greedy_coalescing(&env);
+ if(coalesce_spillslots)
+ do_greedy_coalescing(&env);
assign_spillslots(&env);
/**
* Computes the spill offsets for all spill nodes in the irg
*/
-void be_coalesce_spillslots(const be_chordal_env_t *chordal_env);
+void be_coalesce_spillslots(const be_chordal_env_t *chordal_env, int coalesce_spillslots);
#endif