some minor changes
[libfirm] / ir / be / beraextern.c
index aba3d24..5b97486 100644 (file)
@@ -6,9 +6,11 @@
  *
  * Implementation of the RA-Interface for an external, (non-SSA) register allocator.
  *
- * The external register allocator is a program taking 2 arguments:
- *   1) An input file in which the interference graph is defined
- *   2) An output file containing the instructions to perform
+ * The external register allocator is a program:
+ *    PROG -i INPUTFILE -o OUTPUTFILE
+ *
+ *   1) Input file defines the interference graph
+ *   2) Output file contains the instructions to perform
  *
 
 
@@ -86,6 +88,7 @@ alloc         ::= node-nr reg-nr .
 #include "beirgmod.h"
 #include "besched.h"
 #include "beutil.h"
+#include "belive_t.h"
 
 typedef struct _var_info_t var_info_t;
 
@@ -600,7 +603,7 @@ static void dump_affinities_walker(ir_node *irn, void *env) {
 
 
 static void dump_affinities(be_raext_env_t *raenv) {
-       fprintf(raenv->f, "\ninterferences {\n");
+       fprintf(raenv->f, "\naffinities {\n");
        irg_walk_graph(raenv->irg, NULL, dump_affinities_walker, raenv);
        fprintf(raenv->f, "}\n");
 }
@@ -646,7 +649,7 @@ static void execute(char *prog_to_call, char *out_file, char *result_file) {
        char cmd_line[1024];
        int ret_status;
 
-       snprintf(cmd_line, sizeof(cmd_line), "%s %s %s", prog_to_call, out_file, result_file);
+       snprintf(cmd_line, sizeof(cmd_line), "%s -i %s -o %s", prog_to_call, out_file, result_file);
 
        ret_status = system(cmd_line);
        assert(ret_status != -1 && "Invokation of external register allocator failed");
@@ -711,8 +714,7 @@ static INLINE void var_add_spills_and_reloads(be_raext_env_t *raenv, int var_nr)
                }
 
        /* correct the reload->spill pointers... */
-       be_ssa_constr_sets(raenv->dom_info, spills, reloads);
-
+       be_ssa_constr_set(raenv->dom_info, spills);
 
        /****** correct the variable <--> values mapping: ******
         *
@@ -743,8 +745,6 @@ static INLINE void var_add_spills_and_reloads(be_raext_env_t *raenv, int var_nr)
        pset_foreach(reloads, irn)
                raenv->cls_vars[raenv->n_cls_vars++] = var_add_value(raenv, get_irn_node_nr(irn), irn);
 
-
-
        del_pset(spills);
        del_pset(reloads);
 }
@@ -817,7 +817,7 @@ static int read_and_apply_results(be_raext_env_t *raenv, char *filename) {
  * Default values for options
  */
 static void (*ssa_destr)(be_raext_env_t*) = ssa_destr_simple;
-static char callee[128] = "echo";
+static char callee[128] = "/ben/kimohoff/ipd-registerallocator/register_allocator";
 
 
 /**
@@ -829,12 +829,16 @@ static char callee[128] = "echo";
  * Read in results and apply them
  *
  */
-static void be_ra_extern_main(const be_main_env_t *env, ir_graph *irg) {
+static void be_ra_extern_main(const be_irg_t *bi) {
+       be_main_env_t *env = bi->main_env;
+       ir_graph *irg = bi->irg;
+
        be_raext_env_t raenv;
        int clsnr, clss;
        var_info_t *vi;
 
        compute_doms(irg);
+       be_liveness(irg);
 
        raenv.irg      = irg;
        raenv.aenv     = env->arch_env;
@@ -897,14 +901,15 @@ static void be_ra_extern_main(const be_main_env_t *env, ir_graph *irg) {
 
 #ifdef WITH_LIBCORE
 
-static const lc_opt_enum_const_ptr_items_t ssa_destr_items[] = {
-       { "simple",    ssa_destr_simple },
-       { "rastello",  ssa_destr_rastello },
+
+static const lc_opt_enum_func_ptr_items_t ssa_destr_items[] = {
+       { "simple",     (int (*)()) ssa_destr_simple }, /* TODO make (void*) casts nicer */
+       { "rastello",   (int (*)()) ssa_destr_rastello },
        { NULL,      NULL }
 };
 
-static lc_opt_enum_const_ptr_var_t ssa_destr_var = {
-       (const void **) &ssa_destr, ssa_destr_items
+static lc_opt_enum_func_ptr_var_t ssa_destr_var = {
+        (int (**)()) &ssa_destr, ssa_destr_items
 };
 
 static const lc_opt_table_entry_t be_ra_extern_options[] = {