irprog_t.h 4.75 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Michael Beck's avatar
Michael Beck committed
20
/**
Matthias Braun's avatar
Matthias Braun committed
21
22
23
24
 * @file
 * @brief    Entry point to the representation of a whole program 0-- private header.
 * @author   Goetz Lindenmaier
 * @date     2000
Michael Beck's avatar
Michael Beck committed
25
 */
Matthias Braun's avatar
Matthias Braun committed
26
27
#ifndef FIRM_IR_IRPROG_T_H
#define FIRM_IR_IRPROG_T_H
Götz Lindenmaier's avatar
Götz Lindenmaier committed
28
29

#include "irprog.h"
30
#include "irtypes.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
31
#include "irtypeinfo.h"
32
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
33

Götz Lindenmaier's avatar
Götz Lindenmaier committed
34
35
#include "callgraph.h"

36
#include "array.h"
37

Michael Beck's avatar
Michael Beck committed
38
/** Adds mode to the list of modes in irp. */
Matthias Braun's avatar
Matthias Braun committed
39
void add_irp_mode(ir_mode *mode);
Michael Beck's avatar
Michael Beck committed
40

41
/* inline functions */
42
static inline ir_type *get_segment_type_(ir_segment_t segment)
43
{
44
45
	assert(segment <= IR_SEGMENT_LAST);
	return irp->segment_types[segment];
46
47
}

48
static inline ir_type *get_glob_type_(void)
49
{
50
	return get_segment_type_(IR_SEGMENT_GLOBAL);
51
52
}

53
static inline ir_type *get_tls_type_(void)
54
{
55
	return get_segment_type_(IR_SEGMENT_THREAD_LOCAL);
56
57
}

58
static inline size_t get_irp_n_irgs_(void)
59
{
Matthias Braun's avatar
Matthias Braun committed
60
	assert(irp && irp->graphs);
Matthias Braun's avatar
Matthias Braun committed
61
	return ARR_LEN(irp->graphs);
62
63
}

64
static inline ir_graph *get_irp_irg_(size_t pos)
65
{
Matthias Braun's avatar
Matthias Braun committed
66
	assert(pos < ARR_LEN(irp->graphs));
67
	return irp->graphs[pos];
68
69
}

70
static inline size_t get_irp_n_types_(void)
71
{
Matthias Braun's avatar
Matthias Braun committed
72
	assert(irp && irp->types);
Matthias Braun's avatar
Matthias Braun committed
73
	return ARR_LEN(irp->types);
74
75
}

76
static inline ir_type *get_irp_type_(size_t pos)
77
{
Matthias Braun's avatar
Matthias Braun committed
78
	assert(irp->types);
Matthias Braun's avatar
Matthias Braun committed
79
	assert(pos < ARR_LEN(irp->types));
80
	/* Don't set the skip_tid result so that no double entries are generated. */
Matthias Braun's avatar
Matthias Braun committed
81
	return irp->types[pos];
82
83
}

84
static inline size_t get_irp_n_modes_(void)
85
{
Matthias Braun's avatar
Matthias Braun committed
86
	assert(irp->modes);
Matthias Braun's avatar
Matthias Braun committed
87
	return ARR_LEN(irp->modes);
Michael Beck's avatar
Michael Beck committed
88
89
}

90
static inline ir_mode *get_irp_mode_(size_t pos)
91
{
Matthias Braun's avatar
Matthias Braun committed
92
	assert(irp && irp->modes);
93
	return irp->modes[pos];
Michael Beck's avatar
Michael Beck committed
94
95
}

96
static inline size_t get_irp_n_opcodes_(void)
97
{
Matthias Braun's avatar
Matthias Braun committed
98
	assert(irp && irp->opcodes);
Matthias Braun's avatar
Matthias Braun committed
99
	return ARR_LEN(irp->opcodes);
100
101
}

102
static inline ir_op *get_irp_opcode_(size_t pos)
103
{
Matthias Braun's avatar
Matthias Braun committed
104
	assert(irp && irp->opcodes);
105
	return irp->opcodes[pos];
106
107
}

Michael Beck's avatar
Michael Beck committed
108
/** Returns a new, unique number to number nodes or the like. */
109
110
static inline long get_irp_new_node_nr(void)
{
111
112
	assert(irp);
	return irp->max_node_nr++;
113
}
114

115
static inline size_t get_irp_new_irg_idx(void)
116
{
Matthias Braun's avatar
Matthias Braun committed
117
118
119
120
	assert(irp);
	return irp->max_irg_idx++;
}

121
static inline ir_graph *get_const_code_irg_(void)
122
{
123
124
125
126
	return irp->const_code_irg;
}

/** Returns a new, unique exception region number. */
127
static inline ir_exc_region_t get_irp_next_region_nr_(void)
128
{
129
130
	assert(irp);
	return ++irp->last_region_nr;
131
132
}

Michael Beck's avatar
Michael Beck committed
133
/** Returns a new, unique label number. */
134
static inline ir_label_t get_irp_next_label_nr_(void)
135
{
Michael Beck's avatar
Michael Beck committed
136
137
138
139
	assert(irp);
	return ++irp->last_label_nr;
}

Andreas Zwinkau's avatar
Andreas Zwinkau committed
140
/** Whether optimizations should dump irgs */
141
static inline int get_irp_optimization_dumps_(void)
Andreas Zwinkau's avatar
Andreas Zwinkau committed
142
143
144
145
146
147
{
	assert(irp);
	return irp->optimization_dumps;
}

/** Set optimizations to dump irgs */
148
static inline void enable_irp_optimization_dumps_(void)
Andreas Zwinkau's avatar
Andreas Zwinkau committed
149
150
151
152
153
{
	assert(irp);
	irp->optimization_dumps = 1;
}

154
155
void      set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node** get_irp_ip_outedges(void);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
156

157
158
159
160
161
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

/** Completes ir_prog. */
void init_irprog_2(void);
162

Matthias Braun's avatar
Matthias Braun committed
163
/** Adds type to the list of types in irp. */
Matthias Braun's avatar
Matthias Braun committed
164
void add_irp_type(ir_type *typ);
Matthias Braun's avatar
Matthias Braun committed
165
166
167

/** Removes type from the list of types, deallocates it and
    shrinks the list by one. */
Matthias Braun's avatar
Matthias Braun committed
168
void remove_irp_type(ir_type *typ);
Matthias Braun's avatar
Matthias Braun committed
169

170
/* Inline functions. */
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#define get_irp_n_irgs()                 get_irp_n_irgs_()
#define get_irp_irg(pos)                 get_irp_irg_(pos)
#define get_irp_n_types()                get_irp_n_types_()
#define get_irp_type(pos)                get_irp_type_(pos)
#define get_irp_n_modes()                get_irp_n_modes_()
#define get_irp_mode(pos)                get_irp_mode_(pos)
#define get_irp_n_opcodes()              get_irp_n_opcodes_()
#define get_irp_opcode(pos)              get_irp_opcode_(pos)
#define get_const_code_irg()             get_const_code_irg_()
#define get_segment_type(s)              get_segment_type_(s)
#define get_glob_type()                  get_glob_type_()
#define get_tls_type()                   get_tls_type_()
#define get_irp_next_region_nr()         get_irp_next_region_nr_()
#define get_irp_next_label_nr()          get_irp_next_label_nr_()
#define get_irp_optimization_dumps()     get_irp_optimization_dumps_()
#define enable_irp_optimization_dumps()  enable_irp_optimization_dumps_()
187

Matthias Braun's avatar
Matthias Braun committed
188
#endif