irprog_t.h 6.15 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
2
3
4
5
6
7
8
9
10
11
/*
 * 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$
 * Copyright:   (c) 2000-2003 Universitt Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
Boris Boesler's avatar
Boris Boesler committed
12

Michael Beck's avatar
Michael Beck committed
13
14
15
16
/**
 * @file irprog_t.h
 */

17
18
#ifndef _FIRM_IR_IRPROG_T_H_
#define _FIRM_IR_IRPROG_T_H_
Götz Lindenmaier's avatar
Götz Lindenmaier committed
19

20
#ifdef HAVE_CONFIG_H
21
#include "firm_config.h"
22
23
#endif

Götz Lindenmaier's avatar
Götz Lindenmaier committed
24
#include "irprog.h"
25
#include "irgraph.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
26
#include "pseudo_irg.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
27
#include "ircgcons.h"
28
#include "firm_common_t.h"
29
#include "typegmod.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
30
#include "irtypeinfo.h"
31
#include "tr_inheritance.h"
Götz Lindenmaier's avatar
Götz Lindenmaier committed
32

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

37
#include "array.h"
38

Michael Beck's avatar
Michael Beck committed
39
/** ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
40
struct ir_prog {
Michael Beck's avatar
Michael Beck committed
41
  firm_kind kind;                 /**< must be k_ir_prog */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
42
  ident     *name;                /**< A file name or the like. */
Michael Beck's avatar
Michael Beck committed
43
  ir_graph  *main_irg;            /**< entry point to the compiled program
Götz Lindenmaier's avatar
Götz Lindenmaier committed
44
				       @@@ or a list, in case we compile a library or the like? */
Michael Beck's avatar
Michael Beck committed
45
  ir_graph **graphs;              /**< all graphs in the ir */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
46
  ir_graph **pseudo_graphs;       /**< all pseudo graphs in the ir. See pseudo_irg.c */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
47
  ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
Michael Beck's avatar
Michael Beck committed
48
49
50
                                       to allocate nodes the represent values
                                       of constant entities. It is not meant as
                                       a procedure.  */
51
  ir_type   *glob_type;           /**< The global type.  Must be a class as it can
Michael Beck's avatar
Michael Beck committed
52
                                       have fields and procedures.  */
53
54
  ir_type   *tls_type;            /**< The thread local storage type.  Must be a struct as it can
                                       only have fields.  */
55
  ir_type  **types;               /**< all types in the ir */
Michael Beck's avatar
Michael Beck committed
56
  ir_mode  **modes;               /**< all modes in the ir */
57
  ir_op    **opcodes;             /**< all opcodes in the ir */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
58
59

  /* -- states of and access to generated information -- */
60
  irg_phase_state phase_state;    /**< State of construction. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
61
62
63

  ip_view_state ip_view;          /**< State of interprocedural view. */

Götz Lindenmaier's avatar
Götz Lindenmaier committed
64
  irg_outs_state outs_state;      /**< State of out edges of ir nodes. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
65
  ir_node **ip_outedges;          /**< Huge Array that contains all out edges
Michael Beck's avatar
Michael Beck committed
66
                                       in interprocedural view. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
67
  irg_outs_state trouts_state;    /**< State of out edges of type information. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
68
69

  irg_callee_info_state callee_info_state; /**< Validity of callee information.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
70
71
					      Contains the lowest value or all irgs.  */
  ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
72
  inh_transitive_closure_state inh_trans_closure_state;  /**< trans closure of inh relations. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
73
74

  irp_callgraph_state callgraph_state; /**< State of the callgraph. */
75
  ir_loop *outermost_cg_loop;          /**< For callgraph analysis: entry point
Götz Lindenmaier's avatar
Götz Lindenmaier committed
76
					    to looptree over callgraph. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
77
78
  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
79
  double max_method_execution_frequency;  /**< needed in callgraph. */
80
  irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
81
82
  exec_freq_state execfreq_state;        /**< State of execution freqency information */
  loop_nesting_depth_state lnd_state;  /**< State of loop nesting depth information. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
83
84
  ir_class_cast_state class_cast_state;    /**< kind of cast operations in code. */

Götz Lindenmaier's avatar
Götz Lindenmaier committed
85
#ifdef DEBUG_libfirm
86
  long max_node_nr;                   /**< to generate unique numbers for nodes. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
87
88
89
#endif
};

Michael Beck's avatar
Michael Beck committed
90
91
92
93
/** Adds mode to the list of modes in irp. */
void  add_irp_mode(ir_mode *mode);

/* INLINE functions */
94

95
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
96
_get_glob_type(void) {
97
98
99
100
  assert(irp);
  return irp->glob_type = skip_tid(irp->glob_type);
}

101
102
103
104
105
106
static INLINE ir_type *
_get_tls_type(void) {
  assert(irp);
  return irp->tls_type = skip_tid(irp->tls_type);
}

107
static INLINE int
Michael Beck's avatar
Michael Beck committed
108
_get_irp_n_irgs(void) {
109
  assert (irp && irp->graphs);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
110
  if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
Michael Beck's avatar
Michael Beck committed
111
  return ARR_LEN(irp->graphs);
112
113
114
}

static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
115
_get_irp_irg(int pos){
Götz Lindenmaier's avatar
Götz Lindenmaier committed
116
  if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
Michael Beck's avatar
Michael Beck committed
117
  assert(0 <= pos && pos <= _get_irp_n_irgs());
Beyhan's avatar
Beyhan committed
118
  return irp->graphs[pos];
119
120
121
122
}


static INLINE int
Michael Beck's avatar
Michael Beck committed
123
_get_irp_n_types (void) {
124
  assert (irp && irp->types);
Michael Beck's avatar
Michael Beck committed
125
  return ARR_LEN(irp->types);
126
127
}

128
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
129
_get_irp_type(int pos) {
130
131
  assert (irp && irp->types);
  /* Don't set the skip_tid result so that no double entries are generated. */
Beyhan's avatar
Beyhan committed
132
  return skip_tid(irp->types[pos]);
133
134
}

Michael Beck's avatar
Michael Beck committed
135
136
137
138
139
140
141
142
143
144
145
146
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];
}

147
148
149
150
151
152
153
154
155
156
157
158
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];
}

159
#ifdef DEBUG_libfirm
Michael Beck's avatar
Michael Beck committed
160
/** Returns a new, unique number to number nodes or the like. */
161
162
163
164
165
166
static INLINE long
get_irp_new_node_nr(void) {
  assert(irp);
  return irp->max_node_nr++;
}
#endif /* DEBUG_libfirm */
167

168
static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
169
_get_const_code_irg(void) {
170
171
172
  return irp->const_code_irg;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
173
174
175
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

176
177
178
179
180
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

Michael Beck's avatar
Michael Beck committed
182
183
184
185
186
187
#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)
188
189
#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
190
191
#define get_const_code_irg()   _get_const_code_irg()
#define get_glob_type()        _get_glob_type()
192
#define get_tls_type()         _get_tls_type()
193

194
#endif /* ifndef _FIRM_IR_IRPROG_T_H_ */