Added some statistics events
[libfirm] / ir / be / beschedtrivial.c
1 /**
2  * Trivial node selector.
3  * @author Christian Wuerdig
4  * @date   29.08.2006
5  * @cvs-id $Id$
6  */
7
8 #include <stdlib.h>
9
10 #include "besched_t.h"
11 #include "belistsched.h"
12
13 /**
14  * The trivial selector:
15  * Just assure that branches are executed last, otherwise select
16  * the first node ready.
17  */
18 static ir_node *trivial_select(void *block_env, nodeset *ready_set, nodeset *live_set)
19 {
20         const arch_env_t *arch_env = block_env;
21         ir_node          *irn      = NULL;
22
23         /* assure that branches and constants are executed last */
24         for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
25                 if (! arch_irn_class_is(arch_env, irn, branch)) {
26                         nodeset_break(ready_set);
27                         return irn;
28                 }
29         }
30
31         /* at last: schedule branches */
32         irn = nodeset_first(ready_set);
33         nodeset_break(ready_set);
34
35         return irn;
36 }
37
38 static void *trivial_init_graph(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg)
39 {
40         return (void *)arch_env;
41 }
42
43 static void *trivial_init_block(void *graph_env, ir_node *bl)
44 {
45         return graph_env;
46 }
47
48 static const list_sched_selector_t trivial_selector_struct = {
49         trivial_init_graph,
50         trivial_init_block,
51         trivial_select,
52         NULL,                /* to_appear_in_schedule */
53         NULL,                /* node_ready */
54         NULL,                /* node_selected */
55         NULL,                /* exectime */
56         NULL,                /* latency */
57         NULL,                /* finish_block */
58         NULL                 /* finish_graph */
59 };
60
61 const list_sched_selector_t *trivial_selector = &trivial_selector_struct;