2 * Scheduling utilities for nodes in Blocks and Blocks.
11 #include "firm_types.h"
13 void be_sched_dump(FILE *f, ir_graph *irg);
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);
27 * Returns the first block of a graphs block schedule.
29 ir_node *sched_irg_first(const ir_graph *irg);
31 #define sched_is_end(irn) is_Block(irn)
32 #define sched_is_begin(irn) is_Block(irn)
34 #define sched_foreach_from(from, irn) \
35 for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
37 #define sched_foreach_reverse_from(from, irn) \
38 for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
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.
45 #define sched_foreach(block,irn) \
46 sched_foreach_from(sched_first(block), irn)
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.
53 #define sched_foreach_reverse(block,irn) \
54 sched_foreach_reverse_from(sched_last(block), irn)
57 * Calculates a block schedule. The schedule is returned as
58 * an array allocated on the irg's obstack.
60 * @param irg the graph to be scheduled
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.
65 * This function implements a simple extended block scheduling algorithm.
67 ir_node **sched_create_block_schedule(ir_graph *irg);
69 #endif /* _BESCHED_H */