add support for graph_idx
[libfirm] / ir / ir / irprog_t.h
1 /*
2  * Copyright (C) 1995-2007 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
50 static INLINE ir_type *
51 _get_glob_type(void) {
52         assert(irp);
53         return irp->glob_type = skip_tid(irp->glob_type);
54 }
55
56 static INLINE ir_type *
57 _get_tls_type(void) {
58         assert(irp);
59         return irp->tls_type = skip_tid(irp->tls_type);
60 }
61
62 static INLINE int
63 _get_irp_n_irgs(void) {
64         assert (irp && irp->graphs);
65         if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
66         return ARR_LEN(irp->graphs);
67 }
68
69 static INLINE ir_graph *
70 _get_irp_irg(int pos){
71         if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
72         assert(0 <= pos && pos <= _get_irp_n_irgs());
73         return irp->graphs[pos];
74 }
75
76
77 static INLINE int
78 _get_irp_n_types(void) {
79         assert (irp && irp->types);
80         return ARR_LEN(irp->types);
81 }
82
83 static INLINE ir_type *
84 _get_irp_type(int pos) {
85         assert (irp && irp->types);
86         /* Don't set the skip_tid result so that no double entries are generated. */
87         return skip_tid(irp->types[pos]);
88 }
89
90 static INLINE int
91 _get_irp_n_modes(void) {
92         assert (irp && irp->modes);
93         return ARR_LEN(irp->modes);
94 }
95
96 static INLINE ir_mode *
97 _get_irp_mode(int pos) {
98         assert (irp && irp->modes);
99         return irp->modes[pos];
100 }
101
102 static INLINE int
103 _get_irp_n_opcodes(void) {
104         assert (irp && irp->opcodes);
105         return ARR_LEN(irp->opcodes);
106 }
107
108 static INLINE ir_op *
109 _get_irp_opcode(int pos) {
110         assert (irp && irp->opcodes);
111         return irp->opcodes[pos];
112 }
113
114 #ifdef DEBUG_libfirm
115 /** Returns a new, unique number to number nodes or the like. */
116 static INLINE long
117 get_irp_new_node_nr(void) {
118         assert(irp);
119         return irp->max_node_nr++;
120 }
121 #endif /* DEBUG_libfirm */
122
123 static INLINE int
124 get_irp_new_irg_idx(void) {
125         assert(irp);
126         return irp->max_irg_idx++;
127 }
128
129 static INLINE ir_graph *
130 _get_const_code_irg(void) {
131         return irp->const_code_irg;
132 }
133
134 /** Returns a new, unique exception region number. */
135 static INLINE ir_exc_region_t
136 _get_irp_next_region_nr(void) {
137         assert(irp);
138         return ++irp->last_region_nr;
139 }
140
141 /** Returns a new, unique label number. */
142 static INLINE ir_label_t
143 _get_irp_next_label_nr(void) {
144         assert(irp);
145         return ++irp->last_label_nr;
146 }
147
148 void           set_irp_ip_outedges(ir_node ** ip_outedges);
149 ir_node**      get_irp_ip_outedges(void);
150
151 /** initializes ir_prog. Constructs only the basic lists */
152 void init_irprog_1(void);
153
154 /** Completes ir_prog. */
155 void init_irprog_2(void);
156
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_glob_type()           _get_glob_type()
168 #define get_tls_type()            _get_tls_type()
169 #define get_irp_next_region_nr()  _get_irp_next_region_nr()
170 #define get_irp_next_label_nr()   _get_irp_next_label_nr()
171
172 #endif