renamed type opcode to ir_opcode
[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-2007 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 _FIRM_IR_IRPROG_T_H_
18 #define _FIRM_IR_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 #include "irmemory.h"
33
34 #include "callgraph.h"
35 #include "field_temperature.h"
36 #include "execution_frequency.h"
37
38 #include "array.h"
39
40 /** ir_prog */
41 struct ir_prog {
42   firm_kind kind;                 /**< must be k_ir_prog */
43   ident     *name;                /**< A file name or the like. */
44   ir_graph  *main_irg;            /**< The entry point to the compiled program
45                                        or NULL if no poit exist. */
46   ir_graph **graphs;              /**< A list of all graphs in the ir. */
47   ir_graph **pseudo_graphs;       /**< A list of all pseudo graphs in the ir. See pseudo_irg.c */
48   ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
49                                        to allocate nodes the represent values
50                                        of constant entities. It is not meant as
51                                        a procedure.  */
52   ir_type   *glob_type;           /**< The global type.  Must be a class as it can
53                                        have fields and procedures.  */
54   ir_type   *tls_type;            /**< The thread local storage type.  Must be a struct as it can
55                                        only have fields.  */
56   ir_type  **types;               /**< A list of all types in the ir. */
57   ir_mode  **modes;               /**< A list of all modes in the ir. */
58   ir_op    **opcodes;             /**< A list of all opcodes in the ir. */
59
60   /* -- states of and access to generated information -- */
61   irg_phase_state phase_state;    /**< The state of construction. */
62
63   ip_view_state ip_view;          /**< The state of interprocedural view. */
64
65   irg_outs_state outs_state;      /**< The state of out edges of ir nodes. */
66   ir_node **ip_outedges;          /**< A huge Array that contains all out edges
67                                        in interprocedural view. */
68   irg_outs_state trouts_state;    /**< The state of out edges of type information. */
69
70   irg_callee_info_state callee_info_state; /**< Validity of callee information.
71                                                 Contains the lowest value or all irgs.  */
72   ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
73   inh_transitive_closure_state inh_trans_closure_state;  /**< trans closure of inh relations. */
74
75   irp_callgraph_state callgraph_state; /**< The state of the callgraph. */
76   ir_loop *outermost_cg_loop;          /**< For callgraph analysis: entry point
77                                             to looptree over callgraph. */
78   int max_callgraph_loop_depth;        /**< needed in callgraph. */
79   int max_callgraph_recursion_depth;   /**< needed in callgraph. */
80   double max_method_execution_frequency;  /**< needed in callgraph. */
81   irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
82   exec_freq_state execfreq_state;        /**< The state of execution frequency information */
83   loop_nesting_depth_state lnd_state;  /**< The state of loop nesting depth information. */
84   ir_class_cast_state class_cast_state;    /**< The state of cast operations in code. */
85   ir_address_taken_computed_state globals_adr_taken_state;  /**< Address taken state of the globals. */
86
87 #ifdef DEBUG_libfirm
88   long max_node_nr;                   /**< to generate unique numbers for nodes. */
89 #endif
90 };
91
92 /** Adds mode to the list of modes in irp. */
93 void  add_irp_mode(ir_mode *mode);
94
95 /* INLINE functions */
96
97 static INLINE ir_type *
98 _get_glob_type(void) {
99   assert(irp);
100   return irp->glob_type = skip_tid(irp->glob_type);
101 }
102
103 static INLINE ir_type *
104 _get_tls_type(void) {
105   assert(irp);
106   return irp->tls_type = skip_tid(irp->tls_type);
107 }
108
109 static INLINE int
110 _get_irp_n_irgs(void) {
111   assert (irp && irp->graphs);
112   if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
113   return ARR_LEN(irp->graphs);
114 }
115
116 static INLINE ir_graph *
117 _get_irp_irg(int pos){
118   if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
119   assert(0 <= pos && pos <= _get_irp_n_irgs());
120   return irp->graphs[pos];
121 }
122
123
124 static INLINE int
125 _get_irp_n_types (void) {
126   assert (irp && irp->types);
127   return ARR_LEN(irp->types);
128 }
129
130 static INLINE ir_type *
131 _get_irp_type(int pos) {
132   assert (irp && irp->types);
133   /* Don't set the skip_tid result so that no double entries are generated. */
134   return skip_tid(irp->types[pos]);
135 }
136
137 static INLINE int
138 _get_irp_n_modes(void) {
139   assert (irp && irp->modes);
140   return ARR_LEN(irp->modes);
141 }
142
143 static INLINE ir_mode *
144 _get_irp_mode(int pos) {
145   assert (irp && irp->modes);
146   return irp->modes[pos];
147 }
148
149 static INLINE int
150 _get_irp_n_opcodes(void) {
151   assert (irp && irp->opcodes);
152   return ARR_LEN(irp->opcodes);
153 }
154
155 static INLINE ir_op *
156 _get_irp_opcode(int pos) {
157   assert (irp && irp->opcodes);
158   return irp->opcodes[pos];
159 }
160
161 #ifdef DEBUG_libfirm
162 /** Returns a new, unique number to number nodes or the like. */
163 static INLINE long
164 get_irp_new_node_nr(void) {
165   assert(irp);
166   return irp->max_node_nr++;
167 }
168 #endif /* DEBUG_libfirm */
169
170 static INLINE ir_graph *
171 _get_const_code_irg(void) {
172   return irp->const_code_irg;
173 }
174
175 void           set_irp_ip_outedges(ir_node ** ip_outedges);
176 ir_node**      get_irp_ip_outedges(void);
177
178 /** initializes ir_prog. Constructs only the basic lists */
179 void init_irprog_1(void);
180
181 /** Completes ir_prog. */
182 void init_irprog_2(void);
183
184 #define get_irp_n_irgs()       _get_irp_n_irgs()
185 #define get_irp_irg(pos)       _get_irp_irg(pos)
186 #define get_irp_n_types()      _get_irp_n_types()
187 #define get_irp_type(pos)      _get_irp_type(pos)
188 #define get_irp_n_modes()      _get_irp_n_modes()
189 #define get_irp_mode(pos)      _get_irp_mode(pos)
190 #define get_irp_n_opcodes()    _get_irp_n_opcodes()
191 #define get_irp_opcode(pos)    _get_irp_opcode(pos)
192 #define get_const_code_irg()   _get_const_code_irg()
193 #define get_glob_type()        _get_glob_type()
194 #define get_tls_type()         _get_tls_type()
195
196 #endif /* ifndef _FIRM_IR_IRPROG_T_H_ */