X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2Fbesched.h;h=eb7907d1f80e3c93df88fa2d5956efd8d02e1484;hb=493edb72be97161f5c8762e4589631a6e7083a29;hp=b598ce5e0c8142bc05ecc50530ea1105316ccd4e;hpb=ca26a6bf21156ce99faccae1f8522e463a190cc9;p=libfirm diff --git a/ir/be/besched.h b/ir/be/besched.h index b598ce5e0..eb7907d1f 100644 --- a/ir/be/besched.h +++ b/ir/be/besched.h @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -152,6 +138,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. @@ -165,11 +156,11 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2) return sched_get_time_step(n1) < sched_get_time_step(n2); } -#define sched_foreach_from(from, irn) \ - for (ir_node *irn = from; !sched_is_end(irn); irn = sched_next(irn)) +#define sched_foreach_after(after, irn) \ + for (ir_node *irn = (after); !sched_is_end(irn = sched_next(irn));) -#define sched_foreach_reverse_from(from, irn) \ - for (ir_node *irn = from; !sched_is_begin(irn); irn = sched_prev(irn)) +#define sched_foreach_reverse_before(before, irn) \ + for (ir_node *irn = (before); !sched_is_begin(irn = sched_prev(irn));) /** * A shorthand macro for iterating over a schedule. @@ -177,7 +168,7 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2) * @param irn A ir node pointer used as an iterator. */ #define sched_foreach(block,irn) \ - sched_foreach_from(sched_first(block), irn) + sched_foreach_after((assert(is_Block(block)), block), irn) /** * A shorthand macro for reversely iterating over a schedule. @@ -185,7 +176,27 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2) * @param irn A ir node pointer used as an iterator. */ #define sched_foreach_reverse(block,irn) \ - sched_foreach_reverse_from(sched_last(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;) + +/** + * 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