2 * Scheduling utilities for nodes in Blocks and Blocks.
11 #include "firm_types.h"
15 void be_sched_dump(FILE *f, ir_graph *irg);
17 int sched_get_time_step(const ir_node *irn);
18 int sched_has_next(const ir_node *irn);
19 int sched_has_prev(const ir_node *irn);
20 ir_node *sched_next(const ir_node *irn);
21 ir_node *sched_prev(const ir_node *irn);
22 ir_node *sched_first(const ir_node *block);
23 ir_node *sched_last(const ir_node *block);
24 ir_node *sched_add_before(ir_node *before, ir_node *irn);
25 ir_node *sched_add_after(ir_node *before, ir_node *irn);
26 void sched_remove(ir_node *irn);
29 * Returns the first block of a graphs block schedule.
31 ir_node *sched_irg_first(const ir_graph *irg);
33 #define sched_is_end(irn) is_Block(irn)
34 #define sched_is_begin(irn) is_Block(irn)
36 #define sched_foreach_from(from, irn) \
37 for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
39 #define sched_foreach_reverse_from(from, irn) \
40 for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
43 * A shorthand macro for iterating over a schedule.
44 * @param block The block.
45 * @param irn A ir node pointer used as an iterator.
47 #define sched_foreach(block,irn) \
48 sched_foreach_from(sched_first(block), irn)
51 * A shorthand macro for reversely iterating over a schedule.
52 * @param block The block.
53 * @param irn A ir node pointer used as an iterator.
55 #define sched_foreach_reverse(block,irn) \
56 sched_foreach_reverse_from(sched_last(block), irn)
59 * Calculates a block schedule. The schedule is returned as
60 * an array allocated on the irg's obstack.
62 * @param irg the graph to be scheduled
64 * @return A list of all blocks in schedule order. This list is
65 * allocated on irg's obstack and is freed if the graph is destroyed.
67 * This function implements a simple extended block scheduling algorithm.
69 ir_node **sched_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs);
72 * Removes dead nodes from schedule
73 * @param irg the graph
75 void be_remove_dead_nodes_from_schedule(ir_graph *irg);
77 #endif /* _BESCHED_H */