b170f328195a1427e6fadab57cdae81a8aaffa83
[libfirm] / ir / ir / irdump.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** dump an ir graph, for further use with xvcg
7 */
8
9 /* $Id$ */
10
11 # ifndef _IRDUMP_H_
12 # define _IRDUMP_H_
13
14 # include "irnode.h"
15 # include "irgraph.h"
16
17 /****h* libfirm/irdump
18  *
19  * NAME
20  *   irdump -- dump routines for the graph and all type information
21  * NOTES
22  *   The dump format of most functions is vcg.  This is a text based graph
23  *   representation. Some use the original format,
24  *   but most generate an extended format that is only read by some special
25  *   versions of xvcg or by the comercialized version now calles aiSee.
26  *   A test version of aiSee is available at
27  *   http://www.absint.de/aisee/download/index.htm.
28  *
29  *   Most routines use the name of the passed entity as the name of the
30  *   file dumped to.
31  *
32  ******
33  */
34
35 /* @@@ GL: A hack */
36 extern char *dump_file_suffix;
37
38 /****m* irdump/dump_ir_graph
39  *
40  * NAME
41  *   dump_ir_graph  -- dump a firm graph
42  * SYNOPSIS
43  *  void dump_ir_graph (ir_graph *irg);
44  * FUNCTION
45  *  Dumps all Firm nodes of a single graph for a single procedure in
46  *  standard xvcg format.
47  *  Dumps the graph to a file.  The file name is constructed from the
48  *  name of the entity describing the procedure (irg->entity) and the
49  *  ending .vcg.  Eventually overwrites existing files.
50  * INPUTS
51  *   irg: The firm graph to be dumped.
52  * RESULT
53  *   A file containing the firm graph in vcg format.
54  * SEE ALSO
55  *  turn_of_edge_labels
56  ***
57  */
58 void dump_ir_graph (ir_graph *irg);
59
60 /****m* irdump/dump_ir_block_graph
61  *
62  * NAME
63  *   dump_ir_block_graph -- dump a firm graph without explicit block nodes.
64  * SYNOPSIS
65  *   void dump_ir_block_graph (ir_graph *irg);
66  * FUNCTION
67  *  Dumps all Firm nodes of a single graph for a single procedure in
68  *  extended xvcg format.
69  *  Dumps the graph to a file.  The file name is constructed from the
70  *  name of the entity describing the procedure (irg->entity) and the
71  *  ending .vcg.  Eventually overwrites existing files.
72  * INPUTS
73  *   irg: The firm graph to be dumped.
74  * RESULT
75  *   A file containing the firm graph in vcg format.
76  * SEE ALSO
77  *  turn_of_edge_labels
78  ***
79  */
80 void dump_ir_block_graph (ir_graph *irg);
81
82 /****m* irdump/dump_cfg
83  *
84  * NAME
85  *   dump_cfg -- Dump the control flow graph of a procedure
86  * SYNOPSIS
87  *   void dump_cfg (ir_graph *irg);
88  * FUNCTION
89  *   Dumps the control flow graph of a procedure in standard xvcg format.
90  *   Dumps the graph to a file.  The file name is constructed from the
91  *   name of the entity describing the procedure (irg->entity) and the
92  *   ending -cfg.vcg.  Eventually overwrites existing files.
93  * INPUTS
94  *   irg: The firm graph whose CFG shall be dumped.
95  * RESULT
96  *   A file containing the CFG in vcg format.
97  * SEE ALSO
98  *  turn_of_edge_labels
99  ***
100  */
101 void dump_cfg (ir_graph *irg);
102
103 /****m* irdump/dump_type_graph
104  *
105  * NAME
106  *   dump_type_graph --
107  * SYNOPSIS
108  *   void dump_type_graph (ir_graph *irg);
109  * FUNCTION
110  *  Dumps all the type information needed for Calls, Sels, ... in this graph.
111  *  Dumps this graph to a file.  The file name is constructed from the
112  *  name of the entity describing the procedure (irg->entity) and the
113  *  ending -type.vcg.  Eventually overwrites existing files.
114  * INPUTS
115  *  irg: The firm graph whose type information is to be dumped.
116  * RESULT
117  *  A file containing the type information of the firm graph in vcg format.
118  * SEE ALSO
119  *  turn_of_edge_labels
120  ***
121  */
122 void dump_type_graph (ir_graph *irg);
123
124 /****m* irdump/dump_all_types
125  *
126  * NAME
127  *   dump_all_types -- Dumps all type information
128  * SYNOPSIS
129  *   void dump_all_types (void);
130  * FUNCTION
131  *   Dumps all type information that is somehow reachable in standard vcg
132  *   format.
133  *   Dumps the graph to a file named All_types.vcg.
134  * INPUTS
135  *   No inputs.
136  * RESULT
137  *   A file containing all type information for the program in standard
138  *   vcg format.
139  * SEE ALSO
140  *  turn_of_edge_labels
141  ***
142  */
143 void dump_all_types (void);
144
145 /****m* irdump/dump_class_hierarchy
146  *
147  * NAME
148  *    dump_class_hierarchy -- Dumps the class hierarchy with or without entities.
149  * SYNOPSIS
150  *   void dump_class_hierarchy (bool entities);
151  * FUNCTION
152  *   Dumps a node for all classes and the sub/supertype relations.  If
153  *   entities is set to true also dumps the entities of classes, but without
154  *   any additional information as the entities type.  The overwrites relation
155  *   is dumped along with the entities.
156  *   Dumps to a file class_hierarchy.vcg
157  * INPUTS
158  *   Flag whether to dump the entities.
159  * RESULT
160  *   A file containing the class hierarchy tree for the program in standard
161  *   vcg format.
162  * SEE ALSO
163  *
164  ***
165  */
166 void dump_class_hierarchy (bool entities);
167
168 /****m* irdump/dump_ir_graph_w_types
169  *
170  * NAME
171  *   dump_ir_graph_w_types
172  * SYNOPSIS
173  *   void dump_ir_graph_w_types (ir_graph *irg);
174  * FUNCTION
175  *  Dumps a firm graph and  all the type information needed for Calls,
176  *  Sels, ... in this graph.
177  *  Dumps the graph to a file.  The file name is constructed from the
178  *  name of the entity describing the procedure (irg->entity) and the
179  *  ending -all.vcg.  Eventually overwrites existing files.
180  * INPUTS
181  *   irg: The firm graph to be dumped with its type information.
182  * RESULT
183  *   A file containing the firm graph and the type information of the firm graph in vcg format.
184  * SEE ALSO
185  *  turn_of_edge_labels
186  ***
187  */
188
189 void dump_ir_graph_w_types (ir_graph *irg);
190  /****m* irdump/dump_ir_block_graph_w_types
191  *
192  * NAME
193  *   dump_ir_block_graph_w_types
194  * SYNOPSIS
195  *   void dump_ir_block_graph_w_types (ir_graph *irg);
196  * FUNCTION
197  *  Dumps a firm graph and  all the type information needed for Calls,
198  *  Sels, ... in this graph.  The graph is in blocked format.
199  *  Dumps the graph to a file.  The file name is constructed from the
200  *  name of the entity describing the procedure (irg->entity) and the
201  *  ending -all.vcg.  Eventually overwrites existing files.
202  * INPUTS
203  *   irg: The firm graph to be dumped with its type information.
204  * RESULT
205  *   A file containing the firm graph and the type information of the firm graph in vcg format.
206  * SEE ALSO
207  *  turn_of_edge_labels
208  ***
209  */
210 void dump_ir_block_graph_w_types (ir_graph *irg);
211
212
213
214 /****m* irdump/dump_cg_graph
215  *
216  * NAME
217  *   dump_cg_graph
218  * SYNOPSIS
219  *   void dump_cg_graph (ir_graph *irg);
220  * FUNCTION
221  *  Dumps a interprocedural firm graph as dump_ir_graph.
222  * INPUTS
223  *   irg: The firm graph to be dumped.
224  * RESULT
225  *   A file containing the firm graph in vcg format.
226  * SEE ALSO
227  ***
228  */
229 void dump_cg_graph(ir_graph * irg);
230
231 /****m* irdump/dump_cg_block_graph
232  *
233  * NAME
234  *   dump_cg_block_graph
235  * SYNOPSIS
236  *   void dump_cg_block_graph (ir_graph *irg);
237  * FUNCTION
238  *  Dumps a interprocedural firm graph as dump_ir_block_graph.
239  * INPUTS
240  *   irg: The firm graph to be dumped.
241  * RESULT
242  *   A file containing the firm graph in vcg format.
243  * SEE ALSO
244  ***
245  */
246 void dump_cg_block_graph(ir_graph * irg);
247
248
249 void dump_all_cg_block_graph();
250
251 /****m* irdump/dump_all_ir_graphs
252  *
253  * NAME
254  *   dump_all_ir_graphs -- a walker that calls a dumper for each graph
255  * SYNOPSIS
256  *   void dump_all_ir_graphs (void dump_graph(ir_graph*));
257  * FUNCTION
258  *   Walks over all firm graphs and  calls a dumper for each graph.
259  *   The following dumpers can be passed as arguments:
260  *   dump_ir_graph
261  *   dump_ir_block_graph
262  *   dump_cfg
263  *   dump_type_graph
264  *   dump_ir_graph_w_types
265  * INPUTS
266  *   The dumper to be used for dumping.
267  * RESULT
268  *   Whatever the dumper creates.
269  * SEE ALSO
270  *  turn_of_edge_labels
271  ***
272  */
273 typedef void (dump_graph_func)(ir_graph *);
274 void dump_all_ir_graphs (dump_graph_func *dump_graph);
275
276 /****m* irdump/turn_off_edge_labels
277  *
278  * NAME
279  *   turn_off_edge_labels
280  * SYNOPSIS
281  *   void turn_off_edge_labels();
282  * FUNCTION
283  *   Sets the vcg flag "display_edge_labels" to no.  This is necessary
284  *   as xvcg and aisee both fail to display graphs with self-edges if these
285  *   edges have labes.
286  * INPUTS
287  *   No inputs
288  * RESULT
289  *   dumpers will generate vcg flags with a different header.
290  * SEE ALSO
291  *
292  ***
293  */
294 void turn_off_edge_labels();
295
296 /****m* irdump/dump_consts_local
297  *
298  * NAME
299  *   dump_consts_local
300  * SYNOPSIS
301  *   void dump_consts_local(bool b);
302  * FUNCTION
303  *   If set to true constants will be replicated for every use. In non blocked
304  *   view edges from constant to block are scipped.  Vcg
305  *   then layouts the graphs more compact, this makes them better readable.
306  *   The flag is automatically and temporarily set to false if other
307  *   edges are dumped, as outs, loop, ...
308  *   Default setting: false.
309  * INPUTS
310  * RESULT
311  * SEE ALSO
312  *
313  ***
314  */
315 void dump_consts_local(bool b);
316
317
318 /****m* irdump/turn_off_constant_entity_values
319  *
320  * NAME
321  *   turn_off_constant_entity_values
322  * SYNOPSIS
323  *   void turn_off_constant_entity_values()
324  * FUNCTION
325  *   Turns off dumping the values of constant entities. Makes type graphs
326  *   better readable.
327  * INPUTS
328  *   No inputs
329  * RESULT
330  * SEE ALSO
331  *
332  ***
333  */
334 void turn_off_constant_entity_values();
335
336
337 /****m* irdump/dump_keepalive_edges
338  *
339  * NAME
340  *   dump_keepalive_edges
341  * SYNOPSIS
342  *   void dump_keepalive_edges()
343  * FUNCTION
344  *   Turns on dumping the edges from the End node to nodes to be kept
345  *   alive
346  * INPUTS
347  *   No inputs
348  * RESULT
349  * SEE ALSO
350  *
351  ***
352  */
353 void dump_keepalive_edges(bool b);
354
355
356 /****m* irdump/dump_out_edges
357  *
358  * NAME
359  *   dump_out_edges
360  * SYNOPSIS
361  *   void dump_out_edges()
362  * FUNCTION
363  *   Turns on dumping the out edges starting from the Start block in
364  *   dump_ir_graph.  To test the consistency of the out datastructure.
365  * INPUTS
366  *   No inputs
367  * RESULT
368  * SEE ALSO
369  *
370  ***
371  */
372 void dump_out_edges();
373
374
375 /****m* irdump/dump_dominator_information
376  *
377  * NAME
378  *   dump_dominator_information
379  * SYNOPSIS
380  *   void dump_dominator_information()
381  * FUNCTION
382  *   If this flag is set the dumper dumps edges to immediate dominator in cfg.
383  * INPUTS
384  *   No inputs
385  * RESULT
386  * SEE ALSO
387  *
388  ***
389  */
390 void dump_dominator_information();
391
392
393 /****m* irdump/dump_loop_information
394  *
395  * NAME
396  *   dump_loop_information
397  * SYNOPSIS
398  *   void dump_loop_information()
399  * FUNCTION
400  *   If this flag is set the dumper dumps loop nodes and edges from
401  *   these nodes to the contained ir nodes.
402  *   Can be turned off with dont_dump_loop_information().
403  *   If the loops are interprocedural nodes can be missing.
404  * INPUTS
405  *   No inputs
406  * RESULT
407  * SEE ALSO
408  *
409  ***
410  */
411 void dump_loop_information();
412 void dont_dump_loop_information();
413
414 # endif /* _IRDUMP_H_ */