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 /** frees all memory used by irp. Types in type list and irgs in irg
80 list must be freed by hand before. */
81 void free_ir_prog(void);
83 /** Gets the main routine of the compiled program. */
84 ir_graph *get_irp_main_irg(void);
86 /** Sets the main routine of the compiled program. */
87 void set_irp_main_irg(ir_graph *main_irg);
89 /** Adds irg to the list of ir graphs in irp. */
90 void add_irp_irg(ir_graph *irg);
92 /** Removes irg from the list of irgs, deallocates it and
93 shrinks the list by one. */
94 void remove_irp_irg(ir_graph *irg);
96 /** Returns the number of ir graphs in the irp. */
97 int get_irp_n_irgs(void);
99 /** Returns the ir graph at position pos in the irp. */
100 ir_graph *get_irp_irg(int pos);
102 /** Sets the ir graph at position pos. */
103 void set_irp_irg(int pos, ir_graph *irg);
105 /** Adds type to the list of types in irp. */
106 void add_irp_type(type *typ);
108 /** Removes type from the list of types, deallocates it and
109 shrinks the list by one. */
110 void remove_irp_type(type *typ);
112 /** Returns the number of all types in the irp. */
113 int get_irp_n_types(void);
115 /** Returns the type at position pos in the irp. */
116 type *get_irp_type(int pos);
118 /** Overwrites the type at position pos with another type. */
119 void set_irp_type(int pos, type *typ);
121 /** Returns the "global" type of the irp. */
122 type *get_glob_type(void);
124 /** File name / executable name or the like. Initially NULL! **/
125 void set_irp_prog_name (ident *name);
126 ident *get_irp_prog_ident(void);
127 const char *get_irp_prog_name (void);
130 * Returns an irgraph that only contains constant
132 * expressions for constant entities.
133 * Do not use any access function for this graph, do not generate code
134 * for this graph. This graph contains only one block. The constant
135 * expressions may not contain control flow. See also copy_const_code()
138 ir_graph *get_const_code_irg(void);
140 irg_outs_state get_irp_ip_outs_state(void);
141 void set_irp_ip_outs_inconsistent(void);
142 void set_irp_ip_outedges(ir_node ** ip_outedges);
143 ir_node** get_irp_ip_outedges(void);
145 #endif /* ifndef _IRPROG_H_ */