made code C89 compliant (changed unnamed union in attributes)
[libfirm] / ir / be / becopyilp.c
index 93d329c..3e2469e 100644 (file)
@@ -3,7 +3,6 @@
  * Date:               28.02.2006
  * Copyright:   (c) Universitaet Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
- * $Id$
  *
  * Common stuff used by all ILP fomulations.
  *
@@ -11,7 +10,7 @@
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
 #ifdef WITH_ILP
 
@@ -30,7 +29,7 @@
 
 
 size_red_t *new_size_red(copy_opt_t *co) {
-       size_red_t *res = malloc(sizeof(*res));
+       size_red_t *res = xmalloc(sizeof(*res));
 
        res->co = co;
        res->all_removed = pset_new_ptr_default();
@@ -76,7 +75,11 @@ void sr_remove(size_red_t *sr) {
        while (redo) {
                redo = 0;
                be_ifg_foreach_node(ifg, iter, irn) {
-                       if (!sr_is_removed(sr, irn) && !co_is_optimizable_root(sr->co, irn) && !co_is_optimizable_arg(sr->co, irn)) {
+                       arch_register_req_t req;
+
+                       arch_get_register_req(sr->co->aenv, &req, irn, -1);
+
+                       if (!arch_register_req_is(&req, limited) && !sr_is_removed(sr, irn) && !co_gs_is_optimizable(sr->co, irn)) {
                        if (sr_is_simplicial(sr, irn)) {
                                        coloring_suffix_t *cs = obstack_alloc(&sr->ob, sizeof(*cs));
 
@@ -137,8 +140,10 @@ void free_size_red(size_red_t *sr) {
 
  *****************************************************************************/
 
+#include <stdio.h>
+
 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env) {
-       ilp_env_t *res = malloc(sizeof(*res));
+       ilp_env_t *res = xmalloc(sizeof(*res));
        assert(res);
 
        res->co = co;
@@ -151,16 +156,25 @@ ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, v
 }
 
 lpp_sol_state_t ilp_go(ilp_env_t *ienv) {
+       FILE *f;
+       char buf[256];
+       be_main_env_t *main_env = ienv->co->cenv->birg->main_env;
+
        sr_remove(ienv->sr);
 
        ienv->build(ienv);
 
 #ifdef LPP_SOLVE_NET
-       lpp_solve_net(ienv->lp, LPP_HOST, LPP_SOLVER);
+       lpp_solve_net(ienv->lp, main_env->options->ilp_server, main_env->options->ilp_solver);
 #else
        lpp_solve_cplex(ienv->lp);
 #endif
 
+       snprintf(buf, sizeof(buf), "%s.ilp", ienv->co->name);
+       f = fopen(buf, "wt");
+       lpp_dump_plain(ienv->lp, f);
+       fclose(f);
+
        ienv->apply(ienv);
 
        sr_reinsert(ienv->sr);