- removed Psi nodes, Mux nodes are used again ...
[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 "firm_config.h"
31 #include "irprog.h"
32 #include "irtypes.h"
33 #include "pseudo_irg.h"
34 #include "ircgcons.h"
35 #include "firm_common_t.h"
36 #include "irtypeinfo.h"
37 #include "irmemory.h"
38
39 #include "callgraph.h"
40 #include "field_temperature.h"
41 #include "execution_frequency.h"
42
43 #include "array.h"
44
45 /** Adds mode to the list of modes in irp. */
46 void  add_irp_mode(ir_mode *mode);
47
48 /* INLINE functions */
49 static INLINE ir_type *
50 _get_segment_type(ir_segment_t segment)
51 {
52         ir_type *type;
53
54         assert(segment < IR_SEGMENT_COUNT);
55         type                        = skip_tid(irp->segment_types[segment]);
56         irp->segment_types[segment] = type;
57         return type;
58 }
59
60 static INLINE ir_type *
61 _get_glob_type(void) {
62         return _get_segment_type(IR_SEGMENT_GLOBAL);
63 }
64
65 static INLINE ir_type *
66 _get_tls_type(void) {
67         return _get_segment_type(IR_SEGMENT_THREAD_LOCAL);
68 }
69
70 static INLINE int
71 _get_irp_n_irgs(void) {
72         assert (irp && irp->graphs);
73         if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
74         return ARR_LEN(irp->graphs);
75 }
76
77 static INLINE ir_graph *
78 _get_irp_irg(int pos){
79         if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
80         assert(0 <= pos && pos <= _get_irp_n_irgs());
81         return irp->graphs[pos];
82 }
83
84
85 static INLINE int
86 _get_irp_n_types(void) {
87         assert (irp && irp->types);
88         return ARR_LEN(irp->types);
89 }
90
91 static INLINE ir_type *
92 _get_irp_type(int pos) {
93         assert (irp && irp->types);
94         /* Don't set the skip_tid result so that no double entries are generated. */
95         return skip_tid(irp->types[pos]);
96 }
97
98 static INLINE int
99 _get_irp_n_modes(void) {
100         assert (irp && irp->modes);
101         return ARR_LEN(irp->modes);
102 }
103
104 static INLINE ir_mode *
105 _get_irp_mode(int pos) {
106         assert (irp && irp->modes);
107         return irp->modes[pos];
108 }
109
110 static INLINE int
111 _get_irp_n_opcodes(void) {
112         assert (irp && irp->opcodes);
113         return ARR_LEN(irp->opcodes);
114 }
115
116 static INLINE ir_op *
117 _get_irp_opcode(int pos) {
118         assert (irp && irp->opcodes);
119         return irp->opcodes[pos];
120 }
121
122 #ifdef DEBUG_libfirm
123 /** Returns a new, unique number to number nodes or the like. */
124 static INLINE long
125 get_irp_new_node_nr(void) {
126         assert(irp);
127         return irp->max_node_nr++;
128 }
129 #endif /* DEBUG_libfirm */
130
131 static INLINE int
132 get_irp_new_irg_idx(void) {
133         assert(irp);
134         return irp->max_irg_idx++;
135 }
136
137 static INLINE ir_graph *
138 _get_const_code_irg(void) {
139         return irp->const_code_irg;
140 }
141
142 /** Returns a new, unique exception region number. */
143 static INLINE ir_exc_region_t
144 _get_irp_next_region_nr(void) {
145         assert(irp);
146         return ++irp->last_region_nr;
147 }
148
149 /** Returns a new, unique label number. */
150 static INLINE ir_label_t
151 _get_irp_next_label_nr(void) {
152         assert(irp);
153         return ++irp->last_label_nr;
154 }
155
156 void           set_irp_ip_outedges(ir_node ** ip_outedges);
157 ir_node**      get_irp_ip_outedges(void);
158
159 /** initializes ir_prog. Constructs only the basic lists */
160 void init_irprog_1(void);
161
162 /** Completes ir_prog. */
163 void init_irprog_2(void);
164
165 /* Inline functions. */
166 #define get_irp_n_irgs()          _get_irp_n_irgs()
167 #define get_irp_irg(pos)          _get_irp_irg(pos)
168 #define get_irp_n_types()         _get_irp_n_types()
169 #define get_irp_type(pos)         _get_irp_type(pos)
170 #define get_irp_n_modes()         _get_irp_n_modes()
171 #define get_irp_mode(pos)         _get_irp_mode(pos)
172 #define get_irp_n_opcodes()       _get_irp_n_opcodes()
173 #define get_irp_opcode(pos)       _get_irp_opcode(pos)
174 #define get_const_code_irg()      _get_const_code_irg()
175 #define get_segment_type(s)       _get_segment_type(s
176 #define get_glob_type()           _get_glob_type()
177 #define get_tls_type()            _get_tls_type()
178 #define get_irp_next_region_nr()  _get_irp_next_region_nr()
179 #define get_irp_next_label_nr()   _get_irp_next_label_nr()
180
181 #endif