9 extern size_t sched_irn_data_offset;
11 typedef struct _sched_info_t {
12 struct list_head list;
15 unsigned is_last_use_in_block : 1;
18 #define _sched_entry(list_head) (list_entry(list_head, sched_info_t, list))
20 #define get_irn_sched_info(irn) get_irn_data(irn, sched_info_t, sched_irn_data_offset)
21 #define get_sched_info_irn(sched_info) get_irn_data_base(sched_info, sched_irn_data_offset)
24 * Check, if an ir_node has a scheduling successor.
25 * @param irn The ir node.
26 * @return 1, if the node has a scheduling successor, 0 if not.
28 static INLINE int sched_has_succ(const ir_node *irn)
30 const sched_info_t *info = get_irn_sched_info(irn);
31 const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
32 return info->list.next != &block_info->list;
36 * Check, if an ir_node has a scheduling predecessor.
37 * @param irn The ir node.
38 * @return 1, if the node has a scheduling predecessor, 0 if not.
40 static INLINE int sched_has_prev(const ir_node *irn)
42 const sched_info_t *info = get_irn_sched_info(irn);
43 const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
44 return info->list.prev != &block_info->list;
48 * Get the scheduling successor of a node.
49 * @param irn The node.
50 * @return The next ir node in the schedule or NULL, if this node has no
53 static INLINE const ir_node *sched_succ(const ir_node *irn)
55 const sched_info_t *info = get_irn_sched_info(irn);
56 return sched_has_succ(irn) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
60 * Get the scheduling predecessor of a node.
61 * @param irn The node.
62 * @return The next ir node in the schedule or NULL, if this node has no
65 static INLINE const ir_node *sched_prev(const ir_node *irn)
67 const sched_info_t *info = get_irn_sched_info(irn);
68 return sched_has_prev(irn) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
72 * Get the first node in a block schedule.
73 * @param block The block of which to get the schedule.
74 * @return The first node in the schedule or NULL if there is none.
76 static INLINE const ir_node *sched_first(const ir_node *block)
78 const sched_info_t *info = get_irn_sched_info(block);
79 assert(is_Block(block) && "Need a block here");
80 return !list_empty(&info->list) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
84 * Get the last node in a schedule.
85 * @param block The block to get the schedule for.
86 * @return The last ir node in a schedule, or NULL if no schedule exists
89 static INLINE const ir_node *sched_last(const ir_node *block)
91 const sched_info_t *info = get_irn_sched_info(block);
92 assert(is_Block(block) && "Need a block here");
93 return !list_empty(&info->list) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
97 * Add a node to a block schedule.
98 * @param block The block to whose schedule the node shall be added to.
99 * @param irn The node to add.
100 * @return The given node.
102 static INLINE const ir_node *sched_add(ir_node *block, const ir_node *irn)
104 assert(is_Block(block) && "Need a block here");
105 list_add_tail(&get_irn_sched_info(irn)->list, &get_irn_sched_info(block)->list);
110 * A shorthand macro for iterating over a schedule.
111 * @param block The block.
112 * @param irn A ir node pointer used as an iterator.
114 #define sched_foreach(block,irn) for(irn = sched_first(block); irn; irn = sched_succ(irn))
117 #define sched_foreach_reverse(block,irn) \
118 for(irn = sched_last(block); irn; irn = sched_prev(irn))