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

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

39
#include "array.h"
40

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

44
/* inline functions */
45
static inline ir_type *_get_segment_type(ir_segment_t segment)
46
{
47
48
	assert(segment <= IR_SEGMENT_LAST);
	return irp->segment_types[segment];
49
50
}

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

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

61
62
static inline int _get_irp_n_irgs(void)
{
Matthias Braun's avatar
Matthias Braun committed
63
	assert(irp && irp->graphs);
64
	return (int)ARR_LEN(irp->graphs);
65
66
}

67
68
static inline ir_graph *_get_irp_irg(int pos)
{
Michael Beck's avatar
Michael Beck committed
69
	assert(0 <= pos && pos <= ARR_LEN(irp->graphs));
70
	return irp->graphs[pos];
71
72
}

73
74
static inline int _get_irp_n_types(void)
{
Matthias Braun's avatar
Matthias Braun committed
75
	assert(irp && irp->types);
76
	return (int)ARR_LEN(irp->types);
77
78
}

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

86
87
static inline int _get_irp_n_modes(void)
{
Matthias Braun's avatar
Matthias Braun committed
88
	assert(irp->modes);
89
	return (int)ARR_LEN(irp->modes);
Michael Beck's avatar
Michael Beck committed
90
91
}

92
93
static inline ir_mode *_get_irp_mode(int pos)
{
Matthias Braun's avatar
Matthias Braun committed
94
	assert(irp && irp->modes);
95
	return irp->modes[pos];
Michael Beck's avatar
Michael Beck committed
96
97
}

98
99
static inline int _get_irp_n_opcodes(void)
{
Matthias Braun's avatar
Matthias Braun committed
100
	assert(irp && irp->opcodes);
101
	return (int)ARR_LEN(irp->opcodes);
102
103
}

104
105
static inline ir_op *_get_irp_opcode(int pos)
{
Matthias Braun's avatar
Matthias Braun committed
106
	assert(irp && irp->opcodes);
107
	return irp->opcodes[pos];
108
109
}

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

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

123
124
static inline ir_graph *_get_const_code_irg(void)
{
125
126
127
128
	return irp->const_code_irg;
}

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

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

Götz Lindenmaier's avatar
Götz Lindenmaier committed
142
143
144
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

145
146
147
148
149
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

151
152
153
154
155
156
157
158
159
160
/* 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
161
#define get_segment_type(s)       _get_segment_type(s)
162
163
164
#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
165
#define get_irp_next_label_nr()   _get_irp_next_label_nr()
166

Matthias Braun's avatar
Matthias Braun committed
167
#endif