C99 features removed
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 2 Dec 2005 16:52:04 +0000 (16:52 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 2 Dec 2005 16:52:04 +0000 (16:52 +0000)
more config.h stuff added

ir/be/becopyilp.c
ir/be/becopyoptmain.c
ir/be/bespill.c
ir/be/bespillbelady.c

index 48a74c4..61574db 100644 (file)
@@ -3,6 +3,7 @@
  * Date:               17.05.2005
  * Copyright:   (c) Universitaet Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * CVS-ID:      $Id$
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -589,6 +590,7 @@ static INLINE int get_y_var_idx(problem_instance_t *pi, int nnr1, int nnr2) {
                return res;
 
        assert(0 && "One of them must work");
+  return -1;
 }
 
 static void check_ecc_and_add_cut(problem_instance_t *pi, ir_node **path, int length, pset *remain, ir_node *tgt) {
@@ -670,7 +672,7 @@ static void path_cstr_for_classes_walker(ir_node *irn, void *env) {
        problem_instance_t *pi = env;
        be_chordal_env_t *cenv;
        int i, o, max;
-       ir_node *m;
+       ir_node *m, **cls;
        pset *class = get_phi_class(irn);
        if (!class || pset_find_ptr(pi->done, class))
                return;
@@ -679,7 +681,7 @@ static void path_cstr_for_classes_walker(ir_node *irn, void *env) {
 
        /* pset to array */
        max = pset_count(class);
-       ir_node **cls = alloca(max * sizeof(*cls));
+       cls = alloca(max * sizeof(*cls));
        for(i=0, m = pset_first(class); m; i++, m = pset_next(class)) {
                DBG((dbg, LEVEL_1, " class member: %+F\n", m));
                cls[i] = m;
@@ -887,8 +889,10 @@ static void pi_set_start_sol(problem_instance_t *pi) {
  * Invoke a solver
  */
 static void pi_solve_ilp(problem_instance_t *pi) {
+  double lower_bound;
+
        pi_set_start_sol(pi);
-       double lower_bound = co_get_lower_bound(pi->co) - co_get_inevit_copy_costs(pi->co);
+       lower_bound = co_get_lower_bound(pi->co) - co_get_inevit_copy_costs(pi->co);
        lpp_set_bound(pi->curr_lp, lower_bound);
        lpp_solve_net(pi->curr_lp, LPP_HOST, LPP_SOLVER);
 //     lpp_solve_cplex(pi->curr_lp);
index 0dd5b91..cafcf25 100644 (file)
@@ -68,7 +68,9 @@ void be_copy_opt(be_chordal_env_t *chordal_env) {
        copy_opt_t *co;
        int costs, costs_init=-1, costs_heur=-1, costs_ilp_5_sec=-1, costs_ilp_30_sec=-1, costs_ilp=-1;
        int lower_bound;
+  int was_optimal = 0;
        color_save_t saver;
+
        saver.arch_env = chordal_env->session_env->main_env->arch_env;
        saver.chordal_env = chordal_env;
        saver.saved_colors = pmap_create();
@@ -97,11 +99,13 @@ void be_copy_opt(be_chordal_env_t *chordal_env) {
        save_colors(&saver);
 
 #ifdef DO_HEUR
-       lc_timer_t *timer = lc_timer_register("heur", NULL);
-       lc_timer_reset_and_start(timer);
-       co_heur_opt(co);
-       lc_timer_stop(timer);
-       copystat_add_heur_time(lc_timer_elapsed_msec(timer));
+  {
+         lc_timer_t *timer = lc_timer_register("heur", NULL);
+         lc_timer_reset_and_start(timer);
+         co_heur_opt(co);
+         lc_timer_stop(timer);
+         copystat_add_heur_time(lc_timer_elapsed_msec(timer));
+  }
 #ifdef DO_STAT
        costs = co_get_copy_costs(co);
        costs_heur = costs;
@@ -111,8 +115,6 @@ void be_copy_opt(be_chordal_env_t *chordal_env) {
        assert(lower_bound == -1 || costs_heur == -1 || lower_bound <= costs_heur);
 #endif
 
-       int was_optimal = 0;
-
 #ifdef DO_ILP_5_SEC
        load_colors(&saver);
        was_optimal = co_ilp_opt(co, 5.0);
index 1627763..35a76af 100644 (file)
@@ -188,9 +188,10 @@ void be_insert_spills_reloads(spill_env_t *senv, pset *reload_set) {
                foreach_out_edge(irn, e) {
                        ir_node *user = e->src;
                        if (is_Phi(user) && !pset_find_ptr(senv->mem_phis, user)) {
-                                       DBG((senv->dbg, LEVEL_1, " non-mem-phi user %+F\n", user));
-                                       ir_node *use_bl = get_nodes_block(user);
-                                       be_add_reload_on_edge(senv, irn, use_bl, e->pos); /* (1) */
+                               ir_node *use_bl;
+                               DBG((senv->dbg, LEVEL_1, " non-mem-phi user %+F\n", user));
+                               use_bl = get_nodes_block(user);
+                               be_add_reload_on_edge(senv, irn, use_bl, e->pos); /* (1) */
                        }
                }
        }
index ed71c5e..f915ef4 100644 (file)
@@ -4,8 +4,17 @@
  * Copyright:   (c) Universitaet Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#ifdef HAVE_ALLOCA_H
 #include <alloca.h>
+#endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #include "obst.h"
 #include "set.h"
 #include "pset.h"
@@ -186,9 +195,11 @@ static INLINE int workset_contains(const workset_t *ws, const ir_node *val) {
 
 
 static int is_mem_phi(const ir_node *irn, void *data) {
+       workset_t *sws;
        ir_node *blk = get_nodes_block(irn);
+
        DBG((dbg, DBG_SPILL, "Is %+F a mem-phi?\n", irn));
-       workset_t *sws = ((block_info_t *)get_irn_link(blk))->ws_start;
+       sws = ((block_info_t *)get_irn_link(blk))->ws_start;
        DBG((dbg, DBG_SPILL, "  %d\n", !workset_contains(sws, irn)));
        return !workset_contains(sws, irn);
 }
@@ -400,18 +411,19 @@ static void decide(ir_node *blk, void *env) {
 }
 
 /**
- * 'decide' is block-local and makes assumtions
+ * 'decide' is block-local and makes assumptions
  * about the set of live-ins. Thus we must adapt the
  * live-outs to the live-ins at each block-border.
  */
 static void fix_block_borders(ir_node *blk, void *env) {
        belady_env_t *bel = env;
        int i, max;
+       workset_t *wsb;
 
        DBG((dbg, DBG_FIX, "\n"));
        DBG((dbg, DBG_FIX, "Fixing %+F\n", blk));
 
-       workset_t *wsb = ((block_info_t *)get_irn_link(blk))->ws_start;
+       wsb = ((block_info_t *)get_irn_link(blk))->ws_start;
 
        /* process all pred blocks */
        for (i=0, max=get_irn_arity(blk); i<max; ++i) {
@@ -464,11 +476,12 @@ static void remove_unused_reloads(ir_graph *irg, belady_env_t *bel) {
 
        irg_walk_graph(irg, rescue_used_reloads, NULL, bel->reloads);
        for(irn = pset_first(bel->reloads); irn; irn = pset_next(bel->reloads)) {
+               ir_node *spill;
                DBG((dbg, DBG_SPILL, "Removing %+F before %+F in %+F\n", irn, sched_next(irn), get_nodes_block(irn)));
 
-               ir_node *spill = get_irn_n(irn, 0);
+               spill = get_irn_n(irn, 0);
 
-               /* remove reaload */
+               /* remove reload */
                set_irn_n(irn, 0, new_Bad());
                sched_remove(irn);
 
@@ -482,30 +495,30 @@ static void remove_unused_reloads(ir_graph *irg, belady_env_t *bel) {
 }
 
 void be_spill_belady(const be_main_session_env_t *session, const arch_register_class_t *cls) {
+       belady_env_t bel;
        dbg = firm_dbg_register("ir.be.spillbelady");
        firm_dbg_set_mask(dbg, DEBUG_LVL);
 
        /* init belady env */
-       belady_env_t *bel = alloca(sizeof(*bel));
-       obstack_init(&bel->ob);
-       bel->factory = session->main_env->node_factory;
-       bel->arch = session->main_env->arch_env;
-       bel->cls = cls;
-       bel->n_regs = arch_register_class_n_regs(cls);
-       bel->ws = new_workset(&bel->ob, bel);
-       bel->uses = be_begin_uses(session->irg, session->main_env->arch_env, cls);
-       bel->senv = be_new_spill_env(dbg, session, cls, is_mem_phi, NULL);
-       bel->reloads = pset_new_ptr_default();
+       obstack_init(&bel.ob);
+       bel.factory = session->main_env->node_factory;
+       bel.arch = session->main_env->arch_env;
+       bel.cls = cls;
+       bel.n_regs = arch_register_class_n_regs(cls);
+       bel.ws = new_workset(&bel.ob, &bel);
+       bel.uses = be_begin_uses(session->irg, session->main_env->arch_env, cls);
+       bel.senv = be_new_spill_env(dbg, session, cls, is_mem_phi, NULL);
+       bel.reloads = pset_new_ptr_default();
 
        /* do the work */
-       irg_block_walk_graph(session->irg, decide, NULL, bel);
-       irg_block_walk_graph(session->irg, fix_block_borders, NULL, bel);
-       be_insert_spills_reloads(bel->senv, bel->reloads);
-       remove_unused_reloads(session->irg, bel);
+       irg_block_walk_graph(session->irg, decide, NULL, &bel);
+       irg_block_walk_graph(session->irg, fix_block_borders, NULL, &bel);
+       be_insert_spills_reloads(bel.senv, bel.reloads);
+       remove_unused_reloads(session->irg, &bel);
 
        /* clean up */
-       del_pset(bel->reloads);
-       be_delete_spill_env(bel->senv);
-       be_end_uses(bel->uses);
-       obstack_free(&bel->ob, NULL);
+       del_pset(bel.reloads);
+       be_delete_spill_env(bel.senv);
+       be_end_uses(bel.uses);
+       obstack_free(&bel.ob, NULL);
 }