summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beschedtrivial.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2014-09-12 14:15:21 +0200
committerMatthias Braun <matze@braunis.de>2014-09-15 11:27:30 +0200
commit9b6ad6d6267e5b545bba19844c7567d354ab062e (patch)
tree221f322eb7ba934f55378bb34704a3a1d3192155 /ir/be/beschedtrivial.c
parent98e70a71735df9eda68c99fad8c777040ae9eda5 (diff)
rework and cleanup schedulers
Make the list scheduler a set of helper functions, instead of a complex design with a set of callbacks. Simplified list scheduler code.
Diffstat (limited to 'ir/be/beschedtrivial.c')
-rw-r--r--ir/be/beschedtrivial.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/ir/be/beschedtrivial.c b/ir/be/beschedtrivial.c
index bf572a8..3005fb4 100644
--- a/ir/be/beschedtrivial.c
+++ b/ir/be/beschedtrivial.c
@@ -11,23 +11,21 @@
*/
#include <stdlib.h>
-#include "irnode.h"
-#include "irnodeset.h"
-
#include "bearch.h"
#include "belistsched.h"
#include "bemodule.h"
#include "besched.h"
+#include "irgwalk.h"
+#include "irnode.h"
+#include "irnodeset.h"
/**
* The trivial selector:
* Just assure that branches are executed last, otherwise select
* the first node ready.
*/
-static ir_node *trivial_select(void *block_env, ir_nodeset_t *ready_set)
+static ir_node *trivial_select(ir_nodeset_t *ready_set)
{
- (void)block_env;
-
/* assure that branches and constants are executed last */
foreach_ir_nodeset(ready_set, irn, iter) {
if (!is_cfop(irn)) {
@@ -39,31 +37,22 @@ static ir_node *trivial_select(void *block_env, ir_nodeset_t *ready_set)
return ir_nodeset_first(ready_set);
}
-static void *trivial_init_graph(ir_graph *irg)
+static void sched_block(ir_node *block, void *data)
{
- (void)irg;
- return NULL;
-}
-
-static void *trivial_init_block(void *graph_env, ir_node *block)
-{
- (void)graph_env;
- (void)block;
- return NULL;
+ (void)data;
+ ir_nodeset_t *cands = be_list_sched_begin_block(block);
+ while (ir_nodeset_size(cands) > 0) {
+ ir_node *node = trivial_select(cands);
+ be_list_sched_schedule(node);
+ }
+ be_list_sched_end_block();
}
static void sched_trivial(ir_graph *irg)
{
- static const list_sched_selector_t trivial_selector = {
- trivial_init_graph,
- trivial_init_block,
- trivial_select,
- NULL, /* node_ready */
- NULL, /* node_selected */
- NULL, /* finish_block */
- NULL /* finish_graph */
- };
- be_list_sched_graph(irg, &trivial_selector);
+ be_list_sched_begin(irg);
+ irg_block_walk_graph(irg, sched_block, NULL, NULL);
+ be_list_sched_finish();
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_sched_trivial)