2c06cd9b4ec4b42df5d9ecbc20b1279e34c165aa
[libfirm] / ir / ir / irprog_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irprog_t.h
4  * Purpose:     Entry point to the representation of a whole program 0-- private header.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     2000
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2000-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irprog_t.h
15  */
16
17 #ifndef _IRPROG_T_H_
18 #define _IRPROG_T_H_
19
20 #ifdef HAVE_CONFIG_H
21 #include "firm_config.h"
22 #endif
23
24 #include "irprog.h"
25 #include "irgraph.h"
26 #include "pseudo_irg.h"
27 #include "ircgcons.h"
28 #include "firm_common_t.h"
29 #include "typegmod.h"
30 #include "irtypeinfo.h"
31 #include "tr_inheritance.h"
32
33 #include "callgraph.h"
34 #include "field_temperature.h"
35 #include "execution_frequency.h"
36
37 #include "array.h"
38
39 /** ir_prog */
40 struct ir_prog {
41   firm_kind kind;                 /**< must be k_ir_prog */
42   ident     *name;                /**< A file name or the like. */
43   ir_graph  *main_irg;            /**< entry point to the compiled program
44                                        @@@ or a list, in case we compile a library or the like? */
45   ir_graph **graphs;              /**< all graphs in the ir */
46   ir_graph **pseudo_graphs;       /**< all pseudo graphs in the ir. See pseudo_irg.c */
47   ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
48                                        to allocate nodes the represent values
49                                        of constant entities. It is not meant as
50                                        a procedure.  */
51   type      *glob_type;           /**< global type.  Must be a class as it can
52                                        have fields and procedures.  */
53   type     **types;               /**< all types in the ir */
54   ir_mode  **modes;               /**< all modes in the ir */
55
56   /* -- states of and access to generated information -- */
57   irg_phase_state phase_state;    /**< State of construction. */
58
59   ip_view_state ip_view;          /**< State of interprocedural view. */
60
61   irg_outs_state outs_state;      /**< State of out edges of ir nodes. */
62   ir_node **ip_outedges;          /**< Huge Array that contains all out edges
63                                        in interprocedural view. */
64   irg_outs_state trouts_state;    /**< State of out edges of type information. */
65
66   irg_callee_info_state callee_info_state; /**< Validity of callee information.
67                                               Contains the lowest value or all irgs.  */
68   ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
69   inh_transitive_closure_state inh_trans_closure_state;  /**< trans closure of inh relations. */
70
71   irp_callgraph_state callgraph_state; /**< State of the callgraph. */
72   struct ir_loop *outermost_cg_loop;   /**< For callgraph analysis: entry point
73                                             to looptree over callgraph. */
74   int max_callgraph_loop_depth;        /**< needed in callgraph. */
75   int max_callgraph_recursion_depth;   /**< needed in callgraph. */
76   double max_method_execution_frequency;  /**< needed in callgraph. */
77   irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
78   exec_freq_state execfreq_state;        /**< State of execution freqency information */
79   loop_nesting_depth_state lnd_state;  /**< State of loop nesting depth information. */
80   ir_class_cast_state class_cast_state;    /**< kind of cast operations in code. */
81
82 #ifdef DEBUG_libfirm
83   long max_node_nr;                /**< to generate unique numbers for nodes. */
84 #endif
85 };
86
87 /** Adds mode to the list of modes in irp. */
88 void  add_irp_mode(ir_mode *mode);
89
90 /* INLINE functions */
91
92 static INLINE type *
93 _get_glob_type(void) {
94   assert(irp);
95   return irp->glob_type = skip_tid(irp->glob_type);
96 }
97
98 static INLINE int
99 _get_irp_n_irgs(void) {
100   assert (irp && irp->graphs);
101   if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
102   return ARR_LEN(irp->graphs);
103 }
104
105 static INLINE ir_graph *
106 _get_irp_irg(int pos){
107   if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
108   assert(0 <= pos && pos <= get_irp_n_irgs());
109   return irp->graphs[pos];
110 }
111
112
113 static INLINE int
114 _get_irp_n_types (void) {
115   assert (irp && irp->types);
116   return ARR_LEN(irp->types);
117 }
118
119 static INLINE type *
120 _get_irp_type(int pos) {
121   assert (irp && irp->types);
122   /* Don't set the skip_tid result so that no double entries are generated. */
123   return skip_tid(irp->types[pos]);
124 }
125
126 static INLINE int
127 _get_irp_n_modes(void) {
128   assert (irp && irp->modes);
129   return ARR_LEN(irp->modes);
130 }
131
132 static INLINE ir_mode *
133 _get_irp_mode(int pos) {
134   assert (irp && irp->modes);
135   return irp->modes[pos];
136 }
137
138 #ifdef DEBUG_libfirm
139 /** Returns a new, unique number to number nodes or the like. */
140 int get_irp_new_node_nr(void);
141 #endif
142
143 static INLINE ir_graph *
144 _get_const_code_irg(void) {
145   return irp->const_code_irg;
146 }
147
148 void           set_irp_ip_outedges(ir_node ** ip_outedges);
149 ir_node**      get_irp_ip_outedges(void);
150
151 /** initializes ir_prog. Constructs only the basic lists */
152 void init_irprog_1(void);
153
154 /** Completes ir_prog. */
155 void init_irprog_2(void);
156
157 #define get_irp_n_irgs()       _get_irp_n_irgs()
158 #define get_irp_irg(pos)       _get_irp_irg(pos)
159 #define get_irp_n_types()      _get_irp_n_types()
160 #define get_irp_type(pos)      _get_irp_type(pos)
161 #define get_irp_n_modes()      _get_irp_n_modes()
162 #define get_irp_mode(pos)      _get_irp_mode(pos)
163 #define get_const_code_irg()   _get_const_code_irg()
164 #define get_glob_type()        _get_glob_type()
165
166 #endif /* ifndef _IRPROG_T_H_ */