removed exc.h from libfirm interface
[libfirm] / ir / ir / irdump.c
index def13df..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));
 }
 
@@ -636,7 +668,7 @@ static void print_typespecific_info(type *tp) {
   switch (get_type_tpop_code(tp)) {
   case tpo_class:
     {
-      if(existent == get_class_peculiarity(tp))
+      if (peculiarity_existent == get_class_peculiarity(tp))
        fprintf (F, " " TYPE_CLASS_NODE_ATTR);
       else
        fprintf (F, " " TYPE_DESCRIPTION_NODE_ATTR);
@@ -667,10 +699,11 @@ static void print_typespecific_info(type *tp) {
   } /* switch type */
 }
 
-static void print_type_node(type *tp) {
+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, "\"");
@@ -678,47 +711,53 @@ static void print_type_node(type *tp) {
   fprintf (F, "}\n");
 }
 
-void dump_entity_node(entity *ent) {
+#define X(a)   case a: fprintf(F, #a); break
+void dump_entity_node(entity *ent)
+{
   fprintf (F, "node: {title: \"");
   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:  ");
   switch (get_entity_allocation(ent)) {
-    case dynamic_allocated:   fprintf (F, "dynamic allocated");   break;
-    case automatic_allocated: fprintf (F, "automatic allocated"); break;
-    case static_allocated:    fprintf (F, "static allocated");    break;
-    case parameter_allocated: fprintf (F, "parameter allocated"); break;
+    X(allocation_dynamic);
+    X(allocation_automatic);
+    X(allocation_static);
+    X(allocation_parameter);
   }
+
   fprintf (F, "\nvisibility:  ");
   switch (get_entity_visibility(ent)) {
-    case local:              fprintf (F, "local");             break;
-    case external_visible:   fprintf (F, "external visible");  break;
-    case external_allocated: fprintf (F, "external allocated"); break;
+    X(visibility_local);
+    X(visibility_external_visible);
+    X(visibility_external_allocated);
   }
+
   fprintf (F, "\nvariability: ");
   switch (get_entity_variability(ent)) {
-    case uninitialized: fprintf (F, "uninitialized");break;
-    case initialized:   fprintf (F, "initialized");  break;
-    case part_constant: fprintf (F, "part_constant");break;
-    case constant:      fprintf (F, "constant");     break;
+    X(variability_uninitialized);
+    X(variability_initialized);
+    X(variability_part_constant);
+    X(variability_constant);
   }
+
   fprintf (F, "\nvolatility:  ");
   switch (get_entity_volatility(ent)) {
-    case non_volatile: fprintf (F, "non_volatile"); break;
-    case is_volatile:  fprintf (F, "is_volatile");  break;
+    X(volatility_non_volatile);
+    X(volatility_is_volatile);
   }
+
   fprintf (F, "\npeculiarity: ");
   switch (get_entity_peculiarity(ent)) {
-    case description: fprintf (F, "description"); break;
-    case inherited:   fprintf (F, "inherited");   break;
-    case existent:    fprintf (F, "existent");    break;
+    X(peculiarity_description);
+    X(peculiarity_inherited);
+    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 */
@@ -728,6 +767,7 @@ void dump_entity_node(entity *ent) {
   }
   fprintf(F, "\"\n}\n");
 }
+#undef X
 
 /* dumps a type or entity and it's edges. */
 static void
@@ -754,7 +794,7 @@ dump_type_info (type_or_ent *tore, void *env) {
        }
       }
       /* attached subgraphs */
-      if (const_entities && (get_entity_variability(ent) != uninitialized)) {
+      if (const_entities && (get_entity_variability(ent) != variability_uninitialized)) {
        if (is_atomic_entity(ent)) {
          value = get_atomic_ent_value(ent);
          if (value) {
@@ -1398,7 +1438,8 @@ static void collect_blocks_floats_cg(ir_node * node, pmap * map) {
       ir_node ** arr;
       arr = entry->value;
       assert(arr);
-      ARR_APP1(ir_node *, arr , node);
+      ARR_APP1(ir_node *, arr, node);
+      entry->value = (void *)arr;
     } else {
       ir_node ** arr = NEW_ARR_F(ir_node *, 1);
       assert(arr);
@@ -1450,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];
@@ -1584,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;
+}