Parted common.h into two files common_t.h. By this config.h
[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 /* $Id$ */
19
20 # ifndef _IRPROG_H_
21 # define _IRPROG_H_
22
23 # include "irnode.h"
24 # include "type.h"
25
26 /***** irprog/irprog
27  *
28  * NAME  Datastructure that holds central information about a program
29  *
30  * NOTE  Preliminary documentation ;-)
31  *
32  * SOURCE
33  */
34
35 /***s* irprog/irprog
36  *
37  * NAME  Datastructure that holds central information about a program
38  *
39  * NOTE  Preliminary documentation ;-)
40  *
41  * FIELDS
42  *  main_irg  The ir graph that is the entry point to the program.
43  *            (Anything not reachable from here may be optimized away.
44  *            If we want to translate libraries or the like correctly
45  *            we must replace this by a list.)
46  *  irg       List of all ir graphs in the program.
47  *  type      A list containing all types known to the translated program.
48  *            Some types can have several entries in this list (as a result of
49  *            using exchange_types()).
50  *  glob_type The unique global type that is owner of all global entities.
51  *
52  * SOURCE
53  */
54 typedef struct ir_prog ir_prog;
55
56 /* A variable from where everything in the ir can be accessed. */
57 extern ir_prog *irp;
58
59 /* initializes ir_prog. Calls the constructor for an ir_prog. */
60 void init_irprog(void);
61
62 /* Creates a new ir_prog, returns it and sets irp with it.
63    Automatically called by init_firm through init_irprog.  */
64 ir_prog *new_ir_prog (void);
65
66 /* Access the main routine of the compiled program. */
67 ir_graph *get_irp_main_irg();
68 void      set_irp_main_irg(ir_graph *main_irg);
69
70 /* Adds irg to the list of ir graphs in irp. */
71 void      add_irp_irg(ir_graph *irg);
72 /* Removes irg from the list or irgs, shrinks the list by one.
73    @@@ does not work properly. */
74 void      remove_irp_irg(ir_graph *irg);
75 int       get_irp_n_irgs();
76 ir_graph *get_irp_irg(int pos);
77 void      set_irp_irg(int pos, ir_graph *irg);
78
79 /* Adds type to the list of types in irp. */
80 void  add_irp_type(type *typ);
81 int   get_irp_n_types();
82 type *get_irp_type(int pos);
83 void  set_irp_type(int pos, type *typ);
84
85 /** Functions to access the fields of ir_prog **/
86 type *get_glob_type(void);
87
88 /*****/
89
90 /***p* irprog/get_const_code_irg
91  *
92  * NAME
93  *   get_const_code_irg - Returns an irgraph that only contains constant
94  *   expressions for constant entities.
95  * SYNOPSIS
96  *   ir_graph *get_const_code_irg();
97  * NOTE
98  *   Do not use any access function for this graph, do not generate code
99  *   for this graph.
100  */
101 ir_graph *get_const_code_irg();
102
103 #endif /* ifndef _IRPROG_H_ */