added size and alignment for float and double
[libfirm] / ir / ir / irgraph.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** irgraph.h: ir graph construction
7 */
8
9 # ifndef _IRGRAPH_H_
10 # define _IRGRAPH_H_
11 # include "tv.h"
12
13 /* to resolve recursion between irnode.h and irgraph.h */
14 #ifndef _IR_NODE_TYPEDEF_
15 #define _IR_NODE_TYPEDEF_
16 typedef struct ir_node ir_node;
17 #endif
18
19 /* to resolve recursion between entity.h and irgraph.h */
20 #ifndef _IR_GRAPH_TYPEDEF_
21 #define _IR_GRAPH_TYPEDEF_
22 typedef struct ir_graph ir_graph;
23 #endif
24
25 /***** irgraph/irgraph
26  *
27  * NAME  Datastructure that holds central information about a procedure
28  *
29  * NOTE
30  **    ir_graph *new_ir_graph (entity *ent, int params);
31  *    -------------------------------------------------
32  *
33  *    This constructor generates the basic infrastructure needed to
34  *    represent a procedure in FIRM.
35  *
36  *    The parameters of new_ir_graph are:
37  *
38  *      *ent             A pointer to an entity representing the procedure.
39  *
40  *      params           An integer giving the number of local variables in the
41  *                       procedure.
42  *
43  *    It allocates an ir_graph and sets current_ir_graph to point to this
44  *    graph.  Further it allocates the following nodes needed for every
45  *    procedure:
46  *
47  *    * The start block containing a start node and Proj nodes for it's
48  *      five results (X, M, P, P, T).
49  *    * The end block containing an end node. This block is not matured
50  *      after executing new_ir_graph as predecessors need to be added to it.
51  *      (Maturing a block means fixing it's number of predecessors.)
52  *    * The current block, which is empty and also not matured.
53  *
54  *    Further it enters the global store into the datastructure of the start
55  *    block that contanis all valid values in this block (set_store()).  This
56  *    datastructure is used to build the Phi nodes and removed after
57  *    completion of the graph.  There is no path from end to start in the
58  *    graph after calling ir_graph.
59  * SOURCE
60  */
61
62 /* Global variable holding the current_ir_graph.  This global variable
63    is used by the ir construction interface in ircons and by the
64    optimizations. */
65 extern ir_graph *current_ir_graph;
66
67 /* Create a new ir graph to built ir for a procedure.
68    ent is the entity representing this procedure, i.e., the type of the
69    entity must be of a method type.  The constructor automatically sets the
70    field irg of the entity as well as current_ir_graph to the new ir graph.
71    n_loc is the number of local variables in this procedure including
72    the procedure parameters. */
73 ir_graph *new_ir_graph (entity *ent, int n_loc);
74
75 /* Frees the passed irgraph.
76    Deallocates all nodes in this graph and the ir_graph structure.
77    Sets the field irgraph in the corresponding entity to NULL.
78    Does not remove the irgraph from the list in irprog (requires
79    inefficient search, call remove_irp_irg by hand).
80    Does not free types, entities or modes that are used only by this
81    graph, nor the entity standing for this graph. */
82 void free_ir_graph (ir_graph *irg);
83
84 /* access routines for all ir_graph attributes */
85 ir_node *get_irg_start_block (ir_graph *irg);
86 void     set_irg_start_block (ir_graph *irg, ir_node *node);
87
88 ir_node *get_irg_start (ir_graph *irg);
89 void     set_irg_start (ir_graph *irg, ir_node *node);
90
91 ir_node *get_irg_end_block (ir_graph *irg);
92 void     set_irg_end_block (ir_graph *irg, ir_node *node);
93
94 ir_node *get_irg_end (ir_graph *irg);
95 void     set_irg_end (ir_graph *irg, ir_node *node);
96
97 ir_node *get_irg_cstore (ir_graph *irg);
98 void     set_irg_cstore (ir_graph *irg, ir_node *node);
99
100 ir_node *get_irg_frame (ir_graph *irg);
101 void     set_irg_frame (ir_graph *irg, ir_node *node);
102
103 ir_node *get_irg_globals (ir_graph *irg);
104 void     set_irg_globals (ir_graph *irg, ir_node *node);
105
106 ir_node *get_irg_args (ir_graph *irg);
107 void     set_irg_args (ir_graph *irg, ir_node *node);
108
109 /* Use new_Bad() instead!! */
110 ir_node *get_irg_bad (ir_graph *irg);
111 void     set_irg_bad (ir_graph *irg, ir_node *node);
112
113 ir_node *get_irg_current_block (ir_graph *irg);
114 void     set_irg_current_block (ir_graph *irg, ir_node *node);
115
116 entity  *get_irg_ent (ir_graph *irg);
117 void     set_irg_ent (ir_graph *irg, entity *ent);
118
119 /* Use not encouraged, internal of Phi construction algorithm. */
120 int      get_irg_n_loc (ir_graph *irg);
121 void     set_irg_n_loc (ir_graph *irg, int n_loc);
122
123 /* increments visited by one */
124 void     inc_irg_visited(ir_graph *irg);
125 unsigned long get_irg_visited (ir_graph *irg);
126 void     set_irg_visited(ir_graph *irg, unsigned long i);
127
128 /* increments block_visited by one */
129 void     inc_irg_block_visited(ir_graph *irg);
130 unsigned long get_irg_block_visited (ir_graph *irg);
131 void     set_irg_block_visited(ir_graph *irg, unsigned long i);
132 /*****/
133
134 # endif /* _IRGRAPH_H_ */