irprog_t.h 4.32 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"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
34
#include "irtypeinfo.h"
35
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
36

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

41
#include "array.h"
42

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

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

	assert(segment < IR_SEGMENT_COUNT);
Matthias Braun's avatar
Matthias Braun committed
53
	type                        = irp->segment_types[segment];
54
55
	irp->segment_types[segment] = type;
	return type;
56
57
}

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

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

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

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


83
static inline int
84
_get_irp_n_types(void) {
Matthias Braun's avatar
Matthias Braun committed
85
	assert(irp && irp->types);
86
	return ARR_LEN(irp->types);
87
88
}

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

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

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

108
static inline int
109
_get_irp_n_opcodes(void) {
Matthias Braun's avatar
Matthias Braun committed
110
	assert(irp && irp->opcodes);
111
	return ARR_LEN(irp->opcodes);
112
113
}

114
static inline ir_op *
115
_get_irp_opcode(int pos) {
Matthias Braun's avatar
Matthias Braun committed
116
	assert(irp && irp->opcodes);
117
	return irp->opcodes[pos];
118
119
}

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

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

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

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

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

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

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

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

161
162
163
164
165
166
167
168
169
170
/* 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
171
#define get_segment_type(s)       _get_segment_type(s)
172
173
174
#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
175
#define get_irp_next_label_nr()   _get_irp_next_label_nr()
176

Matthias Braun's avatar
Matthias Braun committed
177
#endif