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