Comments, beautify
[libfirm] / ir / be / besched_t.h
index b803b65..7ecc583 100644 (file)
@@ -6,13 +6,13 @@
 #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))
@@ -20,12 +20,28 @@ typedef struct _sched_info_t {
 #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));
@@ -37,7 +53,7 @@ static INLINE int sched_has_succ(const ir_node *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));
@@ -50,10 +66,10 @@ static INLINE int sched_has_prev(const ir_node *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 const 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;
 }
 
 /**
@@ -62,10 +78,10 @@ static INLINE const ir_node *sched_succ(const ir_node *irn)
  * @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 const 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;
 }
 
 /**
@@ -73,7 +89,7 @@ static INLINE const ir_node *sched_prev(const ir_node *irn)
  * @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 const 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");
@@ -86,7 +102,7 @@ static INLINE const ir_node *sched_first(const ir_node *block)
  * @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 const 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");
@@ -99,22 +115,21 @@ static INLINE const ir_node *sched_last(const ir_node *block)
  * @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 const ir_node *__sched_add(ir_node *block, const 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