Correct a subtle bug in the ia32 backend: Sub(x, x) triggered that the Neg+Add trick...
[libfirm] / ir / ir / irdumptxt.c
index e362352..0c1b9ea 100644 (file)
@@ -37,6 +37,7 @@
 #include "trouts.h"
 #include "irgwalk.h"
 #include "tv_t.h"
+#include "vrp.h"
 #include "irprintf.h"
 #include "error.h"
 
@@ -55,7 +56,8 @@
  * @param suffix2   The second suffix.
  * @param suffix3   The third suffix.
  */
-static FILE *text_open(const char *basename, const char * suffix1, const char *suffix2, const char *suffix3) {
+static FILE *text_open(const char *basename, const char * suffix1, const char *suffix2, const char *suffix3)
+{
        FILE *F;
        int len = strlen(basename), i, j;
        char *fname;  /* filename to put the vcg information in */
@@ -94,10 +96,12 @@ static FILE *text_open(const char *basename, const char * suffix1, const char *s
 }
 
 /* Write the irnode and all its attributes to the file passed. */
-int dump_irnode_to_file(FILE *F, ir_node *n) {
-       int i, bad = 0;
-       char comma;
+int dump_irnode_to_file(FILE *F, ir_node *n)
+{
+       int      i, bad = 0;
+       char     comma;
        ir_graph *irg;
+       vrp_attr *vrp_info;
 
        dump_node_opcode(F, n);
        fprintf(F, " %ld\n", get_irn_node_nr(n));
@@ -273,7 +277,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                if (get_Call_tail_call(n))
                        fprintf(F, "  tail call\n");
                ir_fprintf(F, "  calling method of type %+F\n", tp);
-               if(get_unknown_type() != tp) {
+               if (get_unknown_type() != tp) {
                        for (i = 0; i < get_method_n_params(tp); ++i)
                                ir_fprintf(F, "    param %d type: %+F\n", i, get_method_param_type(tp, i));
                        for (i = 0; i < get_method_n_ress(tp); ++i)
@@ -314,11 +318,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                ir_fprintf(F, "  Const of type %+F\n", get_Const_type(n));
        } break;
        case iro_SymConst: {
-               switch(get_SymConst_kind(n)) {
-               case symconst_addr_name:
-                       fprintf(F, "  kind: addr_name\n");
-                       fprintf(F, "  name: %s\n", get_id_str(get_SymConst_name(n)));
-                       break;
+               switch (get_SymConst_kind(n)) {
                case symconst_addr_ent:
                        fprintf(F, "  kind:   addr_ent\n");
                        fprintf(F, "  entity: ");
@@ -394,7 +394,14 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                        fprintf(F, "\n  volatile");
                fprintf(F, "\n");
        } break;
-       default: ;
+
+       default:
+               break;
+       }
+
+       vrp_info = vrp_get_info(n);
+       if (vrp_info) {
+               dump_vrp_info(F, n);
        }
 
        if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent  ||
@@ -407,27 +414,32 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
 
 
 
-void dump_irnode(ir_node *n) {
+void dump_irnode(ir_node *n)
+{
        dump_irnode_to_file(stdout, n);
 }
 
 
-void dump_graph_to_file(FILE *F, ir_graph *irg) {
+void dump_graph_to_file(FILE *F, ir_graph *irg)
+{
        fprintf(F, "graph %s\n", get_irg_dump_name(irg));
 }
 
-void dump_graph(ir_graph *g) {
+void dump_graph(ir_graph *g)
+{
        dump_graph_to_file(stdout, g);
 }
 
-static void dump_node_to_graph_file(ir_node *n, void *env) {
+static void dump_node_to_graph_file(ir_node *n, void *env)
+{
        FILE *F = (FILE *)env;
 
        dump_irnode_to_file(F, n);
        fprintf(F, "\n");
 }
 
-void dump_graph_as_text(ir_graph *irg, const char *suffix) {
+void dump_graph_as_text(ir_graph *irg, const char *suffix)
+{
        const char *basename = get_irg_dump_name(irg);
        FILE *F;
 
@@ -441,7 +453,8 @@ void dump_graph_as_text(ir_graph *irg, const char *suffix) {
 }
 
 #ifdef EXTENDED_ACCESS_STATS
-static int addr_is_alloc(ir_node *acc) {
+static int addr_is_alloc(ir_node *acc)
+{
        ir_node *addr = NULL;
        ir_opcode addr_op;
        if (is_memop(acc)) {
@@ -497,7 +510,8 @@ static int addr_is_alloc(ir_node *acc) {
 static void dump_node_list(FILE *F, firm_kind *k, char *prefix,
                            int (*get_entity_n_nodes)(firm_kind *ent),
                            ir_node *(*get_entity_node)(firm_kind *ent, int pos),
-                           char *name) {
+                           char *name)
+{
        int i, n_nodes = get_entity_n_nodes(k);
        char *comma = "";
 
@@ -527,7 +541,8 @@ static void dump_node_list(FILE *F, firm_kind *k, char *prefix,
 static void dump_type_list(FILE *F, ir_type *tp, char *prefix,
                            int (*get_n_types)(const ir_type *tp),
                            ir_type *(*get_type)(const ir_type *tp, int pos),
-                           const char *name) {
+                           const char *name)
+{
        int i, n_nodes = get_n_types(tp);
        char *comma = "";
 
@@ -549,7 +564,8 @@ static int need_nl = 1;
  * Dump initializers.
  */
 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
-                                                                                const ir_initializer_t *initializer, ir_type *type) {
+                                                                                const ir_initializer_t *initializer, ir_type *type)
+{
        tarval  *tv;
        ir_node *value;
 
@@ -621,10 +637,6 @@ static void dump_entity_linkage(FILE *F, const ir_entity *entity)
                fprintf(F, " constant");
        if (linkage & IR_LINKAGE_WEAK)
                fprintf(F, " weak");
-       if (linkage & IR_LINKAGE_LOCAL)
-               fprintf(F, " local");
-       if (linkage & IR_LINKAGE_EXTERN)
-               fprintf(F, " extern");
        if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
                fprintf(F, " garbage_collect");
        if (linkage & IR_LINKAGE_MERGE)
@@ -633,7 +645,8 @@ static void dump_entity_linkage(FILE *F, const ir_entity *entity)
                fprintf(F, " hidden_user");
 }
 
-void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned verbosity) {
+void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned verbosity)
+{
        int i, j;
        ir_type *owner, *type;
 
@@ -715,7 +728,6 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
                                if (mask & mtp_property_nothrow)       fputs("nothrow_function, ", F);
                                if (mask & mtp_property_naked)         fputs("naked_function, ", F);
                                if (mask & mtp_property_malloc)        fputs("malloc_function, ", F);
-                               if (mask & mtp_property_weak)          fputs("weak_function, ", F);
                                if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
                                if (mask & mtp_property_intrinsic)     fputs("intrinsic_function, ", F);
                                if (mask & mtp_property_runtime)       fputs("runtime_function, ", F);
@@ -929,16 +941,19 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
        }
 }
 
-void    dump_entity_to_file (FILE *F, ir_entity *ent, unsigned verbosity) {
+void    dump_entity_to_file (FILE *F, ir_entity *ent, unsigned verbosity)
+{
        dump_entity_to_file_prefix (F, ent, "", verbosity);
        fprintf(F, "\n");
 }
 
-void dump_entity(ir_entity *ent) {
+void dump_entity(ir_entity *ent)
+{
   dump_entity_to_file(stdout, ent, dump_verbosity_max);
 }
 
-void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
+void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity)
+{
        int i;
 
        if ((is_Class_type(tp))       && (verbosity & dump_verbosity_noClassTypes)) return;
@@ -1182,11 +1197,13 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
        fprintf(F, "\n\n");
 }
 
-void dump_type(ir_type *tp) {
+void dump_type(ir_type *tp)
+{
        dump_type_to_file (stdout, tp, dump_verbosity_max);
 }
 
-void dump_types_as_text(unsigned verbosity, const char *suffix) {
+void dump_types_as_text(unsigned verbosity, const char *suffix)
+{
        const char *basename;
        FILE *F;
        int i, n_types = get_irp_n_types();
@@ -1205,7 +1222,8 @@ void dump_types_as_text(unsigned verbosity, const char *suffix) {
        fclose(F);
 }
 
-void dump_globals_as_text(unsigned verbosity, const char *suffix) {
+void dump_globals_as_text(unsigned verbosity, const char *suffix)
+{
        const char *basename;
        FILE *F;
        ir_type *g = get_glob_type();