Reset link field to NULL on construction
[libfirm] / ir / ir / irgraph_t.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 */
4
5 /**
6 * @file irgraph_t.h
7 *
8 * ir graph construction.
9 *
10 * @author Martin Trapp, Christian Schaefer
11 */
12
13 /* $Id$ */
14
15 # ifndef _IRGRAPH_T_H_
16 # define _IRGRAPH_T_H_
17 # include "obst.h"
18 # include "pset.h"
19 # include "irgraph.h"
20 # include "firm_common_t.h"
21
22 #define FRAME_TP_SUFFIX "frame_tp"
23
24 /** ir_graph holds all information for a procedure */
25 struct ir_graph {
26   firm_kind         kind;            /**<  always set to k_ir_graph*/
27   /* --  Basics of the representation -- */
28   struct entity  *ent;               /**< The entity of this procedure, i.e.,
29                                         the type of the procedure and the
30                                         class it belongs to. */
31   struct type    *frame_type;        /**< A class type representing the stack frame.
32                                         Can include "inner" methods. */
33   struct ir_node *start_block;       /**< block the start node will belong to */
34   struct ir_node *start;             /**< start node of this ir_graph */
35   struct ir_node *end_block;         /**< block the end node will belong to */
36   struct ir_node *end;               /**< end node of this ir_graph */
37   struct ir_node *cstore;            /**< constant store -- no more needed!! */
38   struct ir_node *frame;             /**< method's frame */
39   struct ir_node *globals;           /**< pointer to the data segment containing all
40                                         globals as well as global procedures. */
41   struct ir_node *args;              /**< methods arguments */
42   struct ir_node *bad;               /**< bad node of this ir_graph, the one and
43                                         only in this graph */
44   struct ir_node *unknown;           /**< unknown node of this ir_graph */
45   struct obstack *obst;              /**< obstack where all of the ir_nodes live */
46   struct ir_node *current_block;     /**< block for newly gen_*()-erated
47                                         ir_nodes */
48
49   /* -- Fields indicating different states of irgraph -- */
50   irg_phase_state phase_state;       /**< compiler phase */
51   op_pinned pinned;                  /**< Flag for status of nodes */
52   irg_outs_state outs_state;         /**< Out edges. */
53   irg_dom_state dom_state;           /**< Dominator information */
54
55   /* -- Fields for construction -- */
56 #if USE_EXPLICIT_PHI_IN_STACK
57   struct Phi_in_stack *Phi_in_stack; /**< needed for automatic Phi construction */
58 #endif
59   int n_loc;                         /**< number of local variable in this
60                                         procedure including procedure parameters. */
61
62   /* -- Fields for optimizations / analysis information -- */
63   pset *value_table;                 /**< hash table for global value numbering (cse)
64                                         for optimizing use in iropt.c */
65   struct ir_node **outs;             /**< Space for the out arrays. */
66   struct ir_loop *loop;              /**< The outermost loop */
67   void *link;                        /**< A void* field to link any information to
68                                         the node. */
69
70   /* -- Fields for Walking the graph -- */
71   unsigned long visited;             /**< this flag is an identifier for
72                                         ir walk. it will be incremented
73                                         every time someone walks through
74                                         the graph */
75   unsigned long block_visited;       /**< same as visited, for a complete block */
76 #ifdef DEBUG_libfirm
77   int graph_nr;             /**< a unique graph number for each graph to make output
78                               readable. */
79 #endif
80 };
81
82 void init_irgraph(void);
83
84 /** Make a rudimentary ir graph for the constant code.
85    Must look like a correct irg, spare everything else. */
86 ir_graph *new_const_code_irg(void);
87
88 /**
89  * Set the pinned state of a graph.
90  *
91  * @irg         the IR graph
92  * @p           new pin state
93  */
94 INLINE void
95 set_irg_pinned (ir_graph *irg, op_pinned p);
96
97 /** Returns the obstack associated with the graph. */
98 struct obstack *get_irg_obstack(ir_graph *irg);
99
100 /**
101  * Returns true if the node n is allocated on the storage of graph irg.
102  *
103  * @param irg   the IR graph
104  * @param n     the IR node
105  */
106 int node_is_in_irgs_storage(ir_graph *irg, ir_node *n);
107
108 # endif /* _IRGRAPH_T_H_ */