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