#include "besched.h"
#include "belistsched.h"
+#include "bemodule.h"
/**
* The random selector:
* Just assure that branches are executed last, otherwise select a random node
*/
-static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set,
- ir_nodeset_t *live_set)
+static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
{
ir_nodeset_iterator_t iter;
ir_node *irn = NULL;
int only_branches_left = 1;
(void)block_env;
- (void)live_set;
/* assure that branches and constants are executed last */
ir_nodeset_iterator_init(&iter, ready_set);
return irn;
}
-static void *random_init_graph(const list_sched_selector_t *vtab, ir_graph *irg)
+static void *random_init_graph(ir_graph *irg)
{
- (void)vtab;
(void)irg;
- /* Using time(NULL) as a seed here gives really random results,
- but is NOT deterministic which makes debugging impossible.
- Moreover no-one want non-deterministic compilers ... */
+ /* TODO: add commandline option for the seed */
srand(0x4711);
return NULL;
}
return NULL;
}
-const list_sched_selector_t random_selector = {
- 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 */
-};
+static void sched_random(ir_graph *irg)
+{
+ static const list_sched_selector_t random_selector = {
+ random_init_graph,
+ random_init_block,
+ random_select,
+ NULL, /* node_ready */
+ NULL, /* node_selected */
+ NULL, /* finish_block */
+ NULL /* finish_graph */
+ };
+ be_list_sched_graph(irg, &random_selector);
+}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_sched_rand)
+void be_init_sched_rand(void)
+{
+ be_register_scheduler("random", sched_random);
+}