irop: Constify get_op_ops().
[libfirm] / include / libfirm / irouts.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Compute and access out edges (also called def-use edges).
9  * @author   Goetz Lindenmaier, Michael Beck
10  * @date     1.2002
11  */
12 #ifndef FIRM_ANA_IROUTS_H
13 #define FIRM_ANA_IROUTS_H
14
15 #include "firm_types.h"
16 #include "begin.h"
17
18 /**
19  * @ingroup irana
20  * @defgroup irout Reverse Edges
21  * Out-Edges are the reverse of the edges in a firm graph (also called def-use
22  * edges)
23  * @{
24  */
25
26 /** Returns the number of successors of the node: */
27 FIRM_API unsigned get_irn_n_outs(const ir_node *node);
28
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);
31
32 /**
33  * Returns the User and its input position from the Def-Use edge of def
34  * at position pos.
35  */
36 FIRM_API ir_node *get_irn_out_ex(const ir_node *def, unsigned pos, int *in_pos);
37
38 /**
39  * Sets the User at position pos.
40  *
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
45  */
46 FIRM_API void set_irn_out(ir_node *def, unsigned pos, ir_node *use, int in_pos);
47
48 /** Returns the number of control flow successors, ignore keep-alives. */
49 FIRM_API unsigned get_Block_n_cfg_outs(const ir_node *node);
50
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);
53
54 /** Access predecessor n, ignore keep-alives. */
55 FIRM_API ir_node *get_Block_cfg_out(const ir_node *node, unsigned pos);
56
57 /** Access predecessor n, honor keep-alives. */
58 FIRM_API ir_node *get_Block_cfg_out_ka(const ir_node *node, unsigned pos);
59
60 /**
61  * Walks over the graph starting at node.  Walks also if graph is in state
62  * "outs_inconsistent".
63  */
64 FIRM_API void irg_out_walk(ir_node *node, irg_walk_func *pre,
65                            irg_walk_func *post, void *env);
66
67 /**
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.
71  */
72 FIRM_API void irg_out_block_walk(ir_node *node, irg_walk_func *pre,
73                                  irg_walk_func *post, void *env);
74
75 /**
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.
80  */
81 FIRM_API void compute_irg_outs(ir_graph *irg);
82
83 /** Recomputes out edges if necessary */
84 FIRM_API void assure_irg_outs(ir_graph *irg);
85
86 /** Frees memory occupied by out edges datastructures */
87 FIRM_API void free_irg_outs(ir_graph *irg);
88
89 /** @} */
90
91 #include "end.h"
92
93 #endif