X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeprofile.c;h=82da025722a05a57363f43f2d44b35c4e666e995;hb=5416b9ba504458151bbcf513b914cc48cebbbded;hp=42c0d4c2b5b37ef2e1f857e55d30b14af6066c30;hpb=bf1c019636f24dc00d86d111e5fffdf6984c9c73;p=libfirm diff --git a/ir/be/beprofile.c b/ir/be/beprofile.c index 42c0d4c2b..82da02572 100644 --- a/ir/be/beprofile.c +++ b/ir/be/beprofile.c @@ -1,13 +1,28 @@ -/** vim: set sw=4 ts=4: - * @file beprofile.c - * @date 2006-04-06 - * @author Adam M. Szalkowski - * @cvs-id $Id$ +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. * - * Code instrumentation and execution count profiling + * This file is part of libFirm. * - * Copyright (C) 2006 Universitaet Karlsruhe - * Released under the GPL + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Code instrumentation and execution count profiling. + * @author Adam M. Szalkowski + * @date 06.04.2006 + * @version $Id$ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -22,7 +37,6 @@ #include "list.h" #include "pmap.h" -#include "entity.h" #include "irprintf.h" #include "irgwalk.h" #include "irdump_t.h" @@ -32,14 +46,13 @@ #include "iredges.h" #include "execfreq.h" #include "irvrfy.h" -#include "type.h" -#include "entity.h" +#include "typerep.h" #include "be_t.h" #include "belive_t.h" #include "besched_t.h" #include "beirgmod.h" -#include "bearch.h" +#include "bearch_t.h" #include "beabi.h" #include "benode_t.h" #include "beutil.h" @@ -49,16 +62,11 @@ #include "bechordal_t.h" -#ifdef WITH_LIBCORE -#include -#include -#endif /* WITH_LIBCORE */ - #include "beprofile.h" /** An entry in the id-to-location map */ typedef struct loc_entry { - entity *fname; /**< the entity holding the file name */ + ir_entity *fname; /**< the entity holding the file name */ unsigned int lineno; /**< line number */ } loc_entry; @@ -178,20 +186,20 @@ fix_ssa(ir_node * bb, void * data) * void __firmprof_initializer(void) { __init_firmprof(ent_filename, bblock_id, bblock_counts, n_blocks); } */ static ir_graph * -gen_initializer_irg(entity * ent_filename, entity * bblock_id, entity * bblock_counts, int n_blocks) +gen_initializer_irg(ir_entity * ent_filename, ir_entity * bblock_id, ir_entity * bblock_counts, int n_blocks) { ir_node *start_block; ir_node *ins[4]; ident *name = new_id_from_str("__firmprof_initializer"); - entity *ent = new_entity(get_glob_type(), name, new_type_method(name, 0, 0)); + ir_entity *ent = new_entity(get_glob_type(), name, new_type_method(name, 0, 0)); ir_node *ret, *call, *symconst; symconst_symbol sym; ident *init_name = new_id_from_str("__init_firmprof"); ir_type *init_type = new_type_method(init_name, 4, 0); ir_type *uint, *uintptr, *string; - entity *init_ent; + ir_entity *init_ent; ir_graph *irg; ir_node *bb; ir_type *empty_frame_type; @@ -250,7 +258,7 @@ static void create_location_data(dbg_info *dbg, block_id_walker_data_t *wd) if (fname) { pmap_entry *entry = pmap_find(wd->fname_map, (void *)fname); - entity *ent; + ir_entity *ent; if (! entry) { static unsigned nr = 0; @@ -313,18 +321,29 @@ block_id_walker(ir_node * bb, void * data) ir_graph * be_profile_instrument(const char *filename, unsigned flags) { - int n, i; - unsigned int n_blocks = 0; - entity *bblock_id, *bblock_counts, *ent_filename, *ent_locations, - *loc_lineno, *loc_name, *ent; - ir_type *array_type, *uint_type, *string_type, *character_type, - *loc_type, *charptr_type, *gtp; - tarval **tarval_array, **tarval_string, *tv; - int filename_len = strlen(filename)+1; - ident *cur_ident; - int align_l, align_n, size; - ir_graph *rem; - + int n, i; + int n_blocks = 0; + ir_entity *bblock_id; + ir_entity *bblock_counts; + ir_entity *ent_filename; + ir_entity *ent_locations = NULL; + ir_entity *loc_lineno = NULL; + ir_entity *loc_name = NULL; + ir_entity *ent; + ir_type *array_type; + ir_type *uint_type; + ir_type *string_type; + ir_type *character_type; + ir_type *loc_type = NULL; + ir_type *charptr_type; + ir_type *gtp; + tarval **tarval_array; + tarval **tarval_string; + tarval *tv; + int filename_len = strlen(filename)+1; + ident *cur_ident; + int align_l, align_n, size; + ir_graph *rem; block_id_walker_data_t wd; symconst_symbol sym; @@ -368,14 +387,14 @@ be_profile_instrument(const char *filename, unsigned flags) loc_lineno = new_entity(loc_type, IDENT("lineno"), uint_type); align_l = get_type_alignment_bytes(uint_type); size = get_type_size_bytes(uint_type); - set_entity_offset_bytes(loc_lineno, 0); + set_entity_offset(loc_lineno, 0); charptr_type = new_type_pointer(IDENT("__charptr"), character_type, mode_P_data); align_n = get_type_size_bytes(charptr_type); set_type_alignment_bytes(charptr_type, align_n); loc_name = new_entity(loc_type, IDENT("name"), charptr_type); size = (size + align_n - 1) & -align_n; - set_entity_offset_bytes(loc_name, size); + set_entity_offset(loc_name, size); size += align_n; if (align_n > align_l) @@ -607,7 +626,7 @@ be_profile_get_block_execcount(const ir_node *block) typedef struct _intialize_execfreq_env_t { ir_graph *irg; - exec_freq_t *execfreqs; + ir_exec_freq *execfreqs; double freq_factor; } initialize_execfreq_env_t; @@ -631,7 +650,7 @@ static void initialize_execfreq(ir_node *block, void *data) { set_execfreq(env->execfreqs, block, freq); } -exec_freq_t *be_create_execfreqs_from_profile(ir_graph *irg) +ir_exec_freq *be_create_execfreqs_from_profile(ir_graph *irg) { ir_node *block2 = NULL; ir_node *start_block;