1 /* Copyright (C) 2000 by Universitaet Karlsruhe
8 * ir representation of a program.
10 * @author Goetz Lindenmaier
12 * This file defines a construct that keeps all information about a
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.)
31 * Datastructure that holds central information about a program
33 * Preliminary documentation ;-)
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.
46 typedef struct ir_prog ir_prog;
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.
55 * Think of the irp as the "handle" of libFirm.
60 * Returns the access points from where everything in the ir can be accessed.
64 ir_prog *get_irp(void);
66 /** initializes ir_prog. Calls the constructor for an ir_prog. */
67 void init_irprog(void);
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);
73 /** Gets the main routine of the compiled program. */
74 ir_graph *get_irp_main_irg(void);
76 /** Sets the main routine of the compiled program. */
77 void set_irp_main_irg(ir_graph *main_irg);
79 /** Adds irg to the list of ir graphs in irp. */
80 void add_irp_irg(ir_graph *irg);
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);
86 /** Returns the number of ir graphs in the irp. */
87 int get_irp_n_irgs(void);
89 /** Returns the ir graph at position pos in the irp. */
90 ir_graph *get_irp_irg(int pos);
92 /** Sets the ir graph at position pos. */
93 void set_irp_irg(int pos, ir_graph *irg);
95 /** Adds type to the list of types in irp. */
96 void add_irp_type(type *typ);
98 /** Removes type from the list of types, deallocates it and
99 shrinks the list by one. */
100 void remove_irp_type(type *typ);
102 /** Returns the number of all types in the irp. */
103 int get_irp_n_types(void);
105 /** Returns the type at position pos in the irp. */
106 type *get_irp_type(int pos);
108 /** Overwrites the type at position pos with another type. */
109 void set_irp_type(int pos, type *typ);
111 /** Returns the "global" type of the irp. */
112 type *get_glob_type(void);
116 * Returns an irgraph that only contains constant
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()
124 ir_graph *get_const_code_irg(void);
126 #endif /* ifndef _IRPROG_H_ */