Added get_irn_edge()
[libfirm] / ir / ir / iredges.h
1
2 /**
3  * Public header for the automatically updating outs.
4  * @author Sebastian Hack
5  * @date 3.2.2005
6  */
7
8 #ifndef _FIRM_EDGES_H
9 #define _FIRM_EDGES_H
10
11 #include "irnode.h"
12
13 #ifndef _IR_EDGE_TYPEDEF_
14 #define _IR_EDGE_TYPEDEF_
15 typedef struct _ir_edge_t ir_edge_t;
16 #endif
17
18 #ifndef _IR_BLOCK_EDGE_TYPEDEF_
19 #define _IR_BLOCK_EDGE_TYPEDEF_
20 typedef struct _ir_block_edge_t ir_block_edge_t;
21 #endif
22
23 /**
24  * Get the first edge pointing to some node.
25  * @note There is no order on out edges. First in this context only
26  * means, that you get some starting point into the list of edges.
27  * @param irn The node.
28  * @return The first out edge that points to this node.
29  */
30 const ir_edge_t *get_irn_out_edge_first(const ir_node *irn);
31
32 /**
33  * Get the next edge in the out list of some node.
34  * @param irn The node.
35  * @param last The last out edge you have seen.
36  * @return The next out edge in @p irn 's out list after @p last.
37  */
38 const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
39                 const ir_edge_t *last);
40
41 /**
42  * A convenience iteration macro over all out edges of a node.
43  * @param irn The node.
44  * @param edge An @c ir_edge_t pointer which shall be set to the current
45  * edge.
46  */
47 #define foreach_out_edge(irn,edge) \
48         for(edge = get_irn_out_edge_first(irn); edge; edge = get_irn_out_edge_next(irn, edge))
49
50 /**
51  * A convenience iteration macro for all control flow edges
52  * leaving a block, and thus are cf successor edges.
53  * @param bl The block.
54  * @param edge An @c ir_edge_t pointer which is set to the current edge.
55  */
56 #define foreach_block_succ(bl,edge) \
57         for(edge = get_block_succ_first(bl); edge; edge = get_block_succ_next(bl, edge))
58
59 /*
60  * Get the source node of an edge.
61  * @param edge The edge.
62  * @return The source node of that edge.
63  */
64 ir_node *get_edge_src_irn(const ir_edge_t *edge);
65
66 /**
67  * Get the number of edges pointing to a node.
68  * @param irn The node.
69  * @return The number of edges pointing to this node.
70  */
71 int get_irn_n_edges(const ir_node *irn);
72
73 /**
74  * Get the position of an edge.
75  * @param edge The edge.
76  * @return The position in the in array of that edges source.
77  */
78 extern int get_edge_src_pos(const ir_edge_t *edge);
79
80 /**
81  * Get the edge object of an outgoing edge at a node.
82  * @param   irg The graph, the node is in.
83  * @param   irn The node at which the edge originates.
84  * @param   pos The position of the edge.
85  * @return      The corresponding edge object or NULL,
86  *              if no such edge exists.
87  */
88 const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *irn, int pos);
89
90 /**
91  * Check, if the out edges are activated.
92  * @param irg The graph.
93  * @return 1, if the edges are present for the given irg, 0 if not.
94  */
95 extern int edges_activated(const ir_graph *irg);
96
97 /**
98  * Activate the edges for an irg.
99  * @param irg The graph to activate the edges for.
100  **/
101 extern void edges_activate(ir_graph *irg);
102
103 /**
104  * Deactivate the edges for an irg.
105  * @param irg The graph.
106  */
107 extern void edges_deactivate(ir_graph *irg);
108
109 #endif /* _FIRM_EDGES_H */