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