projects
/
libfirm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f7ee5f2
)
besched: Add and use sched_foreach_safe().
author
Christoph Mallon
<christoph.mallon@gmx.de>
Fri, 14 Dec 2012 08:28:56 +0000
(09:28 +0100)
committer
Christoph Mallon
<christoph.mallon@gmx.de>
Fri, 14 Dec 2012 23:09:50 +0000
(
00:09
+0100)
ir/be/bechordal.c
patch
|
blob
|
history
ir/be/beirgmod.c
patch
|
blob
|
history
ir/be/bepbqpcoloring.c
patch
|
blob
|
history
ir/be/besched.h
patch
|
blob
|
history
ir/be/ia32/ia32_finish.c
patch
|
blob
|
history
diff --git
a/ir/be/bechordal.c
b/ir/be/bechordal.c
index
619be70
..
d2bfcae
100644
(file)
--- a/
ir/be/bechordal.c
+++ b/
ir/be/bechordal.c
@@
-275,10
+275,8
@@
end:
static void constraints(ir_node *const bl, void *const data)
{
be_chordal_env_t *const env = (be_chordal_env_t*)data;
static void constraints(ir_node *const bl, void *const data)
{
be_chordal_env_t *const env = (be_chordal_env_t*)data;
- for (ir_node *irn = sched_first(bl); !sched_is_end(irn);) {
- ir_node *const next = sched_next(irn);
+ sched_foreach_safe(bl, irn) {
handle_constraints(env, irn);
handle_constraints(env, irn);
- irn = next;
}
}
}
}
diff --git
a/ir/be/beirgmod.c
b/ir/be/beirgmod.c
index
ea14670
..
aa9b51b
100644
(file)
--- a/
ir/be/beirgmod.c
+++ b/
ir/be/beirgmod.c
@@
-285,12
+285,8
@@
static void mark_dead_nodes_walker(ir_node *node, void *data)
static void remove_dead_nodes_walker(ir_node *block, void *data)
{
remove_dead_nodes_env_t *env = (remove_dead_nodes_env_t*) data;
static void remove_dead_nodes_walker(ir_node *block, void *data)
{
remove_dead_nodes_env_t *env = (remove_dead_nodes_env_t*) data;
- ir_node *node, *next;
-
- for (node = sched_first(block); ! sched_is_end(node); node = next) {
- /* get next node now, as after calling sched_remove it will be invalid */
- next = sched_next(node);
+ sched_foreach_safe(block, node) {
if (bitset_is_set(env->reachable, get_irn_idx(node)))
continue;
if (bitset_is_set(env->reachable, get_irn_idx(node)))
continue;
diff --git
a/ir/be/bepbqpcoloring.c
b/ir/be/bepbqpcoloring.c
index
cdc99e1
..
2411b28
100644
(file)
--- a/
ir/be/bepbqpcoloring.c
+++ b/
ir/be/bepbqpcoloring.c
@@
-540,15
+540,11
@@
static void create_pbqp_coloring_instance(ir_node *block, void *data)
static void insert_perms(ir_node *block, void *data)
{
be_chordal_env_t *env = (be_chordal_env_t*)data;
static void insert_perms(ir_node *block, void *data)
{
be_chordal_env_t *env = (be_chordal_env_t*)data;
- ir_node *irn;
- for (irn = sched_first(block); !sched_is_end(irn);) {
- ir_node *const next = sched_next(irn);
- be_insn_t * insn = be_scan_insn(env, irn);
+ sched_foreach_safe(block, irn) {
+ be_insn_t *insn = be_scan_insn(env, irn);
if (insn)
pre_process_constraints(env, &insn);
if (insn)
pre_process_constraints(env, &insn);
-
- irn = next;
}
}
}
}
diff --git
a/ir/be/besched.h
b/ir/be/besched.h
index
7b21400
..
aa8c314
100644
(file)
--- a/
ir/be/besched.h
+++ b/
ir/be/besched.h
@@
-178,6
+178,16
@@
static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
#define sched_foreach_reverse(block,irn) \
sched_foreach_reverse_before((assert(is_Block(block)), block), irn)
#define sched_foreach_reverse(block,irn) \
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
*/
/**
* Type for a function scheduling a graph
*/
diff --git
a/ir/be/ia32/ia32_finish.c
b/ir/be/ia32/ia32_finish.c
index
72f46b5
..
89c123b
100644
(file)
--- a/
ir/be/ia32/ia32_finish.c
+++ b/
ir/be/ia32/ia32_finish.c
@@
-376,18
+376,14
@@
static void fix_am_source(ir_node *irn)
*/
static void ia32_finish_irg_walker(ir_node *block, void *env)
{
*/
static void ia32_finish_irg_walker(ir_node *block, void *env)
{
- ir_node *irn, *next;
(void) env;
/* first: turn back AM source if necessary */
(void) env;
/* first: turn back AM source if necessary */
- for (irn = sched_first(block); ! sched_is_end(irn); irn = next) {
- next = sched_next(irn);
+ sched_foreach_safe(block, irn) {
fix_am_source(irn);
}
fix_am_source(irn);
}
- for (irn = sched_first(block); ! sched_is_end(irn); irn = next) {
- next = sched_next(irn);
-
+ sched_foreach_safe(block, irn) {
/* check if there is a sub which need to be transformed */
if (is_ia32_Sub(irn) || is_ia32_Sbb(irn) || is_ia32_xSub(irn)) {
ia32_transform_sub_to_neg_add(irn);
/* check if there is a sub which need to be transformed */
if (is_ia32_Sub(irn) || is_ia32_Sbb(irn) || is_ia32_xSub(irn)) {
ia32_transform_sub_to_neg_add(irn);
@@
-395,8
+391,7
@@
static void ia32_finish_irg_walker(ir_node *block, void *env)
}
/* second: insert copies and finish irg */
}
/* second: insert copies and finish irg */
- for (irn = sched_first(block); ! sched_is_end(irn); irn = next) {
- next = sched_next(irn);
+ sched_foreach_safe(block, irn) {
if (is_ia32_irn(irn)) {
/* some nodes are just a bit less efficient, but need no fixing if the
* should be same requirement is not fulfilled */
if (is_ia32_irn(irn)) {
/* some nodes are just a bit less efficient, but need no fixing if the
* should be same requirement is not fulfilled */