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