make sparc+arm backend completely independent from beabi
[libfirm] / ir / be / beprefalloc.c
index 1ab4e3c..9c759ad 100644 (file)
@@ -72,6 +72,7 @@
 #include "bespillutil.h"
 #include "beverify.h"
 #include "beutil.h"
+#include "bestack.h"
 
 #define USE_FACTOR                     1.0f
 #define DEF_FACTOR                     1.0f
@@ -86,7 +87,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 static struct obstack               obst;
 static ir_graph                    *irg;
 static const arch_register_class_t *cls;
-static const arch_register_req_t   *default_cls_req;
 static be_lv_t                     *lv;
 static const ir_exec_freq          *execfreqs;
 static unsigned                     n_regs;
@@ -173,24 +173,6 @@ static block_info_t *get_block_info(ir_node *block)
        return info;
 }
 
-/**
- * Get default register requirement for the current register class
- */
-static const arch_register_req_t *get_default_req_current_cls(void)
-{
-       if (default_cls_req == NULL) {
-               struct obstack      *obst = get_irg_obstack(irg);
-               arch_register_req_t *req  = OALLOCZ(obst, arch_register_req_t);
-
-               req->type  = arch_register_req_type_normal;
-               req->cls   = cls;
-               req->width = 1;
-
-               default_cls_req = req;
-       }
-       return default_cls_req;
-}
-
 /**
  * Link the allocation info of a node to a copy.
  * Afterwards, both nodes uses the same allocation info.
@@ -1617,12 +1599,8 @@ static void allocate_coalesce_block(ir_node *block, void *data)
                }
 
                if (need_phi) {
-                       ir_mode                   *mode = get_irn_mode(node);
-                       const arch_register_req_t *req  = get_default_req_current_cls();
-                       ir_node                   *phi;
-
-                       phi = new_r_Phi(block, n_preds, phi_ins, mode);
-                       be_set_phi_reg_req(phi, req);
+                       ir_mode *mode = get_irn_mode(node);
+                       ir_node *phi  = be_new_Phi(block, n_preds, phi_ins, mode, cls);
 
                        DB((dbg, LEVEL_3, "Create Phi %+F (for %+F) -", phi, node));
 #ifdef DEBUG_libfirm
@@ -1921,7 +1899,7 @@ static void spill(void)
 static void be_pref_alloc(ir_graph *new_irg)
 {
        const arch_env_t *arch_env = be_get_irg_arch_env(new_irg);
-       int   n_cls                = arch_env_get_n_reg_class(arch_env);
+       int   n_cls                = arch_env->n_register_classes;
        int   c;
 
        obstack_init(&obst);
@@ -1933,8 +1911,7 @@ static void be_pref_alloc(ir_graph *new_irg)
        determine_block_order();
 
        for (c = 0; c < n_cls; ++c) {
-               cls             = arch_env_get_reg_class(arch_env, c);
-               default_cls_req = NULL;
+               cls = &arch_env->register_classes[c];
                if (arch_register_class_flags(cls) & arch_register_class_flag_manual_ra)
                        continue;
 
@@ -1942,7 +1919,7 @@ static void be_pref_alloc(ir_graph *new_irg)
 
                n_regs      = arch_register_class_n_regs(cls);
                normal_regs = rbitset_malloc(n_regs);
-               be_abi_set_non_ignore_regs(be_get_irg_abi(irg), cls, normal_regs);
+               be_set_allocatable_regs(irg, cls, normal_regs);
 
                spill();