*** empty log message ***
[libfirm] / ir / ir / irprog.h
1 /* Copyright (C) 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Goetz Lindenmaier
5 **
6 ** irprog.h: ir representation of a program
7 **
8 ** This file defines a construct that keeps all information about a
9 ** program:
10 **   - A list of all procedures.
11 **   - A list of all types.
12 **   - A global type that can be thought of as a god-class containing all
13 **     global variables and procedures.  This is not the base class of
14 **     all classes in a class hierarchy (as, e.g., "object" in java).
15 **   - (An obstack containing global things, e.g., the above mentioned lists.)
16 */
17
18 # ifndef _IRPROG_H_
19 # define _IRPROG_H_
20
21 # include "irnode.h"
22 # include "type.h"
23 /*# include "obst.h"*/
24
25 struct ir_prog {
26   firm_kind kind;
27   ir_graph *main_irg;              /* entry point to the compiled program */
28                   /* or a list, in case we compile a library or the like? */
29   ir_graph **graphs;               /* all graphs in the ir */
30   type **types;                    /* all types in the ir */
31   type_class *glob_type;           /* global type.  Class as it can have
32                                       fields and procedures.  Does this work?
33                                       Better name??? @@@ */
34   /*struct obstack *obst;           * @@@ Should we place all types and
35                                       entities on an obstack, too? */
36 #ifdef DEBUG_libfirm
37   long max_node_nr;                /* to generate unique numbers for nodes. */
38 #endif
39 };
40
41 typedef struct ir_prog ir_prog;
42
43 /* A variable from where everything in the ir can be accessed. */
44 ir_prog *irp;
45
46
47 /* initializes ir_prog. Calles the constructor for an ir_prog. */
48 void init_irprog(void);
49
50 /* Creates a new ir_prog, returns it and sets irp with it.
51    Automatically called by init_firm through init_irprog. */
52 ir_prog *new_ir_prog (void);
53
54 /* Access the main routine of the compiled program. */
55 ir_graph *get_irp_main_irg();
56 void      set_irp_main_irg(ir_graph *main_irg);
57
58 /* Adds irg to the list of ir graphs in irp. */
59 void      add_irp_irg(ir_graph *irg);
60 int       get_irp_n_irgs();
61 ir_graph *get_irp_irg(int pos);
62   /*     set_irp_irg()     und das gleiche fuer type */
63
64 /* Adds type to the list of types in irp. */
65 void      add_irp_type(type *typ);
66
67 /** Functions to access the fields of ir_prog **/
68 type_class *get_glob_type(void);
69
70 #ifdef DEBUG_libfirm
71 /* Returns a new, unique number to number nodes or the like. */
72 int get_irp_new_node_nr();
73 #endif
74
75 #endif /* ifndef _IRPROG_H_ */