Commit 71712d24 authored by Michael Beck's avatar Michael Beck
Browse files

- removed obstack from be_main_env_t, it was only used to allocate one...

- removed obstack from be_main_env_t, it was only used to allocate one arch_env, which is now part of the environment itself
- removed unused static variable
- add (yet unfunctional) -b gprof switch
- renamed printev into more logical filtev
- some docu added

[r19264]
parent 95fbf32c
......@@ -593,7 +593,7 @@ static const arch_code_generator_if_t arm_code_gen_if = {
*/
static void *arm_cg_init(be_irg_t *birg) {
static ir_type *int_tp = NULL;
arm_isa_t *isa = (arm_isa_t *)birg->main_env->arch_env->isa;
arm_isa_t *isa = (arm_isa_t *)birg->main_env->arch_env.isa;
arm_code_gen_t *cg;
if (! int_tp) {
......@@ -605,7 +605,7 @@ static void *arm_cg_init(be_irg_t *birg) {
cg->impl = &arm_code_gen_if;
cg->irg = birg->irg;
cg->reg_set = new_set(arm_cmp_irn_reg_assoc, 1024);
cg->arch_env = birg->main_env->arch_env;
cg->arch_env = &birg->main_env->arch_env;
cg->isa = isa;
cg->birg = birg;
cg->int_tp = int_tp;
......
......@@ -34,7 +34,7 @@
#include "pmap.h"
#include "be.h"
#include "bearch.h"
#include "bearch_t.h"
#include "beirg.h"
#define DUMP_NONE 0
......@@ -69,24 +69,24 @@ struct be_options_t {
int opt_profile; /**< instrument code for profiling */
int omit_fp; /**< try to omit the frame pointer */
int pic; /**< create position independent code */
int gprof; /**< create gprof compatible profiling code */
int vrfy_option; /**< backend verify option */
int scheduler; /**< the scheduler */
char target_os[128]; /**< target operating system name */
char ilp_server[128]; /**< the ilp server name */
char ilp_solver[128]; /**< the ilp solver name */
int statev; /**< enable stat event dumping */
char printev[128];
char filtev[128]; /**< filter mask for stat events (regex is supported) */
};
struct be_main_env_t {
struct obstack obst;
arch_env_t *arch_env;
be_options_t *options;
arch_env_t arch_env;
be_options_t *options; /**< backend options */
arch_code_generator_t *cg;
arch_irn_handler_t *phi_handler;
const char *cup_name;
pmap *ent_trampoline_map;
ir_type *pic_trampolines_type;
const char *cup_name; /**< name of the compilation unit */
pmap *ent_trampoline_map; /**< A map containing PIC trampolines for methods. */
ir_type *pic_trampolines_type; /**< Class type containing all trampolines */
pmap *ent_pic_symbol_map;
ir_type *pic_symbols_type;
};
......
......@@ -115,7 +115,6 @@ static heights_t *ir_heights;
/* Flag: if set, try to omit the frame pointer if called by the backend */
static int be_omit_fp = 1;
static int be_pic = 0;
/*
_ ____ ___ ____ _ _ _ _
......@@ -410,7 +409,7 @@ static INLINE int is_on_stack(be_abi_call_t *call, int pos)
static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
{
ir_graph *irg = env->birg->irg;
const arch_env_t *arch_env = env->birg->main_env->arch_env;
const arch_env_t *arch_env = &env->birg->main_env->arch_env;
const arch_isa_t *isa = arch_env->isa;
ir_type *call_tp = get_Call_type(irn);
ir_node *call_ptr = get_Call_ptr(irn);
......@@ -1202,7 +1201,7 @@ static void process_calls(be_abi_irg_t *env)
static ir_type *compute_arg_type(be_abi_irg_t *env, be_abi_call_t *call, ir_type *method_type, ir_entity ***param_map)
{
int dir = env->call->flags.bits.left_to_right ? 1 : -1;
int inc = env->birg->main_env->arch_env->isa->stack_dir * dir;
int inc = env->birg->main_env->arch_env.isa->stack_dir * dir;
int n = get_method_n_params(method_type);
int curr = inc > 0 ? 0 : n - 1;
int ofs = 0;
......@@ -1363,13 +1362,13 @@ static ir_node *create_barrier(be_abi_irg_t *env, ir_node *bl, ir_node **mem, pm
be_set_constr_single_reg(irn, n, reg);
be_set_constr_single_reg(irn, pos, reg);
be_node_set_reg_class(irn, pos, reg->reg_class);
arch_set_irn_register(env->birg->main_env->arch_env, proj, reg);
arch_set_irn_register(&env->birg->main_env->arch_env, proj, reg);
/* if the proj projects a ignore register or a node which is set to ignore, propagate this property. */
if(arch_register_type_is(reg, ignore) || arch_irn_is(env->birg->main_env->arch_env, in[n], ignore))
if(arch_register_type_is(reg, ignore) || arch_irn_is(&env->birg->main_env->arch_env, in[n], ignore))
flags |= arch_irn_flags_ignore;
if(arch_irn_is(env->birg->main_env->arch_env, in[n], modify_sp))
if(arch_irn_is(&env->birg->main_env->arch_env, in[n], modify_sp))
flags |= arch_irn_flags_modify_sp;
be_node_set_flags(irn, pos, flags);
......@@ -1397,8 +1396,8 @@ static ir_node *create_barrier(be_abi_irg_t *env, ir_node *bl, ir_node **mem, pm
static ir_node *create_be_return(be_abi_irg_t *env, ir_node *irn, ir_node *bl,
ir_node *mem, int n_res)
{
be_abi_call_t *call = env->call;
const arch_isa_t *isa = env->birg->main_env->arch_env->isa;
be_abi_call_t *call = env->call;
const arch_isa_t *isa = env->birg->main_env->arch_env.isa;
dbg_info *dbgi;
pmap *reg_map = pmap_create();
ir_node *keep = pmap_get(env->keep_map, bl);
......@@ -1696,7 +1695,7 @@ static void fix_start_block(ir_node *block, void *env) {
static void modify_irg(be_abi_irg_t *env)
{
be_abi_call_t *call = env->call;
const arch_isa_t *isa = env->birg->main_env->arch_env->isa;
const arch_isa_t *isa = env->birg->main_env->arch_env.isa;
const arch_register_t *sp = arch_isa_sp(isa);
ir_graph *irg = env->birg->irg;
ir_node *bl = get_irg_start_block(irg);
......@@ -1837,7 +1836,7 @@ static void modify_irg(be_abi_irg_t *env)
proj = new_r_Proj(irg, reg_params_bl, env->reg_params, mode, nr);
pmap_insert(env->regs, (void *) reg, proj);
be_set_constr_single_reg(env->reg_params, pos, reg);
arch_set_irn_register(env->birg->main_env->arch_env, proj, reg);
arch_set_irn_register(&env->birg->main_env->arch_env, proj, reg);
/*
* If the register is an ignore register,
......@@ -1874,7 +1873,7 @@ static void modify_irg(be_abi_irg_t *env)
create_barrier(env, bl, &mem, env->regs, 0);
env->init_sp = be_abi_reg_map_get(env->regs, sp);
arch_set_irn_register(env->birg->main_env->arch_env, env->init_sp, sp);
arch_set_irn_register(&env->birg->main_env->arch_env, env->init_sp, sp);
frame_pointer = be_abi_reg_map_get(env->regs, fp_reg);
set_irg_frame(irg, frame_pointer);
......@@ -1994,7 +1993,7 @@ void fix_call_state_inputs(be_abi_irg_t *env)
arity = get_irn_arity(call);
/* the statereg inputs are the last n inputs of the calls */
/* the state reg inputs are the last n inputs of the calls */
for(s = 0; s < n_states; ++s) {
int inp = arity - n_states + s;
const arch_register_t *reg = stateregs[s];
......@@ -2005,6 +2004,9 @@ void fix_call_state_inputs(be_abi_irg_t *env)
}
}
/**
* Create a trampoline entity for the given method.
*/
static ir_entity *create_trampoline(be_main_env_t *be, ir_entity *method)
{
ir_type *type = get_entity_type(method);
......@@ -2019,6 +2021,9 @@ static ir_entity *create_trampoline(be_main_env_t *be, ir_entity *method)
return ent;
}
/**
* Returns the trampoline entity for the given method.
*/
static ir_entity *get_trampoline(be_main_env_t *env, ir_entity *method)
{
ir_entity *result = pmap_get(env->ent_trampoline_map, method);
......@@ -2030,6 +2035,9 @@ static ir_entity *get_trampoline(be_main_env_t *env, ir_entity *method)
return result;
}
/**
* Returns non-zero if a given entity can be accessed using a relative address.
*/
static int can_address_relative(ir_entity *entity)
{
return get_entity_variability(entity) == variability_initialized
......@@ -2117,11 +2125,10 @@ be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
unsigned *limited_bitset;
be_omit_fp = birg->main_env->options->omit_fp;
be_pic = birg->main_env->options->pic;
obstack_init(&env->obst);
env->isa = birg->main_env->arch_env->isa;
env->isa = birg->main_env->arch_env.isa;
env->method_type = get_entity_type(get_irg_entity(irg));
env->call = be_abi_call_new(env->isa->sp->reg_class);
arch_isa_get_call_abi(env->isa, env->method_type, env->call);
......@@ -2150,7 +2157,7 @@ be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
env->calls = NEW_ARR_F(ir_node*, 0);
if (be_pic) {
if (birg->main_env->options->pic) {
irg_walk_graph(irg, fix_pic_symconsts, NULL, env);
}
......@@ -2161,7 +2168,7 @@ be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
Beware: init backend abi call object after processing calls,
otherwise some information might be not yet available.
*/
env->cb = env->call->cb->init(env->call, birg->main_env->arch_env, irg);
env->cb = env->call->cb->init(env->call, &birg->main_env->arch_env, irg);
/* Process the IRG */
modify_irg(env);
......@@ -2257,7 +2264,7 @@ void be_abi_fix_stack_nodes(be_abi_irg_t *env)
arch_isa_t *isa;
walker_env.sp_nodes = NEW_ARR_F(ir_node*, 0);
walker_env.arch_env = birg->main_env->arch_env;
walker_env.arch_env = &birg->main_env->arch_env;
isa = walker_env.arch_env->isa;
irg_walk_graph(birg->irg, collect_stack_nodes_walker, NULL, &walker_env);
......@@ -2303,7 +2310,7 @@ void be_abi_fix_stack_nodes(be_abi_irg_t *env)
static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias)
{
const arch_env_t *arch_env = env->birg->main_env->arch_env;
const arch_env_t *arch_env = &env->birg->main_env->arch_env;
int omit_fp = env->call->flags.bits.try_omit_fp;
ir_node *irn;
int wanted_bias = real_bias;
......
......@@ -180,7 +180,7 @@ static INLINE border_t *border_add(be_chordal_env_t *env, struct list_head *head
*/
static INLINE int has_reg_class(const be_chordal_env_t *env, const ir_node *irn)
{
return arch_irn_consider_in_reg_alloc(env->birg->main_env->arch_env, env->cls, irn);
return arch_irn_consider_in_reg_alloc(&env->birg->main_env->arch_env, env->cls, irn);
}
#define has_limited_constr(req, irn) \
......@@ -225,7 +225,7 @@ static be_insn_t *chordal_scan_insn(be_chordal_env_t *env, ir_node *irn)
be_insn_env_t ie;
ie.ignore_colors = env->ignore_colors;
ie.aenv = env->birg->main_env->arch_env;
ie.aenv = &env->birg->main_env->arch_env;
ie.obst = env->obst;
ie.cls = env->cls;
return be_scan_insn(&ie, irn);
......@@ -234,7 +234,7 @@ static be_insn_t *chordal_scan_insn(be_chordal_env_t *env, ir_node *irn)
static ir_node *prepare_constr_insn(be_chordal_env_t *env, ir_node *irn)
{
const be_irg_t *birg = env->birg;
const arch_env_t *aenv = birg->main_env->arch_env;
const arch_env_t *aenv = &birg->main_env->arch_env;
bitset_t *tmp = bitset_alloca(env->cls->n_regs);
bitset_t *def_constr = bitset_alloca(env->cls->n_regs);
ir_node *bl = get_nodes_block(irn);
......@@ -433,7 +433,7 @@ static ir_node *pre_process_constraints(be_chordal_alloc_env_t *alloc_env,
be_insn_t **the_insn)
{
be_chordal_env_t *env = alloc_env->chordal_env;
const arch_env_t *aenv = env->birg->main_env->arch_env;
const arch_env_t *aenv = &env->birg->main_env->arch_env;
be_insn_t *insn = *the_insn;
ir_node *perm = NULL;
bitset_t *out_constr = bitset_alloca(env->cls->n_regs);
......@@ -546,7 +546,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
if(!insn->has_constraints)
goto end;
aenv = env->birg->main_env->arch_env;
aenv = &env->birg->main_env->arch_env;
n_regs = env->cls->n_regs;
bs = bitset_alloca(n_regs);
alloc_nodes = alloca(n_regs * sizeof(alloc_nodes[0]));
......@@ -885,7 +885,7 @@ static void assign(ir_node *block, void *env_ptr)
bitset_t *live = alloc_env->live;
bitset_t *colors = alloc_env->colors;
bitset_t *in_colors = alloc_env->in_colors;
const arch_env_t *arch_env = env->birg->main_env->arch_env;
const arch_env_t *arch_env = &env->birg->main_env->arch_env;
struct list_head *head = get_block_border_head(env, block);
be_lv_t *lv = env->birg->lv;
......
......@@ -467,7 +467,7 @@ void draw_interval_tree(const draw_chordal_opts_t *opts, const be_chordal_env_t
struct block_dims *start_dims;
ir_node *start_block = get_irg_start_block(chordal_env->irg);
env.arch_env = chordal_env->birg->main_env->arch_env;
env.arch_env = &chordal_env->birg->main_env->arch_env;
env.opts = opts;
env.block_dims = pmap_create();
env.plotter = plotter;
......
......@@ -181,7 +181,7 @@ static void dump(unsigned mask, ir_graph *irg,
*/
static void memory_operand_walker(ir_node *irn, void *env) {
be_chordal_env_t *cenv = env;
const arch_env_t *aenv = cenv->birg->main_env->arch_env;
const arch_env_t *aenv = &cenv->birg->main_env->arch_env;
const ir_edge_t *edge, *ne;
ir_node *block;
ir_node *spill;
......@@ -287,7 +287,7 @@ static void node_stats(be_irg_t *birg, const arch_register_class_t *cls, node_st
struct node_stat_walker env;
memset(stat, 0, sizeof(stat[0]));
env.arch_env = birg->main_env->arch_env;
env.arch_env = &birg->main_env->arch_env;
env.mem_phis = bitset_irg_malloc(birg->irg);
env.stat = stat;
env.cls = cls;
......@@ -338,7 +338,7 @@ static void pre_spill(post_spill_env_t *pse, const arch_register_class_t *cls)
stat_ev_ctx_push_str("bechordal_cls", pse->cls->name);
stat_ev_do(node_stats(birg, pse->cls, &node_stat));
stat_ev_do(pse->pre_spill_cost = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq));
stat_ev_do(pse->pre_spill_cost = be_estimate_irg_costs(irg, &main_env->arch_env, birg->exec_freq));
stat_ev_dbl("phis_before_spill", node_stat.n_phis);
/* put all ignore registers into the ignore register set. */
......@@ -374,7 +374,7 @@ static void post_spill(post_spill_env_t *pse, int iteration) {
stat_ev_dbl("mem_phis", node_stat.n_mem_phis);
stat_ev_dbl("reloads", node_stat.n_reloads);
stat_ev_dbl("spills", node_stat.n_spills);
stat_ev_dbl("spillcosts", be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost);
stat_ev_dbl("spillcosts", be_estimate_irg_costs(irg, &main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost);
/*
If we have a backend provided spiller, post spill is
......@@ -473,7 +473,7 @@ static void post_spill(post_spill_env_t *pse, int iteration) {
static void be_ra_chordal_main(be_irg_t *birg)
{
const be_main_env_t *main_env = birg->main_env;
const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
const arch_isa_t *isa = arch_env_get_isa(&main_env->arch_env);
ir_graph *irg = birg->irg;
int j, m;
be_chordal_env_t chordal_env;
......
......@@ -83,7 +83,7 @@ static INLINE struct list_head *_get_block_border_head(const be_chordal_env_t *i
#define border_prev(b) (list_entry((b)->list.prev, border_t, list))
#define chordal_has_class(chordal_env, irn) \
arch_irn_consider_in_reg_alloc(chordal_env->birg->main_env->arch_env, chordal_env->cls, irn)
arch_irn_consider_in_reg_alloc(&chordal_env->birg->main_env->arch_env, chordal_env->cls, irn)
void be_ra_chordal_color(be_chordal_env_t *chordal_env);
......
......@@ -197,7 +197,7 @@ copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs)
co = xcalloc(1, sizeof(*co));
co->cenv = chordal_env;
co->aenv = chordal_env->birg->main_env->arch_env;
co->aenv = &chordal_env->birg->main_env->arch_env;
co->irg = chordal_env->irg;
co->cls = chordal_env->cls;
co->get_costs = get_costs;
......
......@@ -290,7 +290,7 @@ static void stat_phi_class(be_chordal_env_t *chordal_env, ir_node **pc) {
static void copystat_collect_cls(be_chordal_env_t *cenv) {
ir_graph *irg = cenv->irg;
arch_env_t *aenv = cenv->birg->main_env->arch_env;
arch_env_t *aenv = &cenv->birg->main_env->arch_env;
ir_node *n, **pc;
phi_classes_t *pc_obj;
pset *all_phi_classes;
......@@ -490,7 +490,7 @@ void co_compare_solvers(be_chordal_env_t *chordal_env) {
DBG((dbg, LEVEL_1, "----> CO: %s\n", co->name));
/* save colors */
saver.arch_env = chordal_env->birg->main_env->arch_env;
saver.arch_env = &chordal_env->birg->main_env->arch_env;
saver.chordal_env = chordal_env;
saver.saved_colors = pmap_create();
save_colors(&saver);
......
......@@ -400,7 +400,7 @@ void be_ifg_check_performance(be_chordal_env_t *chordal_env)
if (get_irg_estimated_node_cnt(chordal_env->irg) >= BE_CH_PERFORMANCETEST_MIN_NODES)
{
coloring_init(&coloring, chordal_env->irg, chordal_env->birg->main_env->arch_env);
coloring_init(&coloring, chordal_env->irg, &chordal_env->birg->main_env->arch_env);
coloring_save(&coloring);
ir_timer_reset(timer);
......@@ -646,7 +646,7 @@ static void int_comp_rec(be_irg_t *birg, be_ifg_t *ifg, ir_node *n, bitset_t *se
ir_node *m;
be_ifg_foreach_neighbour(ifg, neigh_it, n, m) {
if(!bitset_contains_irn(seen, m) && !arch_irn_is(birg->main_env->arch_env, m, ignore)) {
if(!bitset_contains_irn(seen, m) && !arch_irn_is(&birg->main_env->arch_env, m, ignore)) {
bitset_add_irn(seen, m);
int_comp_rec(birg, ifg, m, seen);
}
......@@ -663,7 +663,7 @@ static int int_component_stat(be_irg_t *birg, be_ifg_t *ifg)
ir_node *n;
be_ifg_foreach_node(ifg, nodes_it, n) {
if (! bitset_contains_irn(seen, n) && ! arch_irn_is(birg->main_env->arch_env, n, ignore)) {
if (! bitset_contains_irn(seen, n) && ! arch_irn_is(&birg->main_env->arch_env, n, ignore)) {
++n_comp;
bitset_add_irn(seen, n);
int_comp_rec(birg, ifg, n, seen);
......
......@@ -133,7 +133,7 @@ static INLINE int _lv_values_interfere(const be_lv_t *lv, const ir_node *a, cons
const ir_edge_t *edge;
ir_node *bb = get_nodes_block(b);
stat_ev_dbl("beintlive_ignore", arch_irn_is(lv->birg->main_env->arch_env, a, ignore));
stat_ev_dbl("beintlive_ignore", arch_irn_is(&lv->birg->main_env->arch_env, a, ignore));
/*
* If a is live end in b's block it is
......
......@@ -68,7 +68,7 @@ _be_get_birg_irg(const be_irg_t *birg) {
static INLINE const arch_env_t *
_be_get_birg_arch_env(const be_irg_t *birg) {
return birg->main_env->arch_env;
return &birg->main_env->arch_env;
}
#define be_get_birg_exec_freq(birg) _be_get_birg_exec_freq(birg)
......
......@@ -84,7 +84,7 @@ ir_node *insert_Perm_after(be_irg_t *birg,
const arch_register_class_t *cls,
ir_node *pos)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
const arch_env_t *arch_env = &birg->main_env->arch_env;
be_lv_t *lv = birg->lv;
ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_graph *irg = get_irn_irg(bl);
......
......@@ -553,7 +553,7 @@ static void list_sched_block(ir_node *block, void *env_ptr)
/* List schedule a graph. */
void list_sched(be_irg_t *birg, be_options_t *be_opts)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
const arch_env_t *arch_env = &birg->main_env->arch_env;
ir_graph *irg = birg->irg;
int num_nodes;
......@@ -627,7 +627,7 @@ void list_sched(be_irg_t *birg, be_options_t *be_opts)
void list_sched_single_block(const be_irg_t *birg, ir_node *block,
be_options_t *be_opts)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
const arch_env_t *arch_env = &birg->main_env->arch_env;
ir_graph *irg = birg->irg;
int num_nodes;
......
......@@ -77,6 +77,8 @@
#include "be_dbgout.h"
#include "beirg_t.h"
#define NEW_ID(s) new_id_from_chars(s, sizeof(s) - 1)
#ifdef WITH_ILP
#include "beilpsched.h"
#endif /* WITH_ILP */
......@@ -88,6 +90,7 @@ static be_options_t be_options = {
0, /* no opt profile */
0, /* try to omit frame pointer */
0, /* create PIC code */
0, /* create gprof compatible profiling code */
BE_VRFY_WARN, /* verification level: warn */
BE_SCHED_LIST, /* scheduler: list scheduler */
"linux", /* target OS name */
......@@ -151,6 +154,7 @@ static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_ENUM_MASK("dump", "dump irg on several occasions", &dump_var),
LC_OPT_ENT_BOOL ("omitfp", "omit frame pointer", &be_options.omit_fp),
LC_OPT_ENT_BOOL ("pic", "create PIC code", &be_options.pic),
LC_OPT_ENT_BOOL ("gprof", "create gprof profiling code", &be_options.gprof),
LC_OPT_ENT_ENUM_PTR ("vrfy", "verify the backend irg", &vrfy_var),
LC_OPT_ENT_BOOL ("time", "get backend timing statistics", &be_options.timing),
LC_OPT_ENT_BOOL ("profile", "instrument the code for execution count profiling", &be_options.opt_profile),
......@@ -158,7 +162,7 @@ static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_STR ("os", "specify target operating system", &be_options.target_os, sizeof(be_options.target_os)),
#ifdef FIRM_STATISTICS
LC_OPT_ENT_BOOL ("statev", "dump statistic events", &be_options.statev),
LC_OPT_ENT_STR ("filtev", "filter for stat events (regex if support is active", &be_options.printev, sizeof(be_options.printev)),
LC_OPT_ENT_STR ("filtev", "filter for stat events (regex if support is active", &be_options.filtev, sizeof(be_options.filtev)),
#endif
#ifdef WITH_ILP
......@@ -172,7 +176,7 @@ static be_module_list_entry_t *isa_ifs = NULL;
void be_register_isa_if(const char *name, const arch_isa_if_t *isa)
{
if(isa_if == NULL)
if (isa_if == NULL)
isa_if = isa;
be_add_module_to_list(&isa_ifs, name, (void*) isa);
......@@ -222,8 +226,7 @@ static const backend_params be_params = {
static void be_sched_vrfy(be_irg_t *birg, int vrfy_opt) {
if (vrfy_opt == BE_VRFY_WARN) {
be_verify_schedule(birg);
}
else if (vrfy_opt == BE_VRFY_ASSERT) {
} else if (vrfy_opt == BE_VRFY_ASSERT) {
assert(be_verify_schedule(birg) && "Schedule verification failed.");
}
}
......@@ -248,45 +251,43 @@ const backend_params *be_init(void)
static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle)
{
memset(env, 0, sizeof(*env));
obstack_init(&env->obst);
env->arch_env = obstack_alloc(&env->obst, sizeof(env->arch_env[0]));
env->options = &be_options;
env->ent_trampoline_map = pmap_create();
env->pic_trampolines_type
= new_type_class(new_id_from_str("$PIC_TRAMPOLINE_TYPE"));
env->ent_pic_symbol_map = pmap_create();
env->pic_symbols_type
= new_type_struct(new_id_from_str("$PIC_SYMBOLS_TYPE"));
env->options = &be_options;
env->ent_trampoline_map = pmap_create();
env->pic_trampolines_type = new_type_class(NEW_ID("$PIC_TRAMPOLINE_TYPE"));
env->ent_pic_symbol_map = pmap_create();
env->pic_symbols_type = new_type_struct(NEW_ID("$PIC_SYMBOLS_TYPE"));
remove_irp_type(env->pic_trampolines_type);
remove_irp_type(env->pic_symbols_type);
set_class_final(env->pic_trampolines_type, 1);
arch_env_init(env->arch_env, isa_if, file_handle, env);
arch_env_init(&env->arch_env, isa_if, file_handle, env);
/* Register the irn handler of the architecture */
if (arch_isa_get_irn_handler(env->arch_env->isa))
arch_env_push_irn_handler(env->arch_env, arch_isa_get_irn_handler(env->arch_env->isa));
if (arch_isa_get_irn_handler(env->arch_env.isa))
arch_env_push_irn_handler(&env->arch_env, arch_isa_get_irn_handler(env->arch_env.isa));
/*
* Register the node handler of the back end infrastructure.
* This irn handler takes care of the platform independent
* spill, reload and perm nodes.
*/
arch_env_push_irn_handler(env->arch_env, &be_node_irn_handler);
env->phi_handler = be_phi_handler_new(env->arch_env);
arch_env_push_irn_handler(env->arch_env, env->phi_handler);
arch_env_push_irn_handler(&env->arch_env, &be_node_irn_handler);
env->phi_handler = be_phi_handler_new(&env->arch_env);
arch_env_push_irn_handler(&env->arch_env, env->phi_handler);
be_dbg_open();
return env;
}
/**
* Called when the be_main_env_t can be destroyed.
*/
static void be_done_env(be_main_env_t *env)
{
env->arch_env->isa->impl->done(env->arch_env->isa);
env->arch_env.isa->impl->done(env->arch_env.isa);
be_dbg_close();
be_phi_handler_free(env->phi_handler);
obstack_free(&env->obst, NULL);
pmap_destroy(env->ent_trampoline_map);
pmap_destroy(env->ent_pic_symbol_map);
......@@ -324,7 +325,7 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
dump(DUMP_INITIAL, irg, "-begin", dump_ir_block_graph);
be_stat_init_irg(env->arch_env, irg);
be_stat_init_irg(&env->arch_env, irg);
be_do_stat_nodes(irg, "01 Begin");
/* set the current graph (this is important for several firm functions) */
......@@ -396,13 +397,13 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_timing = (be_options.timing == BE_TIME_ON);
if (be_timing) {
t_abi = ir_timer_register("time_beabi", "be abi introduction");
t_abi = ir_timer_register("time_beabi", "be abi introduction");
t_codegen = ir_timer_register("time_codegen", "codegeneration");
t_sched = ir_timer_register("time_sched", "scheduling");
t_constr = ir_timer_register("time_constr", "assure constraints");
t_constr = ir_timer_register("time_constr", "assure constraints");
t_finish = ir_timer_register("time_finish", "graph finish");
t_emit = ir_timer_register("time_emiter", "code emiter");
t_verify = ir_timer_register("time_verify", "graph verification");
t_verify = ir_timer_register("time_verify", "graph verification");
t_other = ir_timer_register("time_other", "other");
t_heights = ir_timer_register("time_heights", "heights");
t_live = ir_timer_register("time_liveness", "be liveness");
......@@ -424,7 +425,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_init_env(&env, file_handle);
env.cup_name = cup_name;
isa = arch_env_get_isa(env.arch_env);
isa = arch_env_get_isa(&env.arch_env);
be_dbg_so(cup_name);
be_dbg_types();
......@@ -627,14 +628,14 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
//be_do_stat_reg_pressure(birg);
#ifdef FIRM_STATISTICS
stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, &env.arch_env, birg->exec_freq));
#endif
/* Do register allocation */
be_allocate_registers(birg);
#ifdef FIRM_STATISTICS
stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, &env.arch_env, birg->exec_freq));
#endif
dump(DUMP_RA, irg, "-ra", dump_ir_block_graph_sched);
......@@ -786,7 +787,7 @@ void be_main(FILE *file_handle, const char *cup_name)
buf[pos - cup_name] = '\0';
be_options.statev = 1;
stat_ev_begin(buf, be_options.printev);
stat_ev_begin(buf, be_options.filtev);