summaryrefslogtreecommitdiffhomepage
path: root/ir/be/besched.h
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2012-12-14 09:28:56 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2012-12-15 00:09:50 +0100
commitd6ad56f1135216a000cb556c5a32c95e66883cd7 (patch)
treeac4260155f29a173c942b6a2d72808427f636df7 /ir/be/besched.h
parentf7ee5f2c535d6650ecef9af8653dcbf683cc9db2 (diff)
besched: Add and use sched_foreach_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 7b21400..aa8c314 100644
--- a/ir/be/besched.h
+++ b/ir/be/besched.h
@@ -179,6 +179,16 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
sched_foreach_reverse_before((assert(is_Block(block)), block), irn)
/**
+ * A shorthand macro for 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_safe(block, irn) \
+ for (ir_node *irn, *irn##__next = sched_first(block); !sched_is_end(irn = irn##__next) ? irn##__next = sched_next(irn), 1 : 0;)
+
+/**
* Type for a function scheduling a graph
*/
typedef void (*schedule_func) (ir_graph *irg);