#include "irnode_t.h"
#include "irgraph_t.h"
+#include "besched.h"
+
extern size_t sched_irn_data_offset;
typedef struct _sched_info_t {
struct list_head list;
int time_step;
-
- unsigned is_last_use_in_block : 1;
} sched_info_t;
#define _sched_entry(list_head) (list_entry(list_head, sched_info_t, list))
#define get_irn_sched_info(irn) get_irn_data(irn, sched_info_t, sched_irn_data_offset)
#define get_sched_info_irn(sched_info) get_irn_data_base(sched_info, sched_irn_data_offset)
+/**
+ * Init the scheduling stuff.
+ * To be called from the central backend initialization routine.
+ */
+void be_sched_init(void);
+
+/**
+ * Get the time step of an irn in a schedule.
+ * @param irn The node.
+ * @return The time step in the schedule.
+ */
+static INLINE int _sched_get_time_step(const ir_node *irn)
+{
+ return get_irn_sched_info(irn)->time_step;
+}
+
/**
* Check, if an ir_node has a scheduling successor.
* @param irn The ir node.
* @return 1, if the node has a scheduling successor, 0 if not.
*/
-static INLINE int sched_has_succ(const ir_node *irn)
+static INLINE int _sched_has_succ(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
* @param irn The ir node.
* @return 1, if the node has a scheduling predecessor, 0 if not.
*/
-static INLINE int sched_has_prev(const ir_node *irn)
+static INLINE int _sched_has_prev(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
const sched_info_t *block_info = get_irn_sched_info(get_nodes_block(irn));
* @return The next ir node in the schedule or NULL, if this node has no
* successor.
*/
-static INLINE const ir_node *sched_succ(const ir_node *irn)
+static INLINE ir_node *_sched_succ(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
- return sched_has_succ(irn) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
+ return _sched_has_succ(irn) ? get_sched_info_irn(_sched_entry(info->list.next)) : NULL;
}
/**
* @return The next ir node in the schedule or NULL, if this node has no
* predecessor.
*/
-static INLINE const ir_node *sched_prev(const ir_node *irn)
+static INLINE ir_node *_sched_prev(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
- return sched_has_prev(irn) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
+ return _sched_has_prev(irn) ? get_sched_info_irn(_sched_entry(info->list.prev)) : NULL;
}
/**
* @param block The block of which to get the schedule.
* @return The first node in the schedule or NULL if there is none.
*/
-static INLINE const ir_node *sched_first(const ir_node *block)
+static INLINE ir_node *_sched_first(const ir_node *block)
{
const sched_info_t *info = get_irn_sched_info(block);
assert(is_Block(block) && "Need a block here");
* @return The last ir node in a schedule, or NULL if no schedule exists
* or it is empty.
*/
-static INLINE const ir_node *sched_last(const ir_node *block)
+static INLINE ir_node *_sched_last(const ir_node *block)
{
const sched_info_t *info = get_irn_sched_info(block);
assert(is_Block(block) && "Need a block here");
* @param irn The node to add.
* @return The given node.
*/
-static INLINE const ir_node *sched_add(ir_node *block, const ir_node *irn)
+static INLINE ir_node *_sched_add(ir_node *block, ir_node *irn)
{
assert(is_Block(block) && "Need a block here");
list_add_tail(&get_irn_sched_info(irn)->list, &get_irn_sched_info(block)->list);
return irn;
}
-/**
- * A shorthand macro for iterating over a schedule.
- * @param block The block.
- * @param irn A ir node pointer used as an iterator.
- */
-#define sched_foreach(block,irn) for(irn = sched_first(block); irn; irn = sched_succ(irn))
-
+#define sched_get_time_step(irn) _sched_get_time_step(irn)
+#define sched_has_succ(irn) _sched_has_succ(irn)
+#define sched_has_prev(irn) _sched_has_prev(irn)
+#define sched_succ(irn) _sched_succ(irn)
+#define sched_prev(irn) _sched_prev(irn)
+#define sched_first(irn) _sched_first(irn)
+#define sched_last(irn) _sched_last(irn)
+#define sched_add(block,irn) _sched_add(block,irn)
-#define sched_foreach_reverse(block,irn) \
- for(irn = sched_last(block); irn; irn = sched_prev(irn))
#endif