irprog_t.h 4.43 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
25
 * @file
 * @brief    Entry point to the representation of a whole program 0-- private header.
 * @author   Goetz Lindenmaier
 * @date     2000
 * @version  $Id$
Michael Beck's avatar
Michael Beck committed
26
 */
Matthias Braun's avatar
Matthias Braun committed
27
28
#ifndef FIRM_IR_IRPROG_T_H
#define FIRM_IR_IRPROG_T_H
Götz Lindenmaier's avatar
Götz Lindenmaier committed
29
30

#include "irprog.h"
31
#include "irtypes.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
32
#include "pseudo_irg.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
33
#include "ircgcons.h"
34
#include "firm_common_t.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
35
#include "irtypeinfo.h"
36
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
37

Götz Lindenmaier's avatar
Götz Lindenmaier committed
38
#include "callgraph.h"
39
#include "field_temperature.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
40
#include "execution_frequency.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
41

42
#include "array.h"
43

Michael Beck's avatar
Michael Beck committed
44
45
46
/** Adds mode to the list of modes in irp. */
void  add_irp_mode(ir_mode *mode);

47
48
/* inline functions */
static inline ir_type *
49
50
51
52
53
54
55
56
_get_segment_type(ir_segment_t segment)
{
	ir_type *type;

	assert(segment < IR_SEGMENT_COUNT);
	type                        = skip_tid(irp->segment_types[segment]);
	irp->segment_types[segment] = type;
	return type;
57
58
}

59
static inline ir_type *
60
61
_get_glob_type(void) {
	return _get_segment_type(IR_SEGMENT_GLOBAL);
62
63
}

64
static inline ir_type *
65
66
_get_tls_type(void) {
	return _get_segment_type(IR_SEGMENT_THREAD_LOCAL);
67
68
}

69
static inline int
Michael Beck's avatar
Michael Beck committed
70
_get_irp_n_irgs(void) {
71
72
73
	assert (irp && irp->graphs);
	if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
	return ARR_LEN(irp->graphs);
74
75
}

76
static inline ir_graph *
Michael Beck's avatar
Michael Beck committed
77
_get_irp_irg(int pos){
78
79
80
	if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
	assert(0 <= pos && pos <= _get_irp_n_irgs());
	return irp->graphs[pos];
81
82
83
}


84
static inline int
85
86
87
_get_irp_n_types(void) {
	assert (irp && irp->types);
	return ARR_LEN(irp->types);
88
89
}

90
static inline ir_type *
Michael Beck's avatar
Michael Beck committed
91
_get_irp_type(int pos) {
92
93
94
	assert (irp && irp->types);
	/* Don't set the skip_tid result so that no double entries are generated. */
	return skip_tid(irp->types[pos]);
95
96
}

97
static inline int
Michael Beck's avatar
Michael Beck committed
98
_get_irp_n_modes(void) {
99
100
	assert (irp && irp->modes);
	return ARR_LEN(irp->modes);
Michael Beck's avatar
Michael Beck committed
101
102
}

103
static inline ir_mode *
Michael Beck's avatar
Michael Beck committed
104
_get_irp_mode(int pos) {
105
106
	assert (irp && irp->modes);
	return irp->modes[pos];
Michael Beck's avatar
Michael Beck committed
107
108
}

109
static inline int
110
_get_irp_n_opcodes(void) {
111
112
	assert (irp && irp->opcodes);
	return ARR_LEN(irp->opcodes);
113
114
}

115
static inline ir_op *
116
_get_irp_opcode(int pos) {
117
118
	assert (irp && irp->opcodes);
	return irp->opcodes[pos];
119
120
}

121
#ifdef DEBUG_libfirm
Michael Beck's avatar
Michael Beck committed
122
/** Returns a new, unique number to number nodes or the like. */
123
static inline long
124
get_irp_new_node_nr(void) {
125
126
	assert(irp);
	return irp->max_node_nr++;
127
128
}
#endif /* DEBUG_libfirm */
129

130
static inline int
Matthias Braun's avatar
Matthias Braun committed
131
132
133
134
135
get_irp_new_irg_idx(void) {
	assert(irp);
	return irp->max_irg_idx++;
}

136
static inline ir_graph *
Michael Beck's avatar
Michael Beck committed
137
_get_const_code_irg(void) {
138
139
140
141
	return irp->const_code_irg;
}

/** Returns a new, unique exception region number. */
142
static inline ir_exc_region_t
143
144
145
_get_irp_next_region_nr(void) {
	assert(irp);
	return ++irp->last_region_nr;
146
147
}

Michael Beck's avatar
Michael Beck committed
148
/** Returns a new, unique label number. */
149
static inline ir_label_t
Michael Beck's avatar
Michael Beck committed
150
151
152
153
154
_get_irp_next_label_nr(void) {
	assert(irp);
	return ++irp->last_label_nr;
}

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

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

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

164
165
166
167
168
169
170
171
172
173
/* Inline functions. */
#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()
Matthias Braun's avatar
Matthias Braun committed
174
#define get_segment_type(s)       _get_segment_type(s)
175
176
177
#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()
Michael Beck's avatar
Michael Beck committed
178
#define get_irp_next_label_nr()   _get_irp_next_label_nr()
179

Matthias Braun's avatar
Matthias Braun committed
180
#endif