2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Entry point to the representation of a whole program 0-- private header.
9 * @author Goetz Lindenmaier
12 #ifndef FIRM_IR_IRPROG_T_H
13 #define FIRM_IR_IRPROG_T_H
17 #include "irtypeinfo.h"
20 #include "callgraph.h"
24 /* Inline functions. */
25 #define get_irp_n_irgs() get_irp_n_irgs_()
26 #define get_irp_irg(pos) get_irp_irg_(pos)
27 #define get_irp_n_types() get_irp_n_types_()
28 #define get_irp_type(pos) get_irp_type_(pos)
29 #define get_const_code_irg() get_const_code_irg_()
30 #define get_segment_type(s) get_segment_type_(s)
31 #define get_glob_type() get_glob_type_()
32 #define get_tls_type() get_tls_type_()
33 #define get_irp_next_label_nr() get_irp_next_label_nr_()
35 /* inline functions */
36 static inline ir_type *get_segment_type_(ir_segment_t segment)
38 assert(segment <= IR_SEGMENT_LAST);
39 return irp->segment_types[segment];
42 static inline ir_type *get_glob_type_(void)
44 return get_segment_type_(IR_SEGMENT_GLOBAL);
47 static inline ir_type *get_tls_type_(void)
49 return get_segment_type_(IR_SEGMENT_THREAD_LOCAL);
52 static inline size_t get_irp_n_irgs_(void)
54 return ARR_LEN(irp->graphs);
57 static inline ir_graph *get_irp_irg_(size_t pos)
59 assert(pos < ARR_LEN(irp->graphs));
60 return irp->graphs[pos];
63 static inline size_t get_irp_n_types_(void)
65 return ARR_LEN(irp->types);
68 static inline ir_type *get_irp_type_(size_t pos)
70 assert(pos < ARR_LEN(irp->types));
71 /* Don't set the skip_tid result so that no double entries are generated. */
72 return irp->types[pos];
75 /** Returns a new, unique number to number nodes or the like. */
76 static inline long get_irp_new_node_nr(void)
78 return irp->max_node_nr++;
81 static inline size_t get_irp_new_irg_idx(void)
83 return irp->max_irg_idx++;
86 static inline ir_graph *get_const_code_irg_(void)
88 return irp->const_code_irg;
91 /** Returns a new, unique label number. */
92 static inline ir_label_t get_irp_next_label_nr_(void)
94 return ++irp->last_label_nr;
97 void set_irp_ip_outedges(ir_node ** ip_outedges);
98 ir_node** get_irp_ip_outedges(void);
100 /** initializes ir_prog. Constructs only the basic lists */
101 void init_irprog_1(void);
103 /** Completes ir_prog. */
104 void init_irprog_2(void);
106 /** Adds type to the list of types in irp. */
107 void add_irp_type(ir_type *typ);
109 /** Removes type from the list of types, deallocates it and
110 shrinks the list by one. */
111 void remove_irp_type(ir_type *typ);
113 /** Adds irg to the list of ir graphs in the current irp. */
114 FIRM_API void add_irp_irg(ir_graph *irg);
116 /** Removes irg from the list of irgs and
117 shrinks the list by one. */
118 FIRM_API void remove_irp_irg(ir_graph *irg);