Commit b7908561 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

besched: Add and use sched_foreach_reverse_safe().

parent d6ad56f1
......@@ -166,12 +166,9 @@ static void transform_Spill(ir_node *node)
static void amd64_after_ra_walker(ir_node *block, void *data)
{
ir_node *node, *prev;
(void) data;
for (node = sched_last(block); !sched_is_begin(node); node = prev) {
prev = sched_prev(node);
sched_foreach_reverse_safe(block, node) {
if (be_is_Reload(node)) {
transform_Reload(node);
} else if (be_is_Spill(node)) {
......
......@@ -209,12 +209,9 @@ static void transform_Spill(ir_node *node)
static void arm_after_ra_walker(ir_node *block, void *data)
{
ir_node *node, *prev;
(void) data;
for (node = sched_last(block); !sched_is_begin(node); node = prev) {
prev = sched_prev(node);
sched_foreach_reverse_safe(block, node) {
if (be_is_Reload(node)) {
transform_Reload(node);
} else if (be_is_Spill(node)) {
......
......@@ -188,6 +188,16 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
#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;)
/**
* 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
*/
......
......@@ -893,13 +893,10 @@ static void transform_MemPerm(ir_node *node)
*/
static void ia32_after_ra_walker(ir_node *block, void *env)
{
ir_node *node, *prev;
(void) env;
/* beware: the schedule is changed here */
for (node = sched_last(block); !sched_is_begin(node); node = prev) {
prev = sched_prev(node);
sched_foreach_reverse_safe(block, node) {
if (be_is_Reload(node)) {
transform_to_Load(node);
} else if (be_is_Spill(node)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment