11 extern size_t sched_irn_data_offset;
13 typedef struct _sched_info_t {
14 struct list_head list;
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 * Init the scheduling stuff.
25 * To be called from the central backend initialization routine.
27 void be_sched_init(void);
30 * Get the time step of an irn in a schedule.
31 * @param irn The node.
32 * @return The time step in the schedule.
34 static INLINE int _sched_get_time_step(const ir_node *irn)
36 return get_irn_sched_info(irn)->time_step;
40 * Check, if an ir_node has a scheduling successor.
41 * @param irn The ir node.
42 * @return 1, if the node has a scheduling successor, 0 if not.
44 static INLINE int _sched_has_succ(const ir_node *irn)
46 const sched_info_t *info = get_irn_sched_info(irn);
47 const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
48 return info->list.next != &block_info->list;
52 * Check, if an ir_node has a scheduling predecessor.
53 * @param irn The ir node.
54 * @return 1, if the node has a scheduling predecessor, 0 if not.
56 static INLINE int _sched_has_prev(const ir_node *irn)
58 const sched_info_t *info = get_irn_sched_info(irn);
59 const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
60 return info->list.prev != &block_info->list;
64 * Get the scheduling successor of a node.
65 * @param irn The node.
66 * @return The next ir node in the schedule or NULL, if this node has no
69 static INLINE ir_node *_sched_succ(const ir_node *irn)
71 const sched_info_t *info = get_irn_sched_info(irn);
72 return _sched_has_succ(irn) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
76 * Get the scheduling predecessor of a node.
77 * @param irn The node.
78 * @return The next ir node in the schedule or NULL, if this node has no
81 static INLINE ir_node *_sched_prev(const ir_node *irn)
83 const sched_info_t *info = get_irn_sched_info(irn);
84 return _sched_has_prev(irn) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
88 * Get the first node in a block schedule.
89 * @param block The block of which to get the schedule.
90 * @return The first node in the schedule or NULL if there is none.
92 static INLINE ir_node *_sched_first(const ir_node *block)
94 const sched_info_t *info = get_irn_sched_info(block);
95 assert(is_Block(block) && "Need a block here");
96 return !list_empty(&info->list) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
100 * Get the last node in a schedule.
101 * @param block The block to get the schedule for.
102 * @return The last ir node in a schedule, or NULL if no schedule exists
105 static INLINE ir_node *_sched_last(const ir_node *block)
107 const sched_info_t *info = get_irn_sched_info(block);
108 assert(is_Block(block) && "Need a block here");
109 return !list_empty(&info->list) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
113 * Add a node to a block schedule.
114 * @param block The block to whose schedule the node shall be added to.
115 * @param irn The node to add.
116 * @return The given node.
118 static INLINE ir_node *_sched_add(ir_node *block, ir_node *irn)
120 assert(is_Block(block) && "Need a block here");
121 list_add_tail(&get_irn_sched_info(irn)->list, &get_irn_sched_info(block)->list);
125 #define sched_get_time_step(irn) _sched_get_time_step(irn)
126 #define sched_has_succ(irn) _sched_has_succ(irn)
127 #define sched_has_prev(irn) _sched_has_prev(irn)
128 #define sched_succ(irn) _sched_succ(irn)
129 #define sched_prev(irn) _sched_prev(irn)
130 #define sched_first(irn) _sched_first(irn)
131 #define sched_last(irn) _sched_last(irn)
132 #define sched_add(block,irn) _sched_add(block,irn)