3 * File name: ir/ir/iredges.h
4 * Purpose: Public header for the automatically updating outs.
5 * Author: Sebastian Hack
8 * Copyright: (c) 1998-2005 Universität Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
13 * Public header for the automatically updating outs.
14 * @author Sebastian Hack
21 #include "firm_types.h"
23 #ifndef _IR_EDGE_TYPEDEF_
24 #define _IR_EDGE_TYPEDEF_
25 typedef struct _ir_edge_t ir_edge_t;
28 #ifndef _IR_BLOCK_EDGE_TYPEDEF_
29 #define _IR_BLOCK_EDGE_TYPEDEF_
30 typedef struct _ir_block_edge_t ir_block_edge_t;
34 * Get the first edge pointing to some node.
35 * @note There is no order on out edges. First in this context only
36 * means, that you get some starting point into the list of edges.
37 * @param irn The node.
38 * @return The first out edge that points to this node.
40 const ir_edge_t *get_irn_out_edge_first(const ir_node *irn);
43 * Get the next edge in the out list of some node.
44 * @param irn The node.
45 * @param last The last out edge you have seen.
46 * @return The next out edge in @p irn 's out list after @p last.
48 const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
49 const ir_edge_t *last);
52 * A convenience iteration macro over all out edges of a node.
53 * @param irn The node.
54 * @param edge An ir_edge_t pointer which shall be set to the current
57 #define foreach_out_edge(irn,edge) \
58 for(edge = get_irn_out_edge_first(irn); edge; edge = get_irn_out_edge_next(irn, edge))
61 * A convenience iteration macro over all out edges of a node, which is safe
62 * against alteration of the current edge.
64 * @param irn The node.
65 * @param edge An ir_edge_t pointer which shall be set to the current
67 * @param ne The next edge, enables alteration safe edge processing.
69 #define foreach_out_edge_safe(irn,edge,ne) \
71 (edge) = (get_irn_out_edge_first(irn)), \
72 (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL); \
74 (edge) = (ne), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL) \
79 * A convenience iteration macro for all control flow edges
80 * leaving a block, and thus are cf successor edges.
81 * @param bl The block.
82 * @param edge An @c ir_edge_t pointer which is set to the current edge.
84 #define foreach_block_succ(bl,edge) \
85 for(edge = get_block_succ_first(bl); edge; edge = get_block_succ_next(bl, edge))
88 * Get the source node of an edge.
89 * @param edge The edge.
90 * @return The source node of that edge.
92 ir_node *get_edge_src_irn(const ir_edge_t *edge);
95 * Get the number of edges pointing to a node.
96 * @param irn The node.
97 * @return The number of edges pointing to this node.
99 int get_irn_n_edges(const ir_node *irn);
102 * Get the position of an edge.
103 * @param edge The edge.
104 * @return The position in the in array of that edges source.
106 extern int get_edge_src_pos(const ir_edge_t *edge);
109 * Get the edge object of an outgoing edge at a node.
110 * @param irg The graph, the node is in.
111 * @param irn The node at which the edge originates.
112 * @param pos The position of the edge.
113 * @return The corresponding edge object or NULL,
114 * if no such edge exists.
116 const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *irn, int pos);
119 * Check, if the out edges are activated.
120 * @param irg The graph.
121 * @return 1, if the edges are present for the given irg, 0 if not.
123 extern int edges_activated(const ir_graph *irg);
126 * Activate the edges for an irg.
127 * @param irg The graph to activate the edges for.
129 extern void edges_activate(ir_graph *irg);
132 * Deactivate the edges for an irg.
133 * @param irg The graph.
135 extern void edges_deactivate(ir_graph *irg);
137 #endif /* _FIRM_EDGES_H */