Commit 1de1cf36 authored by Christian Würdig's avatar Christian Würdig
Browse files

fixed profile support

fixed comments
fixed indents
parent 8b493df9
......@@ -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;
}
......
......@@ -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.
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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)) {
......
......@@ -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;
......
/**
* Statistic events
* @date 3.9.2006
* @author Sebastian Hack
*/
* Statistic events
* @date 3.9.2006
* @author Sebastian Hack
* @cvs-id $Id$
*/
#include <assert.h>
#include <string.h>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment