fix is_init_string
[libfirm] / ir / ir / irdumptxt.c
index a4b4085..988d62f 100644 (file)
@@ -22,7 +22,6 @@
  * @brief   Write text representation of firm to file.
  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Hubert Schmidt,
  *          Matthias Braun
- * @version $Id$
  */
 #include "config.h"
 
@@ -33,6 +32,7 @@
 
 #include "irdump_t.h"
 #include "irgraph_t.h"
+#include "irnode_t.h"
 
 #include "irprog_t.h"
 #include "entity_t.h"
@@ -101,8 +101,29 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
 
        fprintf(F, "  Private Attributes:\n");
 
-       if (is_Proj(n))
-               fprintf(F, "  proj nr: %ld\n", get_Proj_proj(n));
+       if (is_Proj(n)) {
+               ir_node *pred = get_Proj_pred(n);
+               long     pn   = get_Proj_proj(n);
+               fprintf(F, "  proj nr: %ld\n", pn);
+               if (is_Switch(pred)) {
+                       const ir_switch_table *table = get_Switch_table(pred);
+                       size_t n_entries = ir_switch_table_get_n_entries(table);
+                       size_t i;
+                       for (i = 0; i < n_entries; ++i) {
+                               const ir_switch_table_entry *entry
+                                       = ir_switch_table_get_entry_const(table, i);
+                               if (entry->pn == pn && entry->min != NULL && entry->max != NULL) {
+                                       ir_tarval *min = entry->min;
+                                       ir_tarval *max = entry->max;
+                                       if (min != max) {
+                                               ir_fprintf(F, "  switch case %+F .. %+F\n", min, max);
+                                       } else {
+                                               ir_fprintf(F, "  switch case %+F\n", min);
+                                       }
+                               }
+                       }
+               }
+       }
 
        if (is_fragile_op(n)) {
                fprintf(F, "  pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
@@ -131,7 +152,7 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
        /* Source types */
        switch (get_irn_opcode(n)) {
        case iro_Block: {
-               if (has_Block_entity(n))
+               if (get_Block_entity(n) != NULL)
                        fprintf(F, "  Label: %lu\n", get_entity_label(get_Block_entity(n)));
                fprintf(F, "  block visited: %lu\n", get_Block_block_visited(n));
                fprintf(F, "  block marked: %u\n", get_Block_mark(n));
@@ -157,7 +178,6 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
                        ir_fprintf(F, "    param %d type: %+F\n", i, get_method_param_type(tp, i));
        } break;
        case iro_Cond: {
-               fprintf(F, "  default ProjNr: %ld\n", get_Cond_default_proj(n));
                if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
                        fprintf(F, "  jump prediction: %s\n",
                                get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
@@ -183,8 +203,6 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
        } break;
        case iro_Call: {
                ir_type *tp = get_Call_type(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) {
                        size_t i;
@@ -229,11 +247,6 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
                        fprintf(F, "  entity: ");
                        dump_entity_to_file(F, get_SymConst_entity(n));
                        break;
-               case symconst_type_tag:
-                       fprintf(F, "  kind: type_tag\n");
-                       fprintf(F, "  type: ");
-                       dump_type_to_file(F, get_SymConst_type(n));
-                       break;
                case symconst_type_size:
                        fprintf(F, "  kind: size\n");
                        fprintf(F, "  type: ");
@@ -331,9 +344,13 @@ static bool is_init_string(ir_initializer_t const* const init, ir_type *const ty
        n = get_initializer_compound_n_entries(init);
        for (i = 0; i != n; ++i) {
                ir_initializer_t const* const val = get_initializer_compound_value(init, i);
-               ir_tarval*              const tv  = get_initializer_tarval_value(val);
+               ir_tarval*                    tv;
                long                          v;
 
+               if (get_initializer_kind(val) != IR_INITIALIZER_TARVAL)
+                       return false;
+               tv = get_initializer_tarval_value(val);
+
                if (!tarval_is_constant(tv))
                        return false;