grrrr bugfix
[libfirm] / ir / ir / irdump.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irdump.h
4  * Purpose:     Write vcg representation of firm to file.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier, Hubert Schmidt
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 /**
15  * @file irdump.h
16  *
17  * Dump routines for the ir graph and all type information.
18  *
19  * @author Martin Trapp, Christian Schaefer
20  *
21  * The dump format of most functions is vcg.  This is a text based graph
22  * representation. Some use the original format,
23  * but most generate an extended format that is only read by some special
24  * versions of xvcg or by the comercialized version now calles aiSee.
25  * A test version of aiSee is available at
26  * http://www.absint.de/aisee/download/index.htm.
27  *
28  * Most routines use the name of the passed entity as the name of the
29  * file dumped to.
30  */
31
32
33 # ifndef _IRDUMP_H_
34 # define _IRDUMP_H_
35
36 # include "irnode.h"
37 # include "irgraph.h"
38 # include "irloop.h"
39
40 /**
41  * The value of this string will be added to the file name before .vcg
42  *
43  * @todo  GL: A hack -- add parameter to dumper function.
44  */
45 extern char *dump_file_suffix;
46 extern char *dump_file_filter;
47
48 /**
49  *  Dump a firm graph.
50  *
51  *  @param irg  The firm graph to be dumped.
52  *
53  *  @return
54  *     A file containing the firm graph in vcg format.
55  *
56  *  Dumps all Firm nodes of a single graph for a single procedure in
57  *  standard xvcg format.  Dumps the graph to a file.  The file name
58  *  is constructed from the name of the entity describing the
59  *  procedure (irg->entity) and the ending -pure<-ip>.vcg.  Eventually
60  *  overwrites existing files.  Visits all nodes in
61  *  interprocedural_view.
62  *
63  * @see turn_off_edge_labels()
64  */
65 void dump_ir_graph (ir_graph *irg);
66 #define dump_cg_graph dump_ir_graph
67
68 /**
69  *  Dump a firm graph without explicit block nodes.
70  *
71  *  @param irg   The firm graph to be dumped.
72  *
73  *  @return
74  *     A file containing the firm graph in vcg format.
75  *
76  *  Dumps all Firm nodes of a single graph for a single procedure in
77  *  extended xvcg format.
78  *  Dumps the graph to a file.  The file name is constructed from the
79  *  name of the entity describing the procedure (irg->entity) and the
80  *  ending <-ip>.vcg.  Eventually overwrites existing files.  Dumps several
81  *  procedures in boxes if interprocedural_view.
82  *
83  * @see turn_off_edge_labels()
84  */
85 void dump_ir_block_graph (ir_graph *irg);
86 #define dump_cg_block_graph dump_ir_block_graph
87
88 /** Dumps all graphs in interprocedural view to a file named All_graphs.vcg.
89  */
90 void dump_all_cg_block_graph(void);
91
92 /**
93  *  Dumps a firm graph and  all the type information needed for Calls,
94  *  Sels, ... in this graph.
95  *
96  *  @param irg   The firm graph to be dumped with its type information.
97  *
98  *  @return
99  *      A file containing the firm graph and the type information of the firm graph in vcg format.
100  *
101  *  Dumps the graph to a file.  The file name is constructed from the
102  *  name of the entity describing the procedure (irg->entity) and the
103  *  ending -all.vcg.  Eventually overwrites existing files.
104  *
105  * @see turn_off_edge_labels()
106  */
107 void dump_ir_graph_w_types (ir_graph *irg);
108
109 /**
110  *  Dumps a firm graph and  all the type information needed for Calls,
111  *  Sels, ... in this graph.
112  *
113  *  @param irg   The firm graph to be dumped with its type information.
114  *
115  *  @return
116  *      A file containing the firm graph and the type information of the firm graph in vcg format.
117  *
118  *  The graph is in blocked format.
119  *  Dumps the graph to a file.  The file name is constructed from the
120  *  name of the entity describing the procedure (irg->entity) and the
121  *  ending -all.vcg.  Eventually overwrites existing files.
122  *
123  * @see turn_off_edge_labels()
124  */
125 void dump_ir_block_graph_w_types (ir_graph *irg);
126
127 /**
128  *   The type of a walker function that is called for each graph.
129  *
130  *   @param irg   current visited graph
131  */
132 typedef void dump_graph_func(ir_graph *irg);
133
134 /**
135  *   A walker that calls a dumper for each graph.
136  *
137  *   @param dump_graph    The dumper to be used for dumping.
138  *
139  *   @return
140  *      Whatever the dumper creates.
141  *
142  *   Walks over all firm graphs and  calls a dumper for each graph.
143  *   The following dumpers can be passed as arguments:
144  *   - dump_ir_graph()
145  *   - dump_ir_block_graph()
146  *   - dump_cfg()
147  *   - dump_type_graph()
148  *   - dump_ir_graph_w_types()
149  *
150  * @see turn_off_edge_labels()
151  */
152 void dump_all_ir_graphs (dump_graph_func *dump_graph);
153
154
155 /**
156  *   Dump the control flow graph of a procedure.
157  *
158  *   @param irg  The firm graph whose CFG shall be dumped.
159  *
160  *   @return
161  *      A file containing the CFG in vcg format.
162  *
163  *   Dumps the control flow graph of a procedure in standard xvcg format.
164  *   Dumps the graph to a file.  The file name is constructed from the
165  *   name of the entity describing the procedure (irg->entity) and the
166  *   ending -cfg.vcg.  Eventually overwrites existing files.
167  *
168  * @see turn_off_edge_labels()
169  */
170 void dump_cfg (ir_graph *irg);
171
172 /**
173  *  Dumps all the type information needed for Calls, Sels, ... in this graph.
174  *  Does not dump the graph!
175  *
176  *  @param irg   The firm graph whose type information is to be dumped.
177  *  @return
178  *      A file containing the type information of the firm graph in vcg format.
179  *
180  *  Dumps this graph to a file.  The file name is constructed from the
181  *  name of the entity describing the procedure (irg->entity) and the
182  *  ending -type.vcg.  Eventually overwrites existing files.
183  *
184  * @see turn_off_edge_labels()
185  */
186 void dump_type_graph (ir_graph *irg);
187
188 /**
189  *   Dumps all type information.
190  *
191  *   @return
192  *      A file containing all type information for the program in standard
193  *      vcg format.
194  *
195  *   Dumps all type information that is somehow reachable in standard vcg
196  *   format.
197  *   Dumps the graph to a file named All_types.vcg.
198  *
199  * @see turn_off_edge_labels()
200  */
201 void dump_all_types (void);
202
203 /**
204  *   Dumps the class hierarchy with or without entities.
205  *
206  *   @param entities    Flag whether to dump the entities.
207  *
208  *   @return
209  *      A file containing the class hierarchy tree for the program in standard
210  *      vcg format.
211  *
212  *   Does not dump the global type.
213  *   Dumps a node for all classes and the sub/supertype relations.  If
214  *   entities is set to true also dumps the entities of classes, but without
215  *   any additional information as the entities type.  The overwrites relation
216  *   is dumped along with the entities.
217  *   Dumps to a file class_hierarchy.vcg
218  */
219 void dump_class_hierarchy (bool entities);
220
221
222 /**
223  * Dump a standalone loop tree, which contains the loop nodes and the firm nodes
224  * belonging to one loop packed together in one subgraph.  Dumps to file
225  * <name of irg><suffix>-looptree.vcg
226  * Turns on edge labels by default.
227  *
228  * Implementing this dumper was stimulated by Florian Liekwegs similar dumper.
229  *
230  * @arg irg     Dump the loop tree for this graph.
231  * @arg suffix  Suffix to filename.
232  */
233 void dump_loop_tree(ir_graph *irg, char *suffix);
234
235 /** Dumps the firm nodes in the sub-loop-tree of loop to a graph.
236  *  Dumps the loop nodes if dump_loop_information() is set.
237  *
238  *  The name of the file is loop_<loop_nr><suffix>.vcg.
239  *
240  *  @arg loop    Dump the loop tree for this loop.
241  *  @arg suffix  Suffix to filename.
242  */
243 void dump_loop (ir_loop *l, char *suffix);
244
245 /**
246  *   Sets the vcg flag "display_edge_labels" to no.
247  *
248  *   This is necessary
249  *   as xvcg and aisee both fail to display graphs with self-edges if these
250  *   edges have labes.
251  *   Dumpers will generate vcg flags with a different header.
252  */
253 void turn_off_edge_labels(void);
254
255 /**
256  *   If set to true constants will be replicated for every use. In non blocked
257  *   view edges from constant to block are scipped.  Vcg
258  *   then layouts the graphs more compact, this makes them better readable.
259  *   The flag is automatically and temporarily set to false if other
260  *   edges are dumped, as outs, loop, ...
261  *   Default setting: false.
262  */
263 void dump_consts_local(bool b);
264 /**
265  * Returns false if dump_out_edge_flag or dump_loop_information_flag
266  * are set, else returns dump_const_local_flag.
267  */
268 bool get_opt_dump_const_local(void);
269
270 /**
271  *   Turns off dumping the values of constant entities. Makes type graphs
272  *   better readable.
273  */
274 void turn_off_constant_entity_values(void);
275
276 /**
277  *   Turns on dumping the edges from the End node to nodes to be kept
278  *   alive
279  */
280 void dump_keepalive_edges(bool b);
281 bool get_opt_dump_keepalive_edges(void);
282
283 /**
284  *   Turns on dumping the out edges starting from the Start block in
285  *   dump_ir_graph.  To test the consistency of the out datastructure.
286  */
287 void dump_out_edges(void);
288
289 /**
290  *   If this flag is set the dumper dumps edges to immediate dominator in cfg.
291  */
292 void dump_dominator_information(void);
293
294 /**
295  *   If this flag is set the dumper dumps loop nodes and edges from
296  *   these nodes to the contained ir nodes.
297  *   Can be turned off with dont_dump_loop_information().
298  *   If the loops are interprocedural nodes can be missing.
299  */
300 void dump_loop_information(void);
301
302 /**
303  * @see dump_loop_information()
304  */
305 void dont_dump_loop_information(void);
306
307 /**
308  * If set and backedge info is computed, backedges are dumped dashed
309  * and as vcg 'backedge' construct.  Default: set.
310  */
311 void dump_backedge_information(bool b);
312
313 /**
314  *  Dump the information of type field specified in ana/irtypeinfo.h.
315  *  If the flag is set, the type name is output in [] in the node label,
316  *  else it is output as info.
317  */
318 void dump_analysed_type_info(bool b);
319
320 /**
321  * Write the address of a node into the vcg info.
322  * This is off per default for automatic comparisons of
323  * vcg graphs -- these will differ in the pointer values!
324  */
325 void dump_pointer_values_to_info(bool b);
326
327
328 # endif /* _IRDUMP_H_ */