X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=html_dumper.c;h=60be3bd7eb0eda49ea0d70c0e48f82d94fe4e687;hb=007d7aaf04ac690f0e6312c7d0f93240accd94c5;hp=8f834a0b3f5517084bab177ef757ab59a14aec19;hpb=777bbb1740045bdbafe1a0e34ff8cc25d148f980;p=libfirm
diff --git a/html_dumper.c b/html_dumper.c
index 8f834a0b3..60be3bd7e 100644
--- a/html_dumper.c
+++ b/html_dumper.c
@@ -1,11 +1,53 @@
+/*
+ * 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 "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)
+{
+ static char buf[10];
+
+ if (cost == INF_COSTS) return "inf";
+#if KAPS_USE_UNSIGNED
+ sprintf(buf, "%u", cost);
+#else
+ sprintf(buf, "%10lld", cost);
+#endif
+ return buf;
+}
/* print vector */
static void dump_vector(FILE *f, vector *vec)
@@ -17,20 +59,11 @@ 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 (vec->entries[index].data == INF_COSTS) {
- fprintf(f, "inf",
- vec->entries[index].name);
- } else {
- fprintf(f, "%6d",
- vec->entries[index].name, vec->entries[index].data);
- }
+#if KAPS_ENABLE_VECTOR_NAMES
+ fprintf(f, "%s ",
+ vec->entries[index].name, cost2a(vec->entries[index].data));
#else
- if (vec->entries[index].data == INF_COSTS) {
- fputs("inf", f);
- } else {
- fprintf(f, "%6d", vec->entries[index].data);
- }
+ fprintf(f, "%s ", cost2a(vec->entries[index].data));
#endif
}
fprintf(f, " )\n");
@@ -46,33 +79,23 @@ static void dump_matrix(FILE *f, pbqp_matrix *mat)
assert(mat->rows> 0);
fprintf(f, "\t\\begin{pmatrix}\n");
for (row = 0; row < mat->rows; ++row) {
- if (*p == INF_COSTS) {
- fputs("\t inf", f);
- p++;
- } else {
- fprintf(f, "\t %6d", *p++);
- }
+ fprintf(f, "\t %s", cost2a(*p++));
for (col = 1; col < mat->cols; ++col) {
- if (*p == INF_COSTS) {
- fputs("& inf", f);
- p++;
- } else {
- fprintf(f, "& %6d", *p++);
- }
+ fprintf(f, "& %s", cost2a(*p++));
}
fprintf(f, "\\\\\n");
}
fprintf(f, "\t\\end{pmatrix}\n");
}
-void dump_edge(pbqp *pbqp, pbqp_edge *edge)
+void dump_edge(FILE *file, pbqp_edge *edge)
{
- fputs("
", pbqp->dump_file);
+ fputs("
", file);
}
static void dump_edge_costs(pbqp *pbqp)
@@ -93,25 +116,23 @@ static void dump_edge_costs(pbqp *pbqp)
unsigned len = ARR_LEN(src_node->edges);
for (edge_index = 0; edge_index < len; ++edge_index) {
pbqp_edge *edge = src_node->edges[edge_index];
- unsigned tgt_index = edge->tgt;
+ unsigned tgt_index = edge->tgt->index;
if (src_index < tgt_index) {
- dump_edge(pbqp, edge);
+ dump_edge(pbqp->dump_file, edge);
}
}
}
fputs("
", pbqp->dump_file); for (index = 0; index < pbqp->num_nodes; ++index) { - dump_node(pbqp, index); + dump_node(pbqp->dump_file, get_node(pbqp, index)); } fputs("
", pbqp->dump_file); } @@ -147,7 +168,7 @@ void pbqp_dump_graph(pbqp *pbqp) fputs("\n