Assert that [gs]et_{,r_}cur_block() are only called in phase_building.
[libfirm] / ir / kaps / html_dumper.c
index 93d0fd1..a9dd2f1 100644 (file)
@@ -22,7 +22,6 @@
  * @brief   HTML dumper for PBQP.
  * @date    03.10.2008
  * @author  Sebastian Buchwald
- * @version $Id$
  */
 #include "config.h"
 
@@ -53,10 +52,9 @@ static const char *cost2a(num const cost)
 static void dump_vector(FILE *f, vector_t *vec)
 {
        unsigned index;
-       assert(vec);
+       unsigned len = vec->len;
 
        fprintf(f, "<span class=\"vector\">( ");
-       unsigned len = vec->len;
        assert(len > 0);
        for (index = 0; index < len; ++index) {
 #if KAPS_ENABLE_VECTOR_NAMES
@@ -72,11 +70,10 @@ static void dump_vector(FILE *f, vector_t *vec)
 static void dump_matrix(FILE *f, pbqp_matrix_t *mat)
 {
        unsigned row, col;
-       assert(mat);
        num *p = mat->entries;
 
-       assert(mat->cols> 0);
-       assert(mat->rows> 0);
+       assert(mat->cols > 0);
+       assert(mat->rows > 0);
        fprintf(f, "\t\\begin{pmatrix}\n");
        for (row = 0; row < mat->rows; ++row) {
                fprintf(f, "\t %s", cost2a(*p++));
@@ -89,10 +86,10 @@ static void dump_matrix(FILE *f, pbqp_matrix_t *mat)
        fprintf(f, "\t\\end{pmatrix}\n");
 }
 
-void dump_edge(FILE *file, pbqp_edge_t *edge)
+void pbqp_dump_edge(FILE *file, pbqp_edge_t *edge)
 {
        fputs("<tex>\n", file);
-       fprintf(file, "\t\\overline\n{C}_{%d,%d}=\n",
+       fprintf(file, "\t\\overline\n{C}_{%u,%u}=\n",
                        edge->src->index, edge->tgt->index);
        dump_matrix(file, edge->costs);
        fputs("</tex><br>", file);
@@ -102,35 +99,31 @@ static void dump_edge_costs(pbqp_t *pbqp)
 {
        unsigned src_index;
 
-       assert(pbqp);
-       assert(pbqp->dump_file);
-
        fputs("<p>", pbqp->dump_file);
        for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) {
                pbqp_node_t *src_node = get_node(pbqp, src_index);
+               size_t edge_index;
+               size_t len;
 
                if (!src_node)
                        continue;
 
-               unsigned edge_index;
-               unsigned len = ARR_LEN(src_node->edges);
+               len = ARR_LEN(src_node->edges);
                for (edge_index = 0; edge_index < len; ++edge_index) {
                        pbqp_edge_t *edge      = src_node->edges[edge_index];
                        unsigned     tgt_index = edge->tgt->index;
                        if (src_index < tgt_index) {
-                               dump_edge(pbqp->dump_file, edge);
+                               pbqp_dump_edge(pbqp->dump_file, edge);
                        }
                }
        }
        fputs("</p>", pbqp->dump_file);
 }
 
-void dump_node(FILE *file, pbqp_node_t *node)
+void pbqp_dump_node(FILE *file, pbqp_node_t *node)
 {
-       assert(file);
-
        if (node) {
-               fprintf(file, "\tc<sub>%d</sub> = ", node->index);
+               fprintf(file, "\tc<sub>%u</sub> = ", node->index);
                dump_vector(file, node->costs);
                fputs("<br>\n", file);
        }
@@ -140,21 +133,16 @@ static void dump_node_costs(pbqp_t *pbqp)
 {
        unsigned index;
 
-       assert(pbqp);
-       assert(pbqp->dump_file);
-
        /* dump node costs */
        fputs("<p>", pbqp->dump_file);
        for (index = 0; index < pbqp->num_nodes; ++index) {
-               dump_node(pbqp->dump_file, get_node(pbqp, index));
+               pbqp_dump_node(pbqp->dump_file, get_node(pbqp, index));
        }
        fputs("</p>", pbqp->dump_file);
 }
 
-void dump_section(FILE *f, int level, const char *txt)
+void pbqp_dump_section(FILE *f, int level, const char *txt)
 {
-       assert(f);
-
        fprintf(f, "<h%d>%s</h%d>\n", level, txt, level);
 }
 
@@ -162,19 +150,18 @@ void pbqp_dump_graph(pbqp_t *pbqp)
 {
        unsigned src_index;
 
-       assert(pbqp);
-       assert(pbqp->dump_file);
-
        fputs("<p>\n<graph>\n\tgraph input {\n", pbqp->dump_file);
        for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) {
                pbqp_node_t *node = get_node(pbqp, src_index);
                if (node && !node_is_reduced(node)) {
-                       fprintf(pbqp->dump_file, "\t n%d;\n", src_index);
+                       fprintf(pbqp->dump_file, "\t n%u;\n", src_index);
                }
        }
 
        for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) {
                pbqp_node_t *node = get_node(pbqp, src_index);
+               unsigned len;
+               unsigned edge_index;
 
                if (!node)
                        continue;
@@ -182,8 +169,7 @@ void pbqp_dump_graph(pbqp_t *pbqp)
                if (node_is_reduced(node))
                        continue;
 
-               unsigned len = ARR_LEN(node->edges);
-               unsigned edge_index;
+               len = ARR_LEN(node->edges);
                for (edge_index = 0; edge_index < len; ++edge_index) {
                        pbqp_node_t *tgt_node  = node->edges[edge_index]->tgt;
                        unsigned     tgt_index = tgt_node->index;
@@ -192,7 +178,7 @@ void pbqp_dump_graph(pbqp_t *pbqp)
                                continue;
 
                        if (src_index < tgt_index) {
-                               fprintf(pbqp->dump_file, "\t n%d -- n%d;\n", src_index,
+                               fprintf(pbqp->dump_file, "\t n%u -- n%u;\n", src_index,
                                                tgt_index);
                        }
                }
@@ -202,24 +188,18 @@ void pbqp_dump_graph(pbqp_t *pbqp)
 
 void pbqp_dump_input(pbqp_t *pbqp)
 {
-       assert(pbqp);
-       assert(pbqp->dump_file);
-
-       dump_section(pbqp->dump_file, 1, "1. PBQP Problem");
-       dump_section(pbqp->dump_file, 2, "1.1 Topology");
+       pbqp_dump_section(pbqp->dump_file, 1, "1. PBQP Problem");
+       pbqp_dump_section(pbqp->dump_file, 2, "1.1 Topology");
        pbqp_dump_graph(pbqp);
-       dump_section(pbqp->dump_file, 2, "1.2 Cost Vectors");
+       pbqp_dump_section(pbqp->dump_file, 2, "1.2 Cost Vectors");
        dump_node_costs(pbqp);
-       dump_section(pbqp->dump_file, 2, "1.3 Cost Matrices");
+       pbqp_dump_section(pbqp->dump_file, 2, "1.3 Cost Matrices");
        dump_edge_costs(pbqp);
 }
 
-void dump_simplifyedge(pbqp_t *pbqp, pbqp_edge_t *edge)
+void pbqp_dump_simplifyedge(pbqp_t *pbqp, pbqp_edge_t *edge)
 {
-       assert(pbqp);
-       assert(pbqp->dump_file);
-
-       dump_node(pbqp->dump_file, edge->src);
-       dump_edge(pbqp->dump_file, edge);
-       dump_node(pbqp->dump_file, edge->tgt);
+       pbqp_dump_node(pbqp->dump_file, edge->src);
+       pbqp_dump_edge(pbqp->dump_file, edge);
+       pbqp_dump_node(pbqp->dump_file, edge->tgt);
 }