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 "irtypeinfo.h"
37 #include "callgraph.h"
38 #include "field_temperature.h"
39 #include "execution_frequency.h"
43 /** Adds mode to the list of modes in irp. */
44 void add_irp_mode(ir_mode *mode);
46 /* inline functions */
47 static inline ir_type *
48 _get_segment_type(ir_segment_t segment)
50 assert(segment <= IR_SEGMENT_LAST);
51 return irp->segment_types[segment];
54 static inline ir_type *
55 _get_glob_type(void) {
56 return _get_segment_type(IR_SEGMENT_GLOBAL);
59 static inline ir_type *
61 return _get_segment_type(IR_SEGMENT_THREAD_LOCAL);
65 _get_irp_n_irgs(void) {
66 assert(irp && irp->graphs);
67 if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
68 return ARR_LEN(irp->graphs);
71 static inline ir_graph *
72 _get_irp_irg(int pos){
73 if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
74 assert(0 <= pos && pos <= ARR_LEN(irp->graphs));
75 return irp->graphs[pos];
80 _get_irp_n_types(void) {
81 assert(irp && irp->types);
82 return ARR_LEN(irp->types);
85 static inline ir_type *
86 _get_irp_type(int pos) {
88 /* Don't set the skip_tid result so that no double entries are generated. */
89 return irp->types[pos];
93 _get_irp_n_modes(void) {
95 return ARR_LEN(irp->modes);
98 static inline ir_mode *
99 _get_irp_mode(int pos) {
100 assert(irp && irp->modes);
101 return irp->modes[pos];
105 _get_irp_n_opcodes(void) {
106 assert(irp && irp->opcodes);
107 return ARR_LEN(irp->opcodes);
110 static inline ir_op *
111 _get_irp_opcode(int pos) {
112 assert(irp && irp->opcodes);
113 return irp->opcodes[pos];
116 /** Returns a new, unique number to number nodes or the like. */
118 get_irp_new_node_nr(void) {
120 return irp->max_node_nr++;
124 get_irp_new_irg_idx(void) {
126 return irp->max_irg_idx++;
129 static inline ir_graph *
130 _get_const_code_irg(void) {
131 return irp->const_code_irg;
134 /** Returns a new, unique exception region number. */
135 static inline ir_exc_region_t
136 _get_irp_next_region_nr(void) {
138 return ++irp->last_region_nr;
141 /** Returns a new, unique label number. */
142 static inline ir_label_t
143 _get_irp_next_label_nr(void) {
145 return ++irp->last_label_nr;
148 void set_irp_ip_outedges(ir_node ** ip_outedges);
149 ir_node** get_irp_ip_outedges(void);
151 /** initializes ir_prog. Constructs only the basic lists */
152 void init_irprog_1(void);
154 /** Completes ir_prog. */
155 void init_irprog_2(void);
157 /* Inline functions. */
158 #define get_irp_n_irgs() _get_irp_n_irgs()
159 #define get_irp_irg(pos) _get_irp_irg(pos)
160 #define get_irp_n_types() _get_irp_n_types()
161 #define get_irp_type(pos) _get_irp_type(pos)
162 #define get_irp_n_modes() _get_irp_n_modes()
163 #define get_irp_mode(pos) _get_irp_mode(pos)
164 #define get_irp_n_opcodes() _get_irp_n_opcodes()
165 #define get_irp_opcode(pos) _get_irp_opcode(pos)
166 #define get_const_code_irg() _get_const_code_irg()
167 #define get_segment_type(s) _get_segment_type(s)
168 #define get_glob_type() _get_glob_type()
169 #define get_tls_type() _get_tls_type()
170 #define get_irp_next_region_nr() _get_irp_next_region_nr()
171 #define get_irp_next_label_nr() _get_irp_next_label_nr()