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 
18 #include "begin.h"
19 
34 FIRM_API const ir_edge_t *get_irn_out_edge_first_kind(const ir_node *irn,
35  ir_edge_kind_t kind);
36 
44 FIRM_API const ir_edge_t *get_irn_out_edge_first(const ir_node *irn);
45 
53 FIRM_API const ir_edge_t *get_block_succ_first(const ir_node *block);
54 
62 FIRM_API const ir_edge_t *get_irn_out_edge_next(const ir_node *irn,
63  const ir_edge_t *last,
64  ir_edge_kind_t kind);
65 
73 #define foreach_out_edge_kind(irn, edge, kind) \
74  for (ir_edge_t const *edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge, kind))
75 
84 #define foreach_out_edge_kind_safe(irn, edge, kind) \
85  for (ir_edge_t const *edge = get_irn_out_edge_first_kind((irn), (kind)), *edge##__next; edge; edge = edge##__next) \
86  if (edge##__next = get_irn_out_edge_next((irn), edge, (kind)), 0) {} else
87 
91 #define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
92 
96 #define foreach_out_edge_safe(irn, edge) foreach_out_edge_kind_safe(irn, edge, EDGE_KIND_NORMAL)
97 
101 #define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
102 
106 #define foreach_block_succ_safe(bl, edge) foreach_out_edge_kind_safe(bl, edge, EDGE_KIND_BLOCK)
107 
113 FIRM_API ir_node *get_edge_src_irn(const ir_edge_t *edge);
114 
120 FIRM_API int get_edge_src_pos(const ir_edge_t *edge);
121 
127 FIRM_API int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
128 
133 FIRM_API int get_irn_n_edges(const ir_node *irn);
134 
143 FIRM_API int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind);
144 
150 FIRM_API int edges_activated(const ir_graph *irg);
151 
158 FIRM_API void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind);
159 
166 FIRM_API void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind);
167 
175 FIRM_API void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind);
176 
183 FIRM_API void edges_reroute(ir_node *old, ir_node *nw);
184 
189 FIRM_API void edges_reroute_except(ir_node *old, ir_node *nw,
190  ir_node *exception);
191 
196 FIRM_API int edges_verify(ir_graph *irg);
197 
202 FIRM_API int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind);
203 
207 FIRM_API void edges_init_dbg(int do_dbg);
208 
216 FIRM_API void edges_activate(ir_graph *irg);
217 
224 FIRM_API void edges_deactivate(ir_graph *irg);
225 
231 FIRM_API void assure_edges(ir_graph *irg);
232 
239 FIRM_API void assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind);
240 
250 FIRM_API void irg_block_edges_walk(ir_node *block, irg_walk_func *pre,
251  irg_walk_func *post, void *env);
252 
254 FIRM_API void irg_walk_edges(ir_node *start, irg_walk_func *pre,
255  irg_walk_func *post, void *env);
256 
259 #include "end.h"
260 
261 #endif
ir_node * get_edge_src_irn(const ir_edge_t *edge)
Returns the source node of an edge.
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.
const ir_edge_t * get_block_succ_first(const ir_node *block)
Returns the first edge pointing to a successor block.
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
void irg_walk_func(ir_node *, void *)
type for graph-walk callbacks
Definition: firm_types.h:97
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 assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind)
Ensures that edges of a given kind are activated.
int get_edge_src_pos(const ir_edge_t *edge)
Returns the position of an edge.
void edges_activate(ir_graph *irg)
Activates data and block edges for an irg.
void edges_init_dbg(int do_dbg)
Sets edge verification flag.
void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
Deactivates the edges for an irg.
int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind)
Verifies a certrain kind of out edges of graph irg.
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
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.
const ir_edge_t * get_irn_out_edge_first(const ir_node *irn)
Returns the first edge pointing to some node.
int get_irn_n_edges(const ir_node *irn)
Returns the number of registered out edges with EDGE_KIND_NORMAL.
ir_edge_kind_t
Supported Edge kinds.
Definition: iredgekinds.h:22
int edges_activated(const ir_graph *irg)
Checks if out edges with EDG_KIND_NORMAL and EDGE_KIND_BLOCK are activated.
void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
Activates the edges for an irg.
void irg_walk_edges(ir_node *start, irg_walk_func *pre, irg_walk_func *post, void *env)
Graph walker following EDGE_KIND_NORMAL edges.
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.
void edges_reroute(ir_node *old, ir_node *nw)
Reroutes edges of EDGE_KIND_NORMAL from an old node to a new one.
int edges_verify(ir_graph *irg)
Verifies the out edges of graph irg.
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 edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind)
Checks if the out edges are activated.
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
void assure_edges(ir_graph *irg)
Ensures that edges are activated.
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.