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