2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * File name: ir/ir/irprog_t.h
23 * Purpose: Entry point to the representation of a whole program 0-- private header.
24 * Author: Goetz Lindenmaier
28 * Copyright: (c) 2000-2007 Universität Karlsruhe
35 #ifndef _FIRM_IR_IRPROG_T_H_
36 #define _FIRM_IR_IRPROG_T_H_
39 #include "firm_config.h"
44 #include "pseudo_irg.h"
46 #include "firm_common_t.h"
48 #include "irtypeinfo.h"
49 #include "tr_inheritance.h"
52 #include "callgraph.h"
53 #include "field_temperature.h"
54 #include "execution_frequency.h"
60 firm_kind kind; /**< must be k_ir_prog */
61 ident *name; /**< A file name or the like. */
62 ir_graph *main_irg; /**< The entry point to the compiled program
63 or NULL if no poit exist. */
64 ir_graph **graphs; /**< A list of all graphs in the ir. */
65 ir_graph **pseudo_graphs; /**< A list of all pseudo graphs in the ir. See pseudo_irg.c */
66 ir_graph *const_code_irg; /**< This ir graph gives the proper environment
67 to allocate nodes the represent values
68 of constant entities. It is not meant as
70 ir_type *glob_type; /**< The global type. Must be a class as it can
71 have fields and procedures. */
72 ir_type *tls_type; /**< The thread local storage type. Must be a struct as it can
74 ir_type **types; /**< A list of all types in the ir. */
75 ir_mode **modes; /**< A list of all modes in the ir. */
76 ir_op **opcodes; /**< A list of all opcodes in the ir. */
78 /* -- states of and access to generated information -- */
79 irg_phase_state phase_state; /**< The state of construction. */
81 ip_view_state ip_view; /**< The state of interprocedural view. */
83 irg_outs_state outs_state; /**< The state of out edges of ir nodes. */
84 ir_node **ip_outedges; /**< A huge Array that contains all out edges
85 in interprocedural view. */
86 irg_outs_state trouts_state; /**< The state of out edges of type information. */
88 irg_callee_info_state callee_info_state; /**< Validity of callee information.
89 Contains the lowest value or all irgs. */
90 ir_typeinfo_state typeinfo_state; /**< Validity of type information. */
91 inh_transitive_closure_state inh_trans_closure_state; /**< trans closure of inh relations. */
93 irp_callgraph_state callgraph_state; /**< The state of the callgraph. */
94 ir_loop *outermost_cg_loop; /**< For callgraph analysis: entry point
95 to looptree over callgraph. */
96 int max_callgraph_loop_depth; /**< needed in callgraph. */
97 int max_callgraph_recursion_depth; /**< needed in callgraph. */
98 double max_method_execution_frequency; /**< needed in callgraph. */
99 irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
100 exec_freq_state execfreq_state; /**< The state of execution frequency information */
101 loop_nesting_depth_state lnd_state; /**< The state of loop nesting depth information. */
102 ir_class_cast_state class_cast_state; /**< The state of cast operations in code. */
103 ir_address_taken_computed_state globals_adr_taken_state; /**< Address taken state of the globals. */
106 long max_node_nr; /**< to generate unique numbers for nodes. */
110 /** Adds mode to the list of modes in irp. */
111 void add_irp_mode(ir_mode *mode);
113 /* INLINE functions */
115 static INLINE ir_type *
116 _get_glob_type(void) {
118 return irp->glob_type = skip_tid(irp->glob_type);
121 static INLINE ir_type *
122 _get_tls_type(void) {
124 return irp->tls_type = skip_tid(irp->tls_type);
128 _get_irp_n_irgs(void) {
129 assert (irp && irp->graphs);
130 if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
131 return ARR_LEN(irp->graphs);
134 static INLINE ir_graph *
135 _get_irp_irg(int pos){
136 if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
137 assert(0 <= pos && pos <= _get_irp_n_irgs());
138 return irp->graphs[pos];
143 _get_irp_n_types (void) {
144 assert (irp && irp->types);
145 return ARR_LEN(irp->types);
148 static INLINE ir_type *
149 _get_irp_type(int pos) {
150 assert (irp && irp->types);
151 /* Don't set the skip_tid result so that no double entries are generated. */
152 return skip_tid(irp->types[pos]);
156 _get_irp_n_modes(void) {
157 assert (irp && irp->modes);
158 return ARR_LEN(irp->modes);
161 static INLINE ir_mode *
162 _get_irp_mode(int pos) {
163 assert (irp && irp->modes);
164 return irp->modes[pos];
168 _get_irp_n_opcodes(void) {
169 assert (irp && irp->opcodes);
170 return ARR_LEN(irp->opcodes);
173 static INLINE ir_op *
174 _get_irp_opcode(int pos) {
175 assert (irp && irp->opcodes);
176 return irp->opcodes[pos];
180 /** Returns a new, unique number to number nodes or the like. */
182 get_irp_new_node_nr(void) {
184 return irp->max_node_nr++;
186 #endif /* DEBUG_libfirm */
188 static INLINE ir_graph *
189 _get_const_code_irg(void) {
190 return irp->const_code_irg;
193 void set_irp_ip_outedges(ir_node ** ip_outedges);
194 ir_node** get_irp_ip_outedges(void);
196 /** initializes ir_prog. Constructs only the basic lists */
197 void init_irprog_1(void);
199 /** Completes ir_prog. */
200 void init_irprog_2(void);
202 #define get_irp_n_irgs() _get_irp_n_irgs()
203 #define get_irp_irg(pos) _get_irp_irg(pos)
204 #define get_irp_n_types() _get_irp_n_types()
205 #define get_irp_type(pos) _get_irp_type(pos)
206 #define get_irp_n_modes() _get_irp_n_modes()
207 #define get_irp_mode(pos) _get_irp_mode(pos)
208 #define get_irp_n_opcodes() _get_irp_n_opcodes()
209 #define get_irp_opcode(pos) _get_irp_opcode(pos)
210 #define get_const_code_irg() _get_const_code_irg()
211 #define get_glob_type() _get_glob_type()
212 #define get_tls_type() _get_tls_type()
214 #endif /* ifndef _FIRM_IR_IRPROG_T_H_ */