+ /* dump edges to nodes in loop -- only if it is a real loop */
+ if (get_loop_depth(loop) != 0) {
+ for (i = 0; i < get_loop_n_nodes(loop); i++) {
+ dump_loop_node_edge(loop, i);
+ }
+ }
+ for (i = 0; i < get_loop_n_sons(loop); i++) {
+ dump_loops(get_loop_son(loop, i));
+ dump_loop_son_edge(loop, i);
+ }
+}
+
+static INLINE
+void dump_loop_nodes_into_graph(ir_graph *irg) {
+ ir_graph *rem = current_ir_graph;
+ current_ir_graph = irg;
+
+ if (get_irg_loop(irg)) dump_loops(get_irg_loop(irg));
+
+ current_ir_graph = rem;
+}
+
+
+/************************************************************************/
+/* open and close vcg file */
+/************************************************************************/
+
+static INLINE void
+dump_vcg_header(const char *name, const char *orientation) {
+ char *label;
+
+ if (edge_label) {
+ label = "yes";
+ } else {
+ label = "no";
+ }
+
+ if (!orientation) orientation = "bottom_to_top";
+
+ /* print header */
+ fprintf (F,
+ "graph: { title: \"ir graph of %s\"\n"
+ "display_edge_labels: %s\n"
+ "layoutalgorithm: mindepth\n"
+ "manhattan_edges: yes\n"
+ "port_sharing: no\n"
+ "orientation: %s\n"
+ "classname 1: \"Data\"\n"
+ "classname 2: \"Block\"\n"
+ "classname 13:\"Control Flow\"\n"
+ "classname 14:\"Memory\"\n"
+ "classname 15:\"Dominators\"\n"
+ "classname 3: \"Entity type\"\n"
+ "classname 4: \"Entity owner\"\n"
+ "classname 5: \"Method Param\"\n"
+ "classname 6: \"Method Res\"\n"
+ "classname 7: \"Super\"\n"
+ "classname 8: \"Union\"\n"
+ "classname 9: \"Points-to\"\n"
+ "classname 10: \"Array Element Type\"\n"
+ "classname 11: \"Overwrites\"\n"
+ "classname 12: \"Member\"\n"
+ "infoname 1: \"Attribute\"\n"
+ "infoname 2: \"Verification errors\"\n",
+ name, label, orientation);
+
+ fprintf (F, "\n"); /* a separator */
+}
+
+static void vcg_open (ir_graph *irg, char * suffix1, char *suffix2) {
+ const char *nm = get_irg_dump_name(irg);
+ int len = strlen(nm), i, j;
+ char *fname; /* filename to put the vcg information in */
+
+ if (!suffix1) suffix1 = "";
+ if (!suffix2) suffix2 = "";
+
+ /** open file for vcg graph */
+ fname = malloc (len * 2 + strlen(suffix1) + strlen(suffix2) + 5);
+
+ //strncpy (fname, nm, len); /* copy the filename */
+ j = 0;
+ for (i = 0; i < len; ++i) { /* replase '/' in the name: escape by @. */
+ if (nm[i] == '/') {
+ fname[j] = '@'; j++; fname[j] = '1'; j++;
+ } else if (nm[i] == '@') {
+ fname[j] = '@'; j++; fname[j] = '2'; j++;
+ } else {
+ fname[j] = nm[i]; j++;
+ }
+ }
+ fname[j] = '\0';
+ strcat (fname, suffix1); /* append file suffix */
+ strcat (fname, suffix2); /* append file suffix */
+ strcat (fname, ".vcg"); /* append the .vcg suffix */
+ F = fopen (fname, "w"); /* open file for writing */
+ if (!F) {
+ panic ("cannot open %s for writing (%m)", fname); /* not reached */
+ }
+ free(fname);
+}
+
+static void vcg_open_name (const char *name, char *suffix) {
+ char *fname; /* filename to put the vcg information in */
+ int i, j, len = strlen(name);
+
+ if (!suffix) suffix = "";
+
+ /** open file for vcg graph */
+ fname = malloc (len * 2 + 5 + strlen(suffix));
+ //strcpy (fname, name); /* copy the filename */
+ j = 0;
+ for (i = 0; i < len; ++i) { /* replase '/' in the name: escape by @. */
+ if (name[i] == '/') {
+ fname[j] = '@'; j++; fname[j] = '1'; j++;
+ } else if (name[i] == '@') {
+ fname[j] = '@'; j++; fname[j] = '2'; j++;
+ } else {
+ fname[j] = name[i]; j++;
+ }
+ }
+ fname[j] = '\0';
+ strcat (fname, suffix);
+ strcat (fname, ".vcg"); /* append the .vcg suffix */
+ F = fopen (fname, "w"); /* open file for writing */
+ if (!F) {
+ panic ("cannot open %s for writing (%m)", fname); /* not reached */
+ }
+ free(fname);
+}
+
+static INLINE void dump_vcg_footer (void) {
+ fprintf (F, "}\n");