beifg: Factorise code to count interference components.
[libfirm] / ir / ir / irprog_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Entry point to the representation of a whole program 0-- private header.
9  * @author   Goetz Lindenmaier
10  * @date     2000
11  */
12 #ifndef FIRM_IR_IRPROG_T_H
13 #define FIRM_IR_IRPROG_T_H
14
15 #include "irprog.h"
16 #include "irtypes.h"
17 #include "irtypeinfo.h"
18 #include "irmemory.h"
19
20 #include "callgraph.h"
21
22 #include "array.h"
23
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_()
34
35 /* inline functions */
36 static inline ir_type *get_segment_type_(ir_segment_t segment)
37 {
38         assert(segment <= IR_SEGMENT_LAST);
39         return irp->segment_types[segment];
40 }
41
42 static inline ir_type *get_glob_type_(void)
43 {
44         return get_segment_type_(IR_SEGMENT_GLOBAL);
45 }
46
47 static inline ir_type *get_tls_type_(void)
48 {
49         return get_segment_type_(IR_SEGMENT_THREAD_LOCAL);
50 }
51
52 static inline size_t get_irp_n_irgs_(void)
53 {
54         return ARR_LEN(irp->graphs);
55 }
56
57 static inline ir_graph *get_irp_irg_(size_t pos)
58 {
59         assert(pos < ARR_LEN(irp->graphs));
60         return irp->graphs[pos];
61 }
62
63 static inline size_t get_irp_n_types_(void)
64 {
65         return ARR_LEN(irp->types);
66 }
67
68 static inline ir_type *get_irp_type_(size_t pos)
69 {
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];
73 }
74
75 /** Returns a new, unique number to number nodes or the like. */
76 static inline long get_irp_new_node_nr(void)
77 {
78         return irp->max_node_nr++;
79 }
80
81 static inline size_t get_irp_new_irg_idx(void)
82 {
83         return irp->max_irg_idx++;
84 }
85
86 static inline ir_graph *get_const_code_irg_(void)
87 {
88         return irp->const_code_irg;
89 }
90
91 /** Returns a new, unique label number. */
92 static inline ir_label_t get_irp_next_label_nr_(void)
93 {
94         return ++irp->last_label_nr;
95 }
96
97 void      set_irp_ip_outedges(ir_node ** ip_outedges);
98 ir_node** get_irp_ip_outedges(void);
99
100 /** initializes ir_prog. Constructs only the basic lists */
101 void init_irprog_1(void);
102
103 /** Completes ir_prog. */
104 void init_irprog_2(void);
105
106 /** Adds type to the list of types in irp. */
107 void add_irp_type(ir_type *typ);
108
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);
112
113 /** Adds irg to the list of ir graphs in the current irp. */
114 FIRM_API void add_irp_irg(ir_graph *irg);
115
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);
119
120 #endif