becopyheur4: Clean up co_mst_irn_init().
[libfirm] / ir / be / belistsched.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Common functions for creating listscheduling algorithms
9  * @author      Sebastian Hack
10  * @date        20.10.2004
11  */
12 #ifndef FIRM_BE_BELISTSCHED_H
13 #define FIRM_BE_BELISTSCHED_H
14
15 #include "firm_types.h"
16 #include "irnodeset.h"
17
18 #include "be.h"
19 #include "be_types.h"
20 #include "bearch.h"
21
22 /**
23  * A selector interface which is used by the list schedule framework.
24  * You can implement your own list scheduler by implementing these
25  * functions.
26  */
27 typedef struct list_sched_selector_t {
28
29         /**
30          * Called before a graph is being scheduled.
31          * May be NULL.
32          *
33          * @param irg      The backend graph.
34          * @return         The environment pointer that is passed to all other
35          *                 functions in this struct.
36          */
37         void *(*init_graph)(ir_graph *irg);
38
39         /**
40          * Called before scheduling starts on a block.
41          * May be NULL.
42          *
43          * @param graph_env   The environment.
44          * @param block       The block which is to be scheduled.
45          * @return A per-block pointer that is additionally passed to select.
46          */
47         void *(*init_block)(void *graph_env, ir_node *block);
48
49         /**
50          * The selection function.
51          * It picks one node out of the ready list to be scheduled next.
52          * The function does not have to delete the node from the ready set.
53          * MUST be implemented.
54          *
55          * @param block_env   Some private information as returned by init_block().
56          * @param sched_head  The schedule so far.
57          * @param ready_set   A set containing all ready nodes. Pick one of these nodes.
58          * @return The chosen node.
59          */
60         ir_node *(*select)(void *block_env, ir_nodeset_t *ready_set);
61
62         /**
63          * This function gets executed after a node finally has been made ready.
64          * May be NULL.
65          *
66          * @param block_env The block environment.
67          * @param irn       The node made ready.
68          * @param pred      The previously scheduled node.
69          */
70         void (*node_ready)(void *block_env, ir_node *irn, ir_node *pred);
71
72         /**
73          * This function gets executed after a node finally has been selected.
74          * May be NULL.
75          *
76          * @param block_env The block environment.
77          * @param irn       The selected node.
78          */
79         void (*node_selected)(void *block_env, ir_node *irn);
80
81         /**
82          * Called after a block has been scheduled.
83          * May be NULL.
84          *
85          * @param env The environment.
86          * @param block_env The per block environment as returned by init_block().
87          */
88         void (*finish_block)(void *block_env);
89
90         /**
91          * Called after a whole graph has been scheduled.
92          * May be NULL.
93          *
94          * @param env The environment.
95          */
96         void (*finish_graph)(void *env);
97 } list_sched_selector_t;
98
99 /**
100  * List schedule a graph.
101  * Each block in the graph gets a list head to its link field being the
102  * head of the schedule. You can walk this list using the functions in
103  * list.h.
104  *
105  * @param irg     The backend irg.
106  */
107 void be_list_sched_graph(ir_graph *irg, const list_sched_selector_t *selector);
108
109 #endif