- add graph pass for edges_verify()
[libfirm] / ir / ir / irio.c
index 110c075..9b4c336 100644 (file)
@@ -190,7 +190,7 @@ static void symtbl_init(void)
        INSERTENUM(tt_builtin, ir_bk_trap);
        INSERTENUM(tt_builtin, ir_bk_debugbreak);
        INSERTENUM(tt_builtin, ir_bk_return_address);
-       INSERTENUM(tt_builtin, ir_bk_frame_addess);
+       INSERTENUM(tt_builtin, ir_bk_frame_address);
        INSERTENUM(tt_builtin, ir_bk_prefetch);
        INSERTENUM(tt_builtin, ir_bk_ffs);
        INSERTENUM(tt_builtin, ir_bk_clz);
@@ -511,7 +511,7 @@ static void export_type_post(io_env_t *env, ir_type *tp)
 static void export_entity(io_env_t *env, ir_entity *ent)
 {
        ir_type *owner = get_entity_owner(ent);
-       fprintf(env->file, "\tentity %ld \"%s\" \"%s\" %ld %ld %d %u %s %s %s %s %s ",
+       fprintf(env->file, "\tentity %ld \"%s\" \"%s\" %ld %ld %d %u %d %s %s %s %s %s ",
                        get_entity_nr(ent),
                        get_entity_name(ent),
                        ent->ld_name ? get_id_str(ent->ld_name) : "",
@@ -519,6 +519,7 @@ static void export_entity(io_env_t *env, ir_entity *ent)
                        get_type_nr(owner),
                        get_entity_offset(ent),
                        (unsigned) get_entity_offset_bits_remainder(ent),
+                       is_entity_compiler_generated(ent),
                        get_allocation_name(get_entity_allocation(ent)),
                        get_visibility_name(get_entity_visibility(ent)),
                        get_variability_name(get_entity_variability(ent)),
@@ -582,6 +583,9 @@ static void export_type_or_ent_post(type_or_ent tore, void *ctx)
        }
 }
 
+/**
+ * Walker: exports every node.
+ */
 static void export_node(ir_node *irn, void *ctx)
 {
        io_env_t *env = (io_env_t *) ctx;
@@ -591,10 +595,9 @@ static void export_node(ir_node *irn, void *ctx)
        if (env->ignoreblocks && opcode == iro_Block)
                return;
 
-       n = get_irn_arity(irn);
-
        fprintf(env->file, "\t%s %ld [ ", get_irn_opname(irn), get_irn_node_nr(irn));
 
+       n = get_irn_arity(irn);
        for (i = -1; i < n; i++) {
                ir_node *pred = get_irn_n(irn, i);
                if (pred == NULL) {
@@ -608,8 +611,7 @@ static void export_node(ir_node *irn, void *ctx)
 
        fprintf(env->file, "] { ");
 
-       switch (opcode)
-       {
+       switch (opcode) {
                #include "gen_irio_export.inl"
        }
        fputs("}\n", env->file);
@@ -649,7 +651,7 @@ static void export_modes(io_env_t *env)
        fputs("}\n\n", env->file);
 }
 
-/** Exports the whole irp to the given file in a textual form. */
+/* Exports the whole irp to the given file in a textual form. */
 void ir_export(const char *filename)
 {
        io_env_t env;
@@ -665,8 +667,7 @@ void ir_export(const char *filename)
 
        fputs("typegraph {\n", env.file);
 
-       type_walk_plus_frames(export_type_or_ent_pre, export_type_or_ent_post, &env);
-       /* TODO: Visit frame types and "types for value params"? */
+       type_walk_prog(export_type_or_ent_pre, export_type_or_ent_post, &env);
 
        for (i = 0; i < n_irgs; i++) {
                ir_graph *irg = get_irp_irg(i);
@@ -691,7 +692,7 @@ void ir_export(const char *filename)
        fclose(env.file);
 }
 
-/** Exports the given irg to the given file. */
+/* Exports the given irg to the given file. */
 void ir_export_irg(ir_graph *irg, const char *filename)
 {
        io_env_t env;
@@ -717,7 +718,7 @@ void ir_export_irg(ir_graph *irg, const char *filename)
        irg_walk_anchors(irg, NULL, export_node, &env);
 
        /* TODO: Only output needed constants */
-       fputs("}\n\nconstirg {\n", env.file);
+       fprintf(env.file, "}\n\nconstirg %ld {\n", get_irn_node_nr(get_const_code_irg()->current_block));
        walk_const_code(NULL, export_node, &env);
        fputs("}\n", env.file);
 
@@ -1126,7 +1127,10 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                        }
 
                        case tpo_class:
-                               type = new_type_class(id);
+                               if(typenr == (long) IR_SEGMENT_GLOBAL)
+                                       type = get_glob_type();
+                               else
+                                       type = new_type_class(id);
                                set_type_size_bytes(type, size);
                                break;
 
@@ -1181,7 +1185,10 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                        }
 
                        case tpo_struct:
-                               type = new_type_struct(id);
+                               if(typenr < (long) IR_SEGMENT_COUNT)
+                                       type = get_segment_type((ir_segment_t) typenr);
+                               else
+                                       type = new_type_struct(id);
                                set_type_size_bytes(type, size);
                                break;
 
@@ -1230,6 +1237,7 @@ static void import_entity(io_env_t *env)
                set_entity_ld_ident(entity, new_id_from_str(ld_name));
        set_entity_offset     (entity, (int) read_long(env));
        set_entity_offset_bits_remainder(entity, (unsigned char) read_long(env));
+       set_entity_compiler_generated(entity, (int) read_long(env));
        set_entity_allocation (entity, read_allocation(env));
        set_entity_visibility (entity, read_visibility(env));
        set_entity_variability(entity, read_variability(env));
@@ -1474,11 +1482,14 @@ static int parse_modes(io_env_t *env)
                                ir_mode_arithmetic arith = read_mode_arithmetic(env);
                                unsigned modulo_shift = read_long(env);
                                int vector_elems = read_long(env);
+                               ir_mode *mode;
 
-                               ir_mode *mode = new_ir_mode(name, sort, size, sign, arith, modulo_shift);
+                               if (vector_elems != 1) {
+                                       panic("no support for import of vector modes yes");
+                               }
 
-                               if (mode_is_reference(mode))
-                               {
+                               mode = new_ir_mode(name, sort, size, sign, arith, modulo_shift);
+                               if (mode_is_reference(mode)) {
                                        set_reference_mode_signed_eq(mode, read_mode(env));
                                        set_reference_mode_unsigned_eq(mode, read_mode(env));
                                }