Converted documentation to doxygen.
[libfirm] / ir / ir / irprog.h
1 /* Copyright (C) 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 */
4
5 /**
6 * @file irprog.h
7 *
8 * ir representation of a program.
9 *
10 * @author Goetz Lindenmaier
11 *
12 * This file defines a construct that keeps all information about a
13 * program:
14 *   - A list of all procedures.
15 *   - A list of all types.
16 *   - A global type that can be thought of as a god-class containing all
17 *     global variables and procedures.  This is not the base class of
18 *     all classes in a class hierarchy (as, e.g., "object" in java).
19 *   - (An obstack containing global things, e.g., the above mentioned lists.)
20 */
21
22 /* $Id$ */
23
24 # ifndef _IRPROG_H_
25 # define _IRPROG_H_
26
27 # include "irnode.h"
28 # include "type.h"
29
30 /**
31  * Datastructure that holds central information about a program
32  *
33  * Preliminary documentation ;-)
34  *
35  * - main_irg:  The ir graph that is the entry point to the program.
36  *              (Anything not reachable from here may be optimized away.
37  *              If we want to translate libraries or the like correctly
38  *              we must replace this by a list.)
39  * - irg:       List of all ir graphs in the program.
40  * - type:      A list containing all types known to the translated program.
41  *              Some types can have several entries in this list (as a result of
42  *              using exchange_types()).
43  * - glob_type: The unique global type that is owner of all global entities.
44  *
45  */
46 typedef struct ir_prog ir_prog;
47
48 /**
49  * A variable from where everything in the ir can be accessed.
50  * This variable contains the irp, the "immediate representation program".
51  * This variable should be considered constant. Moreover, one should use get_irp()
52  * to get access the the irp.
53  *
54  * @note
55  *      Think of the irp as the "handle" of libFirm.
56  */
57 extern ir_prog *irp;
58
59 /**
60  * Returns the access points from where everything in the ir can be accessed.
61  *
62  * @see irp
63  */
64 ir_prog *get_irp(void);
65
66 /** initializes ir_prog. Calls the constructor for an ir_prog. */
67 void init_irprog(void);
68
69 /** Creates a new ir_prog, returns it and sets irp with it.
70    Automatically called by init_firm() through init_irprog.  */
71 ir_prog *new_ir_prog (void);
72
73 /** Gets the main routine of the compiled program. */
74 ir_graph *get_irp_main_irg(void);
75
76 /** Sets the main routine of the compiled program. */
77 void      set_irp_main_irg(ir_graph *main_irg);
78
79 /** Adds irg to the list of ir graphs in irp. */
80 void      add_irp_irg(ir_graph *irg);
81
82 /** Removes irg from the list of irgs, deallocates it and
83    shrinks the list by one. */
84 void      remove_irp_irg(ir_graph *irg);
85
86 /** Returns the number of ir graphs in the irp. */
87 int       get_irp_n_irgs(void);
88
89 /** Returns the ir graph at position pos in the irp. */
90 ir_graph *get_irp_irg(int pos);
91
92 /** Sets the ir graph at position pos. */
93 void      set_irp_irg(int pos, ir_graph *irg);
94
95 /** Adds type to the list of types in irp. */
96 void  add_irp_type(type *typ);
97
98 /** Removes type from the list of types, deallocates it and
99    shrinks the list by one. */
100 void  remove_irp_type(type *typ);
101
102 /** Returns the number of all types in the irp. */
103 int   get_irp_n_types(void);
104
105 /** Returns the type at position pos in the irp. */
106 type *get_irp_type(int pos);
107
108 /** Overwrites the type at position pos with another type. */
109 void  set_irp_type(int pos, type *typ);
110
111 /** Returns the "global" type of the irp. */
112 type *get_glob_type(void);
113
114
115 /**
116  *   Returns an irgraph that only contains constant
117  *
118  *   expressions for constant entities.
119  *   Do not use any access function for this graph, do not generate code
120  *   for this graph.  This graph contains only one block.  The constant
121  *   expressions may not contain control flow.  See also copy_const_code()
122  *   in entity.h.
123  */
124 ir_graph *get_const_code_irg(void);
125
126 #endif /* ifndef _IRPROG_H_ */