start label number with 1, reserve the 0
[libfirm] / ir / ir / irdump.c
index 9d36c01..ca4076a 100644 (file)
@@ -1,13 +1,27 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ir/irdump.c
- * Purpose:     Write vcg representation of firm to file.
- * Author:      Martin Trapp, Christian Schaefer
- * Modified by: Goetz Lindenmaier, Hubert Schmidt
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2006 Universit�t Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 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   Write vcg representation of firm to file.
+ * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Hubert Schmidt
+ * @version $Id$
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -34,9 +48,7 @@
 #include "irdump_t.h"
 
 #include "irgwalk.h"
-#include "typewalk.h"
 #include "tv_t.h"
-#include "type_or_entity.h"
 #include "irouts.h"
 #include "irdom.h"
 #include "irloop_t.h"
@@ -480,6 +492,7 @@ static void ird_set_irg_link(ir_graph *irg, void *x) {
  * Walker, clears the private link field.
  */
 static void clear_link(ir_node * node, void * env) {
+       (void) env;
        ird_set_irn_link(node, NULL);
 }
 
@@ -523,20 +536,10 @@ static int node_floats(ir_node *n) {
  *  Walker that visits the anchors
  */
 static void ird_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
-       irg_walk_graph(irg, pre, post, env);
-
        if (dump_anchors) {
-               int i;
-
-               for (i = anchor_max - 1; i >= 0; --i) {
-                       ir_node *n = irg->anchors[i];
-
-                       if (n) {
-                               /* reset the visit flag: will be increase in the walker */
-                               set_irg_visited(irg, get_irg_visited(irg) - 1);
-                               irg_walk(n, pre, post, env);
-                       }
-               }
+               irg_walk_anchors(irg, pre, post, env);
+       } else {
+               irg_walk_graph(irg, pre, post, env);
        }
 }
 
@@ -544,6 +547,7 @@ static void ird_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *pos
  * Walker, allocates an array for all blocks and puts it's nodes non-floating nodes into this array.
  */
 static void collect_node(ir_node * node, void *env) {
+       (void) env;
        if (is_Block(node)
            || node_floats(node)
            || get_irn_op(node) == op_Bad
@@ -580,12 +584,13 @@ static void collect_node(ir_node * node, void *env) {
 static ir_node **construct_block_lists(ir_graph *irg) {
        int      i;
        int      rem_view  = get_interprocedural_view();
-       int      walk_flag = inside_irg_walk(irg);
+       int      walk_flag = using_visited(irg);
        ir_graph *rem      = current_ir_graph;
 
        current_ir_graph = irg;
 
-       clear_inside_irg_walk(current_ir_graph);
+       if(walk_flag)
+               clear_using_visited(current_ir_graph);
 
        for (i = get_irp_n_irgs() - 1; i >= 0; --i)
                ird_set_irg_link(get_irp_irg(i), NULL);
@@ -602,8 +607,8 @@ static ir_node **construct_block_lists(ir_graph *irg) {
 
        set_interprocedural_view(rem_view);
 
-       if (walk_flag)
-               set_inside_irg_walk(current_ir_graph);
+       if(walk_flag)
+               set_using_visited(current_ir_graph);
 
        current_ir_graph = rem;
        return ird_get_irg_link(irg);
@@ -674,7 +679,7 @@ int dump_node_opcode(FILE *F, ir_node *n)
                int res;
                char buf[1024];
                res = tarval_snprintf(buf, sizeof(buf), get_Const_tarval(n));
-               assert(res < sizeof(buf) && "buffer to small for tarval_snprintf");
+               assert(res < (int) sizeof(buf) && "buffer to small for tarval_snprintf");
                fprintf(F, buf);
        } break;
 
@@ -857,10 +862,11 @@ static const pns_lookup_t cond_lut[] = {
 static const pns_lookup_t call_lut[] = {
 #define X(a)    { pn_Call_##a, #a }
        X(M_regular),
-       X(T_result),
-       X(P_value_res_base),
+       X(X_regular),
        X(X_except),
-       X(M_except)
+       X(T_result),
+       X(M_except),
+       X(P_value_res_base)
 #undef X
 };
 
@@ -868,6 +874,7 @@ static const pns_lookup_t call_lut[] = {
 static const pns_lookup_t quot_lut[] = {
 #define X(a)    { pn_Quot_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res)
 #undef X
@@ -877,6 +884,7 @@ static const pns_lookup_t quot_lut[] = {
 static const pns_lookup_t divmod_lut[] = {
 #define X(a)    { pn_DivMod_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res_div),
        X(res_mod)
@@ -887,6 +895,7 @@ static const pns_lookup_t divmod_lut[] = {
 static const pns_lookup_t div_lut[] = {
 #define X(a)    { pn_Div_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res)
 #undef X
@@ -896,6 +905,7 @@ static const pns_lookup_t div_lut[] = {
 static const pns_lookup_t mod_lut[] = {
 #define X(a)    { pn_Mod_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res)
 #undef X
@@ -905,6 +915,7 @@ static const pns_lookup_t mod_lut[] = {
 static const pns_lookup_t load_lut[] = {
 #define X(a)    { pn_Load_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res)
 #undef X
@@ -914,6 +925,7 @@ static const pns_lookup_t load_lut[] = {
 static const pns_lookup_t store_lut[] = {
 #define X(a)    { pn_Store_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except)
 #undef X
 };
@@ -922,6 +934,7 @@ static const pns_lookup_t store_lut[] = {
 static const pns_lookup_t alloc_lut[] = {
 #define X(a)    { pn_Alloc_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res)
 #undef X
@@ -931,6 +944,7 @@ static const pns_lookup_t alloc_lut[] = {
 static const pns_lookup_t copyb_lut[] = {
 #define X(a)    { pn_CopyB_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(M_except)
 #undef X
@@ -940,6 +954,7 @@ static const pns_lookup_t copyb_lut[] = {
 static const pns_lookup_t instof_lut[] = {
 #define X(a)    { pn_InstOf_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res),
        X(M_except),
@@ -958,6 +973,7 @@ static const pns_lookup_t raise_lut[] = {
 static const pns_lookup_t bound_lut[] = {
 #define X(a)    { pn_Bound_##a, #a }
        X(M),
+       X(X_regular),
        X(X_except),
        X(res),
 #undef X
@@ -1156,6 +1172,9 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad)
        case iro_Tuple:
                print_vcg_color(F, ird_color_yellow);
                break;
+       case iro_ASM:
+               print_vcg_color(F, ird_color_darkyellow);
+               break;
        default:
                PRINT_DEFAULT_NODE_ATTR;
        }
@@ -1399,8 +1418,8 @@ print_mem_edge_vcgattr(FILE *F, ir_node *from, int to) {
                fprintf(F, INTER_MEM_EDGE_ATTR);
 }
 
-static void
-print_edge_vcgattr(FILE *F, ir_node *from, int to) {
+/** Print the vcg attributes for the edge from node from to it's to's input */
+static void print_edge_vcgattr(FILE *F, ir_node *from, int to) {
        assert(from);
 
        if (dump_edge_vcgattr_hook)
@@ -1418,9 +1437,9 @@ print_edge_vcgattr(FILE *F, ir_node *from, int to) {
        case iro_End:
                if (to >= 0) {
                        if (get_irn_mode(get_End_keepalive(from, to)) == mode_BB)
-                               fprintf(F, CF_EDGE_ATTR);
-                       if (get_irn_mode(get_End_keepalive(from, to)) == mode_X)
-                               fprintf(F, INTER_MEM_EDGE_ATTR);
+                               fprintf(F, KEEP_ALIVE_CF_EDGE_ATTR);
+                       else
+                               fprintf(F, KEEP_ALIVE_DF_EDGE_ATTR);
                }
                break;
        default:
@@ -1441,9 +1460,8 @@ print_edge_vcgattr(FILE *F, ir_node *from, int to) {
        }
 }
 
-/* dump edges to our inputs */
-static void
-dump_ir_data_edges(FILE *F, ir_node *n)  {
+/** dump edges to our inputs */
+static void dump_ir_data_edges(FILE *F, ir_node *n)  {
        int i;
        unsigned long visited = get_irn_visited(n);
 
@@ -2171,6 +2189,7 @@ void dump_vcg_header(FILE *F, const char *name, const char *orientation) {
                "classname 17: \"interblock Memory\"\n"
                "classname 18: \"Exception Control Flow for Interval Analysis\"\n"
                "classname 19: \"Postdominators\"\n"
+               "classname 20: \"Keep Alive\"\n"
                "infoname 1: \"Attribute\"\n"
                "infoname 2: \"Verification errors\"\n"
                "infoname 3: \"Debug info\"\n",
@@ -3002,9 +3021,9 @@ void dump_callgraph_loop_tree(const char *suffix) {
 }
 
 
-/*-----------------------------------------------------------------------------*/
-/* Dumps the firm nodes in the loop tree to a graph along with the loop nodes. */
-/*-----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/* Dumps the firm nodes in the loop tree to a graph along with the loop nodes.*/
+/*----------------------------------------------------------------------------*/
 
 void collect_nodeloop(FILE *F, ir_loop *loop, eset *loopnodes) {
        int i, son_number = 0, node_number = 0;