*** empty log message ***
[libfirm] / ir / ir / irdump.c
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** irdump.h: dumping of an intermediate representation graph
7 */
8
9 # include "irnode_t.h"
10 # include "irgraph_t.h"
11 # include "irprog.h"
12 # include "irdump.h"
13 # include "panic.h"
14 # include <string.h>
15 # include "entity.h"
16 # include <stdlib.h>
17 # include "array.h"
18 # include "irop_t.h"
19 # include "tv.h"
20 # include "type_or_entity.h"
21 # include "irgwalk.h"
22 # include "typewalk.h"
23
24 #define DEFAULT_NODE_ATTR ""
25 #define BLOCK_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted"
26 #define NODE2TYPE_EDGE_ATTR ""
27 #define DEFAULT_TYPE_ATTRIBUTE ""
28 #define TYPE_EDGE_ATTR ""
29
30 /* file to dump to */
31 static FILE *F;
32
33
34 /*******************************************************************/
35 /* routines to dump information about a single node                */
36 /*******************************************************************/
37
38
39
40 inline void
41 dump_node_opcode (ir_node *n)
42 {
43   /* Const */
44   if (n->op->code == iro_Const) {
45     xfprintf (F, "%v", n->attr.con);
46   /* SymConst */
47   } else if (n->op->code == iro_SymConst) {
48     if (get_SymConst_kind(n) == linkage_ptr_info) {
49       xfprintf (F, "%I", get_SymConst_ptrinfo(n));
50     } else {
51       assert(get_kind(get_SymConst_type(n)) == k_type_class);
52       assert(get_class_ident((type_class *)get_SymConst_type(n)));
53       xfprintf (F, "%s ", id_to_str(get_class_ident((type_class *)get_SymConst_type(n))));
54       if (get_SymConst_kind == type_tag)
55         xfprintf (F, "tag");
56       else
57         xfprintf (F, "size");
58     }
59   /* all others */
60   } else {
61     xfprintf (F, "%I", n->op->name);
62   }
63 }
64
65 inline void
66 dump_node_mode (ir_node *n)
67 {
68   switch (n->op->code) {
69   case iro_Phi:
70   case iro_Const:
71   case iro_Id:
72   case iro_Proj:
73   case iro_Conv:
74   case iro_Tuple:
75   case iro_Add:
76   case iro_Sub:
77   case iro_Mul:
78   case iro_And:
79   case iro_Or:
80   case iro_Eor:
81   case iro_Shl:
82   case iro_Shr:
83   case iro_Abs:
84   case iro_Cmp:
85     xfprintf (F, "%I", n->mode->name);
86     break;
87   default:
88   }
89 }
90
91 inline void
92 dump_node_nodeattr (ir_node *n)
93 {
94   switch (n->op->code) {
95   case iro_Proj:
96     if (n->in[1]->op->code == iro_Cmp) {
97       xfprintf (F, "%s", get_pnc_string(n->attr.proj));
98     } else {
99       xfprintf (F, "%ld", n->attr.proj);
100     }
101     break;
102   case iro_Sel:
103     /*assert(n->attr.s.ent->kind == k_entity);*/
104     assert(get_kind(get_Sel_entity(n)) == k_entity);
105     xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
106
107     /*  xdoesn't work for some reason.
108         fprintf (F, "\"%I %I\" ", n->op->name, n->attr.s.ent); */
109     break;
110   default:
111   } /* end switch */
112 }
113
114 inline void
115 dump_node_vcgattr (ir_node *n)
116 {
117   switch (n->op->code) {
118   case iro_Start:
119   case iro_End:
120     xfprintf (F, "color: blue");
121     break;
122   case iro_Block:
123     xfprintf (F, "color: lightyellow");
124     break;
125   case iro_Phi:
126     xfprintf (F, "color: green");
127     break;
128   case iro_Const:
129   case iro_Proj:
130   case iro_Tuple:
131     xfprintf (F, "color: yellow");
132     break;
133   default:
134     xfprintf (F, DEFAULT_NODE_ATTR);
135   }
136 }
137
138 void
139 dump_node (ir_node *n) {
140
141   /* dump this node */
142   xfprintf (F, "node: {title: \"%p\" label: \"", n);
143   dump_node_opcode(n);
144   dump_node_mode (n);
145   xfprintf (F, " ");
146   dump_node_nodeattr(n);
147 #ifdef DEBUG_libfirm
148   xfprintf (F, " %ld", get_irn_node_nr(n));
149 #endif
150   xfprintf (F, "\" ");
151   dump_node_vcgattr(n);
152   xfprintf (F, "}\n");
153 }
154
155 void
156 dump_ir_node (ir_node *n)
157 {
158   /* dump this node */
159   xfprintf (F, "node: {title: \"%p\" label: ", n);
160
161   switch (n->op->code) {  /* node label */
162   case iro_Start:
163     xfprintf (F, "\"%I\" color: blue ", n->op->name);
164     xfprintf (F, DEFAULT_NODE_ATTR);
165      break;
166   case iro_End:
167     xfprintf (F, "\"%I\" color: blue ", n->op->name);
168     xfprintf (F, DEFAULT_NODE_ATTR);
169     break;
170   case iro_Block:
171     xfprintf (F, "\"%I\" color: lightyellow ", n->op->name);
172     xfprintf (F, DEFAULT_NODE_ATTR);
173     break;
174   case iro_Phi:
175     xfprintf (F, "\"%I%I\" color: green", n->op->name, n->mode->name);
176     if (n->mode->code == irm_M)
177       xfprintf (F, DEFAULT_NODE_ATTR " color: green");
178     else
179       xfprintf (F, DEFAULT_NODE_ATTR);
180     break;
181   case iro_Const:
182     xfprintf (F, "\"%v%I\" color: yellow ", n->attr.con, n->mode->name);
183     xfprintf (F, DEFAULT_NODE_ATTR);
184     break;
185   case iro_Id:
186     xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
187     xfprintf (F, DEFAULT_NODE_ATTR);
188     break;
189   case iro_Proj:
190     if (n->in[1]->op->code == iro_Cmp) {
191       xfprintf (F, "\"%I%I %s\" color: yellow", n->op->name, n->mode->name,
192                 get_pnc_string(n->attr.proj));
193     } else {
194       xfprintf (F, "\"%I%I %ld\"", n->op->name, n->mode->name, n->attr.proj);
195     }
196     xfprintf (F, DEFAULT_NODE_ATTR);
197     break;
198   case iro_Conv:
199     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
200     xfprintf (F, DEFAULT_NODE_ATTR);
201     break;
202   case iro_Tuple:
203     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
204     xfprintf (F, DEFAULT_NODE_ATTR);
205     break;
206   case iro_Add:
207     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
208     xfprintf (F, DEFAULT_NODE_ATTR);
209     break;
210   case iro_Sub:
211     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
212     xfprintf (F, DEFAULT_NODE_ATTR);
213     break;
214   case iro_Mul:
215     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
216     xfprintf (F, DEFAULT_NODE_ATTR);
217     break;
218   case iro_Quot:
219     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
220     xfprintf (F, DEFAULT_NODE_ATTR);
221     break;
222   case iro_DivMod:
223     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
224     xfprintf (F, DEFAULT_NODE_ATTR);
225     break;
226   case iro_Div:
227     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
228     xfprintf (F, DEFAULT_NODE_ATTR);
229     break;
230   case iro_Mod:
231     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
232     xfprintf (F, DEFAULT_NODE_ATTR);
233     break;
234   case iro_And:
235     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
236     xfprintf (F, DEFAULT_NODE_ATTR);
237     break;
238   case iro_Or:
239     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
240     xfprintf (F, DEFAULT_NODE_ATTR);
241     break;
242   case iro_Eor:
243     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
244     xfprintf (F, DEFAULT_NODE_ATTR);
245     break;
246   case iro_Shl:
247     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
248     xfprintf (F, DEFAULT_NODE_ATTR);
249     break;
250   case iro_Shr:
251     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
252     xfprintf (F, DEFAULT_NODE_ATTR);
253     break;
254   case iro_Abs:
255     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
256     xfprintf (F, DEFAULT_NODE_ATTR);
257     break;
258   case iro_Cmp:
259     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
260     xfprintf (F, DEFAULT_NODE_ATTR);
261     break;
262   case iro_Jmp:
263     xfprintf (F, "\"%I\"", n->op->name);
264     xfprintf (F, DEFAULT_NODE_ATTR);
265     break;
266   case iro_Cond:
267     xfprintf (F, "\"%I\"", n->op->name);
268     xfprintf (F, DEFAULT_NODE_ATTR);
269     break;
270   case iro_Call:
271     xfprintf (F, "\"%I\"", n->op->name);
272     xfprintf (F, DEFAULT_NODE_ATTR);
273     break;
274   case iro_Return:
275     xfprintf (F, "\"%I\"", n->op->name);
276     xfprintf (F, DEFAULT_NODE_ATTR);
277     break;
278   case iro_Raise:
279     xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
280     xfprintf (F, DEFAULT_NODE_ATTR);
281     break;
282   case iro_Load:
283   case iro_Store:
284     xfprintf (F, "\"%R\"", n);
285     xfprintf (F, DEFAULT_NODE_ATTR);
286     break;
287   case iro_Alloc:
288     xfprintf (F, "\"%I\" ", n->op->name);
289     xfprintf (F, DEFAULT_NODE_ATTR);
290     break;
291   case iro_Sel:
292     assert(get_kind(get_Sel_entity(n)) == k_entity);
293     xfprintf (F, "\"%I ", n->op->name);
294     xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
295     /*  xdoesn't work for some reason.
296         fprintf (F, "\"%I %I\" ", n->op->name, get_entity_ident(get_Sel_entity(n))); */
297     xfprintf (F, DEFAULT_NODE_ATTR);
298     break;
299   case iro_SymConst:
300     assert(get_kind(get_SymConst_type(n)) == k_type_class);
301     assert(get_class_ident((type_class *)get_SymConst_type(n)));
302     xfprintf (F, "\"%s ",
303               id_to_str(get_class_ident((type_class *)get_SymConst_type(n))));
304     switch (n->attr.i.num){
305     case type_tag:
306       xfprintf (F, "tag\" ");
307       break;
308     case size:
309       xfprintf (F, "size\" ");
310       break;
311     default:
312       assert(0);
313       break;
314     }
315     xfprintf (F, DEFAULT_NODE_ATTR);
316     break;
317   case iro_Sync:
318     xfprintf (F, "\"%I\" ", n->op->name);
319     xfprintf (F, DEFAULT_NODE_ATTR " color: green");
320     break;
321   case iro_Bad:
322     xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
323     xfprintf (F, DEFAULT_NODE_ATTR);
324     break;
325   default:
326     xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
327   }
328   xfprintf (F, "}\n");          /* footer */
329 }
330
331
332 /* dump the edge to the block this node belongs to */
333 void
334 dump_ir_block_edge(ir_node *n)  {
335   if (is_no_Block(n))
336     xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
337                 BLOCK_EDGE_ATTR "}\n", n, get_nodes_Block(n));
338 }
339
340
341 /* dump edges to our inputs */
342 void
343 dump_ir_data_edges(ir_node *n)  {
344   int i;
345
346   for (i = 0; i < get_irn_arity(n); i++) {
347     assert(get_irn_n(n, i));
348     xfprintf (F, "edge: {sourcename: \"%p\" targetname: \"%p\"",
349               n, get_irn_n(n, i));
350     fprintf (F, " label: \"%d\"", i+1);
351     fprintf (F, "}\n");
352   }
353 }
354
355 /* dumps the edges between nodes and their type or entity attributes. */
356 void dump_node2type_edges (ir_node *n, void *env)
357 {
358   assert(n);
359
360   switch (get_irn_opcode(n)) {
361   case iro_SymConst:
362     if (   (get_SymConst_kind(n) == type_tag)
363         || (get_SymConst_kind(n) == size))
364       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
365                 NODE2TYPE_EDGE_ATTR "}\n", n, get_SymConst_type(n));
366     break;
367   case iro_Sel:
368     xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
369               NODE2TYPE_EDGE_ATTR "}\n", n, get_Sel_entity(n));
370     break;
371   case iro_Call:
372     xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
373               NODE2TYPE_EDGE_ATTR "}\n", n, get_Call_type(n));
374     break;
375   case iro_Alloc:
376     xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
377               NODE2TYPE_EDGE_ATTR "}\n", n, get_Alloc_type(n));
378     break;
379   case iro_Free:
380     printf(" in irdum\n");
381     xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
382               NODE2TYPE_EDGE_ATTR "}\n", n, get_Free_type(n));
383     break;
384   default:
385     break;
386   }
387 }
388
389
390 /* dumps a type or entity and it's edges. */
391 void
392 dump_type_info (type_or_ent *tore, void *env) {
393   int i = 0;  /* to shutup gcc */
394
395   /* dump this type or entity */
396   xfprintf (F, "node: {title: \"%p\" ", tore);
397   xfprintf (F, DEFAULT_TYPE_ATTRIBUTE);
398   xfprintf (F, "label: ");
399
400   switch (get_kind(tore)) {
401   case k_entity:
402     {
403       entity *ent = (entity *)tore;
404       xfprintf (F, "\"ent %I\"}\n", get_entity_ident(ent));
405       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
406                 " label: \"owner\" "
407                 TYPE_EDGE_ATTR "}\n", tore, get_entity_owner(ent));
408       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
409                 " label: \"type\" "
410                 TYPE_EDGE_ATTR "}\n", tore, get_entity_type(ent));
411     }
412     break;
413   case k_type_class:
414     {
415       type_class *type = (type_class *)tore;
416       xfprintf (F, "\"class %I\"}\n", get_class_ident(type));
417       for (i=0; i < get_class_n_supertype(type); i++)
418         xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
419                   " label: \"supertype\" " TYPE_EDGE_ATTR "}\n",
420                   type, get_class_supertype(type, i));
421     }
422     break;
423   case k_type_strct:
424     {
425       type_strct *type = (type_strct *)tore;
426       xfprintf (F, "\"strct %I\"}\n", get_strct_ident(type));
427     }
428     break;
429   case k_type_method:
430     {
431       type_method *type = (type_method *)tore;
432       xfprintf (F, "\"meth %I\"}\n", get_method_ident(type));
433       for (i = 0; i < get_method_arity(type); i++)
434         xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
435                   " label: \"param %d\" " TYPE_EDGE_ATTR "}\n",
436                   tore, get_method_param_type(type, i), i);
437       for (i = 0; i < get_method_n_res(type); i++)
438         xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
439                   " label: \"res %d\" " TYPE_EDGE_ATTR "}\n",
440                   tore, get_method_res_type(type, i), i);
441     }
442     break;
443   case k_type_union:
444     {
445       type_union *type = (type_union *)tore;
446       xfprintf (F, "\"union %I\"}\n", get_union_ident(type));
447       /* edges !!!??? */
448     }
449     break;
450   case k_type_array:
451     {
452       type_array *type = (type_array *)tore;
453       xfprintf (F, "\"array %I\"}\n", get_array_ident(type));
454       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
455                 TYPE_EDGE_ATTR "}\n", tore, get_array_element_type(type), i);
456     }
457     break;
458   case k_type_enumeration:
459     {
460       type_enumeration *type = (type_enumeration *)tore;
461       xfprintf (F, "\"enum %I\"}\n", get_enumeration_ident(type));
462     }
463     break;
464   case k_type_pointer:
465     {
466       type_pointer *type = (type_pointer *)tore;
467       xfprintf (F, "\"ptr %I\"}\n", get_pointer_ident(type));
468       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
469                 TYPE_EDGE_ATTR "}\n", tore,
470                 get_pointer_points_to_type(type), i);
471     }
472     break;
473   case k_type_primitive:
474     {
475       type_primitive *type = (type_primitive *)tore;
476       xfprintf (F, "\"prim %I, mode %I\"}\n", get_primitive_ident(type),
477                 get_mode_ident(get_primitive_mode(type)));
478     }
479     break;
480   default:
481     break;
482   }
483
484 }
485
486 /************************************************************************/
487 /* open and close vcg file                                              */
488 /************************************************************************/
489
490 void vcg_open (ir_graph *irg, char *suffix) {
491   char *fname;  /* filename to put the vcg information in */
492   const char *cp;
493   ident *id;
494   int len;
495
496   /** open file for vcg graph */
497   id    = get_entity_ld_name (get_irg_ent(irg));
498   len   = id_to_strlen (id);
499   cp    = id_to_str (id);
500   fname = malloc (len + 5 + strlen(suffix));
501   strcpy (fname, cp);      /* copy the filename */
502   strcat (fname, suffix);  /* append file suffix */
503   strcat (fname, ".vcg");  /* append the .vcg suffix */
504   F = fopen (fname, "w");  /* open file for writing */
505   if (!F) {
506     panic ("cannot open %s for writing (%m)", fname);  /* not reached */
507   }
508
509   /* print header */
510   xfprintf (F,
511             "graph: { title: \"ir graph of %s\"\n"
512             "display_edge_labels: yes\n"
513             "layoutalgorithm: mindepth\n"
514             "manhattan_edges: yes\n"
515             "port_sharing: no\n"
516             "orientation: bottom_to_top\n"
517             "classname 1: \"Data\"\n"
518             "classname 2: \"Block\"\n", cp);
519
520   xfprintf (F, "\n");           /* a separator */
521 }
522
523 void vcg_open_name (const char *name) {
524   char *fname;  /* filename to put the vcg information in */
525   int len;
526
527   /** open file for vcg graph */
528   len   = strlen(name);
529   fname = malloc (len + 5);
530   strcpy (fname, name);    /* copy the filename */
531   strcat (fname, ".vcg");  /* append the .vcg suffix */
532   F = fopen (fname, "w");  /* open file for writing */
533   if (!F) {
534     panic ("cannot open %s for writing (%m)", fname);  /* not reached */
535   }
536
537   /* print header */
538   xfprintf (F,
539             "graph: { title: \"ir graph of %s\"\n"
540             "display_edge_labels: yes\n"
541             "layoutalgorithm: mindepth\n"
542             "manhattan_edges: yes\n"
543             "port_sharing: no\n"
544             "orientation: bottom_to_top\n"
545             "classname 1: \"Data\"\n"
546             "classname 2: \"Block\"\n", name);
547
548   xfprintf (F, "\n");           /* a separator */
549 }
550
551 void
552 vcg_close () {
553   xfprintf (F, "}\n");  /* print footer */
554   fclose (F);           /* close vcg file */
555 }
556
557 /************************************************************************/
558 /* routines to dump a graph, blocks as conventional nodes.              */
559 /************************************************************************/
560
561 void
562 dump_whole_node (ir_node *n, void* env) {
563   dump_node(n);
564   dump_ir_block_edge(n);
565   dump_ir_data_edges(n);
566 }
567
568 void
569 dump_ir_graph (ir_graph *irg)
570 {
571   ir_graph *rem;
572   rem = current_ir_graph;
573   current_ir_graph = irg;
574
575   vcg_open (irg, "");
576
577   /* walk over the graph */
578   irg_walk(irg->end, dump_whole_node, NULL, NULL);
579
580   vcg_close();
581
582   current_ir_graph = rem;
583 }
584
585 /***********************************************************************/
586 /* the following routines dump the nodes as attached to the blocks.    */
587 /***********************************************************************/
588
589 void
590 dump_ir_blocks_nodes (ir_node *n, void *env) {
591   ir_node *block = (ir_node *)env;
592
593   if (is_no_Block(n) && get_nodes_Block(n) == block) {
594     dump_node(n);
595     dump_ir_data_edges(n);
596   }
597 }
598
599 void
600 dump_ir_block (ir_node *block, void *env) {
601   ir_graph *irg = (ir_graph *)env;
602
603   if (get_irn_opcode(block) == iro_Block) {
604
605     /* This is a block. So dump the vcg information to make a block. */
606     xfprintf(F, "graph: { title: \"%p\"  label: \"", block);
607 #ifdef DEBUG_libfirm
608     xfprintf (F, "%ld", get_irn_node_nr(block));
609 #else
610     xfprintf (F, "%I", block->op->name);
611 #endif
612     xfprintf(F, "\" status:clustered color:lightyellow \n");
613     /* dump the blocks edges */
614     dump_ir_data_edges(block);
615
616     /* dump the nodes that go into the block */
617     irg_walk(irg->end, dump_ir_blocks_nodes, NULL, block);
618
619     /* Close the vcg information for the block */
620     xfprintf(F, "}\n\n");
621   }
622 }
623
624 void
625 dump_ir_block_graph (ir_graph *irg)
626 {
627   ir_graph *rem;
628   rem = current_ir_graph;
629   current_ir_graph = irg;
630
631   vcg_open (irg, "");
632
633   /* walk over the blocks in the graph */
634   irg_block_walk(irg->end, dump_ir_block, NULL, irg);
635
636   vcg_close();
637   current_ir_graph = rem;
638 }
639
640
641 /***********************************************************************/
642 /* the following routines dump a control flow graph                    */
643 /***********************************************************************/
644
645
646 void
647 dump_block_to_cfg (ir_node *block, void *env) {
648   int i;
649   ir_node *pred;
650
651   if (get_irn_opcode(block) == iro_Block) {
652     /* This is a block. Dump a node for the block. */
653     xfprintf (F, "node: {title: \"%p\" label: \"%I\"}", block,
654               block->op->name);
655     /* Dump the edges */
656     for ( i = 0; i < get_Block_n_cfgpreds(block); i++) {
657       pred = get_nodes_Block(skip_Proj(get_Block_cfgpred(block, i)));
658       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" }\n",
659                 block, pred);
660     }
661   }
662 }
663
664 void
665 dump_cfg (ir_graph *irg)
666 {
667   vcg_open (irg, "-cfg");
668
669   /* walk over the blocks in the graph */
670   irg_block_walk(irg->end, dump_block_to_cfg, NULL, NULL);
671
672   vcg_close();
673 }
674
675
676 /***********************************************************************/
677 /* the following routine dumps all type information reachable from an  */
678 /* irg                                                                 */
679 /***********************************************************************/
680
681
682 void
683 dump_type_graph (ir_graph *irg)
684 {
685   ir_graph *rem;
686   rem = current_ir_graph;
687   current_ir_graph = irg;
688
689   vcg_open (irg, "-type");
690
691   /* walk over the blocks in the graph */
692   type_walk_irg(irg, dump_type_info, NULL, NULL);
693
694   vcg_close();
695   current_ir_graph = rem;
696 }
697
698 /***********************************************************************/
699 /* the following routine dumps all type information                    */
700 /***********************************************************************/
701
702
703 void
704 dump_all_types (void)
705 {
706   vcg_open_name ("All_types");
707   type_walk(dump_type_info, NULL, NULL);
708   vcg_close();
709 }
710
711 /***********************************************************************/
712 /* dumps a graph with type information                                 */
713 /***********************************************************************/
714
715
716 void
717 dump_ir_graph_w_types (ir_graph *irg)
718 {
719   ir_graph *rem;
720   rem = current_ir_graph;
721   current_ir_graph = irg;
722
723   vcg_open (irg, "-all");
724
725   /* dump common ir graph */
726   /*  irg_block_walk(irg->end, dump_ir_block, NULL, irg); */
727   irg_walk(irg->end, dump_whole_node, NULL, NULL);
728   /* dump type info */
729   type_walk_irg(irg, dump_type_info, NULL, NULL);
730   /* dump edges from graph to type info */
731   irg_walk(irg->end, dump_node2type_edges, NULL, NULL);
732
733   vcg_close();
734   current_ir_graph = rem;
735 }
736
737 /***********************************************************************/
738 /* dumps all graphs with the graph-dumper passed. Possible dumpers:    */
739 /*  dump_ir_graph                                                      */
740 /*  dump_ir_block_graph                                                */
741 /*  dump_cfg                                                           */
742 /*  dump_type_graph                                                    */
743 /*  dump_ir_graph_w_types                                              */
744 /***********************************************************************/
745 void dump_all_ir_graphs (void dump_graph(ir_graph*)) {
746   int i;
747   for (i=0; i < get_irp_n_irgs(); i++) {
748     dump_graph(get_irp_irg(i));
749   }
750 }