irprog_t.h 4.22 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
/* inline functions */
47
static inline ir_type *_get_segment_type(ir_segment_t segment)
48
{
49
50
	assert(segment <= IR_SEGMENT_LAST);
	return irp->segment_types[segment];
51
52
}

53
54
static inline ir_type *_get_glob_type(void)
{
55
	return _get_segment_type(IR_SEGMENT_GLOBAL);
56
57
}

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

63
64
static inline int _get_irp_n_irgs(void)
{
Matthias Braun's avatar
Matthias Braun committed
65
	assert(irp && irp->graphs);
66
67
	if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
	return ARR_LEN(irp->graphs);
68
69
}

70
71
static inline ir_graph *_get_irp_irg(int pos)
{
72
	if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
Michael Beck's avatar
Michael Beck committed
73
	assert(0 <= pos && pos <= ARR_LEN(irp->graphs));
74
	return irp->graphs[pos];
75
76
77
}


78
79
static inline int _get_irp_n_types(void)
{
Matthias Braun's avatar
Matthias Braun committed
80
	assert(irp && irp->types);
81
	return ARR_LEN(irp->types);
82
83
}

84
85
static inline ir_type *_get_irp_type(int pos)
{
Matthias Braun's avatar
Matthias Braun committed
86
	assert(irp->types);
87
	/* Don't set the skip_tid result so that no double entries are generated. */
Matthias Braun's avatar
Matthias Braun committed
88
	return irp->types[pos];
89
90
}

91
92
static inline int _get_irp_n_modes(void)
{
Matthias Braun's avatar
Matthias Braun committed
93
	assert(irp->modes);
94
	return ARR_LEN(irp->modes);
Michael Beck's avatar
Michael Beck committed
95
96
}

97
98
static inline ir_mode *_get_irp_mode(int pos)
{
Matthias Braun's avatar
Matthias Braun committed
99
	assert(irp && irp->modes);
100
	return irp->modes[pos];
Michael Beck's avatar
Michael Beck committed
101
102
}

103
104
static inline int _get_irp_n_opcodes(void)
{
Matthias Braun's avatar
Matthias Braun committed
105
	assert(irp && irp->opcodes);
106
	return ARR_LEN(irp->opcodes);
107
108
}

109
110
static inline ir_op *_get_irp_opcode(int pos)
{
Matthias Braun's avatar
Matthias Braun committed
111
	assert(irp && irp->opcodes);
112
	return irp->opcodes[pos];
113
114
}

Michael Beck's avatar
Michael Beck committed
115
/** Returns a new, unique number to number nodes or the like. */
116
117
static inline long get_irp_new_node_nr(void)
{
118
119
	assert(irp);
	return irp->max_node_nr++;
120
}
121

122
123
static inline int get_irp_new_irg_idx(void)
{
Matthias Braun's avatar
Matthias Braun committed
124
125
126
127
	assert(irp);
	return irp->max_irg_idx++;
}

128
129
static inline ir_graph *_get_const_code_irg(void)
{
130
131
132
133
	return irp->const_code_irg;
}

/** Returns a new, unique exception region number. */
134
135
static inline ir_exc_region_t _get_irp_next_region_nr(void)
{
136
137
	assert(irp);
	return ++irp->last_region_nr;
138
139
}

Michael Beck's avatar
Michael Beck committed
140
/** Returns a new, unique label number. */
141
142
static inline ir_label_t _get_irp_next_label_nr(void)
{
Michael Beck's avatar
Michael Beck committed
143
144
145
146
	assert(irp);
	return ++irp->last_label_nr;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
147
148
149
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

150
151
152
153
154
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

156
157
158
159
160
161
162
163
164
165
/* 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
166
#define get_segment_type(s)       _get_segment_type(s)
167
168
169
#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
170
#define get_irp_next_label_nr()   _get_irp_next_label_nr()
171

Matthias Braun's avatar
Matthias Braun committed
172
#endif