1d24c94c9408a49658f4d63f96f3c0c903fccbd6
[libfirm] / ir / ir / irdump.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 */
4
5 /**
6  * @file irdump.h
7  *
8  * Dump routines for the ir graph and all type information.
9  *
10  * @author Martin Trapp, Christian Schaefer
11  *
12  * The dump format of most functions is vcg.  This is a text based graph
13  * representation. Some use the original format,
14  * but most generate an extended format that is only read by some special
15  * versions of xvcg or by the comercialized version now calles aiSee.
16  * A test version of aiSee is available at
17  * http://www.absint.de/aisee/download/index.htm.
18  *
19  * Most routines use the name of the passed entity as the name of the
20  * file dumped to.
21  */
22
23 /* $Id$ */
24
25 # ifndef _IRDUMP_H_
26 # define _IRDUMP_H_
27
28 # include "irnode.h"
29 # include "irgraph.h"
30
31 /**
32  * The value of this string will be added to the file name before .vcg
33  *
34  * @todo  GL: A hack
35  */
36 extern char *dump_file_suffix;
37
38 /**
39  *  Dump a firm graph.
40  *
41  *  @param irg  The firm graph to be dumped.
42  *
43  *  @return
44  *     A file containing the firm graph in vcg format.
45  *
46  *  Dumps all Firm nodes of a single graph for a single procedure in
47  *  standard xvcg format.
48  *  Dumps the graph to a file.  The file name is constructed from the
49  *  name of the entity describing the procedure (irg->entity) and the
50  *  ending .vcg.  Eventually overwrites existing files.
51  *
52  * @see turn_of_edge_labels()
53  */
54 void dump_ir_graph (ir_graph *irg);
55
56 /**
57  *  Dump a firm graph without explicit block nodes.
58  *
59  *  @param irg   The firm graph to be dumped.
60  *
61  *  @return
62  *     A file containing the firm graph in vcg format.
63  *
64  *  Dumps all Firm nodes of a single graph for a single procedure in
65  *  extended xvcg format.
66  *  Dumps the graph to a file.  The file name is constructed from the
67  *  name of the entity describing the procedure (irg->entity) and the
68  *  ending .vcg.  Eventually overwrites existing files.
69  *
70  * @see turn_of_edge_labels()
71  */
72 void dump_ir_block_graph (ir_graph *irg);
73
74 /**
75  *   Dump the control flow graph of a procedure.
76  *
77  *   @param irg  The firm graph whose CFG shall be dumped.
78  *
79  *   @return
80  *      A file containing the CFG in vcg format.
81  *
82  *   Dumps the control flow graph of a procedure in standard xvcg format.
83  *   Dumps the graph to a file.  The file name is constructed from the
84  *   name of the entity describing the procedure (irg->entity) and the
85  *   ending -cfg.vcg.  Eventually overwrites existing files.
86  *
87  * @see turn_of_edge_labels()
88  */
89 void dump_cfg (ir_graph *irg);
90
91 /**
92  *  Dumps all the type information needed for Calls, Sels, ... in this graph.
93  *
94  *  @param irg   The firm graph whose type information is to be dumped.
95  *  @return
96  *      A file containing the type information of the firm graph in vcg format.
97  *
98  *  Dumps this graph to a file.  The file name is constructed from the
99  *  name of the entity describing the procedure (irg->entity) and the
100  *  ending -type.vcg.  Eventually overwrites existing files.
101  *
102  * @see turn_of_edge_labels()
103  */
104 void dump_type_graph (ir_graph *irg);
105
106 /**
107  *   Dumps all type information.
108  *
109  *   @return
110  *      A file containing all type information for the program in standard
111  *      vcg format.
112  *
113  *   Dumps all type information that is somehow reachable in standard vcg
114  *   format.
115  *   Dumps the graph to a file named All_types.vcg.
116  *
117  * @see turn_of_edge_labels()
118  */
119 void dump_all_types (void);
120
121 /**
122  *   Dumps the class hierarchy with or without entities.
123  *
124  *   @param entities    Flag whether to dump the entities.
125  *
126  *   @return
127  *      A file containing the class hierarchy tree for the program in standard
128  *      vcg format.
129  *
130  *   Does not dump the global type.
131  *   Dumps a node for all classes and the sub/supertype relations.  If
132  *   entities is set to true also dumps the entities of classes, but without
133  *   any additional information as the entities type.  The overwrites relation
134  *   is dumped along with the entities.
135  *   Dumps to a file class_hierarchy.vcg
136  */
137 void dump_class_hierarchy (bool entities);
138
139 /**
140  *  Dumps a firm graph and  all the type information needed for Calls,
141  *  Sels, ... in this graph.
142  *
143  *  @param irg   The firm graph to be dumped with its type information.
144  *
145  *  @return
146  *      A file containing the firm graph and the type information of the firm graph in vcg format.
147  *
148  *  Dumps the graph to a file.  The file name is constructed from the
149  *  name of the entity describing the procedure (irg->entity) and the
150  *  ending -all.vcg.  Eventually overwrites existing files.
151  *
152  * @see turn_of_edge_labels()
153  */
154 void dump_ir_graph_w_types (ir_graph *irg);
155
156 /**
157  *  Dumps a firm graph and  all the type information needed for Calls,
158  *  Sels, ... in this graph.
159  *
160  *  @param irg   The firm graph to be dumped with its type information.
161  *
162  *  @return
163  *      A file containing the firm graph and the type information of the firm graph in vcg format.
164  *
165  *  The graph is in blocked format.
166  *  Dumps the graph to a file.  The file name is constructed from the
167  *  name of the entity describing the procedure (irg->entity) and the
168  *  ending -all.vcg.  Eventually overwrites existing files.
169  *
170  * @see turn_of_edge_labels()
171  */
172 void dump_ir_block_graph_w_types (ir_graph *irg);
173
174 /**
175  *  Dumps a interprocedural firm graph as dump_ir_graph.
176  *
177  *  @param irg   The firm graph to be dumped.
178  *
179  *  @return
180  *      A file containing the firm graph in vcg format.
181  */
182 void dump_cg_graph(ir_graph * irg);
183
184 /**
185  *  Dumps a interprocedural firm graph as dump_ir_block_graph.
186  *
187  *  @param irg   The firm graph to be dumped.
188  *
189  *  @return
190  *      A file containing the firm graph in vcg format.
191  */
192 void dump_cg_block_graph(ir_graph * irg);
193
194
195 void dump_all_cg_block_graph(void);
196
197 /**
198  *   The type of a walker function that is called for each graph.
199  *
200  *   @param irg   current visited graph
201  */
202 typedef void dump_graph_func(ir_graph *irg);
203
204 /**
205  *   A walker that calls a dumper for each graph.
206  *
207  *   @param dump_graph    The dumper to be used for dumping.
208  *
209  *   @return
210  *      Whatever the dumper creates.
211  *
212  *   Walks over all firm graphs and  calls a dumper for each graph.
213  *   The following dumpers can be passed as arguments:
214  *   - dump_ir_graph()
215  *   - dump_ir_block_graph()
216  *   - dump_cfg()
217  *   - dump_type_graph()
218  *   - dump_ir_graph_w_types()
219  *
220  * @see turn_of_edge_labels()
221  */
222 void dump_all_ir_graphs (dump_graph_func *dump_graph);
223
224 /**
225  *   Sets the vcg flag "display_edge_labels" to no.
226  *
227  *   This is necessary
228  *   as xvcg and aisee both fail to display graphs with self-edges if these
229  *   edges have labes.
230  *   Dumpers will generate vcg flags with a different header.
231  */
232 void turn_off_edge_labels(void);
233
234 /**
235  *   If set to true constants will be replicated for every use. In non blocked
236  *   view edges from constant to block are scipped.  Vcg
237  *   then layouts the graphs more compact, this makes them better readable.
238  *   The flag is automatically and temporarily set to false if other
239  *   edges are dumped, as outs, loop, ...
240  *   Default setting: false.
241  */
242 void dump_consts_local(bool b);
243
244 /**
245  *   Turns off dumping the values of constant entities. Makes type graphs
246  *   better readable.
247  */
248 void turn_off_constant_entity_values(void);
249
250 /**
251  *   Turns on dumping the edges from the End node to nodes to be kept
252  *   alive
253  */
254 void dump_keepalive_edges(bool b);
255
256 /**
257  *   Turns on dumping the out edges starting from the Start block in
258  *   dump_ir_graph.  To test the consistency of the out datastructure.
259  */
260 void dump_out_edges(void);
261
262 /**
263  *   If this flag is set the dumper dumps edges to immediate dominator in cfg.
264  */
265 void dump_dominator_information(void);
266
267 /**
268  *   If this flag is set the dumper dumps loop nodes and edges from
269  *   these nodes to the contained ir nodes.
270  *   Can be turned off with dont_dump_loop_information().
271  *   If the loops are interprocedural nodes can be missing.
272  */
273 void dump_loop_information(void);
274
275 /**
276  * @see dump_loop_information()
277  */
278 void dont_dump_loop_information(void);
279
280 # endif /* _IRDUMP_H_ */