2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Compute and access out edges (also called def-use edges).
9 * @author Goetz Lindenmaier, Michael Beck
12 #ifndef FIRM_ANA_IROUTS_H
13 #define FIRM_ANA_IROUTS_H
15 #include "firm_types.h"
20 * @defgroup irout Reverse Edges
21 * Out-Edges are the reverse of the edges in a firm graph (also called def-use
26 /** Returns the number of successors of the node: */
27 FIRM_API unsigned get_irn_n_outs(const ir_node *node);
29 /** Returns the User of a node from the Def-Use edge at position pos. */
30 FIRM_API ir_node *get_irn_out(const ir_node *def, unsigned pos);
33 * Returns the User and its input position from the Def-Use edge of def
36 FIRM_API ir_node *get_irn_out_ex(const ir_node *def, unsigned pos, int *in_pos);
39 * Sets the User at position pos.
41 * @param def the Def node
42 * @param pos the number of the Def-Use edge tat is modified
43 * @param use the Use node
44 * @param in_pos the number of the corresponding Use-Def edge in the use node in array
46 FIRM_API void set_irn_out(ir_node *def, unsigned pos, ir_node *use, int in_pos);
48 /** Returns the number of control flow successors, ignore keep-alives. */
49 FIRM_API unsigned get_Block_n_cfg_outs(const ir_node *node);
51 /** Returns the number of control flow successors, honor keep-alives. */
52 FIRM_API unsigned get_Block_n_cfg_outs_ka(const ir_node *node);
54 /** Access predecessor n, ignore keep-alives. */
55 FIRM_API ir_node *get_Block_cfg_out(const ir_node *node, unsigned pos);
57 /** Access predecessor n, honor keep-alives. */
58 FIRM_API ir_node *get_Block_cfg_out_ka(const ir_node *node, unsigned pos);
61 * Walks over the graph starting at node. Walks also if graph is in state
62 * "outs_inconsistent".
64 FIRM_API void irg_out_walk(ir_node *node, irg_walk_func *pre,
65 irg_walk_func *post, void *env);
68 * Walks only over Block nodes in the graph. Has its own visited
69 * flag, so that it can be interleaved with the other walker.
70 * node must be either op_Block or mode_X.
72 FIRM_API void irg_out_block_walk(ir_node *node, irg_walk_func *pre,
73 irg_walk_func *post, void *env);
76 * Computes the out edges. Sets a flag in irg to "outs_consistent". If the
77 * graph is changed this flag must be set to "outs_inconsistent". Computes
78 * out edges from block to floating nodes even if graph is in state
79 * "op_pin_state_floats". Optimizes Tuple nodes.
81 FIRM_API void compute_irg_outs(ir_graph *irg);
83 /** Recomputes out edges if necessary */
84 FIRM_API void assure_irg_outs(ir_graph *irg);
86 /** Frees memory occupied by out edges datastructures */
87 FIRM_API void free_irg_outs(ir_graph *irg);