3ddbd2edd80ed56f4e409de69e8e7ad2645912f3
[libfirm] / ir / ana / irouts.h
1 /* Copyright (C) 2002 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Goetz Lindenmaier
5 **
6 **  irouts.h:  Implements Def-Use edges, also called outedges.
7 **  @@@ eventually add reverse conrtol flow graph. (If needed.)
8 */
9
10 /* $Id$ */
11
12 # ifndef _IROUTS_H_
13 # define _IROUTS_H_
14
15 # include "irgraph.h"
16 # include "irnode.h"
17
18 /**********************************************************************/
19 /** Accessing the out datastructures.                                **/
20 /** These routines only work properly if the ir_graph is in state    **/
21 /** outs_consistent or outs_inconsistent.                            **/
22 /**********************************************************************/
23
24 /* To iterate through the successors iterate from 0 to i < get_irn_outs(). No
25    order of successors guaranteed.  Will return edges from block to floating
26    nodes even if irgraph is in state "floats". */
27 /* returns the number of successors of the node: */
28 int             get_irn_n_outs (ir_node *node);
29 /* Access predecessor n */
30 INLINE ir_node *get_irn_out  (ir_node *node, int pos);
31 INLINE void     set_irn_out  (ir_node *node, int pos, ir_node *out);
32
33 /* Methods to iterate through the control flow graph. Iterate from 0 to
34    i < get_Block_cfg_outs(block). No order of successors guaranteed. */
35 int             get_Block_n_cfg_outs (ir_node *node);
36 /* Access predecessor n. */
37 INLINE ir_node *get_Block_cfg_out  (ir_node *node, int pos);
38
39 #ifndef _IRG_WALK_FUNC_TYPEDEF_
40 #define _IRG_WALK_FUNC_TYPEDEF_
41 typedef void (irg_walk_func)(ir_node *, void *);
42 #endif
43
44 /* Walks over the graph starting at node.  Walks also if graph is in state
45    "outs_inconsistent".  Assumes current_ir_graph is set properly. */
46 void irg_out_walk(ir_node *node,
47                   irg_walk_func *pre, irg_walk_func *post,
48                   void *env);
49
50 /* Walks only over Block nodes in the graph.  Has it's own visited
51    flag, so that it can be interleaved with the other walker.
52    node must be either op_Block or mode_X.  */
53 void irg_out_block_walk(ir_node *node,
54                         irg_walk_func *pre, irg_walk_func *post,
55                         void *env);
56
57 /**********************************************************************/
58 /* Building and Removing the out datasturcture                       **/
59 /**********************************************************************/
60
61 /* Computes the out edges.  Sets a flag in irg to "outs_consistent".  If the
62    graph is changed this flag must be set to "outs_inconsistent".  Computes
63    out edges from block to floating nodes even if graph is in state
64    "floats".   Optimizes Tuple nodes. */
65 void compute_outs(ir_graph *irg);
66 /* Frees the out datastructures.  Sets the flag in irg to "no_outs". */
67 void free_outs(ir_graph *irg);
68
69 #endif /* _IROUTS_H_ */