Cleanup: remove firm_common_t.h (and the PRECISE_EXC_CONTEXT define)
[libfirm] / ir / ir / irprog_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Entry point to the representation of a whole program 0-- private header.
23  * @author   Goetz Lindenmaier
24  * @date     2000
25  * @version  $Id$
26  */
27 #ifndef FIRM_IR_IRPROG_T_H
28 #define FIRM_IR_IRPROG_T_H
29
30 #include "irprog.h"
31 #include "irtypes.h"
32 #include "pseudo_irg.h"
33 #include "ircgcons.h"
34 #include "irtypeinfo.h"
35 #include "irmemory.h"
36
37 #include "callgraph.h"
38 #include "field_temperature.h"
39 #include "execution_frequency.h"
40
41 #include "array.h"
42
43 /** Adds mode to the list of modes in irp. */
44 void  add_irp_mode(ir_mode *mode);
45
46 /* inline functions */
47 static inline ir_type *
48 _get_segment_type(ir_segment_t segment)
49 {
50         ir_type *type;
51
52         assert(segment < IR_SEGMENT_COUNT);
53         type                        = skip_tid(irp->segment_types[segment]);
54         irp->segment_types[segment] = type;
55         return type;
56 }
57
58 static inline ir_type *
59 _get_glob_type(void) {
60         return _get_segment_type(IR_SEGMENT_GLOBAL);
61 }
62
63 static inline ir_type *
64 _get_tls_type(void) {
65         return _get_segment_type(IR_SEGMENT_THREAD_LOCAL);
66 }
67
68 static inline int
69 _get_irp_n_irgs(void) {
70         assert (irp && irp->graphs);
71         if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
72         return ARR_LEN(irp->graphs);
73 }
74
75 static inline ir_graph *
76 _get_irp_irg(int pos){
77         if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
78         assert(0 <= pos && pos <= ARR_LEN(irp->graphs));
79         return irp->graphs[pos];
80 }
81
82
83 static inline int
84 _get_irp_n_types(void) {
85         assert (irp && irp->types);
86         return ARR_LEN(irp->types);
87 }
88
89 static inline ir_type *
90 _get_irp_type(int pos) {
91         assert (irp && irp->types);
92         /* Don't set the skip_tid result so that no double entries are generated. */
93         return skip_tid(irp->types[pos]);
94 }
95
96 static inline int
97 _get_irp_n_modes(void) {
98         assert (irp && irp->modes);
99         return ARR_LEN(irp->modes);
100 }
101
102 static inline ir_mode *
103 _get_irp_mode(int pos) {
104         assert (irp && irp->modes);
105         return irp->modes[pos];
106 }
107
108 static inline int
109 _get_irp_n_opcodes(void) {
110         assert (irp && irp->opcodes);
111         return ARR_LEN(irp->opcodes);
112 }
113
114 static inline ir_op *
115 _get_irp_opcode(int pos) {
116         assert (irp && irp->opcodes);
117         return irp->opcodes[pos];
118 }
119
120 /** Returns a new, unique number to number nodes or the like. */
121 static inline long
122 get_irp_new_node_nr(void) {
123         assert(irp);
124         return irp->max_node_nr++;
125 }
126
127 static inline int
128 get_irp_new_irg_idx(void) {
129         assert(irp);
130         return irp->max_irg_idx++;
131 }
132
133 static inline ir_graph *
134 _get_const_code_irg(void) {
135         return irp->const_code_irg;
136 }
137
138 /** Returns a new, unique exception region number. */
139 static inline ir_exc_region_t
140 _get_irp_next_region_nr(void) {
141         assert(irp);
142         return ++irp->last_region_nr;
143 }
144
145 /** Returns a new, unique label number. */
146 static inline ir_label_t
147 _get_irp_next_label_nr(void) {
148         assert(irp);
149         return ++irp->last_label_nr;
150 }
151
152 void           set_irp_ip_outedges(ir_node ** ip_outedges);
153 ir_node**      get_irp_ip_outedges(void);
154
155 /** initializes ir_prog. Constructs only the basic lists */
156 void init_irprog_1(void);
157
158 /** Completes ir_prog. */
159 void init_irprog_2(void);
160
161 /* Inline functions. */
162 #define get_irp_n_irgs()          _get_irp_n_irgs()
163 #define get_irp_irg(pos)          _get_irp_irg(pos)
164 #define get_irp_n_types()         _get_irp_n_types()
165 #define get_irp_type(pos)         _get_irp_type(pos)
166 #define get_irp_n_modes()         _get_irp_n_modes()
167 #define get_irp_mode(pos)         _get_irp_mode(pos)
168 #define get_irp_n_opcodes()       _get_irp_n_opcodes()
169 #define get_irp_opcode(pos)       _get_irp_opcode(pos)
170 #define get_const_code_irg()      _get_const_code_irg()
171 #define get_segment_type(s)       _get_segment_type(s)
172 #define get_glob_type()           _get_glob_type()
173 #define get_tls_type()            _get_tls_type()
174 #define get_irp_next_region_nr()  _get_irp_next_region_nr()
175 #define get_irp_next_label_nr()   _get_irp_next_label_nr()
176
177 #endif