irprog_t.h 6.8 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.
 */

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
#ifdef HAVE_CONFIG_H
31
#include "firm_config.h"
32
33
#endif

Götz Lindenmaier's avatar
Götz Lindenmaier committed
34
#include "irprog.h"
35
#include "irgraph.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
36
#include "pseudo_irg.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
37
#include "ircgcons.h"
38
#include "firm_common_t.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
39
#include "irtypeinfo.h"
40
#include "irmemory.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
41

Götz Lindenmaier's avatar
Götz Lindenmaier committed
42
#include "callgraph.h"
43
#include "field_temperature.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
44
#include "execution_frequency.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
45

46
#include "array.h"
47

Michael Beck's avatar
Michael Beck committed
48
/** ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
49
struct ir_prog {
Michael Beck's avatar
Michael Beck committed
50
  firm_kind kind;                 /**< must be k_ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
51
  ident     *name;                /**< A file name or the like. */
52
53
54
55
  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
56
  ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
Michael Beck's avatar
Michael Beck committed
57
58
59
                                       to allocate nodes the represent values
                                       of constant entities. It is not meant as
                                       a procedure.  */
60
  ir_type   *glob_type;           /**< The global type.  Must be a class as it can
Michael Beck's avatar
Michael Beck committed
61
                                       have fields and procedures.  */
62
63
  ir_type   *tls_type;            /**< The thread local storage type.  Must be a struct as it can
                                       only have fields.  */
64
65
66
  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
67
68

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

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

73
74
  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
75
                                       in interprocedural view. */
76
  irg_outs_state trouts_state;    /**< The state of out edges of type information. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
77
78

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

83
  irp_callgraph_state callgraph_state; /**< The state of the callgraph. */
84
  ir_loop *outermost_cg_loop;          /**< For callgraph analysis: entry point
85
                                            to looptree over callgraph. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
86
87
  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
88
  double max_method_execution_frequency;  /**< needed in callgraph. */
89
  irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
90
91
92
  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. */
93
  ir_address_taken_computed_state globals_adr_taken_state;  /**< Address taken state of the globals. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
94

Götz Lindenmaier's avatar
Götz Lindenmaier committed
95
#ifdef DEBUG_libfirm
96
  long max_node_nr;                   /**< to generate unique numbers for nodes. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
97
98
99
#endif
};

Michael Beck's avatar
Michael Beck committed
100
101
102
103
/** Adds mode to the list of modes in irp. */
void  add_irp_mode(ir_mode *mode);

/* INLINE functions */
104

105
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
106
_get_glob_type(void) {
107
108
109
110
  assert(irp);
  return irp->glob_type = skip_tid(irp->glob_type);
}

111
112
113
114
115
116
static INLINE ir_type *
_get_tls_type(void) {
  assert(irp);
  return irp->tls_type = skip_tid(irp->tls_type);
}

117
static INLINE int
Michael Beck's avatar
Michael Beck committed
118
_get_irp_n_irgs(void) {
119
  assert (irp && irp->graphs);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
120
  if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
Michael Beck's avatar
Michael Beck committed
121
  return ARR_LEN(irp->graphs);
122
123
124
}

static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
125
_get_irp_irg(int pos){
Götz Lindenmaier's avatar
Götz Lindenmaier committed
126
  if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
Michael Beck's avatar
Michael Beck committed
127
  assert(0 <= pos && pos <= _get_irp_n_irgs());
Beyhan's avatar
Beyhan committed
128
  return irp->graphs[pos];
129
130
131
132
}


static INLINE int
Michael Beck's avatar
Michael Beck committed
133
_get_irp_n_types (void) {
134
  assert (irp && irp->types);
Michael Beck's avatar
Michael Beck committed
135
  return ARR_LEN(irp->types);
136
137
}

138
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
139
_get_irp_type(int pos) {
140
141
  assert (irp && irp->types);
  /* Don't set the skip_tid result so that no double entries are generated. */
Beyhan's avatar
Beyhan committed
142
  return skip_tid(irp->types[pos]);
143
144
}

Michael Beck's avatar
Michael Beck committed
145
146
147
148
149
150
151
152
153
154
155
156
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];
}

157
158
159
160
161
162
163
164
165
166
167
168
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];
}

169
#ifdef DEBUG_libfirm
Michael Beck's avatar
Michael Beck committed
170
/** Returns a new, unique number to number nodes or the like. */
171
172
173
174
175
176
static INLINE long
get_irp_new_node_nr(void) {
  assert(irp);
  return irp->max_node_nr++;
}
#endif /* DEBUG_libfirm */
177

178
static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
179
_get_const_code_irg(void) {
180
181
182
  return irp->const_code_irg;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
183
184
185
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

186
187
188
189
190
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

Michael Beck's avatar
Michael Beck committed
192
193
194
195
196
197
#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)
198
199
#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
200
201
#define get_const_code_irg()   _get_const_code_irg()
#define get_glob_type()        _get_glob_type()
202
#define get_tls_type()         _get_tls_type()
203

Matthias Braun's avatar
Matthias Braun committed
204
#endif