1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Martin Trapp, Christian Schaefer
6 ** irdump.h: dumping of an intermediate representation graph
15 # include "irnode_t.h"
16 # include "irgraph_t.h"
26 # include "type_or_entity.h"
28 # include "typewalk.h"
30 /* Attributes of nodes */
31 #define DEFAULT_NODE_ATTR ""
32 #define DEFAULT_TYPE_ATTRIBUTE ""
34 /* Attributes of edges between Firm nodes */
35 #define BLOCK_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted"
36 #define CF_EDGE_ATTR "color: red"
37 #define MEM_EDGE_ATTR "color: blue"
39 /* Attributes of edges between Firm nodes and type/entity nodes */
40 #define NODE2TYPE_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted"
42 /* Attributes of edges in type/entity graphs. */
43 #define TYPE_METH_NODE_ATTR "color: lightyellow"
44 #define TYPE_CLASS_NODE_ATTR "color: green"
45 #define ENTITY_NODE_ATTR "color: yellow"
46 #define ENT_TYPE_EDGE_ATTR "class: 3 label: \"type\" color: red"
47 #define ENT_OWN_EDGE_ATTR "class: 4 label: \"owner\" color: black"
48 #define METH_PAR_EDGE_ATTR "class: 5 label: \"param %d\" color: green"
49 #define METH_RES_EDGE_ATTR "class: 6 label: \"res %d\" color: green"
50 #define TYPE_SUPER_EDGE_ATTR "class: 7 label: \"supertype\" color: blue"
51 #define UNION_EDGE_ATTR "class: 8 label: \"component\" color: blue"
52 #define PTR_PTS_TO_EDGE_ATTR "class: 9 label: \"points to\" color:green"
53 #define ARR_ELT_TYPE_EDGE_ATTR "class: 10 label: \"arr elt tp\" color:green"
54 #define ARR_ENT_EDGE_ATTR "class: 10 label: \"arr ent\" color: green"
55 #define ENT_OVERWRITES_EDGE_ATTR "class: 11 label: \"overwrites\" color:red"
56 #define TYPE_MEMBER_EDGE_ATTR "class: 12 label: \"member\" color:blue"
59 #if DEBUG_libfirm && NODEID_AS_LABEL
60 #define PRINT_NODEID(X) fprintf(F, "%d", get_irn_node_nr(X))
62 #define PRINT_NODEID(X) fprintf(F, "%p", X)
68 /* A compiler option to turn off edge labels */
71 /* A global variable to record output of the Bad node. */
74 /*******************************************************************/
75 /* routines to dump information about a single node */
76 /*******************************************************************/
81 dump_node_opcode (ir_node *n)
85 if (n->op->code == iro_Const) {
86 xfprintf (F, "%v", n->attr.con);
89 } else if (n->op->code == iro_SymConst) {
90 if (get_SymConst_kind(n) == linkage_ptr_info) {
91 xfprintf (F, "%I", get_SymConst_ptrinfo(n));
93 assert(get_kind(get_SymConst_type(n)) == k_type);
94 assert(get_type_ident(get_SymConst_type(n)));
95 xfprintf (F, "%s ", id_to_str(get_type_ident(get_SymConst_type(n))));
96 if (get_SymConst_kind == type_tag)
103 xfprintf (F, "%I", get_irn_opident(n));
108 dump_node_mode (ir_node *n)
110 switch (n->op->code) {
127 xfprintf (F, "%I", get_mode_ident(n->mode));
134 dump_node_nodeattr (ir_node *n)
136 switch (n->op->code) {
138 if (n->in[1]->op->code == iro_Cmp) {
139 xfprintf (F, "%s", get_pnc_string(n->attr.proj));
141 xfprintf (F, "%ld", n->attr.proj);
145 assert(get_kind(get_Sel_entity(n)) == k_entity);
146 xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
153 dump_node_vcgattr (ir_node *n)
155 switch (n->op->code) {
158 xfprintf (F, "color: blue");
161 xfprintf (F, "color: lightyellow");
164 xfprintf (F, "color: green");
169 xfprintf (F, "color: yellow");
172 xfprintf (F, DEFAULT_NODE_ATTR);
177 dump_node (ir_node *n) {
180 xfprintf (F, "node: {title: \""); PRINT_NODEID(n); fprintf(F, "\" label: \"");
185 dump_node_nodeattr(n);
187 xfprintf (F, " %ld", get_irn_node_nr(n));
190 dump_node_vcgattr(n);
195 dump_ir_node (ir_node *n)
198 fprintf (F, "node: {title: \""); PRINT_NODEID(n); fprintf(F, "\" label: ");
200 switch (n->op->code) { /* node label */
202 xfprintf (F, "\"%I\" color: blue ", get_irn_opident(n));
203 xfprintf (F, DEFAULT_NODE_ATTR);
206 xfprintf (F, "\"%I\" color: blue ", get_irn_opident(n));
207 xfprintf (F, DEFAULT_NODE_ATTR);
210 xfprintf (F, "\"%I\" color: lightyellow ", get_irn_opident(n));
211 xfprintf (F, DEFAULT_NODE_ATTR);
214 xfprintf (F, "\"%I%I\" color: green", get_irn_opident(n), get_irn_modeident(n));
215 if (get_irn_modecode(n) == irm_M)
216 xfprintf (F, DEFAULT_NODE_ATTR " color: green");
218 xfprintf (F, DEFAULT_NODE_ATTR);
221 xfprintf (F, "\"%v%I\" color: yellow ", n->attr.con, get_irn_modeident(n));
222 xfprintf (F, DEFAULT_NODE_ATTR);
225 xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
226 xfprintf (F, DEFAULT_NODE_ATTR);
229 if (n->in[1]->op->code == iro_Cmp) {
230 xfprintf (F, "\"%I%I %s\" color: yellow", get_irn_opident(n), get_irn_modeident(n),
231 get_pnc_string(n->attr.proj));
233 xfprintf (F, "\"%I%I %ld\"", get_irn_opident(n), get_irn_modeident(n), n->attr.proj);
235 xfprintf (F, DEFAULT_NODE_ATTR);
238 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
239 xfprintf (F, DEFAULT_NODE_ATTR);
242 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
243 xfprintf (F, DEFAULT_NODE_ATTR);
246 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
247 xfprintf (F, DEFAULT_NODE_ATTR);
250 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
251 xfprintf (F, DEFAULT_NODE_ATTR);
254 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
255 xfprintf (F, DEFAULT_NODE_ATTR);
258 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
259 xfprintf (F, DEFAULT_NODE_ATTR);
262 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
263 xfprintf (F, DEFAULT_NODE_ATTR);
266 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
267 xfprintf (F, DEFAULT_NODE_ATTR);
270 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
271 xfprintf (F, DEFAULT_NODE_ATTR);
274 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
275 xfprintf (F, DEFAULT_NODE_ATTR);
278 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
279 xfprintf (F, DEFAULT_NODE_ATTR);
282 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
283 xfprintf (F, DEFAULT_NODE_ATTR);
286 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
287 xfprintf (F, DEFAULT_NODE_ATTR);
290 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
291 xfprintf (F, DEFAULT_NODE_ATTR);
294 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
295 xfprintf (F, DEFAULT_NODE_ATTR);
298 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
299 xfprintf (F, DEFAULT_NODE_ATTR);
302 xfprintf (F, "\"%I\"", get_irn_opident(n));
303 xfprintf (F, DEFAULT_NODE_ATTR);
306 xfprintf (F, "\"%I\"", get_irn_opident(n));
307 xfprintf (F, DEFAULT_NODE_ATTR);
310 xfprintf (F, "\"%I\"", get_irn_opident(n));
311 xfprintf (F, DEFAULT_NODE_ATTR);
314 xfprintf (F, "\"%I\"", get_irn_opident(n));
315 xfprintf (F, DEFAULT_NODE_ATTR);
318 xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
319 xfprintf (F, DEFAULT_NODE_ATTR);
323 xfprintf (F, "\"%R\"", n);
324 xfprintf (F, DEFAULT_NODE_ATTR);
327 xfprintf (F, "\"%I\" ", get_irn_opident(n));
328 xfprintf (F, DEFAULT_NODE_ATTR);
331 assert(get_kind(get_Sel_entity(n)) == k_entity);
332 xfprintf (F, "\"%I ", get_irn_opident(n));
333 xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
334 xfprintf (F, DEFAULT_NODE_ATTR);
337 assert(get_kind(get_SymConst_type(n)) == k_type);
338 assert(get_type_ident(get_SymConst_type(n)));
339 xfprintf (F, "\"%s ", get_type_name(get_SymConst_type(n)));
340 switch (n->attr.i.num){
342 xfprintf (F, "tag\" ");
345 xfprintf (F, "size\" ");
351 xfprintf (F, DEFAULT_NODE_ATTR);
354 xfprintf (F, "\"%I\" ", get_irn_opident(n));
355 xfprintf (F, DEFAULT_NODE_ATTR " color: green");
358 xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
359 xfprintf (F, DEFAULT_NODE_ATTR);
362 xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
364 xfprintf (F, "}\n"); /* footer */
368 /* dump the edge to the block this node belongs to */
370 dump_ir_block_edge(ir_node *n) {
371 if (is_no_Block(n)) {
372 xfprintf (F, "edge: { sourcename: \"");
374 xfprintf (F, "\" targetname: \"");
375 PRINT_NODEID(get_nodes_Block(n));
376 xfprintf (F, "\" " BLOCK_EDGE_ATTR "}\n");
380 void print_edge_vcgattr(ir_node *from, int to) {
383 switch (get_irn_opcode(from)) {
385 xfprintf (F, CF_EDGE_ATTR);
387 case iro_Start: break;
390 case iro_Cond: break;
393 if (to == 0) xfprintf (F, MEM_EDGE_ATTR);
395 case iro_Const: break;
396 case iro_SymConst:break;
399 if (to == 0) xfprintf (F, MEM_EDGE_ATTR);
403 case iro_Minus: break;
409 if (to == 0) xfprintf (F, MEM_EDGE_ATTR);
417 case iro_Shrs: break;
420 case iro_Conv: break;
422 if (get_irn_modecode(from) == irm_M) xfprintf (F, MEM_EDGE_ATTR);
428 if (to == 0) xfprintf (F, MEM_EDGE_ATTR);
431 xfprintf (F, MEM_EDGE_ATTR);
433 case iro_Tuple: break;
435 switch (get_irn_modecode(from)) {
437 xfprintf (F, CF_EDGE_ATTR);
440 xfprintf (F, MEM_EDGE_ATTR);
451 /* dump edges to our inputs */
453 dump_ir_data_edges(ir_node *n) {
456 for (i = 0; i < get_irn_arity(n); i++) {
457 assert(get_irn_n(n, i));
458 fprintf (F, "edge: {sourcename: \"");
460 fprintf (F, "\" targetname: \"");
461 PRINT_NODEID(get_irn_n(n, i));
463 fprintf (F, " label: \"%d\" ", i);
464 print_edge_vcgattr(n, i);
469 /* dumps the edges between nodes and their type or entity attributes. */
470 void dump_node2type_edges (ir_node *n, void *env)
474 switch (get_irn_opcode(n)) {
476 if ( (get_SymConst_kind(n) == type_tag)
477 || (get_SymConst_kind(n) == size)) {
478 xfprintf (F, "edge: { sourcename: \"");
480 fprintf (F, "\" targetname: \"%p\" "
481 NODE2TYPE_EDGE_ATTR "}\n", get_SymConst_type(n));
485 xfprintf (F, "edge: { sourcename: \"");
487 fprintf (F, "\" targetname: \"%p\" "
488 NODE2TYPE_EDGE_ATTR "}\n", get_Sel_entity(n));
491 xfprintf (F, "edge: { sourcename: \"");
493 fprintf (F, "\" targetname: \"%p\" "
494 NODE2TYPE_EDGE_ATTR "}\n", get_Call_type(n));
497 xfprintf (F, "edge: { sourcename: \"");
499 fprintf (F, "\" targetname: \"%p\" "
500 NODE2TYPE_EDGE_ATTR "}\n", get_Alloc_type(n));
503 xfprintf (F, "edge: { sourcename: \"");
505 fprintf (F, "\" targetname: \"%p\" "
506 NODE2TYPE_EDGE_ATTR "}\n", get_Free_type(n));
514 /* dumps a type or entity and it's edges. */
516 dump_type_info (type_or_ent *tore, void *env) {
517 int i = 0; /* to shutup gcc */
519 /* dump this type or entity */
520 xfprintf (F, "node: {title: \"%p\" ", tore);
521 xfprintf (F, DEFAULT_TYPE_ATTRIBUTE);
522 xfprintf (F, "label: ");
524 switch (get_kind(tore)) {
527 entity *ent = (entity *)tore;
528 xfprintf (F, "\"ent %I\" " ENTITY_NODE_ATTR , get_entity_ident(ent));
529 if(dynamic_allocated == get_entity_allocation(ent))
530 xfprintf (F, " info1:\"dynamic allocated\"}\n");
532 xfprintf (F, " info1:\"static allocated\"}\n");
533 xfprintf (F, "nearedge: { sourcename: \"%p\" targetname: \"%p\" "
534 ENT_OWN_EDGE_ATTR "}\n", tore, get_entity_owner(ent));
535 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
536 ENT_TYPE_EDGE_ATTR "}\n", tore, get_entity_type(ent));
537 for(i = 0; i < get_entity_n_overwrites(ent); i++)
538 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
539 ENT_OVERWRITES_EDGE_ATTR "}\n", tore, get_entity_overwrites(ent, i));
543 type *tp = (type *)tore;
544 xfprintf (F, "\"%I %I", get_type_tpop_nameid(tp), get_type_ident(tp));
546 switch (get_type_tpop_code(tp)) {
549 xfprintf (F, "\" " TYPE_CLASS_NODE_ATTR "}\n");
550 for (i=0; i < get_class_n_supertype(tp); i++)
551 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
552 TYPE_SUPER_EDGE_ATTR "}\n",
553 tp, get_class_supertype(tp, i));
554 for (i=0; i < get_class_n_member(tp); i++)
555 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
556 TYPE_MEMBER_EDGE_ATTR "}\n",
557 tp, get_class_member(tp, i));
561 xfprintf (F, "\"}\n");
562 for (i=0; i < get_struct_n_member(tp); i++)
563 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
564 TYPE_MEMBER_EDGE_ATTR "}\n",
565 tp, get_struct_member(tp, i));
569 xfprintf (F, "\" " TYPE_METH_NODE_ATTR "}\n");
570 for (i = 0; i < get_method_n_params(tp); i++)
571 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
572 METH_PAR_EDGE_ATTR "}\n",
573 tp, get_method_param_type(tp, i), i);
574 for (i = 0; i < get_method_n_res(tp); i++)
575 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
576 METH_RES_EDGE_ATTR "}\n",
577 tp, get_method_res_type(tp, i), i);
581 xfprintf (F, "\"}\n");
582 for (i = 0; i < get_union_n_members(tp); i++)
583 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
584 "label: \"\"f" UNION_EDGE_ATTR "}\n",
585 tp, get_union_member(tp, i));
589 xfprintf (F, "\"}\n");
590 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
591 ARR_ELT_TYPE_EDGE_ATTR "}\n", tp, get_array_element_type(tp), i);
592 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
593 ARR_ENT_EDGE_ATTR "}\n", tp, get_array_element_entity(tp), i);
595 case tpo_enumeration:
597 xfprintf (F, "\"}\n");
601 xfprintf (F, "\"}\n");
602 xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
603 PTR_PTS_TO_EDGE_ATTR "}\n", tp,
604 get_pointer_points_to_type(tp), i);
608 xfprintf (F, " (mode %I)\"}\n", get_mode_ident(get_type_mode(tp)));
613 break; /* case k_type */
616 xfprintf (F, "\" faulty type \"}\n");
617 printf(" *** irdump, %s(l.%i), faulty type.\n", __FUNCTION__, __LINE__);
619 } /* switch kind_or_entity */
622 /************************************************************************/
623 /* open and close vcg file */
624 /************************************************************************/
626 void vcg_open (ir_graph *irg, char *suffix) {
627 char *fname; /* filename to put the vcg information in */
633 /** open file for vcg graph */
634 id = get_entity_ld_ident (get_irg_ent(irg));
635 len = id_to_strlen (id);
638 fname = malloc (len + 5 + strlen(suffix));
639 strncpy (fname, cp, len); /* copy the filename */
641 strcat (fname, suffix); /* append file suffix */
643 fname = malloc (len + 5 + strlen(suffix));
644 strncpy (fname, cp, len); /* copy the filename */
645 fname[len] = '\0'; /* ensure string termination */
646 /*strcpy (fname, cp); * copy the filename *
647 this produces wrong, too long strings in conjuction with the
648 jocca frontend. The \0 seems to be missing. */
649 strcat (fname, suffix); /* append file suffix */
650 strcat (fname, ".vcg"); /* append the .vcg suffix */
651 F = fopen (fname, "w"); /* open file for writing */
653 panic ("cannot open %s for writing (%m)", fname); /* not reached */
657 strcpy(label, "yes");
659 strcpy (label, "no");
664 "graph: { title: \"ir graph of %s\"\n"
665 "display_edge_labels: %s\n"
666 "layoutalgorithm: mindepth\n"
667 "manhattan_edges: yes\n"
669 "orientation: bottom_to_top\n"
670 "classname 1: \"Data\"\n"
671 "classname 2: \"Block\"\n"
672 "classname 3: \"Entity type\""
673 "classname 4: \"Entity owner\""
674 "classname 5: \"Method Param\""
675 "classname 6: \"Method Res\""
676 "classname 7: \"Super\""
677 "classname 8: \"Union\""
678 "classname 9: \"Points-to\""
679 "classname 10: \"Array Element Type\""
680 "classname 11: \"Overwrites\""
681 "classname 12: \"Member\""
684 xfprintf (F, "\n"); /* a separator */
687 void vcg_open_name (const char *name) {
688 char *fname; /* filename to put the vcg information in */
692 /** open file for vcg graph */
694 fname = malloc (len + 5);
695 strcpy (fname, name); /* copy the filename */
696 strcat (fname, ".vcg"); /* append the .vcg suffix */
697 F = fopen (fname, "w"); /* open file for writing */
699 panic ("cannot open %s for writing (%m)", fname); /* not reached */
703 strcpy(label, "yes");
705 strcpy (label, "no");
710 "graph: { title: \"ir graph of %s\"\n"
711 "display_edge_labels: %s\n"
712 "layoutalgorithm: mindepth\n"
713 "manhattan_edges: yes\n"
715 "orientation: bottom_to_top\n"
716 "classname 1: \"Data\"\n"
717 "classname 2: \"Block\"\n"
718 "classname 3: \"Entity type\"\n"
719 "classname 4: \"Entity owner\"\n"
720 "classname 5: \"Method Param\"\n"
721 "classname 6: \"Method Res\"\n"
722 "classname 7: \"Super\"\n"
723 "classname 8: \"Union\"\n"
724 "classname 9: \"Points-to\"\n"
725 "classname 10: \"Array Element Type\"\n"
726 "classname 11: \"Overwrites\"\n"
727 "classname 12: \"Member\"\n"
730 xfprintf (F, "\n"); /* a separator */
735 xfprintf (F, "}\n"); /* print footer */
736 fclose (F); /* close vcg file */
739 /************************************************************************/
740 /* routines to dump a graph, blocks as conventional nodes. */
741 /************************************************************************/
744 dump_whole_node (ir_node *n, void* env) {
746 dump_ir_block_edge(n);
747 dump_ir_data_edges(n);
751 dump_ir_graph (ir_graph *irg)
754 rem = current_ir_graph;
755 current_ir_graph = irg;
759 /* walk over the graph */
760 irg_walk(irg->end, dump_whole_node, NULL, NULL);
764 current_ir_graph = rem;
767 /***********************************************************************/
768 /* the following routines dump the nodes as attached to the blocks. */
769 /***********************************************************************/
772 dump_ir_blocks_nodes (ir_node *n, void *env) {
773 ir_node *block = (ir_node *)env;
775 if (is_no_Block(n) && get_nodes_Block(n) == block) {
777 dump_ir_data_edges(n);
779 if (get_irn_op(n) == op_Bad)
784 dump_ir_block (ir_node *block, void *env) {
785 ir_graph *irg = (ir_graph *)env;
787 if (get_irn_opcode(block) == iro_Block) {
789 /* This is a block. So dump the vcg information to make a block. */
790 xfprintf(F, "graph: { title: \""); PRINT_NODEID(block); fprintf(F, "\" label: \"");
792 xfprintf (F, "%ld", get_irn_node_nr(block));
794 xfprintf (F, "%I", block->op->name);
796 xfprintf(F, "\" status:clustered color:lightyellow \n");
797 /* dump the blocks edges */
798 dump_ir_data_edges(block);
800 /* dump the nodes that go into the block */
801 irg_walk(irg->end, dump_ir_blocks_nodes, NULL, block);
803 /* Close the vcg information for the block */
804 xfprintf(F, "}\n\n");
810 dump_blockless_nodes (ir_node *n, void *env) {
811 if (is_no_Block(n) && get_irn_op(get_nodes_Block(n)) == op_Bad) {
813 dump_ir_data_edges(n);
814 dump_ir_block_edge(n);
816 if (get_irn_op(n) == op_Bad)
820 void dump_ir_block_graph_2 (ir_graph *irg)
823 /* walk over the blocks in the graph */
824 irg_block_walk(irg->end, dump_ir_block, NULL, irg);
826 /* dump all nodes that are not in a Block */
827 irg_walk(irg->end, dump_blockless_nodes, NULL, NULL);
829 /* dump the Bad node */
831 dump_node(get_irg_bad(irg));
835 dump_ir_block_graph (ir_graph *irg)
838 rem = current_ir_graph;
839 current_ir_graph = irg;
843 dump_ir_block_graph_2 (irg);
846 current_ir_graph = rem;
850 /***********************************************************************/
851 /* the following routines dump a control flow graph */
852 /***********************************************************************/
856 dump_block_to_cfg (ir_node *block, void *env) {
860 if (get_irn_opcode(block) == iro_Block) {
861 /* This is a block. Dump a node for the block. */
862 xfprintf (F, "node: {title: \"%p\" label: \"%I\"}", block,
865 for ( i = 0; i < get_Block_n_cfgpreds(block); i++) {
866 pred = get_nodes_Block(skip_Proj(get_Block_cfgpred(block, i)));
867 xfprintf (F, "edge: { sourcename: \"");
869 fprintf (F, "\" targetname: \"");
871 fprintf (F, "\" }\n");
877 dump_cfg (ir_graph *irg)
879 vcg_open (irg, "-cfg");
881 /* walk over the blocks in the graph */
882 irg_block_walk(irg->end, dump_block_to_cfg, NULL, NULL);
888 /***********************************************************************/
889 /* the following routine dumps all type information reachable from an */
891 /***********************************************************************/
895 dump_type_graph (ir_graph *irg)
898 rem = current_ir_graph;
899 current_ir_graph = irg;
901 vcg_open (irg, "-type");
903 /* walk over the blocks in the graph */
904 type_walk_irg(irg, dump_type_info, NULL, NULL);
907 current_ir_graph = rem;
910 /***********************************************************************/
911 /* the following routine dumps all type information */
912 /***********************************************************************/
916 dump_all_types (void)
918 vcg_open_name ("All_types");
919 type_walk(dump_type_info, NULL, NULL);
923 /***********************************************************************/
924 /* dumps a graph with type information */
925 /***********************************************************************/
929 dump_ir_graph_w_types (ir_graph *irg)
932 rem = current_ir_graph;
933 current_ir_graph = irg;
935 vcg_open (irg, "-all");
937 /* dump common ir graph */
938 irg_walk(irg->end, dump_whole_node, NULL, NULL);
940 type_walk_irg(irg, dump_type_info, NULL, NULL);
941 /* dump edges from graph to type info */
942 irg_walk(irg->end, dump_node2type_edges, NULL, NULL);
945 current_ir_graph = rem;
949 dump_ir_block_graph_w_types (ir_graph *irg)
952 rem = current_ir_graph;
953 current_ir_graph = irg;
955 vcg_open (irg, "-all");
957 /* dump common blocked ir graph */
958 dump_ir_block_graph_2(irg);
960 type_walk_irg(irg, dump_type_info, NULL, NULL);
961 /* dump edges from graph to type info */
962 irg_walk(irg->end, dump_node2type_edges, NULL, NULL);
965 current_ir_graph = rem;
968 /***********************************************************************/
969 /* dumps all graphs with the graph-dumper passed. Possible dumpers: */
971 /* dump_ir_block_graph */
973 /* dump_type_graph */
974 /* dump_ir_graph_w_types */
975 /***********************************************************************/
976 void dump_all_ir_graphs (void dump_graph(ir_graph*)) {
978 for (i=0; i < get_irp_n_irgs(); i++) {
979 dump_graph(get_irp_irg(i));
984 /* To turn off display of edge labels. Edge labels offen cause xvcg to
985 abort with a segmentation fault. */
986 void turn_of_edge_labels() {