libFirm
iredges.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5 
12 #ifndef FIRM_IR_IREDGES_H
13 #define FIRM_IR_IREDGES_H
14 
15 #include "firm_types.h"
16 #include "iredgekinds.h"
17 #include "begin.h"
18 
33 FIRM_API const ir_edge_t *get_irn_out_edge_first_kind(const ir_node *irn,
34  ir_edge_kind_t kind);
35 
43 FIRM_API const ir_edge_t *get_irn_out_edge_first(const ir_node *irn);
44 
52 FIRM_API const ir_edge_t *get_block_succ_first(const ir_node *block);
53 
61 FIRM_API const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
62  const ir_edge_t *last,
63  ir_edge_kind_t kind);
64 
72 #define foreach_out_edge_kind(irn, edge, kind) \
73  for (ir_edge_t const *edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge, kind))
74 
83 #define foreach_out_edge_kind_safe(irn, edge, kind) \
84  for (ir_edge_t const *edge = get_irn_out_edge_first_kind((irn), (kind)), *edge##__next; edge; edge = edge##__next) \
85  if (edge##__next = get_irn_out_edge_next((irn), edge, (kind)), 0) {} else
86 
90 #define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
91 
95 #define foreach_out_edge_safe(irn, edge) foreach_out_edge_kind_safe(irn, edge, EDGE_KIND_NORMAL)
96 
100 #define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
101 
105 #define foreach_block_succ_safe(bl, edge) foreach_out_edge_kind_safe(bl, edge, EDGE_KIND_BLOCK)
106 
112 FIRM_API ir_node *get_edge_src_irn(const ir_edge_t *edge);
113 
119 FIRM_API int get_edge_src_pos(const ir_edge_t *edge);
120 
126 FIRM_API int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
127 
132 FIRM_API int get_irn_n_edges(const ir_node *irn);
133 
142 FIRM_API int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind);
143 
149 FIRM_API int edges_activated(const ir_graph *irg);
150 
157 FIRM_API void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind);
158 
165 FIRM_API void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind);
166 
174 FIRM_API void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind);
175 
182 FIRM_API void edges_reroute(ir_node *old, ir_node *nw);
183 
188 FIRM_API void edges_reroute_except(ir_node *old, ir_node *nw,
189  ir_node *exception);
190 
195 FIRM_API int edges_verify(ir_graph *irg);
196 
201 FIRM_API int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind);
202 
206 FIRM_API void edges_init_dbg(int do_dbg);
207 
215 FIRM_API void edges_activate(ir_graph *irg);
216 
223 FIRM_API void edges_deactivate(ir_graph *irg);
224 
230 FIRM_API void assure_edges(ir_graph *irg);
231 
238 FIRM_API void assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind);
239 
249 FIRM_API void irg_block_edges_walk(ir_node *block, irg_walk_func *pre,
250  irg_walk_func *post, void *env);
251 
253 FIRM_API void irg_walk_edges(ir_node *start, irg_walk_func *pre,
254  irg_walk_func *post, void *env);
255 
258 #include "end.h"
259 
260 #endif
void irg_block_edges_walk(ir_node *block, irg_walk_func *pre, irg_walk_func *post, void *env)
Walks only over Block nodes in the graph.
void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
Activates the edges for an irg.
void assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind)
Ensures that edges of a given kind are activated.
ir_edge_kind_t
Supported Edge kinds.
Definition: iredgekinds.h:20
void edges_deactivate(ir_graph *irg)
Deactivates data and block edges for an irg.
struct ir_edge_t ir_edge_t
Dynamic Reverse Edge.
Definition: firm_types.h:62
int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind)
Verifies a certrain kind of out edges of graph irg.
const ir_edge_t * get_block_succ_first(const ir_node *block)
Returns the first edge pointing to a successor block.
void irg_walk_edges(ir_node *start, irg_walk_func *pre, irg_walk_func *post, void *env)
Graph walker following EDGE_KIND_NORMAL edges.
int edges_activated(const ir_graph *irg)
Checks if out edges with EDG_KIND_NORMAL and EDGE_KIND_BLOCK are activated.
const ir_edge_t * get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last, ir_edge_kind_t kind)
Returns the next edge in the out list of some node.
int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind)
Checks if the out edges are activated.
void irg_walk_func(ir_node *, void *)
type for graph-walk callbacks
Definition: firm_types.h:94
ir_node * get_edge_src_irn(const ir_edge_t *edge)
Returns the source node of an edge.
void edges_reroute_except(ir_node *old, ir_node *nw, ir_node *exception)
reroutes (normal) edges from an old node to a new node, except for the exception node which keeps its...
int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind)
Returns the number of registered out edges for a specific kind.
int edges_verify(ir_graph *irg)
Verifies the out edges of graph irg.
void assure_edges(ir_graph *irg)
Ensures that edges are activated.
void edges_activate(ir_graph *irg)
Activates data and block edges for an irg.
const ir_edge_t * get_irn_out_edge_first(const ir_node *irn)
Returns the first edge pointing to some node.
void edges_reroute(ir_node *old, ir_node *nw)
Reroutes edges of EDGE_KIND_NORMAL from an old node to a new one.
void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
Deactivates the edges for an irg.
int get_edge_src_pos(const ir_edge_t *edge)
Returns the position of an edge.
void edges_init_dbg(int do_dbg)
Sets edge verification flag.
int get_irn_n_edges(const ir_node *irn)
Returns the number of registered out edges with EDGE_KIND_NORMAL.
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind)
Reroutes edges of a specified kind from an old node to a new one.
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
const ir_edge_t * get_irn_out_edge_first_kind(const ir_node *irn, ir_edge_kind_t kind)
Returns the first edge pointing to some node.