Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / graph.c
index d9b0adec2f1341ec9f7a076d8c2231d5bef07b97..f13530082174053e8e7ef6fae8b7ce887ce66635 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * graph.c: Helper routines to graph various internal states of the code generator
+/**
+ * \file
+ * Helper routines to graph various internal states of the code generator
  *
  * Author:
  *   Dietmar Maurer (dietmar@ximian.com)
@@ -8,6 +9,7 @@
  */
 
 #include <config.h>
+#include <mono/utils/mono-compiler.h>
 
 #ifndef DISABLE_JIT
 
@@ -20,7 +22,7 @@ static char *
 convert_name (const char *str)
 {
        int i, j, len = strlen (str);
-       char *res = g_malloc (len * 2);
+       char *res = (char *)g_malloc (len * 2);
 
        j = 0;
        for (i = 0; i < len; i++) {
@@ -154,121 +156,6 @@ mono_draw_cfg (MonoCompile *cfg, FILE *fp)
        fprintf (fp, "}\n");
 }
 
-#if 0
-
-static void
-mono_print_label (FILE *fp, MonoInst *tree) {
-       int arity;
-
-       if (!tree)
-               return;
-
-       arity = mono_burg_arity [tree->opcode];
-
-       fprintf (fp, "\\ %s%s", arity? "(": "",  mono_inst_name (tree->opcode));
-
-       switch (tree->opcode) {
-       case OP_ICONST:
-               fprintf (fp, "[%ld]", (long)tree->inst_c0);
-               break;
-       case OP_I8CONST:
-               fprintf (fp, "[%lld]", (long long)tree->inst_l);
-               break;
-       case OP_R8CONST:
-               fprintf (fp, "[%f]", *(double*)tree->inst_p0);
-               break;
-       case OP_R4CONST:
-               fprintf (fp, "[%f]", *(float*)tree->inst_p0);
-               break;
-       case OP_ARG:
-       case OP_LOCAL:
-               fprintf (fp, "[%d]", (int)tree->inst_c0);
-               break;
-       case OP_REGOFFSET:
-               fprintf (fp, "[0x%x(%s)]", (int)tree->inst_offset, mono_arch_regname (tree->inst_basereg));
-               break;
-       case OP_REGVAR:
-               fprintf (fp, "[%s]", mono_arch_regname (tree->dreg));
-               break;
-       case CEE_NEWARR:
-               fprintf (fp, "[%s]",  tree->inst_newa_class->name);
-               mono_print_label (fp, tree->inst_newa_len);
-               break;
-       case OP_CALL:
-       case OP_CALL_MEMBASE:
-       case OP_FCALL:
-       case OP_FCALL_MEMBASE:
-       case OP_LCALL:
-       case OP_LCALL_MEMBASE:
-       case OP_VCALL:
-       case OP_VCALL_MEMBASE:
-       case OP_VOIDCALL:
-       case OP_VOIDCALL_MEMBASE: {
-               MonoCallInst *call = (MonoCallInst*)tree;
-               if (call->method) {
-                       if (mono_method_signature (call->method)->hasthis && tree->inst_left) {
-                               mono_print_label (fp, tree->inst_left);
-                       }
-                       fprintf (fp, "[%s]", call->method->name);
-               }
-               break;
-       }
-       case OP_PHI: {
-               int i;
-               fprintf (fp, "[%d\\ (", (int)tree->inst_c0);
-               for (i = 0; i < tree->inst_phi_args [0]; i++) {
-                       if (i)
-                               fprintf (fp, ",\\ ");
-                       fprintf (fp, "%d", tree->inst_phi_args [i + 1]);
-               }
-               fprintf (fp, ")]");
-               break;
-       }
-       case OP_NOP:
-       case OP_JMP:
-       case OP_BREAK:
-               break;
-       case OP_BR:
-               fprintf (fp, "[B%d]", tree->inst_target_bb->block_num);
-               break;
-       case OP_SWITCH:
-       case CEE_ISINST:
-       case CEE_CASTCLASS:
-       case OP_CALL_REG:
-       case OP_FCALL_REG:
-       case OP_LCALL_REG:
-       case OP_VCALL_REG:
-       case OP_VOIDCALL_REG:
-               mono_print_label (fp, tree->inst_left);
-               break;
-       case CEE_BNE_UN:
-       case CEE_BEQ:
-       case CEE_BLT:
-       case CEE_BLT_UN:
-       case CEE_BGT:
-       case CEE_BGT_UN:
-       case CEE_BGE:
-       case CEE_BGE_UN:
-       case CEE_BLE:
-       case CEE_BLE_UN:
-               fprintf (fp, "[B%dB%d]", tree->inst_true_bb->block_num, tree->inst_false_bb->block_num);
-               mono_print_label (fp, tree->inst_left);
-               break;
-       default:
-               if (arity) {
-                       mono_print_label (fp, tree->inst_left);
-                       if (arity > 1)
-                               mono_print_label (fp, tree->inst_right);
-               }
-               break;
-       }
-
-       if (arity)
-               fprintf (fp, ")");
-}
-
-#endif
-
 static void
 mono_draw_code_cfg (MonoCompile *cfg, FILE *fp)
 {
@@ -336,11 +223,19 @@ mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options)
 
        fclose (fp);
 
+#ifdef HAVE_SYSTEM
        //com = g_strdup_printf ("dot %s -Tpng -o %s.png; eog %s.png", fn, fn, fn);
        com = g_strdup_printf ("dot %s -Tps -o %s.ps;gv %s.ps", fn, fn, fn);
        _i = system (com);
        g_free (com);
+#else
+       g_assert_not_reached ();
+#endif
 }
 
-#endif /* DISABLE_JIT */
+#else /* !DISABLE_JIT */
+
+MONO_EMPTY_SOURCE_FILE (graph);
+
+#endif /* !DISABLE_JIT */