Commit 75070034 authored by Sebastian Hack's avatar Sebastian Hack
Browse files

Adapted to new benode.c

parent 2e05b466
......@@ -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
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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 */
......
......@@ -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);
}
This diff is collapsed.
......@@ -12,6 +12,7 @@
#ifndef _BENODE_T_H
#define _BENODE_T_H
#include "firm_config.h"
#include "pmap.h"
#include "irmode.h"
......@@ -20,65 +21,41 @@
#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);
......
......@@ -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.
......
......@@ -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();
......
......@@ -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));
}
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment