3f3bf9c5d08c4e107624857a862274c9c85d3652
[libfirm] / ir / be / besched.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /*
21  * Scheduling utilities for nodes in Blocks and Blocks.
22  *
23  * $Id$
24  */
25 #ifndef _BESCHED_H
26 #define _BESCHED_H
27
28 #include <stdio.h>
29
30 #include "firm_types.h"
31
32 void be_sched_dump(FILE *f, ir_graph *irg);
33
34 int     sched_get_time_step(const ir_node *irn);
35 int     sched_has_next(const ir_node *irn);
36 int     sched_has_prev(const ir_node *irn);
37 int     sched_is_scheduled(const ir_node *irn);
38 ir_node *sched_next(const ir_node *irn);
39 ir_node *sched_prev(const ir_node *irn);
40 ir_node *sched_first(const ir_node *block);
41 ir_node *sched_last(const ir_node *block);
42 ir_node *sched_add_before(ir_node *before, ir_node *irn);
43 ir_node *sched_add_after(ir_node *before, ir_node *irn);
44 void    sched_init_block(ir_node *block);
45 void    sched_reset(ir_node *node);
46 void    sched_remove(ir_node *irn);
47
48 #define sched_is_end(irn) is_Block(irn)
49 #define sched_is_begin(irn) is_Block(irn)
50
51 #define sched_foreach_from(from, irn) \
52   for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
53
54 #define sched_foreach_reverse_from(from, irn) \
55   for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
56
57 /**
58  * A shorthand macro for iterating over a schedule.
59  * @param block The block.
60  * @param irn A ir node pointer used as an iterator.
61  */
62 #define sched_foreach(block,irn) \
63         sched_foreach_from(sched_first(block), irn)
64
65 /**
66  * A shorthand macro for reversely iterating over a schedule.
67  * @param block The block.
68  * @param irn A ir node pointer used as an iterator.
69  */
70 #define sched_foreach_reverse(block,irn) \
71   sched_foreach_reverse_from(sched_last(block), irn)
72
73 /**
74  * Removes dead nodes from schedule
75  * @param irg  the graph
76  */
77 void be_remove_dead_nodes_from_schedule(ir_graph *irg);
78
79 #endif /* _BESCHED_H */