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