summaryrefslogtreecommitdiffhomepage
path: root/ir/be/besched.h
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2012-12-14 09:33:52 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2012-12-15 00:11:05 +0100
commitb7908561f0eedb4fd052a2c5396f33e0883dfa5d (patch)
treef0fa2529f03826bf56e8aa226e643f017447db4e /ir/be/besched.h
parentd6ad56f1135216a000cb556c5a32c95e66883cd7 (diff)
besched: Add and use sched_foreach_reverse_safe().
Diffstat (limited to 'ir/be/besched.h')
-rw-r--r--ir/be/besched.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/ir/be/besched.h b/ir/be/besched.h
index aa8c314..eb7907d 100644
--- a/ir/be/besched.h
+++ b/ir/be/besched.h
@@ -189,6 +189,16 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
for (ir_node *irn, *irn##__next = sched_first(block); !sched_is_end(irn = irn##__next) ? irn##__next = sched_next(irn), 1 : 0;)
/**
+ * A shorthand macro for reversely iterating over a schedule while the current
+ * node may be removed or replaced.
+ *
+ * @param block The block.
+ * @param irn A ir node pointer used as an iterator.
+ */
+#define sched_foreach_reverse_safe(block, irn) \
+ for (ir_node *irn, *irn##__prev = sched_last(block); !sched_is_begin(irn = irn##__prev) ? irn##__prev = sched_prev(irn), 1 : 0;)
+
+/**
* Type for a function scheduling a graph
*/
typedef void (*schedule_func) (ir_graph *irg);