Commit 9d771b94 authored by Michael Beck's avatar Michael Beck
Browse files

- placed phi_handler into the be_main environment, removing unnecessary allocations

[r19715]
parent 0563b37d
......@@ -79,16 +79,23 @@ struct be_options_t {
char filtev[128]; /**< filter mask for stat events (regex is supported) */
};
typedef struct {
arch_irn_handler_t irn_handler;
arch_irn_ops_t irn_ops;
const arch_env_t *arch_env;
pmap *phi_attrs;
} phi_handler_t;
struct be_main_env_t {
arch_env_t arch_env;
be_options_t *options; /**< backend options */
arch_code_generator_t *cg;
arch_irn_handler_t *phi_handler;
const char *cup_name; /**< name of the compilation unit */
pmap *ent_trampoline_map; /**< A map containing PIC trampolines for methods. */
ir_type *pic_trampolines_type; /**< Class type containing all trampolines */
pmap *ent_pic_symbol_map;
ir_type *pic_symbols_type;
phi_handler_t phi_handler;
};
/**
......
......@@ -250,6 +250,8 @@ const backend_params *be_init(void)
*/
static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle)
{
const arch_irn_handler_t *handler;
memset(env, 0, sizeof(*env));
env->options = &be_options;
env->ent_trampoline_map = pmap_create();
......@@ -264,8 +266,9 @@ static be_main_env_t *be_init_env(be_main_env_t *env, FILE *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))
arch_env_push_irn_handler(&env->arch_env, arch_isa_get_irn_handler(env->arch_env.isa));
handler = arch_isa_get_irn_handler(env->arch_env.isa);
if (handler != NULL)
arch_env_push_irn_handler(&env->arch_env, handler);
/*
* Register the node handler of the back end infrastructure.
......@@ -273,8 +276,8 @@ static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle)
* spill, reload and perm nodes.
*/
arch_env_push_irn_handler(&env->arch_env, &be_node_irn_handler);
env->phi_handler = be_phi_handler_new(&env->arch_env);
arch_env_push_irn_handler(&env->arch_env, env->phi_handler);
be_phi_handler_new(env);
arch_env_push_irn_handler(&env->arch_env, &env->phi_handler.irn_handler);
be_dbg_open();
return env;
......@@ -287,7 +290,7 @@ static void be_done_env(be_main_env_t *env)
{
env->arch_env.isa->impl->done(env->arch_env.isa);
be_dbg_close();
be_phi_handler_free(env->phi_handler);
be_phi_handler_free(env);
pmap_destroy(env->ent_trampoline_map);
pmap_destroy(env->ent_pic_symbol_map);
......@@ -475,10 +478,16 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
/* set the current graph (this is important for several firm functions) */
current_ir_graph = irg;
#if 0
{
unsigned percent = 100*i/num_birgs;
ir_printf("%u.%02u %+F\n", percent/100, percent%100, irg);
}
#endif
be_sched_init_phase(irg);
/* reset the phi handler. */
be_phi_handler_reset(env.phi_handler);
be_phi_handler_reset(&env);
stat_ev_ctx_push_fobj("bemain_irg", irg);
......@@ -529,7 +538,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
stat_ev_ctx_pop("bemain_phase");
/* reset the phi handler. */
be_phi_handler_reset(env.phi_handler);
be_phi_handler_reset(&env);
be_do_stat_nodes(irg, "03 Prepare");
......
......@@ -1369,13 +1369,6 @@ typedef struct {
arch_irn_flags_t flags;
} phi_attr_t;
typedef struct {
arch_irn_handler_t irn_handler;
arch_irn_ops_t irn_ops;
const arch_env_t *arch_env;
pmap *phi_attrs;
} phi_handler_t;
#define get_phi_handler_from_handler(h) container_of(h, phi_handler_t, irn_handler)
#define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops)
......@@ -1589,27 +1582,25 @@ const arch_irn_ops_if_t phi_irn_ops = {
NULL, /* perform_memory_operand */
};
arch_irn_handler_t *be_phi_handler_new(const arch_env_t *arch_env)
void be_phi_handler_new(be_main_env_t *env)
{
phi_handler_t *h = xmalloc(sizeof(h[0]));
phi_handler_t *h = &env->phi_handler;
h->irn_handler.get_irn_ops = phi_get_irn_ops;
h->irn_ops.impl = &phi_irn_ops;
h->arch_env = arch_env;
h->arch_env = &env->arch_env;
h->phi_attrs = pmap_create();
return &h->irn_handler;
}
void be_phi_handler_free(arch_irn_handler_t *handler)
void be_phi_handler_free(be_main_env_t *env)
{
phi_handler_t *h = get_phi_handler_from_handler(handler);
phi_handler_t *h = &env->phi_handler;
pmap_destroy(h->phi_attrs);
h->phi_attrs = NULL;
free(handler);
}
void be_phi_handler_reset(arch_irn_handler_t *handler)
void be_phi_handler_reset(be_main_env_t *env)
{
phi_handler_t *h = get_phi_handler_from_handler(handler);
phi_handler_t *h = &env->phi_handler;
if(h->phi_attrs)
pmap_destroy(h->phi_attrs);
h->phi_attrs = pmap_create();
......
......@@ -505,23 +505,22 @@ void be_node_set_reg_class(ir_node *irn, int pos, const arch_register_class_t *c
void be_node_set_req_type(ir_node *irn, int pos, arch_register_req_type_t type);
/**
* Make a new phi handler.
* @param env The architecture environment.
* @return A new phi handler.
* Initialize the Phi handler.
* @param env The be_main environment.
*/
arch_irn_handler_t *be_phi_handler_new(const arch_env_t *arch_env);
void be_phi_handler_new(be_main_env_t *env);
/**
* Free a phi handler.
* @param handler The handler to free.
* Destroy the Phi handler.
* @param env The be_main environment.
*/
void be_phi_handler_free(arch_irn_handler_t *handler);
void be_phi_handler_free(be_main_env_t *env);
/**
* Reset the register data in the phi handler.
* Reset the register data in the Phi handler.
* This should be called on each new graph and deletes the register information of the current graph.
*/
void be_phi_handler_reset(arch_irn_handler_t *handler);
void be_phi_handler_reset(be_main_env_t *env);
/**
* Set the register requirements for a phi node.
......
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