3 * File name: ir/ir/iredges_t.h
4 * Purpose: Everlasting outs -- private header.
5 * Author: Sebastian Hack
8 * Copyright: (c) 1998-2005 Universit�t Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
14 * @author Sebastian Hack
18 #ifndef _FIRM_EDGES_T_H
19 #define _FIRM_EDGES_T_H
21 #include "firm_config.h"
28 #include "irgraph_t.h"
32 #if FIRM_EDGES_INPLACE
34 #define DBG_EDGES "edges"
41 long src_nr; /**< The node number of the source node. */
43 ir_node *src; /**< The source node of the edge. */
44 int pos; /**< The position of the edge at @p src. */
45 struct list_head list; /**< The list head to queue all out edges at a node. */
46 unsigned invalid : 1; /**< edges that are removed are marked invalid. */
47 unsigned present : 1; /**< Used by the verifier. Don't rely on its content. */
50 /** Accessor for private irn info. */
51 #define _get_irn_edge_info(irn) ((irn_edge_info_t *) &(irn)->edge_info)
53 /** Accessor for private irg info. */
54 #define _get_irg_edge_info(irg) ((irg_edge_info_t *) &(irg)->edge_info)
57 * Convenience macro to get the outs_head from a irn_edge_info_t
60 #define _get_irn_outs_head(irn) (&_get_irn_edge_info(irn)->outs_head)
63 * Get the first edge pointing to some node.
64 * @note There is no order on out edges. First in this context only
65 * means, that you get some starting point into the list of edges.
66 * @param irn The node.
67 * @return The first out edge that points to this node.
69 static INLINE const ir_edge_t *_get_irn_out_edge_first(const ir_node *irn)
71 struct list_head *head = _get_irn_outs_head(irn);
72 return list_empty(head) ? NULL : list_entry(head->next, ir_edge_t, list);
76 * Get the next edge in the out list of some node.
77 * @param irn The node.
78 * @param last The last out edge you have seen.
79 * @return The next out edge in @p irn 's out list after @p last.
81 static INLINE const ir_edge_t *_get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last)
83 struct list_head *next = last->list.next;
84 return next == _get_irn_outs_head(irn) ? NULL : list_entry(next, ir_edge_t, list);
88 * Get the source node of an edge.
89 * @param edge The edge.
90 * @return The source node of that edge.
92 static INLINE ir_node *_get_edge_src_irn(const ir_edge_t *edge)
94 return edge ? edge->src : NULL;
98 * Get the position of an edge.
100 * @return The position in the in array of that edges source.
102 static INLINE int _get_edge_src_pos(const ir_edge_t *edge)
104 return edge ? edge->pos : -1;
107 static INLINE int _edges_activated(const ir_graph *irg)
109 return _get_irg_edge_info(irg)->activated;
113 * Assure, that the edges information is present for a certain graph.
114 * @param irg The graph.
116 static INLINE void _edges_assure(ir_graph *irg)
118 if(!_edges_activated(irg))
122 void edges_reroute(ir_node *old, ir_node *nw, ir_graph *irg);
124 void edges_init_graph(ir_graph *irg);
126 void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg);
128 void edges_node_deleted(ir_node *old, ir_graph *irg);
130 void edges_invalidate(ir_node *irn, ir_graph *irg);
133 * Initialize the out edges.
134 * This must be called before firm is initialized.
136 extern void init_edges(void);
138 #define get_irn_out_edge_first(irn) _get_irn_out_edge_first(irn)
139 #define get_irn_out_edge_next(irn,last) _get_irn_out_edge_next(irn, last)
140 #define get_edge_src_irn(edge) _get_edge_src_irn(edge)
141 #define get_edge_src_pos(edge) _get_edge_src_pos(edge)
142 #define edges_activated(irg) _edges_activated(irg)
143 #define edges_assure(irg) _edges_assure(irg)
146 /* new edges are disabled */
149 #define edges_reroute(old, nw, irg)
150 #define edges_init_graph(irg);
151 #define edges_notify_edge(src, pos, tgt, old_tgt, irg)
152 #define edges_node_deleted(old, irg)
153 #define edges_invalidate(irn, irg)
154 #define get_irn_out_edge_first(irn) NULL
155 #define get_irn_out_edge_next(irn,last) NULL
156 #define get_edge_src_irn(edge) NULL
157 #define get_edge_src_pos(edge) -1
158 #define edges_activated(irg) 0
159 #define edges_assure(irg)
161 #endif /* FIRM_EDGES_INPLACE */
163 #endif /* _FIRM_EDGES_T_H */