9fc9ad80e265107414935b23e749d223bbb1b01e
[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 "array.h"
31
32 /** ir_prog */
33 struct ir_prog {
34   firm_kind kind;
35   ir_graph  *main_irg;            /**< entry point to the compiled program
36                                      @@@ or a list, in case we compile a library or the like? */
37   ir_graph **graphs;              /**< all graphs in the ir */
38   type      *glob_type;           /**< global type.  Must be a class as it can
39                                      have fields and procedures.  */
40   type     **types;               /**< all types 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
46   irg_outs_state outs_state;     /**< Out edges. */
47   ir_node **ip_outedges;         /**< Huge Array that contains all out edges
48                                     in interprocedural view. */
49   ip_view_state ip_view;         /**< State of interprocedural view. */
50   ident     *name;
51   /*struct obstack *obst;          * @@@ Should we place all types and
52                                      entities on an obstack, too? */
53
54 #ifdef DEBUG_libfirm
55   long max_node_nr;                /**< to generate unique numbers for nodes. */
56 #endif
57 };
58
59 INLINE void remove_irp_type_from_list (type *typ);
60
61 static INLINE type *
62 __get_glob_type(void) {
63   assert(irp);
64   return irp->glob_type = skip_tid(irp->glob_type);
65 }
66
67 static INLINE int
68 __get_irp_n_irgs(void) {
69   assert (irp && irp->graphs);
70   /* Strangely the first element of the array is NULL.  Why??  */
71   return (ARR_LEN((irp)->graphs));
72 }
73
74 static INLINE ir_graph *
75 __get_irp_irg(int pos){
76   assert (irp && irp->graphs);
77   /* Strangely the first element of the array is NULL.  Why??  */
78   return irp->graphs[pos];
79 }
80
81
82 static INLINE int
83 __get_irp_n_types (void) {
84   assert (irp && irp->types);
85   /* Strangely the first element of the array is NULL.  Why??  */
86   return (ARR_LEN((irp)->types));
87 }
88
89 static INLINE type *
90 __get_irp_type(int pos) {
91   assert (irp && irp->types);
92   /* Strangely the first element of the array is NULL.  Why??  */
93   /* Don't set the skip_tid result so that no double entries are generated. */
94   return skip_tid(irp->types[pos]);
95 }
96
97 #ifdef DEBUG_libfirm
98 /** Returns a new, unique number to number nodes or the like. */
99 int get_irp_new_node_nr(void);
100 #endif
101
102 static INLINE ir_graph *
103 __get_const_code_irg(void)
104 {
105   return irp->const_code_irg;
106 }
107
108 #define get_irp_n_irgs()       __get_irp_n_irgs()
109 #define get_irp_irg(pos)       __get_irp_irg(pos)
110 #define get_irp_n_types()      __get_irp_n_types()
111 #define get_irp_type(pos)      __get_irp_type(pos)
112 #define get_const_code_irg()   __get_const_code_irg()
113 #define get_glob_type()        __get_glob_type()
114
115 #endif /* ifndef _IRPROG_T_H_ */