1 /* Copyright (C) 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Goetz Lindenmaier
6 ** irprog.h: ir representation of a program
8 ** This file defines a construct that keeps all information about a
10 ** - A list of all procedures.
11 ** - A list of all types.
12 ** - A global type that can be thought of as a god-class containing all
13 ** global variables and procedures. This is not the base class of
14 ** all classes in a class hierarchy (as, e.g., "object" in java).
15 ** - (An obstack containing global things, e.g., the above mentioned lists.)
28 * NAME Datastructure that holds central information about a program
30 * NOTE Preliminary documentation ;-)
37 * NAME Datastructure that holds central information about a program
39 * NOTE Preliminary documentation ;-)
42 * main_irg The ir graph that is the entry point to the program.
43 * (Anything not reachable from here may be optimized away.
44 * If we want to translate libraries or the like correctly
45 * we must replace this by a list.)
46 * irg List of all ir graphs in the program.
47 * type A list containing all types known to the translated program.
48 * Some types can have several entries in this list (as a result of
49 * using exchange_types()).
50 * glob_type The unique global type that is owner of all global entities.
54 typedef struct ir_prog ir_prog;
56 /* A variable from where everything in the ir can be accessed. */
60 /* initializes ir_prog. Calls the constructor for an ir_prog. */
61 void init_irprog(void);
63 /* Creates a new ir_prog, returns it and sets irp with it.
64 Automatically called by init_firm through init_irprog. */
65 ir_prog *new_ir_prog (void);
67 /* Access the main routine of the compiled program. */
68 ir_graph *get_irp_main_irg();
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);
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();
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 /***p* irprog/get_const_code_irg
97 * get_const_code_irg - Returns an irgraph that only contains constant
98 * expressions for constant entities.
100 * ir_graph *get_const_code_irg();
102 * Do not use any access function for this graph, do not generate code
103 * for this graph. This graph contains only one block. The constant
104 * expressions may not contain control flow. See also copy_const_code
107 ir_graph *get_const_code_irg();
109 #endif /* ifndef _IRPROG_H_ */