+/** For dumping class hierarchies.
+ * Dumps a class type node and a superclass edge.
+ * If env != null dumps entities of classes and overwrites edges.
+ */
+static void
+dump_class_hierarchy_node (type_or_ent *tore, void *env) {
+ int i = 0; /* to shutup gcc */
+
+ /* dump this type or entity */
+ switch (get_kind(tore)) {
+ case k_entity: {
+ entity *ent = (entity *)tore;
+ if (get_entity_owner(ent) == get_glob_type()) break;
+ if ((env) && is_class_type(get_entity_owner(ent))) {
+ /* The node */
+ dump_entity_node(ent);
+ /* The edges */
+ print_type_ent_edge(F,get_entity_owner(ent),ent,TYPE_MEMBER_EDGE_ATTR);
+ for(i = 0; i < get_entity_n_overwrites(ent); i++)
+ {
+ print_ent_ent_edge(F,get_entity_overwrites(ent, i),ent, ENT_OVERWRITES_EDGE_ATTR);
+ }
+ }
+ } break; /* case k_entity */
+ case k_type:
+ {
+ type *tp = (type *)tore;
+ if (tp == get_glob_type()) break;
+ switch (get_type_tpop_code(tp)) {
+ case tpo_class: {
+ print_type_node(tp);
+ /* and now the edges */
+ for (i=0; i < get_class_n_supertypes(tp); i++)
+ {
+ print_type_type_edge(F,tp,get_class_supertype(tp, i),TYPE_SUPER_EDGE_ATTR);
+ }
+ } break;
+ default: break;
+ } /* switch type */
+ }
+ break; /* case k_type */
+ default:
+ {
+ printf(" *** irdump, dump_class_hierarchy_node(l.%i), faulty type.\n", __LINE__);
+ } break;
+ } /* switch kind_or_entity */
+}
+
+/*******************************************************************/
+/* dump analysis information that is expressed in graph terms. */
+/*******************************************************************/
+
+/* dump out edges */
+static void
+dump_out_edge (ir_node *n, void* env) {
+ int i;
+ for (i = 0; i < get_irn_n_outs(n); i++) {
+ assert(get_irn_out(n, i));
+ fprintf (F, "edge: {sourcename: \"");
+ PRINT_NODEID(n);
+ fprintf (F, "\" targetname: \"");
+ PRINT_NODEID(get_irn_out(n, i));
+ fprintf (F, "\" color: red linestyle: dashed");
+ fprintf (F, "}\n");
+ }
+}
+
+static INLINE void
+dump_loop_label(ir_loop *loop) {
+ fprintf (F, "loop %d, %d sons, %d nodes",
+ get_loop_depth(loop), get_loop_n_sons(loop), get_loop_n_nodes(loop));
+}
+
+static INLINE void dump_loop_info(ir_loop *loop) {
+ fprintf (F, " info1: \"");
+ fprintf (F, " loop nr: %d", get_loop_loop_nr(loop));
+#if DEBUG_libfirm /* GL @@@ debug analyses */
+ fprintf (F, "\n The loop was analyzed %d times.", (int)get_loop_link(loop));
+#endif
+ fprintf (F, "\"");
+}
+
+static INLINE void
+dump_loop_node(ir_loop *loop) {
+ fprintf (F, "node: {title: \"");
+ PRINT_LOOPID(loop);
+ fprintf (F, "\" label: \"");
+ dump_loop_label(loop);
+ fprintf (F, "\" ");
+ dump_loop_info(loop);
+ fprintf (F, "}\n");
+
+}
+
+static INLINE void
+dump_loop_node_edge (ir_loop *loop, int i) {
+ assert(loop);
+ fprintf (F, "edge: {sourcename: \"");
+ PRINT_LOOPID(loop);
+ fprintf (F, "\" targetname: \"");
+ PRINT_NODEID(get_loop_node(loop, i));
+ fprintf (F, "\" color: green");
+ fprintf (F, "}\n");
+}
+
+static INLINE void
+dump_loop_son_edge (ir_loop *loop, int i) {
+ assert(loop);
+ fprintf (F, "edge: {sourcename: \"");
+ PRINT_LOOPID(loop);
+ fprintf (F, "\" targetname: \"");
+ PRINT_LOOPID(get_loop_son(loop, i));
+ fprintf (F, "\" color: darkgreen label: \"%d\"}\n",
+ get_loop_element_pos(loop, get_loop_son(loop, i)));
+}
+
+static
+void dump_loops (ir_loop *loop) {
+ int i;
+ /* dump this loop node */
+ dump_loop_node(loop);
+
+ /* 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;
+}
+
+