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;
48 /** A variable from where everything in the ir can be accessed. */
52 * Returns the access points from where everything in the ir can be accessed.
56 ir_prog *get_irp(void);
58 /** initializes ir_prog. Calls the constructor for an ir_prog. */
59 void init_irprog(void);
61 /** Creates a new ir_prog, returns it and sets irp with it.
62 Automatically called by init_firm() through init_irprog. */
63 ir_prog *new_ir_prog (void);
65 /** Gets the main routine of the compiled program. */
66 ir_graph *get_irp_main_irg(void);
68 /** Sets the main routine of the compiled program. */
69 void set_irp_main_irg(ir_graph *main_irg);
71 /** Adds irg to the list of ir graphs in irp. */
72 void add_irp_irg(ir_graph *irg);
73 /** Removes irg from the list of irgs, deallocates it and
74 shrinks the list by one. */
75 void remove_irp_irg(ir_graph *irg);
76 int get_irp_n_irgs(void);
77 ir_graph *get_irp_irg(int pos);
78 void set_irp_irg(int pos, ir_graph *irg);
80 /** Adds type to the list of types in irp. */
81 void add_irp_type(type *typ);
82 /* Removes type from the list of types, deallocates it and
83 shrinks the list by one. */
84 void remove_irp_type(type *typ);
85 int get_irp_n_types(void);
86 type *get_irp_type(int pos);
87 void set_irp_type(int pos, type *typ);
89 /* --- Functions to access the fields of ir_prog --- */
90 type *get_glob_type(void);
94 * Returns an irgraph that only contains constant
96 * expressions for constant entities.
97 * Do not use any access function for this graph, do not generate code
98 * for this graph. This graph contains only one block. The constant
99 * expressions may not contain control flow. See also copy_const_code()
102 ir_graph *get_const_code_irg(void);
104 #endif /* ifndef _IRPROG_H_ */