2 * Copyright (C) 1995-2008 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 * @brief Entry point to the representation of a whole program 0-- private header.
23 * @author Goetz Lindenmaier
27 #ifndef FIRM_IR_IRPROG_T_H
28 #define FIRM_IR_IRPROG_T_H
32 #include "pseudo_irg.h"
34 #include "firm_common_t.h"
35 #include "irtypeinfo.h"
38 #include "callgraph.h"
39 #include "field_temperature.h"
40 #include "execution_frequency.h"
44 /** Adds mode to the list of modes in irp. */
45 void add_irp_mode(ir_mode *mode);
47 /* inline functions */
48 static inline ir_type *
49 _get_segment_type(ir_segment_t segment)
53 assert(segment < IR_SEGMENT_COUNT);
54 type = skip_tid(irp->segment_types[segment]);
55 irp->segment_types[segment] = type;
59 static inline ir_type *
60 _get_glob_type(void) {
61 return _get_segment_type(IR_SEGMENT_GLOBAL);
64 static inline ir_type *
66 return _get_segment_type(IR_SEGMENT_THREAD_LOCAL);
70 _get_irp_n_irgs(void) {
71 assert (irp && irp->graphs);
72 if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
73 return ARR_LEN(irp->graphs);
76 static inline ir_graph *
77 _get_irp_irg(int pos){
78 if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
79 assert(0 <= pos && pos <= ARR_LEN(irp->graphs));
80 return irp->graphs[pos];
85 _get_irp_n_types(void) {
86 assert (irp && irp->types);
87 return ARR_LEN(irp->types);
90 static inline ir_type *
91 _get_irp_type(int pos) {
92 assert (irp && irp->types);
93 /* Don't set the skip_tid result so that no double entries are generated. */
94 return skip_tid(irp->types[pos]);
98 _get_irp_n_modes(void) {
99 assert (irp && irp->modes);
100 return ARR_LEN(irp->modes);
103 static inline ir_mode *
104 _get_irp_mode(int pos) {
105 assert (irp && irp->modes);
106 return irp->modes[pos];
110 _get_irp_n_opcodes(void) {
111 assert (irp && irp->opcodes);
112 return ARR_LEN(irp->opcodes);
115 static inline ir_op *
116 _get_irp_opcode(int pos) {
117 assert (irp && irp->opcodes);
118 return irp->opcodes[pos];
121 /** Returns a new, unique number to number nodes or the like. */
123 get_irp_new_node_nr(void) {
125 return irp->max_node_nr++;
129 get_irp_new_irg_idx(void) {
131 return irp->max_irg_idx++;
134 static inline ir_graph *
135 _get_const_code_irg(void) {
136 return irp->const_code_irg;
139 /** Returns a new, unique exception region number. */
140 static inline ir_exc_region_t
141 _get_irp_next_region_nr(void) {
143 return ++irp->last_region_nr;
146 /** Returns a new, unique label number. */
147 static inline ir_label_t
148 _get_irp_next_label_nr(void) {
150 return ++irp->last_label_nr;
153 void set_irp_ip_outedges(ir_node ** ip_outedges);
154 ir_node** get_irp_ip_outedges(void);
156 /** initializes ir_prog. Constructs only the basic lists */
157 void init_irprog_1(void);
159 /** Completes ir_prog. */
160 void init_irprog_2(void);
162 /* Inline functions. */
163 #define get_irp_n_irgs() _get_irp_n_irgs()
164 #define get_irp_irg(pos) _get_irp_irg(pos)
165 #define get_irp_n_types() _get_irp_n_types()
166 #define get_irp_type(pos) _get_irp_type(pos)
167 #define get_irp_n_modes() _get_irp_n_modes()
168 #define get_irp_mode(pos) _get_irp_mode(pos)
169 #define get_irp_n_opcodes() _get_irp_n_opcodes()
170 #define get_irp_opcode(pos) _get_irp_opcode(pos)
171 #define get_const_code_irg() _get_const_code_irg()
172 #define get_segment_type(s) _get_segment_type(s)
173 #define get_glob_type() _get_glob_type()
174 #define get_tls_type() _get_tls_type()
175 #define get_irp_next_region_nr() _get_irp_next_region_nr()
176 #define get_irp_next_label_nr() _get_irp_next_label_nr()