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 reference point to the method to be executed on program start.
23 * - A list of all procedures.
24 * - A list of all types.
25 * - A global type that contais all global variables and procedures that do
26 * not belong to a class. This type represents the data segment of the
27 * program. It is not the base class of
28 * all classes in a class hierarchy (as, e.g., "object" in java).
29 * - A degenerated graph that contains constant expressions.
30 * - interprocedural outs state.
31 * - a flag indicating validity of the interprocedural representation.
32 * - the output file name
43 * Datastructure that holds central information about a program
45 * Preliminary documentation ;-)
47 * - main_irg: The ir graph that is the entry point to the program.
48 * (Anything not reachable from here may be optimized away.
49 * If we want to translate libraries or the like correctly
50 * we must replace this by a list.)
51 * - irg: List of all ir graphs in the program.
52 * - type: A list containing all types known to the translated program.
53 * Some types can have several entries in this list (as a result of
54 * using exchange_types()).
55 * - glob_type: The unique global type that is owner of all global entities.
58 typedef struct ir_prog ir_prog;
61 * A variable from where everything in the ir can be accessed.
62 * This variable contains the irp, the "immediate representation program".
63 * This variable should be considered constant. Moreover, one should use get_irp()
64 * to get access the the irp.
67 * Think of the irp as the "handle" of libFirm.
72 * Returns the access points from where everything in the ir can be accessed.
76 ir_prog *get_irp(void);
78 /** initializes ir_prog. Calls the constructor for an ir_prog. */
79 void init_irprog(void);
81 /** Creates a new ir_prog, returns it and sets irp with it.
82 Automatically called by init_firm() through init_irprog. */
83 ir_prog *new_ir_prog (void);
85 /** frees all memory used by irp. Types in type list and irgs in irg
86 list must be freed by hand before. */
87 void free_ir_prog(void);
89 /** Gets the main routine of the compiled program. */
90 ir_graph *get_irp_main_irg(void);
92 /** Sets the main routine of the compiled program. */
93 void set_irp_main_irg(ir_graph *main_irg);
95 /** Adds irg to the list of ir graphs in irp. */
96 void add_irp_irg(ir_graph *irg);
98 /** Removes irg from the list of irgs, deallocates it and
99 shrinks the list by one. */
100 void remove_irp_irg(ir_graph *irg);
102 /** Returns the number of ir graphs in the irp. */
103 int get_irp_n_irgs(void);
105 /** Returns the ir graph at position pos in the irp. */
106 ir_graph *get_irp_irg(int pos);
108 /** Sets the ir graph at position pos. */
109 void set_irp_irg(int pos, ir_graph *irg);
111 /** Adds type to the list of types in irp. */
112 void add_irp_type(type *typ);
114 /** Removes type from the list of types, deallocates it and
115 shrinks the list by one. */
116 void remove_irp_type(type *typ);
118 /** Returns the number of all types in the irp. */
119 int get_irp_n_types(void);
121 /** Returns the type at position pos in the irp. */
122 type *get_irp_type(int pos);
124 /** Overwrites the type at position pos with another type. */
125 void set_irp_type(int pos, type *typ);
127 /** Returns the "global" type of the irp. */
128 type *get_glob_type(void);
130 /** File name / executable name or the like. Initially NULL! **/
131 void set_irp_prog_name (ident *name);
132 ident *get_irp_prog_ident(void);
133 const char *get_irp_prog_name (void);
136 * Returns an irgraph that only contains constant
137 * expressions for constant entities.
138 * Do not use any access function for this graph, do not generate code
139 * for this graph. This graph contains only one block. The constant
140 * expressions may not contain control flow. See also copy_const_code()
143 ir_graph *get_const_code_irg(void);
145 irg_outs_state get_irp_ip_outs_state(void);
146 void set_irp_ip_outs_inconsistent(void);
148 /* @@@ Must this be global visible? */
149 void set_irp_ip_outedges(ir_node ** ip_outedges);
150 ir_node** get_irp_ip_outedges(void);
152 #endif /* ifndef _IRPROG_H_ */