more
[libfirm] / ir / ir / irprog_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irprog_t.h
4  * Purpose:     Entry point to the representation of a whole program 0-- private header.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     2000
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2000-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irprog_t.h
15  */
16
17 #ifndef _IRPROG_T_H_
18 #define _IRPROG_T_H_
19
20 #ifdef HAVE_CONFIG_H
21 #include "firm_config.h"
22 #endif
23
24 #include "irprog.h"
25 #include "irgraph.h"
26 #include "pseudo_irg.h"
27 #include "ircgcons.h"
28 #include "firm_common_t.h"
29 #include "typegmod.h"
30 #include "irtypeinfo.h"
31
32 #include "callgraph.h"
33 #include "field_temperature.h"
34
35 #include "array.h"
36
37 /** ir_prog */
38 struct ir_prog {
39   firm_kind kind;
40   ident     *name;                /**< A file name or the like. */
41   ir_graph  *main_irg;            /**< entry point to the compiled program
42                                        @@@ or a list, in case we compile a library or the like? */
43   ir_graph **graphs;              /**< all graphs in the ir */
44   ir_graph **pseudo_graphs;       /**< all pseudo graphs in the ir. See pseudo_irg.c */
45   ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
46                                        to allocate nodes the represent values
47                                        of constant entities. It is not meant as
48                                        a procedure.  */
49   type      *glob_type;           /**< global type.  Must be a class as it can
50                                        have fields and procedures.  */
51   type     **types;               /**< all types in the ir */
52
53   /* -- states of and access to generated information -- */
54   irg_phase_state phase_state;    /**< State of construction. */
55
56   ip_view_state ip_view;          /**< State of interprocedural view. */
57
58   irg_outs_state outs_state;      /**< State of out edges of ir nodes. */
59   ir_node **ip_outedges;          /**< Huge Array that contains all out edges
60                                        in interprocedural view. */
61   irg_outs_state trouts_state;    /**< State of out edges of type information. */
62
63   irg_callee_info_state callee_info_state; /**< Validity of callee information.
64                                               Contains the lowest value or all irgs.  */
65   ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
66
67   irp_callgraph_state callgraph_state; /**< State of the callgraph. */
68   struct ir_loop *outermost_cg_loop;   /**< For callgraph analysis: entry point
69                                             to looptree over callgraph. */
70   int max_callgraph_loop_depth;        /**< needed in callgraph. */
71   int max_callgraph_recursion_depth;   /**< needed in callgraph. */
72   int max_method_execution_frequency;  /**< needed in callgraph. */
73   irp_temperature_state temperature_state; /**< accumulated temperatures computed? */
74
75 #ifdef DEBUG_libfirm
76   long max_node_nr;                /**< to generate unique numbers for nodes. */
77 #endif
78 };
79
80 void remove_irp_type_from_list (type *typ);
81
82 static INLINE type *
83 __get_glob_type(void) {
84   assert(irp);
85   return irp->glob_type = skip_tid(irp->glob_type);
86 }
87
88 static INLINE int
89 __get_irp_n_irgs(void) {
90   assert (irp && irp->graphs);
91   if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
92   return (ARR_LEN((irp)->graphs));
93 }
94
95 static INLINE ir_graph *
96 __get_irp_irg(int pos){
97   if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
98   assert(0 <= pos && pos <= get_irp_n_irgs());
99   return irp->graphs[pos];
100 }
101
102
103 static INLINE int
104 __get_irp_n_types (void) {
105   assert (irp && irp->types);
106   return (ARR_LEN((irp)->types));
107 }
108
109 static INLINE type *
110 __get_irp_type(int pos) {
111   assert (irp && irp->types);
112   /* Don't set the skip_tid result so that no double entries are generated. */
113   return skip_tid(irp->types[pos]);
114 }
115
116 #ifdef DEBUG_libfirm
117 /** Returns a new, unique number to number nodes or the like. */
118 int get_irp_new_node_nr(void);
119 #endif
120
121 static INLINE ir_graph *
122 __get_const_code_irg(void)
123 {
124   return irp->const_code_irg;
125 }
126
127 void           set_irp_ip_outedges(ir_node ** ip_outedges);
128 ir_node**      get_irp_ip_outedges(void);
129
130 /** initializes ir_prog. Calls the constructor for an ir_prog. */
131 void init_irprog(void);
132
133 #define get_irp_n_irgs()       __get_irp_n_irgs()
134 #define get_irp_irg(pos)       __get_irp_irg(pos)
135 #define get_irp_n_types()      __get_irp_n_types()
136 #define get_irp_type(pos)      __get_irp_type(pos)
137 #define get_const_code_irg()   __get_const_code_irg()
138 #define get_glob_type()        __get_glob_type()
139
140 #endif /* ifndef _IRPROG_T_H_ */