From 901bb930a86871ff22dd4aa1c34424a3083ef5fa Mon Sep 17 00:00:00 2001 From: Moritz Kroll Date: Tue, 3 Mar 2009 00:54:27 +0000 Subject: [PATCH] - walk_const_code now walks all segments, not just global. - Renamed type_walk_plus_frames to type_walk_prog. - irio: Added support for the other segments [r25598] --- include/libfirm/typerep.h | 4 ++-- ir/ir/irgwalk.c | 3 ++- ir/ir/irio.c | 19 +++++++++++++------ ir/tr/typewalk.c | 8 +++++++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/libfirm/typerep.h b/include/libfirm/typerep.h index 12ef8acca..efe353e7f 100644 --- a/include/libfirm/typerep.h +++ b/include/libfirm/typerep.h @@ -2577,8 +2577,8 @@ typedef void class_walk_func(ir_type *clss, void *env); void type_walk(type_walk_func *pre, type_walk_func *post, void *env); /** Touches every type, entity, frame type, and value param type in - * unspecified order. */ -void type_walk_plus_frames(type_walk_func *pre, type_walk_func *post, void *env); + * unspecified order (also all segment types). */ +void type_walk_prog(type_walk_func *pre, type_walk_func *post, void *env); /** Walks over all type information reachable from an ir graph. * diff --git a/ir/ir/irgwalk.c b/ir/ir/irgwalk.c index f4726194e..3cebf32ef 100644 --- a/ir/ir/irgwalk.c +++ b/ir/ir/irgwalk.c @@ -726,7 +726,8 @@ void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env) { my_env.env = env; /* Walk all types that can contain constant entities. */ - walk_types_entities(get_glob_type(), &walk_entity, &my_env); + for (i = 0; i < IR_SEGMENT_COUNT; i++) + walk_types_entities(get_segment_type((ir_segment_t) i), &walk_entity, &my_env); n_types = get_irp_n_types(); for (i = 0; i < n_types; i++) walk_types_entities(get_irp_type(i), &walk_entity, &my_env); diff --git a/ir/ir/irio.c b/ir/ir/irio.c index 110c07583..c94065e98 100644 --- a/ir/ir/irio.c +++ b/ir/ir/irio.c @@ -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)), @@ -665,8 +666,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); @@ -717,7 +717,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 +1126,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 +1184,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 +1236,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)); diff --git a/ir/tr/typewalk.c b/ir/tr/typewalk.c index 1c0b0d6cc..afbcb38a4 100644 --- a/ir/tr/typewalk.c +++ b/ir/tr/typewalk.c @@ -276,7 +276,7 @@ void type_walk(type_walk_func *pre, type_walk_func *post, void *env) { do_type_walk(cont, pre, post, env); } -void type_walk_plus_frames(type_walk_func *pre, type_walk_func *post, void *env) { +void type_walk_prog(type_walk_func *pre, type_walk_func *post, void *env) { int i, n_irgs = get_irp_n_irgs(); type_or_ent cont; @@ -291,6 +291,12 @@ void type_walk_plus_frames(type_walk_func *pre, type_walk_func *post, void *env) if(cont.typ) do_type_walk(cont, pre, post, env); } + + for (i = 0; i < IR_SEGMENT_COUNT; ++i) { + cont.typ = get_segment_type((ir_segment_t) i); + if(cont.typ) + do_type_walk(cont, pre, post, env); + } } void type_walk_irg(ir_graph *irg, -- 2.20.1