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
9 * Copyright: (c) 2000-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
21 #include "firm_config.h"
26 #include "pseudo_irg.h"
28 #include "firm_common_t.h"
30 #include "irtypeinfo.h"
31 #include "tr_inheritance.h"
33 #include "callgraph.h"
34 #include "field_temperature.h"
35 #include "execution_frequency.h"
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
51 ir_type *glob_type; /**< global type. Must be a class as it can
52 have fields and procedures. */
53 ir_type **types; /**< all types in the ir */
54 ir_mode **modes; /**< all modes in the ir */
55 ir_op **opcodes; /**< all opcodes in the ir */
57 /* -- states of and access to generated information -- */
58 irg_phase_state phase_state; /**< State of construction. */
60 ip_view_state ip_view; /**< State of interprocedural view. */
62 irg_outs_state outs_state; /**< State of out edges of ir nodes. */
63 ir_node **ip_outedges; /**< Huge Array that contains all out edges
64 in interprocedural view. */
65 irg_outs_state trouts_state; /**< State of out edges of type information. */
67 irg_callee_info_state callee_info_state; /**< Validity of callee information.
68 Contains the lowest value or all irgs. */
69 ir_typeinfo_state typeinfo_state; /**< Validity of type information. */
70 inh_transitive_closure_state inh_trans_closure_state; /**< trans closure of inh relations. */
72 irp_callgraph_state callgraph_state; /**< State of the callgraph. */
73 ir_loop *outermost_cg_loop; /**< For callgraph analysis: entry point
74 to looptree over callgraph. */
75 int max_callgraph_loop_depth; /**< needed in callgraph. */
76 int max_callgraph_recursion_depth; /**< needed in callgraph. */
77 double max_method_execution_frequency; /**< needed in callgraph. */
78 irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
79 exec_freq_state execfreq_state; /**< State of execution freqency information */
80 loop_nesting_depth_state lnd_state; /**< State of loop nesting depth information. */
81 ir_class_cast_state class_cast_state; /**< kind of cast operations in code. */
84 long max_node_nr; /**< to generate unique numbers for nodes. */
88 /** Adds mode to the list of modes in irp. */
89 void add_irp_mode(ir_mode *mode);
91 /* INLINE functions */
93 static INLINE ir_type *
94 _get_glob_type(void) {
96 return irp->glob_type = skip_tid(irp->glob_type);
100 _get_irp_n_irgs(void) {
101 assert (irp && irp->graphs);
102 if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
103 return ARR_LEN(irp->graphs);
106 static INLINE ir_graph *
107 _get_irp_irg(int pos){
108 if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
109 assert(0 <= pos && pos <= _get_irp_n_irgs());
110 return irp->graphs[pos];
115 _get_irp_n_types (void) {
116 assert (irp && irp->types);
117 return ARR_LEN(irp->types);
120 static INLINE ir_type *
121 _get_irp_type(int pos) {
122 assert (irp && irp->types);
123 /* Don't set the skip_tid result so that no double entries are generated. */
124 return skip_tid(irp->types[pos]);
128 _get_irp_n_modes(void) {
129 assert (irp && irp->modes);
130 return ARR_LEN(irp->modes);
133 static INLINE ir_mode *
134 _get_irp_mode(int pos) {
135 assert (irp && irp->modes);
136 return irp->modes[pos];
140 _get_irp_n_opcodes(void) {
141 assert (irp && irp->opcodes);
142 return ARR_LEN(irp->opcodes);
145 static INLINE ir_op *
146 _get_irp_opcode(int pos) {
147 assert (irp && irp->opcodes);
148 return irp->opcodes[pos];
152 /** Returns a new, unique number to number nodes or the like. */
154 get_irp_new_node_nr(void) {
156 return irp->max_node_nr++;
158 #endif /* DEBUG_libfirm */
160 static INLINE ir_graph *
161 _get_const_code_irg(void) {
162 return irp->const_code_irg;
165 void set_irp_ip_outedges(ir_node ** ip_outedges);
166 ir_node** get_irp_ip_outedges(void);
168 /** initializes ir_prog. Constructs only the basic lists */
169 void init_irprog_1(void);
171 /** Completes ir_prog. */
172 void init_irprog_2(void);
174 #define get_irp_n_irgs() _get_irp_n_irgs()
175 #define get_irp_irg(pos) _get_irp_irg(pos)
176 #define get_irp_n_types() _get_irp_n_types()
177 #define get_irp_type(pos) _get_irp_type(pos)
178 #define get_irp_n_modes() _get_irp_n_modes()
179 #define get_irp_mode(pos) _get_irp_mode(pos)
180 #define get_irp_n_opcodes() _get_irp_n_opcodes()
181 #define get_irp_opcode(pos) _get_irp_opcode(pos)
182 #define get_const_code_irg() _get_const_code_irg()
183 #define get_glob_type() _get_glob_type()
185 #endif /* ifndef _IRPROG_T_H_ */