From: Christian Würdig Date: Mon, 4 Sep 2006 15:10:32 +0000 (+0000) Subject: fixed profile support X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=1de1cf3646fc245433c89cf4e8faf1654c762d3b;p=libfirm fixed profile support fixed comments fixed indents --- diff --git a/ir/be/bearch.c b/ir/be/bearch.c index 7e0dc72df..4f2882cf2 100644 --- a/ir/be/bearch.c +++ b/ir/be/bearch.c @@ -31,10 +31,12 @@ #include "irprintf.h" /* Initialize the architecture environment struct. */ -arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if, FILE *file_handle) +arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if, FILE *file_handle, be_main_env_t *main_env) { memset(env, 0, sizeof(*env)); - env->isa = isa_if->init(file_handle); + env->isa = isa_if->init(file_handle); + env->constructor_entities = pset_new_ptr(5); + env->isa->main_env = main_env; return env; } diff --git a/ir/be/bearch.h b/ir/be/bearch.h index efd7fccf9..20685c288 100644 --- a/ir/be/bearch.h +++ b/ir/be/bearch.h @@ -585,10 +585,11 @@ struct _arch_code_generator_t { * ISA base class. */ struct _arch_isa_t { - const arch_isa_if_t *impl; + const arch_isa_if_t *impl; const arch_register_t *sp; /** The stack pointer register. */ const arch_register_t *bp; /** The base pointer register. */ const int stack_dir; /** -1 for decreasing, 1 for increasing. */ + const be_main_env_t *main_env; /** the be main environment */ }; #define arch_isa_stack_dir(isa) ((isa)->stack_dir) @@ -602,8 +603,9 @@ struct _arch_isa_if_t { /** * Initialize the isa interface. - * @param file_handle the file handle to write the output to - * @return a new isa instance + * @param file_handle the file handle to write the output to + * @param main_env the be main environment + * @return a new isa instance */ void *(*init)(FILE *file_handle); @@ -728,7 +730,7 @@ struct _arch_env_t { * @param file_handle The file handle * @return The environment. */ -extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa, FILE *file_handle); +extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa, FILE *file_handle, be_main_env_t *main_env); /** * Add a node handler to the environment. diff --git a/ir/be/bemain.c b/ir/be/bemain.c index ccc9dff72..7dfb88eb0 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -267,11 +267,10 @@ static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle) memset(env, 0, sizeof(*env)); obstack_init(&env->obst); env->arch_env = obstack_alloc(&env->obst, sizeof(env->arch_env[0])); - env->arch_env->constructor_entities = pset_new_ptr(5); env->options = &be_options; FIRM_DBG_REGISTER(env->dbg, "be.main"); - arch_env_init(env->arch_env, isa_if, file_handle); + arch_env_init(env->arch_env, isa_if, file_handle, env); /* Register the irn handler of the architecture */ if (arch_isa_get_irn_handler(env->arch_env->isa)) @@ -429,7 +428,7 @@ static void be_main_loop(FILE *file_handle) ir_graph *prof_init_irg = be_profile_instrument(); pset_insert_ptr(env.arch_env->constructor_entities, get_irg_entity(prof_init_irg)); } - be_profile_read("test.c"); //FIXME + be_profile_read("test.c.prof"); //FIXME /* For all graphs */ for (i = 0, n = get_irp_n_irgs(); i < n; ++i) { diff --git a/ir/be/beprofile.c b/ir/be/beprofile.c index 6d25caefc..6819dd1d4 100644 --- a/ir/be/beprofile.c +++ b/ir/be/beprofile.c @@ -105,15 +105,15 @@ instrument_block(ir_node * bb, ir_node * address, unsigned int id) if(bb == start_block || bb == get_irg_end_block(irg)) return; - cnst = new_r_Const_long(irg, start_block, mode_Iu, get_mode_size_bytes(mode_Iu) * id); + cnst = new_r_Const_long(irg, start_block, mode_Iu, get_mode_size_bytes(mode_Iu) * id); offset = new_r_Add(irg, bb, address, cnst, mode_P); - load = new_r_Load(irg, bb, new_NoMem(), offset, mode_Iu); - projm = new_r_Proj(irg, bb, load, mode_M, pn_Load_M); - proji = new_r_Proj(irg, bb, load, mode_Iu, pn_Load_res); - cnst = new_r_Const_long(irg, start_block, mode_Iu, 1); - add = new_r_Add(irg, bb, proji, cnst, mode_Iu); - store = new_r_Store(irg, bb, projm, offset, add); - projm = new_r_Proj(irg, bb, store, mode_M, pn_Store_M); + load = new_r_Load(irg, bb, new_NoMem(), offset, mode_Iu); + projm = new_r_Proj(irg, bb, load, mode_M, pn_Load_M); + proji = new_r_Proj(irg, bb, load, mode_Iu, pn_Load_res); + cnst = new_r_Const_long(irg, start_block, mode_Iu, 1); + add = new_r_Add(irg, bb, proji, cnst, mode_Iu); + store = new_r_Store(irg, bb, projm, offset, add); + projm = new_r_Proj(irg, bb, store, mode_M, pn_Store_M); keep_alive(projm); } @@ -137,6 +137,7 @@ gen_initializer_irg(entity * ent_filename, entity * bblock_id, entity * bblock_c entity *init_ent; ir_graph *irg; ir_node *bb; + ir_type *empty_frame_type; uint = new_type_primitive(new_id_from_str("__uint"), mode_Iu); uintptr = new_type_pointer(new_id_from_str("__uintptr"), uint, mode_P); @@ -150,6 +151,8 @@ gen_initializer_irg(entity * ent_filename, entity * bblock_id, entity * bblock_c irg = new_ir_graph(ent, 0); set_current_ir_graph(irg); + empty_frame_type = get_irg_frame_type(irg); + set_type_size_bytes(empty_frame_type, 0); bb = get_cur_block(); @@ -170,7 +173,7 @@ gen_initializer_irg(entity * ent_filename, entity * bblock_id, entity * bblock_c bb, //ir_node * block, get_irg_initial_mem(irg), //ir_node * store, symconst, //ir_node * callee, - 3, //int arity, + 4, //int arity, ins, //ir_node ** in, init_type //ir_type * tp ); @@ -209,7 +212,7 @@ be_profile_instrument(void) ir_node *const_block = get_irg_start_block(const_irg); int n, i; unsigned int n_blocks = 0; - entity *bblock_id, *bblock_counts, *bblock_count, *ent_filename; + entity *bblock_id, *bblock_counts, *ent_filename; ir_type *array_type, *integer_type, *string_type, *character_type; tarval **tarval_array, **tarval_string; char *filename = "test.c"; //FIXME @@ -228,8 +231,6 @@ be_profile_instrument(void) set_entity_variability(bblock_id, variability_initialized); bblock_counts = new_entity(get_glob_type(), new_id_from_str("__BLOCK_COUNTS"), array_type); set_entity_variability(bblock_counts, variability_initialized); - bblock_count = new_entity(get_glob_type(), new_id_from_str("__N_BLOCKS"), integer_type); - set_entity_variability(bblock_count, variability_initialized); ent_filename = new_entity(get_glob_type(), new_id_from_str("__FUNCTION_NAME"), string_type); set_entity_variability(ent_filename, variability_initialized); @@ -246,9 +247,6 @@ be_profile_instrument(void) } set_array_entity_values(bblock_counts, tarval_array, n_blocks); - /* initialize the block count entity */ - set_atomic_ent_value(bblock_count, new_r_Const_long(const_irg, const_block, mode_Iu, n_blocks)); - /* initialize function name string constant */ tarval_string = alloca(sizeof(*tarval_string) * (filename_len)); for(i = 0; i < filename_len; ++i) { @@ -264,7 +262,7 @@ be_profile_instrument(void) ir_graph *irg = get_irp_irg(n); /* generate a symbolic constant pointing to the count array */ - sym.entity_p = bblock_count; + sym.entity_p = bblock_counts; wd.symconst = new_r_SymConst(irg, get_irg_start_block(irg), sym, symconst_addr_ent); irg_block_walk_graph(irg, block_id_walker, NULL, &wd); diff --git a/ir/be/bespillcost.c b/ir/be/bespillcost.c index 32851006d..fbbb2c88b 100644 --- a/ir/be/bespillcost.c +++ b/ir/be/bespillcost.c @@ -74,7 +74,7 @@ execution_frequency(const be_chordal_env_t * chordal_env, const ir_node * irn) } -static double +static int get_cost(const be_chordal_env_t * chordal_env, const ir_node * irn) { if(be_is_Spill(irn)) { diff --git a/ir/be/bespillremat.c b/ir/be/bespillremat.c index df7c0e6f3..543a3241f 100644 --- a/ir/be/bespillremat.c +++ b/ir/be/bespillremat.c @@ -485,11 +485,11 @@ get_remat_from_op(spill_ilp_t * si, const ir_node * dest_value, const ir_node * if(!is_rematerializable(si, op)) return NULL; - remat = obstack_alloc(si->obst, sizeof(*remat)); - remat->op = op; - remat->cost = get_cost(si, op); - remat->value = dest_value; - remat->proj = proj; + remat = obstack_alloc(si->obst, sizeof(*remat)); + remat->op = op; + remat->cost = get_cost(si, op); + remat->value = dest_value; + remat->proj = proj; remat->inverse = 0; } else { arch_inverse_t inverse; diff --git a/ir/be/bestatevent.c b/ir/be/bestatevent.c index 70b43e1de..3627ee470 100644 --- a/ir/be/bestatevent.c +++ b/ir/be/bestatevent.c @@ -1,8 +1,9 @@ /** -* Statistic events -* @date 3.9.2006 -* @author Sebastian Hack -*/ + * Statistic events + * @date 3.9.2006 + * @author Sebastian Hack + * @cvs-id $Id$ + */ #include #include