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
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 * Dump routines for the ir graph and all type information.
19 * @author Martin Trapp, Christian Schaefer
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.
28 * Most routines use the name of the passed entity as the name of the
41 /* **************************************************************************** */
43 /* **************************************************************************** */
46 * This hook is called to dump the vcg attributes of a node to a file.
47 * If this function returns zero, the default attributes are added, else
50 typedef int (*DUMP_NODE_VCGATTR_FUNC)(FILE *F, ir_node *node, ir_node *local);
52 /** Set the node_vcgattr hook. */
53 void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook);
55 typedef int (*DUMP_NODE_EDGE_FUNC)(FILE *f, ir_node *node);
58 * Set the hook to be called to dump additional edges to a node.
59 * @param func The hook to be called.
61 void set_dump_node_edge_hook(DUMP_NODE_EDGE_FUNC func);
64 * Get the additional edge dump hook.
65 * @return The current additional edge dump hook.]
67 DUMP_NODE_EDGE_FUNC get_dump_node_edge_hook(void);
69 /** Dump a firm graph.
71 * @param irg The firm graph to be dumped.
74 * A file containing the firm graph in vcg format.
76 * Dumps all Firm nodes of a single graph for a single procedure in
77 * standard xvcg format. Dumps the graph to a file. The file name
78 * is constructed from the name of the entity describing the
79 * procedure (irg->entity) and the ending -pure<-ip>.vcg. Eventually
80 * overwrites existing files. Visits all nodes in
81 * interprocedural_view.
83 * @see turn_off_edge_labels()
85 void dump_ir_graph (ir_graph *irg, const char *suffix);
87 /** Dump a firm graph without explicit block nodes.
89 * @param irg The firm graph to be dumped.
92 * A file containing the firm graph in vcg format.
94 * Dumps all Firm nodes of a single graph for a single procedure in
95 * extended xvcg format.
96 * Dumps the graph to a file. The file name is constructed from the
97 * name of the entity describing the procedure (irg->entity) and the
98 * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
99 * procedures in boxes if interprocedural_view.
101 * @see turn_off_edge_labels()
103 void dump_ir_block_graph (ir_graph *irg, const char *suffix);
105 /** Dump a firm graph without explicit block nodes but grouped in extended blocks.
107 * @param irg The firm graph to be dumped.
110 * A file containing the firm graph in vcg format.
112 * Dumps all Firm nodes of a single graph for a single procedure in
113 * extended xvcg format.
114 * Dumps the graph to a file. The file name is constructed from the
115 * name of the entity describing the procedure (irg->entity) and the
116 * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
117 * procedures in boxes if interprocedural_view.
119 * @see turn_off_edge_labels()
121 void dump_ir_extblock_graph (ir_graph *irg, const char *suffix);
123 /** Dumps all graphs in interprocedural view to a file named All_graphs.vcg.
125 void dump_all_cg_block_graph(const char *suffix);
127 /** Dumps a firm graph and all the type information needed for Calls,
128 * Sels, ... in this graph.
130 * @param irg The firm graph to be dumped with its type information.
133 * A file containing the firm graph and the type information of the firm graph in vcg format.
135 * Dumps the graph to a file. The file name is constructed from the
136 * name of the entity describing the procedure (irg->entity) and the
137 * ending -all.vcg. Eventually overwrites existing files.
139 * @see turn_off_edge_labels()
141 void dump_ir_graph_w_types (ir_graph *irg, const char *suffix);
143 /** Dumps a firm graph and all the type information needed for Calls,
144 * Sels, ... in this graph.
146 * @param irg The firm graph to be dumped with its type information.
149 * A file containing the firm graph and the type information of the firm graph in vcg format.
151 * The graph is in blocked format.
152 * Dumps the graph to a file. The file name is constructed from the
153 * name of the entity describing the procedure (irg->entity) and the
154 * ending -all.vcg. Eventually overwrites existing files.
156 * @see turn_off_edge_labels()
158 void dump_ir_block_graph_w_types (ir_graph *irg, const char *suffix);
160 /** The type of a walker function that is called for each graph.
162 * @param irg current visited graph
164 typedef void dump_graph_func(ir_graph *irg, const char *suffix);
166 /** A walker that calls a dumper for each graph.
168 * @param dump_graph The dumper to be used for dumping.
171 * Whatever the dumper creates.
173 * Walks over all firm graphs and calls a dumper for each graph.
174 * The following dumpers can be passed as arguments:
176 * - dump_ir_block_graph()
178 * - dump_type_graph()
179 * - dump_ir_graph_w_types()
181 * @see turn_off_edge_labels()
183 void dump_all_ir_graphs (dump_graph_func *dump_graph, const char *suffix);
186 /** Dump the control flow graph of a procedure.
188 * @param irg The firm graph whose CFG shall be dumped.
191 * A file containing the CFG in vcg format.
193 * Dumps the control flow graph of a procedure in standard xvcg format.
194 * Dumps the graph to a file. The file name is constructed from the
195 * name of the entity describing the procedure (irg->entity) and the
196 * ending -cfg.vcg. Eventually overwrites existing files.
198 * @see turn_off_edge_labels()
200 void dump_cfg (ir_graph *irg, const char *suffix);
202 /** Dump a node and its predecessors forming a subgraph to a vcg file.
204 * @param root The node serving as root for the subgraph.
205 * @param depth Dump nodes on paths starting at root with length depth.
206 * @param suffix A suffix for the file name.
208 * Dumps the graph to a file. The file name is constructed from the
209 * name of the entity describing the procedure the passed node is
210 * in, suffix and the ending -subg_<nr>.vcg. nr is a unique number
211 * for each graph dumped. Eventually overwrites existing files.
214 * A file containing the subgraph in vcg format.
216 void dump_subgraph (ir_node *root, int depth, const char *suffix);
218 /* **************************************************************************** */
219 /* CALLGRAPH DUMPERS */
220 /* **************************************************************************** */
223 /** Dump the call graph.
225 * Dumps the callgraph to a file "Callgraph"<suffix>".vcg".
227 * @see dump_callgraph_loop_tree(const char *suffix)
229 void dump_callgraph(const char *suffix);
231 /* **************************************************************************** */
232 /* TYPEGRAPH DUMPERS */
233 /* **************************************************************************** */
236 * Dumps all the type information needed for Calls, Sels, ... in this graph.
237 * Does not dump the graph!
239 * @param irg The firm graph whose type information is to be dumped.
241 * A file containing the type information of the firm graph in vcg format.
243 * Dumps this graph to a file. The file name is constructed from the
244 * name of the entity describing the procedure (irg->entity) and the
245 * ending -type.vcg. Eventually overwrites existing files.
247 * @see turn_off_edge_labels()
249 void dump_type_graph (ir_graph *irg, const char *suffix);
251 /** Dumps all type information.
254 * A file containing all type information for the program in standard
257 * Dumps all type information that is somehow reachable in standard vcg
259 * Dumps the graph to a file named All_types.vcg.
261 * @see turn_off_edge_labels()
263 void dump_all_types (const char *suffix);
265 /** Dumps the class hierarchy with or without entities.
267 * @param entities Flag whether to dump the entities.
270 * A file containing the class hierarchy tree for the program in standard
273 * Does not dump the global type.
274 * Dumps a node for all classes and the sub/supertype relations. If
275 * entities is set to true also dumps the entities of classes, but without
276 * any additional information as the entities type. The overwrites relation
277 * is dumped along with the entities.
278 * Dumps to a file class_hierarchy.vcg
280 void dump_class_hierarchy (bool entities, const char *suffix);
282 /* **************************************************************************** */
283 /* LOOPTREE DUMPERS */
284 /* **************************************************************************** */
287 * Dump a standalone loop tree, which contains the loop nodes and the firm nodes
288 * belonging to one loop packed together in one subgraph. Dumps to file
289 * <name of irg><suffix>-looptree.vcg
290 * Turns on edge labels by default.
292 * Implementing this dumper was stimulated by Florian Liekwegs similar dumper.
294 * @arg irg Dump the loop tree for this graph.
295 * @arg suffix Suffix to filename.
297 void dump_loop_tree(ir_graph *irg, const char *suffix);
299 /** Dumps the firm nodes in the sub-loop-tree of loop to a graph.
301 * Dumps the loop nodes if dump_loop_information() is set.
302 * The name of the file is loop_<loop_nr><suffix>.vcg.
304 * @arg loop Dump the loop tree for this loop.
305 * @arg suffix Suffix to filename.
307 void dump_loop (ir_loop *l, const char *suffix);
309 /** Dumps the loop tree over the call graph.
311 * See for yourself what you can use this for.
312 * The filename is "Callgraph_looptree<suffix>.vcg".
314 * @arg suffix Suffix to filename.
316 void dump_callgraph_loop_tree(const char *suffix);
319 /* **************************************************************************** */
321 /* **************************************************************************** */
324 /** Write the irnode and all its attributes to the file passed.
326 int dump_irnode_to_file (FILE *f, ir_node *n);
328 /** Write the irnode and all its attributes to stdout.
330 void dump_irnode (ir_node *n);
332 /** Write the graph and all its attributes to the file passed.
333 * Does not write the nodes.
335 void dump_graph_to_file(FILE *F, ir_graph *irg);
337 /** Write the graph and all its attributes to stdout.
338 * Does not write the nodes.
340 void dump_graph(ir_graph *g);
343 /** Dump graph information as text.
345 * Often graphs are unhandy in their vcg representation. The text
346 * dumper represents the information for the firm nodes more compact,
347 * but the relations between the nodes only implicitly.
349 * The file name is the graph name (get_entity_name()), appended by
352 void dump_graph_as_text(ir_graph *irg, const char *suffix);
355 /** Verbosity for text dumpers */
357 dump_verbosity_onlynames = 0x00000001, /**< only dump names. turns off all other
358 flags up to 0x00010000. */
359 dump_verbosity_fields = 0x00000002, /**< dump types and fields (like a type declaration) */
360 dump_verbosity_methods = 0x00000004, /**< dump types and methods (like a type declaration) */
361 dump_verbosity_nostatic = 0x00000040, /**< dump types and dynamic allocated fields (like a
362 type declaration). This excludes methods and
363 static, polymorphic fields. */
364 dump_verbosity_typeattrs = 0x00000008, /**< dump all type attributes */
365 dump_verbosity_entattrs = 0x00000010, /**< dump all entity attributes */
366 dump_verbosity_entconsts = 0x00000020, /**< dump entity constants */
368 dump_verbosity_accessStats = 0x00000100, /**< dump entity access statistics */
369 dump_verbosity_csv = 0x00000200, /**< dump access statistics as comma separated list */
371 dump_verbosity_noClassTypes = 0x00001000, /**< dump no class types */
372 dump_verbosity_noStructTypes = 0x00002000, /**< dump no struct types */
373 dump_verbosity_noUnionTypes = 0x00004000, /**< dump no union types */
374 dump_verbosity_noArrayTypes = 0x00008000, /**< dump no array types */
375 dump_verbosity_noPointerTypes = 0x00010000, /**< dump no pointer types */
376 dump_verbosity_noMethodTypes = 0x00020000, /**< dump no method types */
377 dump_verbosity_noPrimitiveTypes = 0x00040000, /**< dump no primitive types */
378 dump_verbosity_noEnumerationTypes= 0x00080000, /**< dump no enumeration types */
380 dump_verbosity_onlyClassTypes = 0x000FE000, /**< dump only class types */
381 dump_verbosity_onlyStructTypes = 0x000FD000, /**< dump only struct types */
382 dump_verbosity_onlyUnionTypes = 0x000FB000, /**< dump only union types */
383 dump_verbosity_onlyArrayTypes = 0x000F7000, /**< dump only array types */
384 dump_verbosity_onlyPointerTypes = 0x000EF000, /**< dump only pointer types */
385 dump_verbosity_onlyMethodTypes = 0x000DF000, /**< dump only method types */
386 dump_verbosity_onlyPrimitiveTypes = 0x000BF000, /**< dump only primitive types */
387 dump_verbosity_onlyEnumerationTypes=0x0007F000, /**< dump only enumeration types */
389 dump_verbosity_max = 0x4FF00FBE /**< turn on all verbosity.
390 Do not turn on negative flags!
391 @@@ Because of a bug in gcc 3.2 we can not set the
396 /** Write the entity and all its attributes to the passed file.
398 void dump_entity_to_file (FILE *F, entity *ent, unsigned verbosity);
400 /** Write the entity and all its attributes to the stdout.
402 * Calls dump_entity_to_file(). */
403 void dump_entity (entity *ent);
405 /** Write the type and all its attributes to the file passed.
407 void dump_type_to_file (FILE *f, type *tp, dump_verbosity verbosity);
409 /** Write the type and all its attributes to stdout.
411 void dump_type (type *tp);
414 /** Dump type information as text.
416 * Often type graphs are unhandy in their vcg representation. The text
417 * dumper represents the information for a single type more compact, but
418 * the relations between the types only implicitly.
419 * Dumps only 'real' types, i.e., those in the type list. Does not dump
420 * the global type nor frame types or the like.
422 * The file name is the program name (get_irp_name()), or 'TextTypes'
423 * if the program name is not set, appended by <suffix>-types.txt.
424 * For verbosity see the documentation of the verbosity flags above.
426 void dump_types_as_text(unsigned verbosity, const char *suffix);
428 /** Dumps all global variables as text.
430 * Dumps a text representation of the entities in the global type.
432 * The file name is the program name (get_irp_name()), or 'TextTypes'
433 * if the program name is not set, appended by <suffix>-globals.txt.
434 * For verbosity see the documentation of the verbosity flags above.
436 void dump_globals_as_text(unsigned verbosity, const char *suffix);
438 /* **************************************************************************** */
440 /* **************************************************************************** */
442 /** Output a selected graph.
444 * All graph dumpers check this name. If the name is != "" and
445 * not a prefix of the graph to be dumped, the dumper does not
448 * @param name The prefix of the name (not the ld_name) of the method
449 * entity to be dumped.
451 void only_dump_method_with_name(ident *name);
453 /** Returns the name set with only_dump_method_with_name(). */
454 ident *get_dump_file_filter_ident(void);
456 /** Returns true if dump file filter is not set, or if it is a
458 int is_filtered_dump_name(ident *name);
460 /** Sets the vcg flag "display_edge_labels" to no.
462 * This is necessary as xvcg and aisee both fail to display graphs
463 * with self-edges if these edges have labels.
465 void turn_off_edge_labels(void);
468 * If set to true constants will be replicated for every use. In non
469 * blocked view edges from constant to block are skipped. Vcg then
470 * layouts the graphs more compact, this makes them better readable.
471 * The flag is automatically and temporarily set to false if other
472 * edges are dumped, as outs, loop, ...
473 * Default setting: false.
475 void dump_consts_local(bool b);
478 * Returns false if dump_out_edge_flag or dump_loop_information_flag
479 * are set, else returns dump_const_local_flag.
481 bool get_opt_dump_const_local(void);
483 /** Turns off dumping the values of constant entities. Makes type graphs
486 void dump_constant_entity_values(bool b);
488 /** Turns on dumping the edges from the End node to nodes to be kept
491 void dump_keepalive_edges(bool b);
492 bool get_opt_dump_keepalive_edges(void);
494 /** Turns on dumping the out edges starting from the Start block in
497 * To test the consistency of the out data structure.
499 void dump_out_edges(bool b);
501 /** If this flag is set the dumper dumps edges to immediate dominator in cfg.
503 void dump_dominator_information(bool b);
505 /** If this flag is set the dumper dumps loop nodes and edges from
506 * these nodes to the contained ir nodes.
508 * If the loops are interprocedural nodes can be missing.
510 void dump_loop_information(bool b);
512 /** If set and backedge info is computed, backedges are dumped dashed
513 * and as vcg 'backedge' construct.
517 void dump_backedge_information(bool b);
519 /** Dump the information of type field specified in ana/irtypeinfo.h.
521 * If the flag is set, the type name is output in [] in the node label,
522 * else it is output as info.
524 void set_opt_dump_analysed_type_info(bool b);
526 /** Write the address of a node into the vcg info.
528 * This is off per default for automatic comparisons of
529 * vcg graphs -- these will differ in the pointer values!
531 void dump_pointer_values_to_info(bool b);
534 # endif /* _IRDUMP_H_ */