Adapted to new benode.c
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Wed, 18 Jan 2006 17:15:49 +0000 (17:15 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Wed, 18 Jan 2006 17:15:49 +0000 (17:15 +0000)
17 files changed:
ir/be/be_t.h
ir/be/bearch.c
ir/be/bechordal.c
ir/be/bechordal_main.c
ir/be/bechordal_t.h
ir/be/beconstrperm.c
ir/be/belistsched.h
ir/be/belower.c
ir/be/bemain.c
ir/be/benode.c
ir/be/benode_t.h
ir/be/bera.h
ir/be/besched.c
ir/be/bespill.c
ir/be/bespillbelady.c
ir/be/bessadestr.c
ir/be/firm/bearch_firm.c

index 35fc5d0..8d7f90c 100644 (file)
@@ -28,14 +28,4 @@ struct _be_main_env_t {
   firm_dbg_module_t *dbg;
 };
 
-#if 0
-struct _be_main_session_env_t {
-  const struct _be_main_env_t *main_env;
-  ir_graph *irg;
-  struct _dom_front_info_t *dom_front;
-};
-#endif
-
-
-
 #endif
index b8df9b5..2ce562f 100644 (file)
@@ -80,6 +80,7 @@ const arch_register_req_t *arch_get_register_req(const arch_env_t *env,
     arch_register_req_t *req, const ir_node *irn, int pos)
 {
   const arch_irn_ops_t *ops = get_irn_ops(env, irn);
+  req->type = arch_register_req_type_none;
   return ops->get_irn_reg_req(ops, req, irn, pos);
 }
 
@@ -90,25 +91,16 @@ int arch_get_allocatable_regs(const arch_env_t *env, const ir_node *irn,
   const arch_irn_ops_t *ops = get_irn_ops(env, irn);
   const arch_register_req_t *req = ops->get_irn_reg_req(ops, &local_req, irn, pos);
 
-  switch(req->type) {
-       case arch_register_req_type_none:
-               bitset_clear_all(bs);
-               return 0;
-
-       case arch_register_req_type_should_be_different:
-       case arch_register_req_type_should_be_same:
-    case arch_register_req_type_normal:
-      arch_register_class_put(req->cls, bs);
-      return req->cls->n_regs;
-
-    case arch_register_req_type_limited:
-      return req->limited(irn, pos, bs);
-
-    default:
-      assert(0 && "This register requirement case is not covered");
+  if(arch_register_req_is(req, none)) {
+         bitset_clear_all(bs);
+         return 0;
   }
 
-  return 0;
+  if(arch_register_req_is(req, limited))
+         return req->limited(irn, pos, bs);
+
+  arch_register_class_put(req->cls, bs);
+  return req->cls->n_regs;
 }
 
 int arch_is_register_operand(const arch_env_t *env,
index 0640305..9c0b224 100644 (file)
@@ -297,7 +297,7 @@ static ir_node *handle_constraints_at_perm(be_chordal_alloc_env_t *alloc_env, ir
                int colored = 0;
 
                for(precol = pset_first(pre_colored); precol; precol = pset_next(pre_colored)) {
-                       arch_register_t *pre_col_reg = arch_get_irn_register(arch_env, precol);
+                       const arch_register_t *pre_col_reg = arch_get_irn_register(arch_env, precol);
 
                        if(!values_interfere(irn, precol)) {
                                reg = arch_get_irn_register(arch_env, precol);
index 813d0e2..c18835c 100644 (file)
@@ -211,7 +211,7 @@ static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
 }
 #endif
 
-static void dump(int mask, ir_graph *irg,
+static void dump(unsigned mask, ir_graph *irg,
                                 const arch_register_class_t *cls,
                                 const char *suffix,
                                 void (*dump_func)(ir_graph *, const char *))
@@ -237,7 +237,7 @@ static void be_ra_chordal_main(const be_main_env_t *main_env, ir_graph *irg)
        compute_doms(irg);
 
        chordal_env.irg          = irg;
-       chordal_env.dbg          = firm_dbg_register("firm.be.chordal");
+       chordal_env.dbg          = firm_dbg_register("be.chordal");
        chordal_env.main_env     = main_env;
        chordal_env.dom_front    = be_compute_dominance_frontiers(irg);
 
@@ -276,6 +276,7 @@ static void be_ra_chordal_main(const be_main_env_t *main_env, ir_graph *irg)
 
                /* Color the graph. */
                be_ra_chordal_color(&chordal_env);
+               dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
 
                /* Build the interference graph. */
                chordal_env.ifg = be_ifg_std_new(&chordal_env);
index 4c02ed3..c652eb4 100644 (file)
@@ -87,11 +87,12 @@ enum {
        /* Dump flags */
        BE_CH_DUMP_NONE       = (1 << 0),
        BE_CH_DUMP_SPILL      = (1 << 1),
-       BE_CH_DUMP_COPYMIN    = (1 << 2),
-       BE_CH_DUMP_SSADESTR   = (1 << 3),
-       BE_CH_DUMP_TREE_INTV  = (1 << 4),
-       BE_CH_DUMP_CONSTR     = (1 << 5),
-       BE_CH_DUMP_LOWER      = (1 << 6),
+       BE_CH_DUMP_COLOR      = (1 << 2),
+       BE_CH_DUMP_COPYMIN    = (1 << 3),
+       BE_CH_DUMP_SSADESTR   = (1 << 4),
+       BE_CH_DUMP_TREE_INTV  = (1 << 5),
+       BE_CH_DUMP_CONSTR     = (1 << 6),
+       BE_CH_DUMP_LOWER      = (1 << 7),
        BE_CH_DUMP_ALL        = 2 * BE_CH_DUMP_LOWER - 1,
 
        /* copymin method */
index eeab5b1..5155727 100644 (file)
@@ -43,7 +43,7 @@ static void check_constraints(const be_chordal_env_t *cenv, ir_node *base, ir_no
                * would help.
                        */
                        if(*perm == NULL) {
-                               *perm = insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(base));
+                               *perm = insert_Perm_after(aenv, cenv->cls, cenv->dom_front, sched_prev(base));
                                be_liveness(cenv->irg);
                        }
 
index 5e2c554..9a337cf 100644 (file)
@@ -80,6 +80,12 @@ typedef struct _list_sched_selector_t {
  */
 extern const list_sched_selector_t *trivial_selector;
 
+/**
+ * A selector that tries to minimize the register pressure.
+ * @note Not really operational yet.
+ */
+extern const list_sched_selector_t *reg_pressure_selector;
+
 /**
  * List schedule a graph.
  * Each block in the graph gets a list head to its link field being the
index 23415d1..7ea6429 100644 (file)
@@ -207,7 +207,6 @@ static perm_cycle_t *get_perm_cycle(perm_cycle_t *cycle, reg_pair_t *pairs, int
  * @param walk_env The environment
  */
 static void lower_perm_node(ir_node *irn, void *walk_env) {
-       const be_node_factory_t     *fact;
        const arch_register_class_t *reg_class;
        const arch_env_t            *arch_env;
        firm_dbg_module_t           *mod;
@@ -223,7 +222,6 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
        if (is_Block(irn))
                return;
 
-       fact     = env->chord_env->main_env->node_factory;
        arch_env = env->chord_env->main_env->arch_env;
        do_copy  = env->do_copy;
        mod      = env->dbg_module;
@@ -342,7 +340,7 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
                                DBG((mod, LEVEL_1, "%+F                        (%+F, %s) and (%+F, %s)\n",
                                        irn, res1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
 
-                               cpyxchg = new_Perm(fact, reg_class, env->chord_env->irg, block, 2, in);
+                               cpyxchg = be_new_Perm(reg_class, env->chord_env->irg, block, 2, in);
 
                                sched_remove(res1);
                                sched_remove(res2);
@@ -362,7 +360,7 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
                                DBG((mod, LEVEL_1, "%+F creating copy node (%+F, %s) -> (%+F, %s)\n",
                                        irn, arg1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
 
-                               cpyxchg = new_Copy(fact, reg_class, env->chord_env->irg, block, arg1);
+                               cpyxchg = be_new_Copy(reg_class, env->chord_env->irg, block, arg1);
                                arch_set_irn_register(arch_env, cpyxchg, cycle->elems[i + 1]);
 
                                /* remove the proj from the schedule */
index bc4f54c..2d2b8d4 100644 (file)
@@ -72,7 +72,7 @@ static unsigned dump_flags = DUMP_INITIAL | DUMP_SCHED | DUMP_PREPARED | DUMP_RA
 static const be_ra_t *ra = &be_ra_chordal_allocator;
 
 /* back end instruction set architecture to use */
-static const arch_isa_if_t *isa_if = &firm_isa;
+static const arch_isa_if_t *isa_if = &ia32_isa_if;
 
 #ifdef WITH_LIBCORE
 
@@ -180,9 +180,7 @@ static be_main_env_t *be_init_env(be_main_env_t *env)
    * This irn handler takes care of the platform independent
    * spill, reload and perm nodes.
    */
-  env->node_factory = obstack_alloc(&env->obst, sizeof(*env->node_factory));
-  be_node_factory_init(env->node_factory, env->arch_env->isa);
-  arch_env_add_irn_handler(env->arch_env, be_node_get_irn_handler(env->node_factory));
+  arch_env_add_irn_handler(env->arch_env, &be_node_irn_handler);
 
   return env;
 }
@@ -285,5 +283,6 @@ static void be_main_loop(FILE *file_handle)
 
 void be_main(FILE *file_handle)
 {
-  be_main_loop(file_handle);
+       be_node_init();
+       be_main_loop(file_handle);
 }
index b8e3090..673f9ad 100644 (file)
 
 #include "beirgmod.h"
 
-#define DBG_LEVEL 0
+/* Sometimes we want to put const nodes into get_irn_generic_attr ... */
+#define get_irn_attr(irn) get_irn_generic_attr((ir_node *) (irn))
 
-#define BENODE_MAGIC FOURCC('B', 'E', 'N', 'O')
+static unsigned be_node_tag = FOURCC('B', 'E', 'N', 'O');
 
 typedef enum _node_kind_t {
        node_kind_spill,
@@ -64,160 +65,179 @@ typedef struct {
 } be_reg_data_t;
 
 typedef struct {
-       unsigned      magic;
-       const be_op_t *op;
-       int           n_regs;
-       be_reg_data_t reg_data[1];
+       int                         n_outs;
+       const arch_register_class_t *cls;
+       be_reg_data_t               *reg_data;
 } be_node_attr_t;
 
 typedef struct {
-       be_node_attr_t attr;
+       be_node_attr_t node_attr;
        ir_node *spill_ctx;  /**< The node in whose context this spill was introduced. */
        unsigned offset;     /**< The offset of the memory location the spill writes to
                                                   in the spill area. */
 } be_spill_attr_t;
 
+static ir_op *op_Spill;
+static ir_op *op_Reload;
+static ir_op *op_Perm;
+static ir_op *op_Copy;
+static ir_op *op_Keep;
 
-ir_node *new_Keep(ir_graph *irg, ir_node *bl, int n, ir_node *in[])
-{
-       static ir_op *keep_op = NULL;
-       ir_node *irn;
+static int beo_base = -1;
 
-       if(!keep_op)
-               keep_op = new_ir_op(get_next_ir_opcode(), "Keep", op_pin_state_pinned,
-                       irop_flag_keep, oparity_variable, 0, 0, NULL);
+static const ir_op_ops be_node_op_ops;
 
-       irn = new_ir_node(NULL, irg, bl, keep_op, mode_ANY, n, in);
-       keep_alive(irn);
+void be_node_init(void) {
+       static int inited = 0;
+       int i;
 
-       return irn;
-}
+       if(inited)
+               return;
 
-static int templ_pos_Spill[] = {
-       0
-};
+       inited = 1;
 
-static int templ_pos_Reload[] = {
-       -1
-};
+       beo_base = get_next_ir_opcode();
 
-static int templ_pos_Copy[] = {
-       0, -1
-};
+       /* Acquire all needed opcodes. We assume that they are consecutive! */
+       for(i = beo_Spill; i < beo_Last; ++i)
+               get_next_ir_opcode();
 
-static int templ_pos_Kill[] = {
-       0
-};
+       op_Spill  = new_ir_op(beo_base + beo_Spill,  "Spill",  op_pin_state_mem_pinned, 0, oparity_unary,    0, sizeof(be_spill_attr_t), &be_node_op_ops);
+       op_Reload = new_ir_op(beo_base + beo_Reload, "Reload", op_pin_state_mem_pinned, 0, oparity_zero,     0, sizeof(be_node_attr_t),  &be_node_op_ops);
+       op_Perm   = new_ir_op(beo_base + beo_Perm,   "Perm",   op_pin_state_pinned,     0, oparity_variable, 0, sizeof(be_node_attr_t),  &be_node_op_ops);
+       op_Copy   = new_ir_op(beo_base + beo_Copy,   "Copy",   op_pin_state_pinned,     0, oparity_unary,    0, sizeof(be_node_attr_t),  &be_node_op_ops);
+       op_Keep   = new_ir_op(beo_base + beo_Keep,   "Keep",   op_pin_state_pinned,     0, oparity_variable, 0, sizeof(be_node_attr_t),  &be_node_op_ops);
 
-static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason);
+       set_op_tag(op_Spill,  &be_node_tag);
+       set_op_tag(op_Reload, &be_node_tag);
+       set_op_tag(op_Perm,   &be_node_tag);
+       set_op_tag(op_Copy,   &be_node_tag);
+       set_op_tag(op_Keep,   &be_node_tag);
+}
 
-static const ir_op_ops be_node_ops = {
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       dump_node,
-       NULL
-};
+static void *init_node_attr(ir_node* irn, const arch_register_class_t *cls, ir_graph *irg, int n_outs)
+{
+       be_node_attr_t *a = get_irn_attr(irn);
+
+       a->n_outs   = n_outs;
+       a->cls      = cls;
+       a->reg_data = NULL;
+
+       if(n_outs > 0) {
+               int i;
+
+               a->reg_data = NEW_ARR_D(be_reg_data_t, get_irg_obstack(irg), n_outs);
+               memset(a->reg_data, 0, n_outs * sizeof(a->reg_data[0]));
+               for(i = 0; i < n_outs; ++i) {
+                       a->reg_data[i].req.cls  = cls;
+                       a->reg_data[i].req.type = arch_register_req_type_normal;
+               }
+       }
+
+       return a;
+}
 
 static INLINE int is_be_node(const ir_node *irn)
 {
-       const be_node_attr_t *attr = (const be_node_attr_t *) &irn->attr;
-       return attr->magic == BENODE_MAGIC;
+       return get_op_tag(get_irn_op(irn)) == &be_node_tag;
 }
 
-static INLINE int is_be_kind(const ir_node *irn, node_kind_t kind)
+be_opcode_t get_irn_be_opcode(const ir_node *irn)
 {
-       const be_node_attr_t *a = (const be_node_attr_t *) &irn->attr;
-       return a->magic == BENODE_MAGIC && a->op && a->op->kind == kind;
+       return is_be_node(irn) ? get_irn_opcode(irn) - beo_base : beo_NoBeOp;
 }
 
-static INLINE void *get_attr_and_check(ir_node *irn, node_kind_t kind)
+ir_node *be_new_Spill(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *to_spill, ir_node *ctx)
 {
-       is_be_kind(irn, kind);
-       return &irn->attr;
-}
+       be_spill_attr_t *a;
+       ir_node *in[1];
+       ir_node *res;
 
-static be_node_attr_t *init_node_attr(ir_node *irn,
-                                                                         const be_op_t *op,
-                                                                         const arch_register_class_t *cls,
-                                                                         int n_regs)
+       in[0] = to_spill;
+       res   = new_ir_node(NULL, irg, bl, op_Spill, mode_M, 1, in);
+       a     = init_node_attr(res, cls, irg, 0);
+       a->offset    = BE_SPILL_NO_OFFSET;
+       a->spill_ctx = ctx;
+       return res;
+}
 
+ir_node *be_new_Reload(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_mode *mode, ir_node *mem)
 {
-       be_node_attr_t *attr = (be_node_attr_t *) &irn->attr;
-       int i;
+       ir_node *in[1];
+       ir_node *res;
 
-       attr->magic   = BENODE_MAGIC;
-       attr->n_regs  = n_regs;
-       attr->op      = op;
+       in[0] = mem;
+       res   = new_ir_node(NULL, irg, bl, op_Reload, mode, 1, in);
+       init_node_attr(res, cls, irg, 1);
+       return res;
+}
 
-       for(i = 0; i < n_regs; ++i) {
-               be_reg_data_t *rd = attr->reg_data + i;
+ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
+{
+       ir_node *irn = new_ir_node(NULL, irg, bl, op_Perm, mode_T, n, in);
+       init_node_attr(irn, cls, irg, n);
+       return irn;
+}
 
-               memset(&rd->req, 0, sizeof(rd->req));
-               rd->reg         = NULL;
-               rd->req.cls     = cls;
-               rd->req.type    = arch_register_req_type_normal;
-       }
+ir_node *be_new_Copy(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *op)
+{
+       ir_node *in[1];
+       ir_node *res;
 
-       return attr;
+       in[0] = op;
+       res   = new_ir_node(NULL, irg, bl, op_Copy, get_irn_mode(op), 1, in);
+       init_node_attr(res, cls, irg, 1);
+       return res;
 }
 
-#define ARRSIZE(x) (sizeof(x) / sizeof(x[0]))
-
-static int cmp_op_map(const void *a, const void *b, size_t size)
+ir_node *be_new_Keep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
 {
-       const be_op_t *x = a;
-       const be_op_t *y = b;
+       ir_node *irn;
 
-       return !(x->kind == y->kind && x->cls == y->cls);
+       irn = new_ir_node(NULL, irg, bl, op_Keep, mode_ANY, n, in);
+       init_node_attr(irn, cls, irg, 0);
+       keep_alive(irn);
+       return irn;
 }
 
-static be_op_t *get_op(const be_node_factory_t *fact,
-               const arch_register_class_t *cls, node_kind_t kind)
+int be_is_Spill(const ir_node *irn)
 {
-       be_op_t templ;
-
-       templ.kind = kind;
-       templ.cls = cls;
+       return get_irn_be_opcode(irn) == beo_Spill;
+}
 
-       return set_insert(fact->ops, &templ, sizeof(templ),
-               HASH_PTR(cls) + 7 * kind);
+int be_is_Reload(const ir_node *irn)
+{
+       return get_irn_be_opcode(irn) == beo_Reload;
 }
 
+int be_is_Copy(const ir_node *irn)
+{
+       return get_irn_be_opcode(irn) == beo_Copy;
+}
 
+int be_is_Perm(const ir_node *irn)
+{
+       return get_irn_be_opcode(irn) == beo_Perm;
+}
 
-ir_node *new_Spill(const be_node_factory_t *factory,
-               const arch_register_class_t *cls,
-               ir_graph *irg, ir_node *bl, ir_node *node_to_spill, ir_node *ctx)
+int be_is_Keep(const ir_node *irn)
 {
-       be_spill_attr_t *a;
-       ir_node *irn;
-       ir_node *in[1];
-       be_op_t *bop = get_op(factory, cls, node_kind_spill);
-       ir_op *op    = bop->op;
+       return get_irn_be_opcode(irn) == beo_Keep;
+}
 
-       assert(op && "Spill opcode must be present for this register class");
-       in[0]        = node_to_spill;
-       irn          = new_ir_node(NULL, irg, bl, op, mode_M, 1, in);
-       a            = (be_spill_attr_t *) init_node_attr(irn, bop, cls, 0);
-       a->spill_ctx = ctx;
-       a->offset    = 0;
+void be_set_Perm_out_req(ir_node *irn, int pos, const arch_register_req_t *req)
+{
+       be_node_attr_t *a = get_irn_attr(irn);
 
-       return irn;
+       assert(be_is_Perm(irn));
+       assert(pos >= 0 && pos < get_irn_arity(irn));
+       memcpy(&a->reg_data[pos].req, req, sizeof(req[0]));
 }
 
-void set_Spill_offset(ir_node *irn, unsigned offset)
+void be_set_Spill_offset(ir_node *irn, unsigned offset)
 {
-       be_spill_attr_t *a = (be_spill_attr_t *) &irn->attr;
-       assert(is_be_kind(irn, node_kind_spill));
+       be_spill_attr_t *a = get_irn_attr(irn);
+       assert(be_is_Spill(irn));
        a->offset = offset;
 }
 
@@ -235,16 +255,16 @@ static ir_node *find_a_spill_walker(ir_node *irn, unsigned visited_nr)
                        }
                }
 
-               else if(is_be_kind(irn, node_kind_spill))
+               else if(get_irn_be_opcode(irn) == beo_Spill)
                        return irn;
        }
 
        return NULL;
 }
 
-ir_node *get_Spill_context(const ir_node *irn) {
-       be_spill_attr_t *a = (be_spill_attr_t *) &irn->attr;
-       assert(is_be_kind(irn, node_kind_spill));
+ir_node *be_get_Spill_context(const ir_node *irn) {
+       const be_spill_attr_t *a = get_irn_attr(irn);
+       assert(be_is_Spill(irn));
        return a->spill_ctx;
 }
 
@@ -259,87 +279,38 @@ static INLINE ir_node *find_a_spill(ir_node *irn)
        ir_graph *irg       = get_irn_irg(irn);
        unsigned visited_nr = get_irg_visited(irg) + 1;
 
-       assert(is_be_kind(irn, node_kind_reload));
+       assert(be_is_Reload(irn));
        set_irg_visited(irg, visited_nr);
        return find_a_spill_walker(irn, visited_nr);
 }
 
 
-unsigned get_Spill_offset(ir_node *irn)
+unsigned be_get_spill_offset(ir_node *irn)
 {
-       be_node_attr_t *a = (be_node_attr_t *) &irn->attr;
-       assert(is_be_node(irn));
+       int opc           = get_irn_opcode(irn);
 
-       switch(a->op->kind) {
-       case node_kind_reload:
-               assert(0 && "not yet implemented");
-               return get_Spill_offset(find_a_spill(irn));
-       case node_kind_spill:
-               return ((be_spill_attr_t *) a)->offset;
+       switch(get_irn_be_opcode(irn)) {
+       case beo_Reload:
+               return be_get_spill_offset(find_a_spill(irn));
+       case beo_Spill:
+               {
+                       be_spill_attr_t *a = get_irn_attr(irn);
+                       return a->offset;
+               }
        default:
-               assert(0 && "Illegal node kind (spill/reload required)");
+               assert(0 && "Must give spill/reload node");
        }
 
-       return 0;
-}
-
-ir_node *new_Reload(const be_node_factory_t *factory,
-               const arch_register_class_t *cls, ir_graph *irg,
-               ir_node *bl, ir_mode *mode, ir_node *spill_node)
-{
-       ir_node *irn, *in[1];
-       be_op_t *bop = get_op(factory, cls, node_kind_reload);
-       ir_op *op    = bop->op;
-
-       assert(op && "Reload opcode must be present for this register class");
-       in[0] = spill_node;
-
-       irn  = new_ir_node(NULL, irg, bl, op, mode, 1, in);
-       init_node_attr(irn, bop, cls, 1);
-
-       return irn;
+       return (unsigned) -1;
 }
 
-ir_node *new_Perm(const be_node_factory_t *factory,
-               const arch_register_class_t *cls,
-               ir_graph *irg, ir_node *bl, int arity, ir_node **in)
-{
-       ir_node *irn;
-       be_op_t *bop = get_op(factory, cls, node_kind_perm);
-       ir_op *op    = bop->op;
-
-       irn  = new_ir_node(NULL, irg, bl, op, mode_T, arity, in);
-       init_node_attr(irn, bop, cls, arity);
-
-       return irn;
-}
-
-ir_node *new_Copy(const be_node_factory_t *factory,
-               const arch_register_class_t *cls,
-               ir_graph *irg, ir_node *bl, ir_node *in)
-{
-       ir_node *irn, *ins[1];
-       be_op_t *bop = get_op(factory, cls, node_kind_copy);
-       ir_op *op    = bop->op;
-
-       ins[0] = in;
-
-       irn  = new_ir_node(NULL, irg, bl, op, get_irn_mode(in), 1, ins);
-       init_node_attr(irn, bop, cls, 1);
-
-       return irn;
-}
-
-ir_node *be_spill(
-               const be_node_factory_t *factory,
-               const arch_env_t *arch_env,
-               ir_node *irn, ir_node *ctx)
+ir_node *be_spill(const arch_env_t *arch_env, ir_node *irn, ir_node *ctx)
 {
        const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, irn, -1);
 
        ir_node *bl    = get_nodes_block(irn);
        ir_graph *irg  = get_irn_irg(bl);
-       ir_node *spill = new_Spill(factory, cls, irg, bl, irn, ctx);
+       ir_node *spill = be_new_Spill(cls, irg, bl, irn, ctx);
        ir_node *insert;
 
        /*
@@ -355,165 +326,133 @@ ir_node *be_spill(
        return spill;
 }
 
-ir_node *be_reload(const be_node_factory_t *factory,
-                                        const arch_env_t *arch_env,
-                                        const arch_register_class_t *cls,
-                                        ir_node *irn, int pos, ir_mode *mode, ir_node *spill)
+ir_node *be_reload(const arch_env_t *arch_env,
+                                  const arch_register_class_t *cls,
+                                  ir_node *irn, int pos, ir_mode *mode, ir_node *spill)
 {
        ir_node *reload;
 
        ir_node *bl   = get_nodes_block(irn);
        ir_graph *irg = get_irn_irg(bl);
 
-       assert(be_is_Spill(spill)
-                       || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
+       assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
 
-       reload = new_Reload(factory, cls, irg, bl, mode, spill);
+       reload = be_new_Reload(cls, irg, bl, mode, spill);
 
        set_irn_n(irn, pos, reload);
        sched_add_before(irn, reload);
        return reload;
 }
 
-/**
- * If the node is a proj, reset the node to the proj's target and return
- * the proj number.
- * @param node The address of a node pointer.
- * @param def  A default value.
- * @return     If *node is a Proj, *node is set to the Proj's target and
- *             the Proj number is returned. Else *node remains the same and @p def
- *             is returned.
- */
-static int redir_proj(const ir_node **node, int def)
+static int redir_proj(const ir_node **node, int pos)
 {
        const ir_node *n = *node;
 
        if(is_Proj(n)) {
+               assert(pos == -1 && "Illegal pos for a Proj");
                *node = get_Proj_pred(n);
-               def = -(get_Proj_proj(n) + 1);
+               return get_Proj_proj(n);
        }
 
-       return def;
+       return 0;
 }
 
-static const arch_register_req_t *
-be_node_get_irn_reg_req(const arch_irn_ops_t *_self,
-               arch_register_req_t *req, const ir_node *irn, int pos)
+static void *put_out_reg_req(arch_register_req_t *req, const ir_node *irn, int out_pos)
 {
-       /* We cannot get output requirements for tuple nodes. */
-       if(get_irn_mode(irn) == mode_T && pos < 0)
-               return NULL;
+       const be_node_attr_t *a = get_irn_attr(irn);
 
-       /*
-        * if we're interested in an output operand (pos < 0), so let's resolve projs.
-        */
-       if(pos < 0)
-               pos = redir_proj((const ir_node **) &irn, pos);
-
-       if(is_be_node(irn)) {
-               const be_node_attr_t *a = (const be_node_attr_t *) &irn->attr;
-               const be_op_t *bo       = a->op;
-               int i;
 
-               for(i = 0; i < bo->n_pos; ++i) {
-                       if(pos == bo->pos[i]) {
-
-                               /* be nodes have no input constraints.
-                                  so return normal register requirements. */
-                               if(pos >= 0) {
-                                       memset(req, 0, sizeof(req[0]));
-                                       req->cls = bo->cls;
-                                       req->type = arch_register_req_type_normal;
-                               }
-
-                               /*
-                                * if an output requirement is requested,
-                                * return the one stored in the node.
-                                */
-                               else
-                                       *req = a->reg_data[-pos - 1].req;
-
-                               return req;
-                       }
-               }
+       if(out_pos < a->n_outs)
+               memcpy(req, &a->reg_data[out_pos].req, sizeof(req[0]));
+       else {
+               req->type = arch_register_req_type_none;
+               req->cls  = NULL;
        }
 
-       return NULL;
+       return req;
 }
 
-void be_set_Perm_out_req(ir_node *irn, int pos, const arch_register_req_t *req)
+static void *put_in_reg_req(arch_register_req_t *req, const ir_node *irn, int pos)
 {
-       be_node_attr_t *a = get_attr_and_check(irn, node_kind_perm);
-       assert(pos >= 0 && pos < get_irn_arity(irn) && "position out of range");
-       a->reg_data[pos].req = *req;
+       const be_node_attr_t *a = get_irn_attr(irn);
+       int n                   = get_irn_arity(irn);
+
+       req->type = arch_register_req_type_none;
+       req->cls  = NULL;
+
+       switch(get_irn_be_opcode(irn)) {
+       case beo_Spill:
+       case beo_Copy:
+       case beo_Keep:
+       case beo_Perm:
+               if(pos < n) {
+                       req->type = arch_register_req_type_normal;
+                       req->cls  = a->cls;
+               }
+               break;
+       case beo_Reload:
+       default:
+               req = NULL;
+       }
+
+       return req;
 }
 
-void
-be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn,
-               const arch_register_t *reg)
+static const arch_register_req_t *
+be_node_get_irn_reg_req(const arch_irn_ops_t *self, arch_register_req_t *req, const ir_node *irn, int pos)
 {
-       int pos;
-       be_op_t *bo;
-       be_node_attr_t *attr;
-       const be_node_factory_t *factory =
-               container_of(_self, const be_node_factory_t, irn_ops);
+       int out_pos = redir_proj((const ir_node **) &irn, pos);
 
-       if(get_irn_mode(irn) == mode_T)
-               return;
+       if(pos < 0 && get_irn_mode(irn) == mode_T)
+               return NULL;
 
-       pos = redir_proj((const ir_node **) &irn, -1);
-       bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
+       if(!is_be_node(irn))
+               return NULL;
 
-       if(!bo)
-               return;
+       req = pos >= 0 ? put_in_reg_req(req, irn, pos) : put_out_reg_req(req, irn, out_pos);
 
-       attr = (be_node_attr_t *) &irn->attr;
-       attr->reg_data[-pos - 1].reg = reg;
+       return req;
 }
 
-const arch_register_t *
-be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn)
+static void
+be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn, const arch_register_t *reg)
 {
-       int i, pos;
-       be_op_t *bo;
-       const be_node_factory_t *factory =
-               container_of(_self, const be_node_factory_t, irn_ops);
+       int out_pos;
+       be_node_attr_t *a;
 
-       if(get_irn_mode(irn) == mode_T)
-               return NULL;
+       out_pos = redir_proj(&irn, -1);
+       a       = get_irn_attr(irn);
+
+       assert(is_be_node(irn));
+       assert(out_pos < a->n_outs && "position too high");
+       a->reg_data[out_pos].reg = reg;
+}
 
-       pos = redir_proj((const ir_node **) &irn, -1);
-       bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
+const arch_register_t *
+be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn)
+{
+       int out_pos;
+       be_node_attr_t *a;
 
-       if(!bo)
-               return NULL;
+       out_pos = redir_proj(&irn, -1);
+       a       = get_irn_attr(irn);
 
-       for(i = 0; i < bo->n_pos; ++i) {
-               if(bo->pos[i] == pos) {
-                       be_node_attr_t *attr = (be_node_attr_t *) &irn->attr;
-                       return attr->reg_data[-pos - 1].reg;
-               }
-       }
+       assert(is_be_node(irn));
+       assert(out_pos < a->n_outs && "position too high");
 
-       return NULL;
+       return a->reg_data[out_pos].reg;
 }
 
 arch_irn_class_t be_node_classify(const arch_irn_ops_t *_self, const ir_node *irn)
 {
-       const be_node_factory_t *factory = container_of(_self, const be_node_factory_t, irn_ops);
-
-       be_op_t *bo;
-       int idx;
+       redir_proj(&irn, -1);
 
-       idx = redir_proj(&irn, 0);
-       bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
-
-       switch(bo->kind) {
-#define XXX(a) case node_kind_ ## a: return arch_irn_class_ ## a;
-               XXX(spill)
-               XXX(reload)
-               XXX(perm)
-               XXX(copy)
+       switch(get_irn_be_opcode(irn)) {
+#define XXX(a,b) case beo_ ## a: return arch_irn_class_ ## b;
+               XXX(Spill, spill)
+               XXX(Reload, reload)
+               XXX(Perm, perm)
+               XXX(Copy, copy)
 #undef XXX
                default:
                return 0;
@@ -527,131 +466,47 @@ arch_irn_class_t be_node_get_flags(const arch_irn_ops_t *_self, const ir_node *i
        return 0;
 }
 
-static const arch_irn_ops_t *
-be_node_get_irn_ops(const arch_irn_handler_t *_self, const ir_node *irn)
-{
-       be_op_t *bo;
-       const be_node_factory_t *factory =
-               container_of(_self, const be_node_factory_t, handler);
-
-       redir_proj(&irn, 0);
-       bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
-
-       return bo ? &factory->irn_ops : NULL;
-}
-
-const arch_irn_handler_t *be_node_get_irn_handler(const be_node_factory_t *f)
-{
-       return &f->handler;
-}
-
-int be_is_Spill(const ir_node *irn)
-{
-       return is_be_kind(irn, node_kind_spill);
-}
-
-int be_is_Reload(const ir_node *irn)
-{
-       return is_be_kind(irn, node_kind_reload);
-}
-
-int be_is_Copy(const ir_node *irn)
-{
-       return is_be_kind(irn, node_kind_copy);
-}
+static const arch_irn_ops_t be_node_irn_ops = {
+       be_node_get_irn_reg_req,
+       be_node_set_irn_reg,
+       be_node_get_irn_reg,
+       be_node_classify,
+       be_node_get_flags,
+};
 
-int be_is_Perm(const ir_node *irn)
+const arch_irn_ops_t *be_node_get_arch_ops(const arch_irn_handler_t *self, const ir_node *irn)
 {
-       return is_be_kind(irn, node_kind_perm);
+       redir_proj((const ir_node **) &irn, -1);
+       return is_be_node(irn) ? &be_node_irn_ops : NULL;
 }
 
-
-be_node_factory_t *be_node_factory_init(be_node_factory_t *factory, const arch_isa_t *isa)
-{
-       int i, j, n;
-
-       factory->ops = new_set(cmp_op_map, 64);
-       factory->irn_op_map = pmap_create();
-       obstack_init(&factory->obst);
-
-       factory->handler.get_irn_ops = be_node_get_irn_ops;
-
-       factory->irn_ops.get_irn_reg_req = be_node_get_irn_reg_req;
-       factory->irn_ops.set_irn_reg     = be_node_set_irn_reg;
-       factory->irn_ops.get_irn_reg     = be_node_get_irn_reg;
-       factory->irn_ops.classify        = be_node_classify;
-       factory->irn_ops.get_flags       = be_node_get_flags;
-
-       for(i = 0, n = arch_isa_get_n_reg_class(isa); i < n; ++i) {
-               const arch_register_class_t *cls = arch_isa_get_reg_class(isa, i);
-               be_op_t *ent;
-
-               ent = get_op(factory, cls, node_kind_spill);
-               ent->op = new_ir_op(get_next_ir_opcode(), "Spill", op_pin_state_pinned,
-                               0, oparity_unary, 0, sizeof(be_spill_attr_t), &be_node_ops);
-               ent->n_pos = ARRSIZE(templ_pos_Spill);
-               ent->pos = templ_pos_Spill;
-               pmap_insert(factory->irn_op_map, ent->op, ent);
-
-               ent = get_op(factory, cls, node_kind_reload);
-               ent->op = new_ir_op(get_next_ir_opcode(), "Reload", op_pin_state_pinned, 0,
-                               oparity_unary, 0, sizeof(be_node_attr_t), &be_node_ops);
-               ent->n_pos = ARRSIZE(templ_pos_Reload);
-               ent->pos = templ_pos_Reload;
-               pmap_insert(factory->irn_op_map, ent->op, ent);
-
-               ent = get_op(factory, cls, node_kind_copy);
-               ent->op = new_ir_op(get_next_ir_opcode(), "Copy", op_pin_state_pinned, 0,
-                               oparity_unary, 0, sizeof(be_node_attr_t), &be_node_ops);
-               ent->n_pos = ARRSIZE(templ_pos_Copy);
-               ent->pos = templ_pos_Copy;
-               pmap_insert(factory->irn_op_map, ent->op, ent);
-
-               ent = get_op(factory, cls, node_kind_perm);
-               ent->op = new_ir_op(get_next_ir_opcode(), "Perm", op_pin_state_pinned, 0,
-                               oparity_variable, 0,
-                               sizeof(be_node_attr_t)
-                               + sizeof(be_reg_data_t) * cls->n_regs, &be_node_ops);
-               ent->n_pos = 2 * cls->n_regs;
-               ent->pos = obstack_alloc(&factory->obst, sizeof(ent->pos[0]) * ent->n_pos);
-               for(j = 0; j < ent->n_pos; j += 2) {
-                       int k = j / 2;
-                       ent->pos[j] = k;
-                       ent->pos[j + 1] = -(k + 1);
-               }
-               pmap_insert(factory->irn_op_map, ent->op, ent);
-
-       }
-
-       return factory;
-}
+const arch_irn_handler_t be_node_irn_handler = {
+       be_node_get_arch_ops
+};
 
 static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
 {
-       be_node_attr_t *at = (be_node_attr_t *) &irn->attr;
-       const be_op_t *bo;
+       be_node_attr_t *at = get_irn_attr(irn);
        int i;
 
        assert(is_be_node(irn));
-       bo = at->op;
 
        switch(reason) {
                case dump_node_opcode_txt:
-                       fprintf(f, get_op_name(bo->op));
+                       fprintf(f, get_op_name(get_irn_op(irn)));
                        break;
                case dump_node_mode_txt:
                        fprintf(f, get_mode_name(get_irn_mode(irn)));
                        break;
                case dump_node_nodeattr_txt:
-                       fprintf(f, "%s ", bo->cls->name);
                        break;
                case dump_node_info_txt:
-                       for(i = 0; i < at->n_regs; ++i) {
+                       for(i = 0; i < at->n_outs; ++i) {
                                const arch_register_t *reg = at->reg_data[i].reg;
                                fprintf(f, "reg #%d: %s\n", i, reg ? reg->name : "n/a");
                        }
 
-                       if(bo->kind == node_kind_spill) {
+                       if(get_irn_be_opcode(irn) == beo_Spill) {
                                be_spill_attr_t *a = (be_spill_attr_t *) at;
                                ir_fprintf(f, "spill context: %+F\n", a->spill_ctx);
                                ir_fprintf(f, "spill offset: %u\n", a->offset);
@@ -662,12 +517,27 @@ static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
        return 0;
 }
 
-ir_node *insert_Perm_after(const be_main_env_t *env,
-                                                        const arch_register_class_t *cls,
-                                                        dom_front_info_t *dom_front,
-                                                        ir_node *pos)
+static const ir_op_ops be_node_op_ops = {
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       dump_node,
+       NULL
+};
+
+ir_node *insert_Perm_after(const arch_env_t *arch_env,
+                                                  const arch_register_class_t *cls,
+                                                  dom_front_info_t *dom_front,
+                                                  ir_node *pos)
 {
-       const arch_env_t *arch_env  = env->arch_env;
        ir_node *bl                 = is_Block(pos) ? pos : get_nodes_block(pos);
        ir_graph *irg               = get_irn_irg(bl);
        pset *live                  = pset_new_ptr_default();
@@ -720,7 +590,7 @@ ir_node *insert_Perm_after(const be_main_env_t *env,
                nodes[i] = irn;
        }
 
-       perm = new_Perm(env->node_factory, cls, irg, bl, n, nodes);
+       perm = be_new_Perm(cls, irg, bl, n, nodes);
        sched_add_after(pos, perm);
        free(nodes);
 
@@ -738,7 +608,7 @@ ir_node *insert_Perm_after(const be_main_env_t *env,
                curr = proj;
 
                copies[0] = proj;
-               be_introduce_copies(dom_front, perm_op, array_size(copies), copies);
+               be_introduce_copies(dom_front, perm_op, 1, copies);
        }
        return perm;
 }
index 785b788..55bb360 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef _BENODE_T_H
 #define _BENODE_T_H
 
+#include "firm_config.h"
 #include "pmap.h"
 
 #include "irmode.h"
 #include "be_t.h"
 #include "bearch.h"
 
-struct _be_node_factory_t {
-  const arch_isa_if_t *isa;
+#define BE_SPILL_NO_OFFSET ((unsigned) -1)
 
-  struct obstack      obst;
-  set                 *ops;
-  pmap                *irn_op_map;
-  pmap                *reg_req_map;
+typedef enum {
+       beo_NoBeOp = 0,
+       beo_Spill,
+       beo_Reload,
+       beo_Perm,
+       beo_Copy,
+       beo_Keep,
+       beo_Last
+} be_opcode_t;
 
-  arch_irn_handler_t  handler;
-  arch_irn_ops_t      irn_ops;
-};
+void be_node_init(void);
 
-typedef struct _be_node_factory_t                      be_node_factory_t;
+const arch_irn_handler_t be_node_irn_handler;
 
-be_node_factory_t *be_node_factory_init(be_node_factory_t *factory, const arch_isa_t *isa);
+ir_node *be_new_Spill(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *node_to_spill, ir_node *ctx);
+ir_node *be_new_Reload(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_mode *mode, ir_node *spill_node);
+ir_node *be_new_Copy(const arch_register_class_t *cls, ir_graph *irg, ir_node *block, ir_node *in);
+ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int arity, ir_node *in[]);
+ir_node *be_new_Keep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int arity, ir_node *in[]);
 
-const arch_irn_handler_t *be_node_get_irn_handler(const be_node_factory_t *f);
-
-ir_node *new_Spill(const be_node_factory_t *factory,
-    const arch_register_class_t *cls,
-    ir_graph *irg, ir_node *bl, ir_node *node_to_spill, ir_node *ctx);
-
-ir_node *new_Reload(const be_node_factory_t *factory,
-    const arch_register_class_t *cls, ir_graph *irg,
-    ir_node *bl, ir_mode *mode, ir_node *spill_node);
-
-ir_node *new_Perm(const be_node_factory_t *factory,
-    const arch_register_class_t *cls,
-    ir_graph *irg, ir_node *bl, int arity, ir_node **in);
-
-ir_node *new_Copy(const be_node_factory_t *factory,
-    const arch_register_class_t *cls,
-    ir_graph *irg, ir_node *block, ir_node *in);
-
-ir_node *be_spill(
-               const be_node_factory_t *factory,
-               const arch_env_t *arch_env,
-               ir_node *irn,
-               ir_node *spill_ctx);
-
-ir_node *be_reload(
-               const be_node_factory_t *factory,
-               const arch_env_t *arch_env,
-               const arch_register_class_t *cls,
-               ir_node *irn, int pos, ir_mode *mode, ir_node *spill);
-
-ir_node *new_Keep(ir_graph *irg, ir_node *bl, int n, ir_node *in[]);
+ir_node *be_spill(const arch_env_t *arch_env, ir_node *irn,ir_node *spill_ctx);
+ir_node *be_reload(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_node *irn, int pos, ir_mode *mode, ir_node *spill);
 
 int be_is_Spill(const ir_node *irn);
 int be_is_Reload(const ir_node *irn);
 int be_is_Copy(const ir_node *irn);
 int be_is_Perm(const ir_node *irn);
+int be_is_Keep(const ir_node *irn);
 
-const arch_register_class_t *be_node_get_reg_class(const ir_node *irn);
-
-void set_Spill_offset(ir_node *irn, unsigned offset);
-unsigned get_Spill_offset(ir_node *irn);
+void be_set_Spill_offset(ir_node *irn, unsigned offset);
+unsigned be_get_spill_offset(ir_node *irn);
 
-ir_node *get_Spill_context(const ir_node *irn);
+ir_node *be_get_Spill_context(const ir_node *irn);
 
 
 /**
@@ -95,7 +72,7 @@ void be_set_Perm_out_req(ir_node *irn, int pos, const arch_register_req_t *req);
  * This means that all liveness intervals are cut apart at this
  * location in the program.
  */
-ir_node *insert_Perm_after(const be_main_env_t *env,
+ir_node *insert_Perm_after(const arch_env_t *env,
                                                   const arch_register_class_t *cls,
                                                   dom_front_info_t *dom_front,
                                                   ir_node *pos);
index 7680f90..5afee30 100644 (file)
@@ -27,6 +27,8 @@ typedef struct {
        void (*allocate)(const be_main_env_t *env, ir_graph *irg);
 } be_ra_t;
 
+
+
 /**
  * Check, if two values interfere.
  * @param a The first value.
index c7571a9..e85e47a 100644 (file)
@@ -73,7 +73,7 @@ int sched_verify(const ir_node *block)
   const ir_node *irn;
   int i, n;
   int *save_time_step;
-  const ir_node **save_nodes;
+  ir_node **save_nodes;
   const ir_edge_t *edge;
   pset *scheduled_nodes = pset_new_ptr_default();
 
index d21d62e..9b35df1 100644 (file)
@@ -105,7 +105,7 @@ static ir_node *be_spill_irn(spill_env_t *senv, ir_node *irn, ir_node *ctx_irn)
        ctx = be_get_spill_ctx(senv->spill_ctxs, irn, ctx_irn);
        if(!ctx->spill) {
                const be_main_env_t *env = senv->chordal_env->main_env;
-               ctx->spill = be_spill(env->node_factory, env->arch_env, irn, ctx_irn);
+               ctx->spill = be_spill(env->arch_env, irn, ctx_irn);
        }
 
        return ctx->spill;
@@ -219,8 +219,7 @@ void be_insert_spills_reloads(spill_env_t *senv, pset *reload_set) {
 
                        /* the reload */
                        ir_node *bl      = is_Block(rld->reloader) ? rld->reloader : get_nodes_block(rld->reloader);
-                       ir_node *reload  = new_Reload(senv->chordal_env->main_env->node_factory,
-                               senv->cls, irg, bl, mode, spill);
+                       ir_node *reload  = be_new_Reload(senv->cls, irg, bl, mode, spill);
 
                        DBG((senv->dbg, LEVEL_1, " %+F of %+F before %+F\n", reload, si->spilled_node, rld->reloader));
                        if(reload_set)
@@ -302,7 +301,7 @@ static void compute_spill_slots_walker(ir_node *spill, void *env) {
                return;
 
        /* check, if this spill is for a context already known */
-       ctx = get_Spill_context(spill);
+       ctx = be_get_Spill_context(spill);
        entry = pmap_find(ssenv->slots, ctx);
 
        if (!entry) {
@@ -411,7 +410,7 @@ interf_detected: /*nothing*/ ;
                        if (tgt_slot != i)
                                pset_insert_ptr(ass[tgt_slot]->members, n1);
 
-                       set_Spill_offset(n1, ass[tgt_slot]->offset);
+                       be_set_Spill_offset(n1, ass[tgt_slot]->offset);
                        DBG((ssenv->dbg, LEVEL_1, "    Offset %+F  %d\n", n1, ass[tgt_slot]->offset));
                }
        }
index 4e588b7..5fa5af5 100644 (file)
@@ -56,7 +56,6 @@ typedef struct _workset_t workset_t;
 
 typedef struct _belady_env_t {
        struct obstack ob;
-       const be_node_factory_t *factory;
        const arch_env_t *arch;
        const arch_register_class_t *cls;
        int n_regs;                     /** number of regs in this reg-class */
@@ -292,7 +291,7 @@ static void compute_block_start_info(ir_node *blk, void *env) {
                for (max=get_irn_arity(irn), o=0; o<max; ++o) {
                        ir_node *arg = get_irn_n(irn, o);
                        ir_node *pred_block = get_Block_cfgpred_block(get_nodes_block(irn), o);
-                       ir_node *cpy = new_Copy(bel->factory, bel->cls, irg, pred_block, arg);
+                       ir_node *cpy = be_new_Copy(bel->cls, irg, pred_block, arg);
                        DBG((dbg, DBG_START, "    place a %+F of %+F in %+F\n", cpy, arg, pred_block));
                        sched_add_before(pred_block, cpy);
                        set_irn_n(irn, o, cpy);
@@ -563,7 +562,6 @@ void be_spill_belady(const be_chordal_env_t *chordal_env) {
 
        /* init belady env */
        obstack_init(&bel.ob);
-       bel.factory = chordal_env->main_env->node_factory;
        bel.arch    = chordal_env->main_env->arch_env;
        bel.cls     = chordal_env->cls;
        bel.n_regs  = arch_register_class_n_regs(bel.cls);
index 681dfd3..211521c 100644 (file)
@@ -85,7 +85,6 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
        be_chordal_env_t *chordal_env = data;
        pmap *perm_map = chordal_env->data;
        ir_graph *irg = chordal_env->irg;
-       const be_node_factory_t *fact = chordal_env->main_env->node_factory;
        int i, n;
 
        assert(is_Block(bl));
@@ -139,7 +138,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
                        for(pp = set_first(arg_set); pp; pp = set_next(arg_set))
                                in[pp->pos] = pp->arg;
 
-                       perm = new_Perm(fact, chordal_env->cls, irg, pred_bl, n_projs, in);
+                       perm = be_new_Perm(chordal_env->cls, irg, pred_bl, n_projs, in);
                        free(in);
                        insert_after = sched_skip(sched_last(pred_bl), 0, sched_skip_cf_predicator, chordal_env->main_env->arch_env);
                        sched_add_after(insert_after, perm);
@@ -223,7 +222,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
                                 * insert it into schedule,
                                 * pin it
                                 */
-                               ir_node *dupl = new_Copy(chordal_env->main_env->node_factory, cls, chordal_env->irg, arg_block, arg);
+                               ir_node *dupl = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
                                assert(get_irn_mode(phi) == get_irn_mode(dupl));
                                set_irn_n(phi, i, dupl);
                                set_reg(dupl, phi_reg);
@@ -274,7 +273,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
                                 */
                                ir_node *perm = get_Proj_pred(arg);
                                ir_node *orig_val = get_irn_n(perm, get_Proj_proj(arg));
-                               ir_node *dupl = new_Copy(chordal_env->main_env->node_factory, cls, chordal_env->irg, arg_block, orig_val);
+                               ir_node *dupl = be_new_Copy(cls, chordal_env->irg, arg_block, orig_val);
                                assert(get_irn_mode(phi) == get_irn_mode(dupl));
                                set_irn_n(phi, i, dupl);
                                set_reg(dupl, phi_reg);
index dbec46d..ed68e6a 100644 (file)
@@ -200,7 +200,7 @@ static const arch_register_req_t firm_std_reg_req = {
   arch_register_req_type_normal,
   &reg_classes[CLS_DATAB],
   NULL,
-  0
+  NULL
 };
 
 static const arch_register_req_t *