removed exc.h from libfirm interface
[libfirm] / ir / ir / irdump.c
index 29a8d29..2477602 100644 (file)
@@ -119,6 +119,7 @@ int dump_out_edge_flag = 0;
 int dump_dominator_information_flag = 0;
 int dump_loop_information_flag = 0;
 int dump_const_local = 0;
+bool opt_dump_analysed_type_info = 1;
 
 INLINE bool get_opt_dump_const_local(void) {
   if (!dump_out_edge_flag && !dump_loop_information_flag)
@@ -158,7 +159,7 @@ dump_node_opcode (ir_node *n)
     } else {
       assert(get_kind(get_SymConst_type(n)) == k_type);
       assert(get_type_ident(get_SymConst_type(n)));
-      fprintf (F, "SymC %s ", get_id_str(get_type_ident(get_SymConst_type(n))));
+      fprintf (F, "SymC %s ", get_type_name(get_SymConst_type(n)));
       if (get_SymConst_kind(n) == type_tag)
         fprintf (F, "tag");
       else
@@ -196,20 +197,32 @@ dump_node_mode (ir_node *n)
   case iro_Shr:
   case iro_Abs:
   case iro_Cmp:
-    fprintf (F, "%s", get_id_str(get_mode_ident(get_irn_mode(n))));
+    fprintf (F, "%s", get_mode_name(get_irn_mode(n)));
     break;
   default:
     ;
   }
 }
 
+static void dump_node_typeinfo(ir_node *n) {
+  if (!opt_dump_analysed_type_info) return;
+  if (get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_consistent  ||
+      get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_inconsistent  ) {
+    type *tp = get_irn_type(n);
+    if (tp != none_type)
+      fprintf (F, " [%s]", get_type_name(tp));
+    else
+      fprintf (F, " []");
+  }
+}
+
 static INLINE void
 dump_node_nodeattr (ir_node *n)
 {
   switch (get_irn_opcode(n)) {
   case iro_Start:
     if (false && interprocedural_view) {
-      fprintf (F, "%s", get_id_str(get_entity_ident(get_irg_ent(current_ir_graph))));
+      fprintf (F, "%s", get_entity_name(get_irg_ent(current_ir_graph)));
     }
     break;
   case iro_Proj:
@@ -227,7 +240,7 @@ dump_node_nodeattr (ir_node *n)
     fprintf (F, "%s", get_entity_name(get_Sel_entity(n)));
     } break;
   case iro_Cast: {
-    fprintf (F, "to %s", get_type_name(get_Cast_type(n)));
+    fprintf (F, "(%s)", get_type_name(get_Cast_type(n)));
     } break;
   default:
     ;
@@ -295,9 +308,26 @@ dump_node_info (ir_node *n) {
     for (i = 0; i < get_method_n_ress(tp); ++i)
       fprintf(F, "  resul %d type: %s \n", i, get_type_name(get_method_res_type(tp, i)));
   } break;
+  case iro_Return: {
+    if (!interprocedural_view) {
+      type *tp = get_entity_type(get_irg_ent(current_ir_graph));
+      fprintf(F, "return in method of type %s \n", get_type_name(tp));
+      for (i = 0; i < get_method_n_ress(tp); ++i)
+       fprintf(F, "  res %d type: %s \n", i, get_type_name(get_method_res_type(tp, i)));
+    }
+    } break;
+  case iro_Const: {
+    type *tp = get_Const_type(n);
+    assert(tp != none_type);
+    fprintf(F, "Const of type %s \n", get_type_name(get_Const_type(n)));
+  } break;
   default: ;
   }
 
+  if (get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_consistent  ||
+      get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_inconsistent  )
+    if (get_irn_type(n) != none_type)
+      fprintf (F, "\nAnalysed type: %s", get_type_name(get_irn_type(n)));
 
   fprintf (F, "\"");
 
@@ -349,6 +379,7 @@ static void dump_const_node_local(ir_node *n, pmap *irgmap) {
       fprintf(F, " label: \"");
       dump_node_opcode(con);
       dump_node_mode (con);
+      dump_node_typeinfo(con);
       fprintf (F, " ");
       dump_node_nodeattr(con);
 #ifdef DEBUG_libfirm
@@ -371,6 +402,7 @@ dump_node (ir_node *n, pmap * map) {
 
   dump_node_opcode(n);
   dump_node_mode (n);
+  dump_node_typeinfo(n);
   fprintf (F, " ");
   dump_node_nodeattr(n);
 #ifdef DEBUG_libfirm
@@ -627,7 +659,7 @@ static void print_type_info(type *tp) {
     fprintf(F, "state: layout_fixed,\n");
   }
   if (get_type_mode(tp))
-    fprintf(F, "mode: %s,\n", get_id_str(get_mode_ident(get_type_mode(tp))));
+    fprintf(F, "mode: %s,\n", get_mode_name(get_type_mode(tp)));
   fprintf(F, "size: %dB,\n", get_type_size(tp));
 }
 
@@ -671,7 +703,7 @@ static void print_type_node(type *tp)
 {
   fprintf (F, "node: {title: ");
   PRINT_TYPEID(tp);
-  fprintf (F, " label: \"%s %s\"", get_id_str(get_type_tpop_nameid(tp)), get_id_str(get_type_ident(tp)));
+  fprintf (F, " label: \"%s %s\"", get_type_tpop_name(tp), get_type_name(tp));
   fprintf (F, " info1: \"");
   print_type_info(tp);
   fprintf (F, "\"");
@@ -686,7 +718,7 @@ void dump_entity_node(entity *ent)
   PRINT_ENTID(ent); fprintf(F, "\"");
   fprintf (F, DEFAULT_TYPE_ATTRIBUTE);
   fprintf (F, "label: ");
-  fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , get_id_str(get_entity_ident(ent)));
+  fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , get_entity_name(ent));
   fprintf (F, "\n info1: \"\nid: "); PRINT_ENTID(ent);
 
   fprintf (F, "\nallocation:  ");
@@ -725,8 +757,7 @@ void dump_entity_node(entity *ent)
     X(peculiarity_existent);
   }
   fprintf(F, "\nname:    %s\nld_name: %s",
-         get_id_str(get_entity_ident(ent)),
-         get_id_str(get_entity_ld_ident(ent)));
+         get_entity_name(ent), get_entity_ld_name(ent));
   fprintf(F, "\noffset:  %d", get_entity_offset(ent));
   if (is_method_type(get_entity_type(ent))) {
     if (get_entity_irg(ent))   /* can be null */
@@ -1460,7 +1491,7 @@ static void d_cg_block_graph(ir_graph *irg, ir_node **arr, pmap *irgmap) {
   int i;
 
   fprintf(F, "graph: { title: %p label: %s status:clustered color:white \n",
-          (void*) irg, get_id_str(get_entity_ident(get_irg_ent(irg))));
+          (void*) irg, get_entity_name(get_irg_ent(irg)));
 
   for (i = ARR_LEN(arr) - 1; i >= 0; --i) {
     ir_node * node = arr[i];
@@ -1594,3 +1625,11 @@ void dump_cg_graph(ir_graph * irg) {
 
   vcg_close();
 }
+
+/* Dump the information of type field specified in ana/irtypeinfo.h.
+ * If the flag is set, the type name is output in [] in the node label,
+ * else it is output as info.
+ */
+void dump_analysed_type_info(bool b) {
+  opt_dump_analysed_type_info = b;
+}