irprog_t.h 7.04 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
 *
 * 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.
 */

Götz Lindenmaier's avatar
Götz Lindenmaier committed
20
21
22
23
24
25
26
27
/*
 * Project:     libFIRM
 * File name:   ir/ir/irprog_t.h
 * Purpose:     Entry point to the representation of a whole program 0-- private header.
 * Author:      Goetz Lindenmaier
 * Modified by:
 * Created:     2000
 * CVS-ID:      $Id$
28
 * Copyright:   (c) 2000-2007 Universitt Karlsruhe
Götz Lindenmaier's avatar
Götz Lindenmaier committed
29
 */
Boris Boesler's avatar
Boris Boesler committed
30

Michael Beck's avatar
Michael Beck committed
31
32
33
34
/**
 * @file irprog_t.h
 */

35
36
#ifndef _FIRM_IR_IRPROG_T_H_
#define _FIRM_IR_IRPROG_T_H_
Götz Lindenmaier's avatar
Götz Lindenmaier committed
37

38
#ifdef HAVE_CONFIG_H
39
#include "firm_config.h"
40
41
#endif

Götz Lindenmaier's avatar
Götz Lindenmaier committed
42
#include "irprog.h"
43
#include "irgraph.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
44
#include "pseudo_irg.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
45
#include "ircgcons.h"
46
#include "firm_common_t.h"
47
#include "typegmod.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
48
#include "irtypeinfo.h"
49
#include "tr_inheritance.h"
50
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
51

Götz Lindenmaier's avatar
Götz Lindenmaier committed
52
#include "callgraph.h"
53
#include "field_temperature.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
54
#include "execution_frequency.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
55

56
#include "array.h"
57

Michael Beck's avatar
Michael Beck committed
58
/** ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
59
struct ir_prog {
Michael Beck's avatar
Michael Beck committed
60
  firm_kind kind;                 /**< must be k_ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
61
  ident     *name;                /**< A file name or the like. */
62
63
64
65
  ir_graph  *main_irg;            /**< The entry point to the compiled program
                                       or NULL if no poit exist. */
  ir_graph **graphs;              /**< A list of all graphs in the ir. */
  ir_graph **pseudo_graphs;       /**< A list of all pseudo graphs in the ir. See pseudo_irg.c */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
66
  ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
Michael Beck's avatar
Michael Beck committed
67
68
69
                                       to allocate nodes the represent values
                                       of constant entities. It is not meant as
                                       a procedure.  */
70
  ir_type   *glob_type;           /**< The global type.  Must be a class as it can
Michael Beck's avatar
Michael Beck committed
71
                                       have fields and procedures.  */
72
73
  ir_type   *tls_type;            /**< The thread local storage type.  Must be a struct as it can
                                       only have fields.  */
74
75
76
  ir_type  **types;               /**< A list of all types in the ir. */
  ir_mode  **modes;               /**< A list of all modes in the ir. */
  ir_op    **opcodes;             /**< A list of all opcodes in the ir. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
77
78

  /* -- states of and access to generated information -- */
79
  irg_phase_state phase_state;    /**< The state of construction. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
80

81
  ip_view_state ip_view;          /**< The state of interprocedural view. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
82

83
84
  irg_outs_state outs_state;      /**< The state of out edges of ir nodes. */
  ir_node **ip_outedges;          /**< A huge Array that contains all out edges
Michael Beck's avatar
Michael Beck committed
85
                                       in interprocedural view. */
86
  irg_outs_state trouts_state;    /**< The state of out edges of type information. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
87
88

  irg_callee_info_state callee_info_state; /**< Validity of callee information.
89
                                                Contains the lowest value or all irgs.  */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
90
  ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
91
  inh_transitive_closure_state inh_trans_closure_state;  /**< trans closure of inh relations. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
92

93
  irp_callgraph_state callgraph_state; /**< The state of the callgraph. */
94
  ir_loop *outermost_cg_loop;          /**< For callgraph analysis: entry point
95
                                            to looptree over callgraph. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
96
97
  int max_callgraph_loop_depth;        /**< needed in callgraph. */
  int max_callgraph_recursion_depth;   /**< needed in callgraph. */
