*** 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
24 struct ir_prog {
25   firm_kind kind;
26   ir_graph *main_irg;              /* entry point to the compiled program */
27                   /* or a list, in case we compile a library or the like? */
28   ir_graph **graphs;               /* all graphs in the ir */
29   type_class *glob_type;           /* global type.  Class as it can have
30                                       fields and procedures.  Does this work?
31                                       Better name??? @@@ */
32   type **types;                    /* all types in the ir */
33   /*struct obstack *obst;           * @@@ Should we place all types and
34                                       entities on an obstack, too? */
35 #ifdef DEBUG_libfirm
36   long max_node_nr;                /* to generate unique numbers for nodes. */
37 #endif
38 };
39
40 typedef struct ir_prog ir_prog;
41
42 /* A variable from where everything in the ir can be accessed. */
43 extern ir_prog *irp;
44
45 /* initializes ir_prog. Calles the constructor for an ir_prog. */
46 void init_irprog(void);
47
48 /* Creates a new ir_prog, returns it and sets irp with it.
49    Automatically called by init_firm through init_irprog. */
50 ir_prog *new_ir_prog (void);
51
52 /* Access the main routine of the compiled program. */
53 ir_graph *get_irp_main_irg();
54 void      set_irp_main_irg(ir_graph *main_irg);
55
56 /* Adds irg to the list of ir graphs in irp. */
57 void      add_irp_irg(ir_graph *irg);
58 int       get_irp_n_irgs();
59 ir_graph *get_irp_irg(int pos);
60 void      set_irp_irg(int pos, ir_graph *irg);
61
62 /* Adds type to the list of types in irp. */
63 void  add_irp_type(type *typ);
64 int   get_irp_n_types();
65 type *get_irp_type(int pos);
66 void  set_irp_type(int pos, type *typ);
67
68 /** Functions to access the fields of ir_prog **/
69 type_class *get_glob_type(void);
70
71 #ifdef DEBUG_libfirm
72 /* Returns a new, unique number to number nodes or the like. */
73 int get_irp_new_node_nr();
74 #endif
75
76 #endif /* ifndef _IRPROG_H_ */