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;
};
/**
*/
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();
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.
* 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;
{
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);
/* 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);
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");
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)
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();
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.