Added test name
[libfirm] / ir / ir / irprog.h
1 /* Copyright (C) 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 */
4
5 /**
6 * @file irprog.h
7 *
8 * ir representation of a program.
9 *
10 * @author Goetz Lindenmaier
11 *
12 * This file defines a construct that keeps all information about a
13 * program:
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.)
20 */
21
22 /* $Id$ */
23
24 # ifndef _IRPROG_H_
25 # define _IRPROG_H_
26
27 # include "irnode.h"
28 # include "type.h"
29
30 /**
31  * Datastructure that holds central information about a program
32  *
33  *   Preliminary documentation ;-)
34  *
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.
44  *
45  */
46 typedef struct ir_prog ir_prog;
47
48 /** A variable from where everything in the ir can be accessed. */
49 extern ir_prog *irp;
50
51 /**
52  * Returns the access points from where everything in the ir can be accessed.
53  *
54  * @see irp
55  */
56 ir_prog *get_irp(void);
57
58 /** initializes ir_prog. Calls the constructor for an ir_prog. */
59 void init_irprog(void);
60
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);
64
65 /** Gets the main routine of the compiled program. */
66 ir_graph *get_irp_main_irg(void);
67
68 /** Sets the main routine of the compiled program. */
69 void      set_irp_main_irg(ir_graph *main_irg);
70
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);
79
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);
88
89 /* --- Functions to access the fields of ir_prog --- */
90 type *get_glob_type(void);
91
92
93 /**
94  *   Returns an irgraph that only contains constant
95  *
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()
100  *   in entity.h.
101  */
102 ir_graph *get_const_code_irg(void);
103
104 #endif /* ifndef _IRPROG_H_ */