verifier to check that no out edges point to dead/removed nodes
[libfirm] / ir / be / besched.h
1 /*
2  * Scheduling utilities for nodes in Blocks and Blocks.
3  *
4  * $Id$
5  */
6 #ifndef _BESCHED_H
7 #define _BESCHED_H
8
9 #include <stdio.h>
10
11 #include "firm_types.h"
12
13 void be_sched_dump(FILE *f, ir_graph *irg);
14
15 int     sched_get_time_step(const ir_node *irn);
16 int     sched_has_next(const ir_node *irn);
17 int     sched_has_prev(const ir_node *irn);
18 ir_node *sched_next(const ir_node *irn);
19 ir_node *sched_prev(const ir_node *irn);
20 ir_node *sched_first(const ir_node *block);
21 ir_node *sched_last(const ir_node *block);
22 ir_node *sched_add_before(ir_node *before, ir_node *irn);
23 ir_node *sched_add_after(ir_node *before, ir_node *irn);
24 void    sched_remove(ir_node *irn);
25
26 /**
27  * Returns the first block of a graphs block schedule.
28  */
29 ir_node *sched_irg_first(const ir_graph *irg);
30
31 #define sched_is_end(irn) is_Block(irn)
32 #define sched_is_begin(irn) is_Block(irn)
33
34 #define sched_foreach_from(from, irn) \
35   for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
36
37 #define sched_foreach_reverse_from(from, irn) \
38   for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
39
40 /**
41  * A shorthand macro for iterating over a schedule.
42  * @param block The block.
43  * @param irn A ir node pointer used as an iterator.
44  */
45 #define sched_foreach(block,irn) \
46         sched_foreach_from(sched_first(block), irn)
47
48 /**
49  * A shorthand macro for reversely iterating over a schedule.
50  * @param block The block.
51  * @param irn A ir node pointer used as an iterator.
52  */
53 #define sched_foreach_reverse(block,irn) \
54   sched_foreach_reverse_from(sched_last(block), irn)
55
56 /**
57  * Calculates a block schedule. The schedule is returned as
58  * an array allocated on the irg's obstack.
59  *
60  * @param irg  the graph to be scheduled
61  *
62  * @return A list of all blocks in schedule order. This list is
63  *         allocated on irg's obstack and is freed if the graph is destroyed.
64  *
65  * This function implements a simple extended block scheduling algorithm.
66  */
67 ir_node **sched_create_block_schedule(ir_graph *irg);
68
69 /**
70  * Removes dead nodes from schedule
71  * @param irg  the graph
72  */
73 void be_remove_dead_nodes_from_schedule(ir_graph *irg);
74
75 #endif /* _BESCHED_H */