169ec12191e9f6b6a39d87e8e2da3b3763d01536
[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
34 #include "array.h"
35
36 /** ir_prog */
37 struct ir_prog {
38   firm_kind kind;
39   ident     *name;                /**< A file name or the like. */
40   ir_graph  *main_irg;            /**< entry point to the compiled program
41                                        @@@ or a list, in case we compile a library or the like? */
42   ir_graph **graphs;              /**< all graphs in the ir */
43   ir_graph **pseudo_graphs;       /**< all pseudo graphs in the ir. See pseudo_irg.c */
44   ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
45                                        to allocate nodes the represent values
46                                        of constant entities. It is not meant as
47                                        a procedure.  */
48   type      *glob_type;           /**< global type.  Must be a class as it can
49                                        have fields and procedures.  */
50   type     **types;               /**< all types in the ir */
51
52   /* -- states of and access to generated information -- */
53
54   ip_view_state ip_view;          /**< State of interprocedural view. */
55
56   irg_outs_state outs_state;      /**< State of out edges of ir nodes. */
57   ir_node **ip_outedges;          /**< Huge Array that contains all out edges
58                                        in interprocedural view. */
59   irg_outs_state trouts_state;    /**< State of out edges of type information. */
60
61   irg_callee_info_state callee_info_state; /**< Validity of callee information.
62                                               Contains the lowest value or all irgs.  */
63   ir_typeinfo_state typeinfo_state;    /**< Validity of type information. */
64
65   irp_callgraph_state callgraph_state; /**< State of the callgraph. */
66   struct ir_loop *outermost_cg_loop;   /**< For callgraph analysis: entry point
67                                             to looptree over callgraph. */
68   int max_callgraph_loop_depth;        /**< needed in callgraph. */
69   int max_callgraph_recursion_depth;   /**< needed in callgraph. */
70   int max_method_execution_frequency;  /**< needed in callgraph. */
71
72 #ifdef DEBUG_libfirm
73   long max_node_nr;                /**< to generate unique numbers for nodes. */
74 #endif
75 };
76
77 void remove_irp_type_from_list (type *typ);
78
79 static INLINE type *
80 __get_glob_type(void) {
81   assert(irp);
82   return irp->glob_type = skip_tid(irp->glob_type);
83 }
84
85 static INLINE int
86 __get_irp_n_irgs(void) {
87   assert (irp && irp->graphs);
88   if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
89   return (ARR_LEN((irp)->graphs));
90 }
91
92 static INLINE ir_graph *
93 __get_irp_irg(int pos){
94   if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
95   assert(0 <= pos && pos <= get_irp_n_irgs());
96   return irp->graphs[pos];
97 }
98
99
100 static INLINE int
101 __get_irp_n_types (void) {
102   assert (irp && irp->types);
103   return (ARR_LEN((irp)->types));
104 }
105
106 static INLINE type *
107 __get_irp_type(int pos) {
108   assert (irp && irp->types);
109   /* Don't set the skip_tid result so that no double entries are generated. */
110   return skip_tid(irp->types[pos]);
111 }
112
113 #ifdef DEBUG_libfirm
114 /** Returns a new, unique number to number nodes or the like. */
115 int get_irp_new_node_nr(void);
116 #endif
117
118 static INLINE ir_graph *
119 __get_const_code_irg(void)
120 {
121   return irp->const_code_irg;
122 }
123
124 void           set_irp_ip_outedges(ir_node ** ip_outedges);
125 ir_node**      get_irp_ip_outedges(void);
126
127 /** initializes ir_prog. Calls the constructor for an ir_prog. */
128 void init_irprog(void);
129
130 #define get_irp_n_irgs()       __get_irp_n_irgs()
131 #define get_irp_irg(pos)       __get_irp_irg(pos)
132 #define get_irp_n_types()      __get_irp_n_types()
133 #define get_irp_type(pos)      __get_irp_type(pos)
134 #define get_const_code_irg()   __get_const_code_irg()
135 #define get_glob_type()        __get_glob_type()
136
137 #endif /* ifndef _IRPROG_T_H_ */