bescripts: Copy all common node attributes into the constructor variants.
[libfirm] / ir / be / besched.h
index 9ef2f53..15e0996 100644 (file)
 /**
  * @file
  * @brief       data structures for scheduling nodes in basic blocks.
- *              (This file does not contain the scheduling algorithms)
  * @author      Sebastian Hack, Matthias Braun
- * @version     $Id$
  */
 #ifndef FIRM_BE_BESCHED_H
 #define FIRM_BE_BESCHED_H
 
-#include <stdio.h>
 #include <stdbool.h>
 
-#include "irgraph.h"
-#include "irnode.h"
-#include "beirg.h"
 #include "beinfo.h"
-#include "beutil.h"
 
 static sched_info_t *get_irn_sched_info(const ir_node *node)
 {
@@ -43,6 +36,8 @@ static sched_info_t *get_irn_sched_info(const ir_node *node)
 
 /**
  * Check, if the node is scheduled.
+ * Block nodes are reported as scheduled as they mark the begin and end
+ * of the scheduling list.
  * @param irn The node.
  * @return 1, if the node is scheduled, 0 if not.
  */
@@ -52,8 +47,8 @@ static inline bool sched_is_scheduled(const ir_node *irn)
 }
 
 /**
- * returns the time step of a node. Each node in a block has a timestep
- * unique to that block. a node schedule before another node has a lower
+ * Returns the time step of a node. Each node in a block has a timestep
+ * unique to that block. A node schedule before another node has a lower
  * timestep than this node.
  * @param irn The node.
  * @return The time step in the schedule.
@@ -74,30 +69,6 @@ static inline bool sched_is_begin(const ir_node *node)
        return is_Block(node);
 }
 
-/**
- * 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 bool sched_has_next(const ir_node *irn)
-{
-       const sched_info_t *info  = get_irn_sched_info(irn);
-       const ir_node      *block = is_Block(irn) ? irn : get_nodes_block(irn);
-       return info->next != block;
-}
-
-/**
- * Check, if an ir_node has a scheduling predecessor.
- * @param irn The ir node.
- * @return 1, if the node has a scheduling predecessor, 0 if not.
- */
-static inline bool sched_has_prev(const ir_node *irn)
-{
-       const sched_info_t *info  = get_irn_sched_info(irn);
-       const ir_node      *block = is_Block(irn) ? irn : get_nodes_block(irn);
-       return info->prev != block;
-}
-
 /**
  * Get the scheduling successor of a node.
  * @param irn The node.
@@ -147,7 +118,6 @@ static inline ir_node *sched_last(const ir_node *block)
 
 /**
  * Add a node to a block schedule.
- * @param block The block to whose schedule the node shall be added to.
  * @param irn The node to add.
  * @return The given node.
  */
@@ -156,7 +126,6 @@ void sched_add_before(ir_node *before, ir_node *irn);
 
 /**
  * Add a node to a block schedule.
- * @param block The block to whose schedule the node shall be added to.
  * @param irn The node to add.
  * @return The given node.
  */
@@ -183,6 +152,11 @@ static inline void sched_reset(ir_node *node)
  */
 void sched_remove(ir_node *irn);
 
+/**
+ * Remove @p old from the schedule and put @p irn in its place.
+ */
+void sched_replace(ir_node *old, ir_node *irn);
+
 /**
  * Checks, if one node is scheduled before another.
  * @param n1   A node.
@@ -192,17 +166,15 @@ void sched_remove(ir_node *irn);
  */
 static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
 {
-       assert(sched_is_scheduled(n1));
-       assert(sched_is_scheduled(n2));
        assert((is_Block(n1) ? n1 : get_nodes_block(n1)) == (is_Block(n2) ? n2 : get_nodes_block(n2)));
        return sched_get_time_step(n1) < sched_get_time_step(n2);
 }
 
 #define sched_foreach_from(from, irn) \
-  for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
+  for (ir_node *irn = from; !sched_is_end(irn); irn = sched_next(irn))
 
 #define sched_foreach_reverse_from(from, irn) \
-  for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
+  for (ir_node *irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
 
 /**
  * A shorthand macro for iterating over a schedule.
@@ -221,11 +193,18 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
   sched_foreach_reverse_from(sched_last(block), irn)
 
 /**
- * A shorthand macro for iterating over all Phi nodes of a schedule.
- * @param block The block.
- * @param phi A ir node pointer used as an iterator.
+ * Type for a function scheduling a graph
+ */
+typedef void (*schedule_func) (ir_graph *irg);
+
+/**
+ * Register new scheduling algorithm
+ */
+void be_register_scheduler(const char *name, schedule_func func);
+
+/**
+ * schedule a graph with the currenty selected scheduler.
  */
-#define sched_foreach_Phi(block,phi) \
-       for (phi = sched_first(block); is_Phi(phi); phi = sched_next(phi))
+void be_schedule_graph(ir_graph *irg);
 
 #endif