Götz Lindenmaier's avatar
bugfix    
Götz Lindenmaier committed
98
  double max_method_execution_frequency;  /**< needed in callgraph. */
99
  irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
100
101
102
  exec_freq_state execfreq_state;        /**< The state of execution frequency information */
  loop_nesting_depth_state lnd_state;  /**< The state of loop nesting depth information. */
  ir_class_cast_state class_cast_state;    /**< The state of cast operations in code. */
103
  ir_address_taken_computed_state globals_adr_taken_state;  /**< Address taken state of the globals. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
104

Götz Lindenmaier's avatar
Götz Lindenmaier committed
105
#ifdef DEBUG_libfirm
106
  long max_node_nr;                   /**< to generate unique numbers for nodes. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
107
108
109
#endif
};

Michael Beck's avatar
Michael Beck committed
110
111
112
113
/** Adds mode to the list of modes in irp. */
void  add_irp_mode(ir_mode *mode);

/* INLINE functions */
114

115
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
116
_get_glob_type(void) {
117
118
119
120
  assert(irp);
  return irp->glob_type = skip_tid(irp->glob_type);
}

121
122
123
124
125
126
static INLINE ir_type *
_get_tls_type(void) {
  assert(irp);
  return irp->tls_type = skip_tid(irp->tls_type);
}

127
static INLINE int
Michael Beck's avatar
Michael Beck committed
128
_get_irp_n_irgs(void) {
129
  assert (irp && irp->graphs);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
130
  if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
Michael Beck's avatar
Michael Beck committed
131
  return ARR_LEN(irp->graphs);
132
133
134
}

static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
135
_get_irp_irg(int pos){
Götz Lindenmaier's avatar
Götz Lindenmaier committed
136
  if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
Michael Beck's avatar
Michael Beck committed
137
  assert(0 <= pos && pos <= _get_irp_n_irgs());
Beyhan's avatar
Beyhan committed
138
  return irp->graphs[pos];
139
140
141
142
}


static INLINE int
Michael Beck's avatar
Michael Beck committed
143
_get_irp_n_types (void) {
144
  assert (irp && irp->types);
Michael Beck's avatar
Michael Beck committed
145
  return ARR_LEN(irp->types);
146
147
}

148
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
149
_get_irp_type(int pos) {
150
151
  assert (irp && irp->types);
  /* Don't set the skip_tid result so that no double entries are generated. */
Beyhan's avatar
Beyhan committed
152
  return skip_tid(irp->types[pos]);
153
154
}

Michael Beck's avatar
Michael Beck committed
155
156
157
158
159
160
161
162
163
164
165
166
static INLINE int
_get_irp_n_modes(void) {
  assert (irp && irp->modes);
  return ARR_LEN(irp->modes);
}

static INLINE ir_mode *
_get_irp_mode(int pos) {
  assert (irp && irp->modes);
  return irp->modes[pos];
}

167
168
169
170
171
172
173
174
175
176
177
178
static INLINE int
_get_irp_n_opcodes(void) {
  assert (irp && irp->opcodes);
  return ARR_LEN(irp->opcodes);
}

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

179
#ifdef DEBUG_libfirm
Michael Beck's avatar
Michael Beck committed
180
/** Returns a new, unique number to number nodes or the like. */
181
182
183
184
185
186
static INLINE long
get_irp_new_node_nr(void) {
  assert(irp);
  return irp->max_node_nr++;
}
#endif /* DEBUG_libfirm */
187

188
static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
189
_get_const_code_irg(void) {
190
191
192
  return irp->const_code_irg;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
193
194
195
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

196
197
198
199
200
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

Michael Beck's avatar
Michael Beck committed
202
203
204
205
206
207
#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)
208
209
#define get_irp_n_opcodes()    _get_irp_n_opcodes()
#define get_irp_opcode(pos)    _get_irp_opcode(pos)
Michael Beck's avatar
Michael Beck committed
210
211
#define get_const_code_irg()   _get_const_code_irg()
#define get_glob_type()        _get_glob_type()
212
#define get_tls_type()         _get_tls_type()
213

214
#endif /* ifndef _FIRM_IR_IRPROG_T_H_ */