irprog_t.h 4.11 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
}

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

Matthias Braun's avatar
Matthias Braun committed
67
static inline ir_graph *_get_irp_irg(size_t pos)
68
{
Matthias Braun's avatar
Matthias Braun committed
69
	assert(pos < ARR_LEN(irp->graphs));
70
	return irp->graphs[pos];
71
72
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Matthias Braun's avatar
Matthias Braun committed
168
#endif