2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Entry point to the representation of a whole program 0-- private header.
23 * @author Goetz Lindenmaier
26 #ifndef FIRM_IR_IRPROG_T_H
27 #define FIRM_IR_IRPROG_T_H
31 #include "irtypeinfo.h"
34 #include "callgraph.h"
38 /* Inline functions. */
39 #define get_irp_n_irgs() get_irp_n_irgs_()
40 #define get_irp_irg(pos) get_irp_irg_(pos)
41 #define get_irp_n_types() get_irp_n_types_()
42 #define get_irp_type(pos) get_irp_type_(pos)
43 #define get_const_code_irg() get_const_code_irg_()
44 #define get_segment_type(s) get_segment_type_(s)
45 #define get_glob_type() get_glob_type_()
46 #define get_tls_type() get_tls_type_()
47 #define get_irp_next_label_nr() get_irp_next_label_nr_()
49 /* inline functions */
50 static inline ir_type *get_segment_type_(ir_segment_t segment)
52 assert(segment <= IR_SEGMENT_LAST);
53 return irp->segment_types[segment];
56 static inline ir_type *get_glob_type_(void)
58 return get_segment_type_(IR_SEGMENT_GLOBAL);
61 static inline ir_type *get_tls_type_(void)
63 return get_segment_type_(IR_SEGMENT_THREAD_LOCAL);
66 static inline size_t get_irp_n_irgs_(void)
68 return ARR_LEN(irp->graphs);
71 static inline ir_graph *get_irp_irg_(size_t pos)
73 assert(pos < ARR_LEN(irp->graphs));
74 return irp->graphs[pos];
77 static inline size_t get_irp_n_types_(void)
79 return ARR_LEN(irp->types);
82 static inline ir_type *get_irp_type_(size_t pos)
84 assert(pos < ARR_LEN(irp->types));
85 /* Don't set the skip_tid result so that no double entries are generated. */
86 return irp->types[pos];
89 /** Returns a new, unique number to number nodes or the like. */
90 static inline long get_irp_new_node_nr(void)
92 return irp->max_node_nr++;
95 static inline size_t get_irp_new_irg_idx(void)
97 return irp->max_irg_idx++;
100 static inline ir_graph *get_const_code_irg_(void)
102 return irp->const_code_irg;
105 /** Returns a new, unique label number. */
106 static inline ir_label_t get_irp_next_label_nr_(void)
108 return ++irp->last_label_nr;
111 void set_irp_ip_outedges(ir_node ** ip_outedges);
112 ir_node** get_irp_ip_outedges(void);
114 /** initializes ir_prog. Constructs only the basic lists */
115 void init_irprog_1(void);
117 /** Completes ir_prog. */
118 void init_irprog_2(void);
120 /** Adds type to the list of types in irp. */
121 void add_irp_type(ir_type *typ);
123 /** Removes type from the list of types, deallocates it and
124 shrinks the list by one. */
125 void remove_irp_type(ir_type *typ);
127 /** Adds irg to the list of ir graphs in the current irp. */
128 FIRM_API void add_irp_irg(ir_graph *irg);
130 /** Removes irg from the list of irgs and
131 shrinks the list by one. */
132 FIRM_API void remove_irp_irg(ir_graph *irg);