irprog_t.h 4.45 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 "firm_config.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
31
#include "irprog.h"
32
#include "irtypes.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
33
#include "pseudo_irg.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
34
#include "ircgcons.h"
35
#include "firm_common_t.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
36
#include "irtypeinfo.h"
37
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
38

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

43
#include "array.h"
44

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

/* INLINE functions */
49
static INLINE ir_type *
50
51
52
53
54
55
56
57
_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;
58
59
}

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

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

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

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


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

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

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

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

110
111
static INLINE int
_get_irp_n_opcodes(void) {
112
113
	assert (irp && irp->opcodes);
	return ARR_LEN(irp->opcodes);
114
115
116
117
}

static INLINE ir_op *
_get_irp_opcode(int pos) {
118
119
	assert (irp && irp->opcodes);
	return irp->opcodes[pos];
120
121
}

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

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

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

/** Returns a new, unique exception region number. */
Michael Beck's avatar
Michael Beck committed
143
static INLINE ir_exc_region_t
144
145
146
_get_irp_next_region_nr(void) {
	assert(irp);
	return ++irp->last_region_nr;
147
148
}

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

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

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

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

165
166
167
168
169
170
171
172
173
174
/* 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
175
#define get_segment_type(s)       _get_segment_type(s)
176
177
178
#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
179
#define get_irp_next_label_nr()   _get_irp_next_label_nr()
180

Matthias Braun's avatar
Matthias Braun committed
181
#endif