Speed up RN by explicitely reducing the incident edges.
[libfirm] / html_dumper.c
index 43901ba..60be3bd 100644 (file)
@@ -1,12 +1,39 @@
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief   HTML dumper for PBQP.
+ * @date    03.10.2008
+ * @author  Sebastian Buchwald
+ * @version $Id$
+ */
+#include "config.h"
+
 #include "adt/array.h"
 #include "assert.h"
 
 #include "pbqp_edge_t.h"
 #include "pbqp_node_t.h"
-#include "heuristical.h"
+#include "optimal.h"
 #include "html_dumper.h"
 #include "kaps.h"
-#include "pbqp_t.h"
 
 /* Caution: Due to static buffer use only once per statement */
 static const char *cost2a(num const cost)
@@ -14,7 +41,11 @@ static const char *cost2a(num const cost)
        static char buf[10];
 
        if (cost == INF_COSTS) return "inf";
-       sprintf(buf, "%6d", cost);
+#if KAPS_USE_UNSIGNED
+       sprintf(buf, "%u", cost);
+#else
+       sprintf(buf, "%10lld", cost);
+#endif
        return buf;
 }
 
@@ -28,7 +59,7 @@ static void dump_vector(FILE *f, vector *vec)
        unsigned len = vec->len;
        assert(len > 0);
        for (index = 0; index < len; ++index) {
-#if EXT_GRS_DEBUG
+#if KAPS_ENABLE_VECTOR_NAMES
                fprintf(f, "<span title=\"%s\">%s</span> ",
                                vec->entries[index].name, cost2a(vec->entries[index].data));
 #else
@@ -58,13 +89,13 @@ static void dump_matrix(FILE *f, pbqp_matrix *mat)
        fprintf(f, "\t\\end{pmatrix}\n");
 }
 
-void dump_edge(pbqp *pbqp, pbqp_edge *edge)
+void dump_edge(FILE *file, pbqp_edge *edge)
 {
-       fputs("<tex>\n", pbqp->dump_file);
-       fprintf(pbqp->dump_file, "\t\\overline\n{C}_{%d,%d}=\n",
+       fputs("<tex>\n", file);
+       fprintf(file, "\t\\overline\n{C}_{%d,%d}=\n",
                        edge->src->index, edge->tgt->index);
-       dump_matrix(pbqp->dump_file, edge->costs);
-       fputs("</tex><br>", pbqp->dump_file);
+       dump_matrix(file, edge->costs);
+       fputs("</tex><br>", file);
 }
 
 static void dump_edge_costs(pbqp *pbqp)
@@ -87,22 +118,21 @@ static void dump_edge_costs(pbqp *pbqp)
                        pbqp_edge *edge = src_node->edges[edge_index];
                        unsigned tgt_index = edge->tgt->index;
                        if (src_index < tgt_index) {
-                               dump_edge(pbqp, edge);
+                               dump_edge(pbqp->dump_file, edge);
                        }
                }
        }
        fputs("</p>", pbqp->dump_file);
 }
 
-void dump_node(pbqp *pbqp, pbqp_node *node)
+void dump_node(FILE *file, pbqp_node *node)
 {
-       assert(pbqp);
-       assert(pbqp->dump_file);
+       assert(file);
 
        if (node) {
-               fprintf(pbqp->dump_file, "\tc<sub>%d</sub> = ", node->index);
-               dump_vector(pbqp->dump_file, node->costs);
-               fputs("<br>\n", pbqp->dump_file);
+               fprintf(file, "\tc<sub>%d</sub> = ", node->index);
+               dump_vector(file, node->costs);
+               fputs("<br>\n", file);
        }
 }
 
@@ -116,7 +146,7 @@ static void dump_node_costs(pbqp *pbqp)
        /* dump node costs */
        fputs("<p>", pbqp->dump_file);
        for (index = 0; index < pbqp->num_nodes; ++index) {
-               dump_node(pbqp, get_node(pbqp, index));
+               dump_node(pbqp->dump_file, get_node(pbqp, index));
        }
        fputs("</p>", pbqp->dump_file);
 }
@@ -189,7 +219,7 @@ void dump_simplifyedge(pbqp *pbqp, pbqp_edge *edge)
        assert(pbqp);
        assert(pbqp->dump_file);
 
-       dump_node(pbqp, edge->src);
-       dump_edge(pbqp, edge);
-       dump_node(pbqp, edge->tgt);
+       dump_node(pbqp->dump_file, edge->src);
+       dump_edge(pbqp->dump_file, edge);
+       dump_node(pbqp->dump_file, edge->tgt);
 }