- placed phi_handler into the be_main environment, removing unnecessary allocations
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 21 May 2008 20:50:35 +0000 (20:50 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 21 May 2008 20:50:35 +0000 (20:50 +0000)
[r19715]

ir/be/be_t.h
ir/be/bemain.c
ir/be/benode.c
ir/be/benode_t.h

index 330d67b..1caeb61 100644 (file)
@@ -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;
 };
 
 /**
index 01b1905..46c6296 100644 (file)
@@ -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");
 
index 45f0374..0ba1c1a 100644 (file)
@@ -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();
index 54abbce..45e4dc3 100644 (file)
@@ -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.