added doxygen comments
[libfirm] / ir / ir / iredges_t.h
1
2 /**
3  * everlasting outs.
4  * @author Sebastian Hack
5  * @date 15.1.2005
6  */
7
8 #ifndef _FIRM_EDGES_T_H
9 #define _FIRM_EDGES_T_H
10
11 #include "config.h"
12 #include "debug.h"
13
14 #include "set.h"
15 #include "list.h"
16
17 #include "irnode_t.h"
18 #include "irgraph_t.h"
19
20 #include "iredges.h"
21
22 #define DBG_EDGES                               "edges"
23
24 /**
25  * An edge.
26  */
27 typedef struct _ir_edge_t {
28 #ifdef DEBUG_libfirm
29         long src_nr;                                            /**< The node number of the source node. */
30 #endif
31          ir_node *src;          /**< The source node of the edge. */
32         int pos;                                                                /**< The position of the edge at @p src. */
33         struct list_head list;  /**< The list head to queue all out edges at a node. */
34         unsigned invalid : 1;           /**< edges that are removed are marked invalid. */
35         unsigned present : 1;           /**< Used by the verifier. Don't rely on its content. */
36 } ir_edge_t;
37
38 /** Accessor for private irn info. */
39 #define _get_irn_edge_info(irn) ((irn_edge_info_t *) &(irn)->edge_info)
40
41 /** Accessor for private irg info. */
42 #define _get_irg_edge_info(irg) ((irg_edge_info_t *) &(irg)->edge_info)
43
44 /**
45  * Convenience macro to get the outs_head from a irn_edge_info_t
46  * struct.
47  */
48 #define _get_irn_outs_head(irn) (&_get_irn_edge_info(irn)->outs_head)
49
50 /**
51  * Get the first edge pointing to some node.
52  * @note There is no order on out edges. First in this context only
53  * means, that you get some starting point into the list of edges.
54  * @param irn The node.
55  * @return The first out edge that points to this node.
56  */
57 static INLINE const ir_edge_t *_get_irn_out_edge_first(const ir_node *irn)
58 {
59         struct list_head *head = _get_irn_outs_head(irn);
60         return list_empty(head) ? NULL : list_entry(head->next, ir_edge_t, list);
61 }
62
63 /**
64  * Get the next edge in the out list of some node.
65  * @param irn The node.
66  * @param last The last out edge you have seen.
67  * @return The next out edge in @p irn 's out list after @p last.
68  */
69 static INLINE const ir_edge_t *_get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last)
70 {
71         struct list_head *next = last->list.next;
72         return next == _get_irn_outs_head(irn) ? NULL : list_entry(next, ir_edge_t, list);
73 }
74
75 /**
76  * A convenience iteration macro over all out edges of a node.
77  * @param irn The node.
78  * @param edge An @c ir_edge_t pointer which shall be set to the current
79  * edge.
80  */
81 #define foreach_out_edge(irn,edge) \
82         for(edge = get_irn_out_edge_first(irn); edge; edge = get_irn_out_edge_next(irn, edge))
83
84 /**
85  * Get the source node of an edge.
86  * @param edge The edge.
87  * @return The source node of that edge.
88  */
89 static INLINE  ir_node *_get_edge_src_irn(const ir_edge_t *edge)
90 {
91         return edge ? edge->src : NULL;
92 }
93
94 /**
95  * Get the position of an edge.
96  * @param edge.
97  * @return The position in the in array of that edges source.
98  */
99 static INLINE int _get_edge_src_pos(const ir_edge_t *edge)
100 {
101         return edge ? edge->pos : -1;
102 }
103
104 static INLINE int _edges_activated(const ir_graph *irg)
105 {
106         return _get_irg_edge_info(irg)->activated;
107 }
108
109 void edges_reroute(ir_node *old, ir_node *nw, ir_graph *irg);
110
111 void edges_init_graph(ir_graph *irg);
112
113 void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg);
114
115 void edges_node_deleted(ir_node *old, ir_graph *irg);
116
117 void edges_invalidate(ir_node *irn, ir_graph *irg);
118
119 /**
120  * Initialize the out edges.
121  * This must be called before firm is initialized.
122  */
123 extern void init_edges(void);
124
125 #define get_irn_out_edge_first(irn)                                     _get_irn_out_edge_first(irn)
126 #define get_irn_out_edge_next(irn,last)                 _get_irn_out_edge_next(irn, last)
127 #define get_edge_src_irn(edge)                                                  _get_edge_src_irn(edge)
128 #define get_edge_src_pos(edge)                                                  _get_edge_src_pos(edge)
129 #define edges_activated(irg)                                                            _edges_activated(irg)
130
131 #endif /* _FIRM_EDGES_T_H */