renamed node type Rot to Rotl to make clear that this is a LEFT rotation
[libfirm] / ir / ir / irdumptxt.c
index 247bc41..c543596 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #include <stdarg.h>
 
 #include "irdump_t.h"
+#include "irgraph_t.h"
 
 #include "firm_common_t.h"
 
-#include "irgraph_t.h"
 #include "irprog_t.h"
 #include "entity_t.h"
 #include "trouts.h"
 #include "irgwalk.h"
 #include "tv_t.h"
+#include "irprintf.h"
+#include "error.h"
 
 #include "irdom.h"
 #include "field_temperature.h"
@@ -157,15 +159,14 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
 
        fprintf(F, "  Private Attributes:\n");
 
-       if (get_irn_opcode(n) == iro_Proj)
+       if (is_Proj(n))
                fprintf(F, "  proj nr: %ld\n", get_Proj_proj(n));
 
 #ifdef INTERPROCEDURAL_VIEW
-       if ((get_irp_ip_view_state() != ip_view_no)
-               && (get_irn_opcode(n) == iro_Filter || get_irn_opcode(n) == iro_Block)) {
+       if ((get_irp_ip_view_state() != ip_view_no) && (is_Filter(n) || is_Block(n))) {
                fprintf(F, "  inter arity: %d\n", get_irn_inter_arity(n));
                fprintf(F, "  inter pred nodes: \n");
-               for ( i = 0; i < get_irn_inter_arity(n); ++i) {
+               for (i = 0; i < get_irn_inter_arity(n); ++i) {
                        fprintf(F, "     %d: %s ", i, is_intra_backedge(n, i) ? "be" : "  ");
                        dump_node_opcode(F, get_irn_inter_n(n, i));
                        fprintf(F, " %ld\n", get_irn_node_nr(get_irn_inter_n(n, i)));
@@ -200,8 +201,11 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
        /* Source types */
        switch (get_irn_opcode(n)) {
        case iro_Block: {
+               if (has_Block_label(n))
+                       fprintf(F, "  Label: %lu\n", get_Block_label(n));
                ir_fprintf(F, "  macro Block: %+F\n", get_Block_MacroBlock(n));
                fprintf(F, "  block visited: %ld\n", get_Block_block_visited(n));
+               fprintf(F, "  block marked: %u\n", get_Block_mark(n));
                if (get_irg_dom_state(get_irn_irg(n)) != dom_none) {
                        fprintf(F, "  dom depth %d\n", get_Block_dom_depth(n));
                        fprintf(F, "  tree pre num %d\n", get_Block_dom_tree_pre_num(n));
@@ -222,8 +226,6 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                        (get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent))
                        fprintf(F, "    final evaluation:           **%8.2lf**\n", get_irn_final_cost(n));
 #endif
-    if (has_Block_label(n))
-      fprintf(F, "    Label: %lu\n", get_Block_label(n));
 
                /* not dumped: graph_arr */
                /* not dumped: mature    */
@@ -529,9 +531,9 @@ static void dump_node_list(FILE *F, firm_kind *k, char *prefix,
  *  "prefix"    node16, node17\n
  */
 static void dump_type_list(FILE *F, ir_type *tp, char *prefix,
-                           int (*get_n_types)(ir_type *tp),
-                           ir_type *(*get_type)(ir_type *tp, int pos),
-                           char *name) {
+                           int (*get_n_types)(const ir_type *tp),
+                           ir_type *(*get_type)(const ir_type *tp, int pos),
+                           const char *name) {
        int i, n_nodes = get_n_types(tp);
        char *comma = "";
 
@@ -548,6 +550,77 @@ static void dump_type_list(FILE *F, ir_type *tp, char *prefix,
        fprintf(F, "\n");
 }
 
+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) {
+       tarval  *tv;
+       ir_node *value;
+
+       if (need_nl) {
+               fprintf(F, "\n%s    ", prefix);
+               need_nl = 0;
+       }
+       switch (get_initializer_kind(initializer)) {
+       case IR_INITIALIZER_NULL:
+               fprintf(F, "\t = <NOT_SET>");
+               break;
+       case IR_INITIALIZER_TARVAL:
+               tv = get_initializer_tarval_value(initializer);
+               ir_fprintf(F, "\t = <TV>%F", tv);
+               break;
+       case IR_INITIALIZER_CONST:
+               value = get_initializer_const_value(initializer);
+               fprintf(F, "\t = <CONST>");
+               dump_node_opcode(F, value);
+               break;
+       case IR_INITIALIZER_COMPOUND:
+               if (is_Array_type(type)) {
+                       size_t i, n = get_initializer_compound_n_entries(initializer);
+                       ir_type *element_type = get_array_element_type(type);
+                       for (i = 0; i < n; ++i) {
+                               ir_initializer_t *sub_initializer
+                                       = get_initializer_compound_value(initializer, i);
+
+                               if (need_nl) {
+                                       fprintf(F, "\n%s    ", prefix);
+                                       need_nl = 0;
+                               }
+                               fprintf(F, "[%d]", i);
+                               dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
+                       }
+               } else {
+                       size_t i, n;
+                       assert(is_compound_type(type));
+                       n = get_compound_n_members(type);
+                       for (i = 0; i < n; ++i) {
+                               ir_entity        *member    = get_compound_member(type, i);
+                               ir_type          *subtype   = get_entity_type(member);
+                               ir_initializer_t *sub_initializer;
+
+                               assert(i < get_initializer_compound_n_entries(initializer));
+                               sub_initializer
+                                       = get_initializer_compound_value(initializer, i);
+
+                               if (need_nl) {
+                                       fprintf(F, "\n%s    ", prefix);
+                                       need_nl = 0;
+                               }
+                               ir_fprintf(F, ".%F", member);
+                               dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
+                       }
+               }
+               break;
+       default:
+               panic("invalid ir_initializer kind found");
+       }
+       need_nl = 1;
+}
+
+
 void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned verbosity) {
        int i, j;
        ir_type *owner, *type;
@@ -633,6 +706,9 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
                        fprintf(F, "\n%s  calling convention: ", prefix);
                        if (cc & cc_reg_param) fprintf(F, "regparam, ");
                        if (cc & cc_this_call) fprintf(F, "thiscall, ");
+                       if (cc & cc_compound_ret) fprintf(F, "compound_ret, ");
+                       if (cc & cc_frame_on_caller_stk) fprintf(F, "frame on caller's stack, ");
+                       cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
                        if (IS_CDECL(cc))
                                fprintf(F, "cdecl");
                        else if (IS_STDCALL(cc))
@@ -661,26 +737,34 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
 
        if (verbosity & dump_verbosity_entconsts) {
                if (get_entity_variability(ent) != variability_uninitialized) {
-                       if (is_atomic_entity(ent)) {
-                               fprintf(F, "%s  atomic value: ", prefix);
-                               dump_node_opcode(F, get_atomic_ent_value(ent));
+                       if (ent->has_initializer) {
+                               const ir_initializer_t *initializer = get_entity_initializer(ent);
+                               fprintf(F, "\n%s  Initializers:", prefix);
+                               need_nl = 1;
+                               dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
                        } else {
-                               fprintf(F, "%s  compound values:", prefix);
-                               for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
-                                       compound_graph_path *path = get_compound_ent_value_path(ent, i);
-                                       ir_entity *ent0 = get_compound_graph_path_node(path, 0);
-                                       fprintf(F, "\n%s    %3d:%u ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
-                                       if (get_type_state(type) == layout_fixed)
-                                               fprintf(F, "(%3u:%u) ",   get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
-                                       fprintf(F, "%s", get_entity_name(ent));
-                                       for (j = 0; j < get_compound_graph_path_length(path); ++j) {
-                                               ir_entity *node = get_compound_graph_path_node(path, j);
-                                               fprintf(F, ".%s", get_entity_name(node));
-                                               if (is_Array_type(get_entity_owner(node)))
-                                                       fprintf(F, "[%d]", get_compound_graph_path_array_index(path, j));
+                               /* old compound_graph_path based initializers */
+                               if (is_atomic_entity(ent)) {
+                                       fprintf(F, "%s  atomic value: ", prefix);
+                                       dump_node_opcode(F, get_atomic_ent_value(ent));
+                               } else {
+                                       fprintf(F, "%s  compound values:", prefix);
+                                       for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
+                                               compound_graph_path *path = get_compound_ent_value_path(ent, i);
+                                               ir_entity *ent0 = get_compound_graph_path_node(path, 0);
+                                               fprintf(F, "\n%s    %3d:%u ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
+                                               if (get_type_state(type) == layout_fixed)
+                                                       fprintf(F, "(%3u:%u) ",   get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
+                                               fprintf(F, "%s", get_entity_name(ent));
+                                               for (j = 0; j < get_compound_graph_path_length(path); ++j) {
+                                                       ir_entity *node = get_compound_graph_path_node(path, j);
+                                                       fprintf(F, ".%s", get_entity_name(node));
+                                                       if (is_Array_type(get_entity_owner(node)))
+                                                               fprintf(F, "[%d]", get_compound_graph_path_array_index(path, j));
+                                               }
+                                               fprintf(F, "\t = ");
+                                               dump_node_opcode(F, get_compound_ent_value(ent, i));
                                        }
-                                       fprintf(F, "\t = ");
-                                       dump_node_opcode(F, get_compound_ent_value(ent, i));
                                }
                        }
                        fprintf(F, "\n");