typo fixed
[libfirm] / ir / be / besched.h
1 /*
2  * Copyright (C) 1995-2008 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  * @file
22  * @brief       Scheduling utilities for nodes in Blocks and Blocks.
23  * @author      Sebastian Hack
24  * @version     $Id$
25  */
26 #ifndef FIRM_BE_BESCHED_H
27 #define FIRM_BE_BESCHED_H
28
29 #include <stdio.h>
30
31 #include "irgraph.h"
32 #include "irnode.h"
33 #include "beirg.h"
34
35 void be_sched_dump(FILE *f, ir_graph *irg);
36
37 /**
38  * returns the time step of a node. Each node in a block has a timestep
39  * unique to that block. a node schedule before another node has a lower
40  * timestep than this node.
41  */
42 int     have_sched_info(const ir_graph *irg);
43 int     sched_get_time_step(const ir_node *irn);
44 int     sched_has_next(const ir_node *irn);
45 int     sched_has_prev(const ir_node *irn);
46 int     sched_is_scheduled(const ir_node *irn);
47 ir_node *sched_next(const ir_node *irn);
48 ir_node *sched_prev(const ir_node *irn);
49 ir_node *sched_first(const ir_node *block);
50 ir_node *sched_last(const ir_node *block);
51 void    sched_add_before(const ir_node *before, const ir_node *irn);
52 void    sched_add_after(const ir_node *after, const ir_node *irn);
53 void    sched_init_block(const ir_node *block);
54 void    sched_reset(const ir_node *node);
55 void    sched_remove(const ir_node *irn);
56
57 #define sched_is_end(irn) is_Block(irn)
58 #define sched_is_begin(irn) is_Block(irn)
59
60 #define sched_foreach_from(from, irn) \
61   for(irn = from; !sched_is_end(irn); irn = sched_next(irn))
62
63 #define sched_foreach_reverse_from(from, irn) \
64   for(irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
65
66 /**
67  * A shorthand macro for iterating over a schedule.
68  * @param block The block.
69  * @param irn A ir node pointer used as an iterator.
70  */
71 #define sched_foreach(block,irn) \
72         sched_foreach_from(sched_first(block), irn)
73
74 /**
75  * A shorthand macro for reversely iterating over a schedule.
76  * @param block The block.
77  * @param irn A ir node pointer used as an iterator.
78  */
79 #define sched_foreach_reverse(block,irn) \
80   sched_foreach_reverse_from(sched_last(block), irn)
81
82 /**
83  * Removes dead nodes from schedule
84  * @param irg  the graph
85  */
86 void be_remove_dead_nodes_from_schedule(be_irg_t *birg);
87
88 void be_sched_init_phase(ir_graph *irg);
89 void be_sched_free_phase(ir_graph *irg);
90
91 #endif /* FIRM_BE_BESCHED_H */