irprog_t.h 5.83 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;           /**< global type.  Must be a class as it can
Michael Beck's avatar
Michael Beck committed
52
                                       have fields and procedures.  */
53
  ir_type  **types;               /**< all types in the ir */
Michael Beck's avatar
Michael Beck committed
54
  ir_mode  **modes;               /**< all modes in the ir */
55
  ir_op    **opcodes;             /**< all opcodes in the ir */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
56
57

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

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

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

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

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

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

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

/* INLINE functions */
92

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

static INLINE int
Michael Beck's avatar
Michael Beck committed
100
_get_irp_n_irgs(void) {
101
  assert (irp && irp->graphs);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
102
  if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
Michael Beck's avatar
Michael Beck committed
103
  return ARR_LEN(irp->graphs);
104
105
106
}

static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
107
_get_irp_irg(int pos){
Götz Lindenmaier's avatar
Götz Lindenmaier committed
108
  if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
Michael Beck's avatar
Michael Beck committed
109
  assert(0 <= pos && pos <= _get_irp_n_irgs());
Beyhan's avatar
Beyhan committed
110
  return irp->graphs[pos];
111
112
113
114
}


static INLINE int
Michael Beck's avatar
Michael Beck committed
115
_get_irp_n_types (void) {
116
  assert (irp && irp->types);
Michael Beck's avatar
Michael Beck committed
117
  return ARR_LEN(irp->types);
118
119
}

120
static INLINE ir_type *
Michael Beck's avatar
Michael Beck committed
121
_get_irp_type(int pos) {
122
123
  assert (irp && irp->types);
  /* Don't set the skip_tid result so that no double entries are generated. */
Beyhan's avatar
Beyhan committed
124
  return skip_tid(irp->types[pos]);
125
126
}

Michael Beck's avatar
Michael Beck committed
127
128
129
130
131
132
133
134
135
136
137
138
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];
}

139
140
141
142
143
144
145
146
147
148
149
150
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];
}

151
#ifdef DEBUG_libfirm
Michael Beck's avatar
Michael Beck committed
152
/** Returns a new, unique number to number nodes or the like. */
153
154
155
156
157
158
static INLINE long
get_irp_new_node_nr(void) {
  assert(irp);
  return irp->max_node_nr++;
}
#endif /* DEBUG_libfirm */
159

160
static INLINE ir_graph *
Michael Beck's avatar
Michael Beck committed
161
_get_const_code_irg(void) {
162
163
164
  return irp->const_code_irg;
}

Götz Lindenmaier's avatar
Götz Lindenmaier committed
165
166
167
void           set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node**      get_irp_ip_outedges(void);

168
169
170
171
172
/** initializes ir_prog. Constructs only the basic lists */
void init_irprog_1(void);

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

Michael Beck's avatar
Michael Beck committed
174
175
176
177
178
179
#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)
180
181
#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
182
183
#define get_const_code_irg()   _get_const_code_irg()
#define get_glob_type()        _get_glob_type()
184

185
#endif /* ifndef _FIRM_IR_IRPROG_T_H_ */