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