3 * File name: ir/ir/irprog.h
4 * Purpose: Entry point to the representation of a whole program.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2000-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 * ir representation of a program.
18 * @author Goetz Lindenmaier
20 * This file defines a construct that keeps all information about a
22 * - A list of all procedures.
23 * - A list of all types.
24 * - A global type that can be thought of as a god-class containing all
25 * global variables and procedures. This is not the base class of
26 * all classes in a class hierarchy (as, e.g., "object" in java).
27 * - (An obstack containing global things, e.g., the above mentioned lists.)
37 * Datastructure that holds central information about a program
39 * Preliminary documentation ;-)
41 * - main_irg: The ir graph that is the entry point to the program.
42 * (Anything not reachable from here may be optimized away.
43 * If we want to translate libraries or the like correctly
44 * we must replace this by a list.)
45 * - irg: List of all ir graphs in the program.
46 * - type: A list containing all types known to the translated program.
47 * Some types can have several entries in this list (as a result of
48 * using exchange_types()).
49 * - glob_type: The unique global type that is owner of all global entities.
52 typedef struct ir_prog ir_prog;
55 * A variable from where everything in the ir can be accessed.
56 * This variable contains the irp, the "immediate representation program".
57 * This variable should be considered constant. Moreover, one should use get_irp()
58 * to get access the the irp.
61 * Think of the irp as the "handle" of libFirm.
66 * Returns the access points from where everything in the ir can be accessed.
70 ir_prog *get_irp(void);
72 /** initializes ir_prog. Calls the constructor for an ir_prog. */
73 void init_irprog(void);
75 /** Creates a new ir_prog, returns it and sets irp with it.
76 Automatically called by init_firm() through init_irprog. */
77 ir_prog *new_ir_prog (void);
79 /** Gets the main routine of the compiled program. */
80 ir_graph *get_irp_main_irg(void);
82 /** Sets the main routine of the compiled program. */
83 void set_irp_main_irg(ir_graph *main_irg);
85 /** Adds irg to the list of ir graphs in irp. */
86 void add_irp_irg(ir_graph *irg);
88 /** Removes irg from the list of irgs, deallocates it and
89 shrinks the list by one. */
90 void remove_irp_irg(ir_graph *irg);
92 /** Returns the number of ir graphs in the irp. */
93 int get_irp_n_irgs(void);
95 /** Returns the ir graph at position pos in the irp. */
96 ir_graph *get_irp_irg(int pos);
98 /** Sets the ir graph at position pos. */
99 void set_irp_irg(int pos, ir_graph *irg);
101 /** Adds type to the list of types in irp. */
102 void add_irp_type(type *typ);
104 /** Removes type from the list of types, deallocates it and
105 shrinks the list by one. */
106 void remove_irp_type(type *typ);
108 /** Returns the number of all types in the irp. */
109 int get_irp_n_types(void);
111 /** Returns the type at position pos in the irp. */
112 type *get_irp_type(int pos);
114 /** Overwrites the type at position pos with another type. */
115 void set_irp_type(int pos, type *typ);
117 /** Returns the "global" type of the irp. */
118 type *get_glob_type(void);
120 /** File name / executable name or the like. Initially NULL! **/
121 void set_irp_prog_name (ident *name);
122 ident *get_irp_prog_ident(void);
123 const char *get_irp_prog_name (void);
126 * Returns an irgraph that only contains constant
128 * expressions for constant entities.
129 * Do not use any access function for this graph, do not generate code
130 * for this graph. This graph contains only one block. The constant
131 * expressions may not contain control flow. See also copy_const_code()
134 ir_graph *get_const_code_irg(void);
136 #endif /* ifndef _IRPROG_H_ */