Commit 42c0abe8 authored by Matthias Braun's avatar Matthias Braun
Browse files

simplify bemain callbacks

before_abi() callback was removed, you can simply put that code at the end
of the init() callback. custom_abi flag was removed, if a backend needs the
be_abi_introduce() stuff (formerly custom_abi == false) then it can call
it at the end of the init() callback.
parent f88e34db
......@@ -121,7 +121,6 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = {
2, /* power of two stack alignment for calls, 2^2 == 4 */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
true, /* custom abi handling */
},
};
......@@ -332,7 +331,6 @@ const arch_isa_if_t TEMPLATE_isa_if = {
TEMPLATE_register_saved_by,
NULL, /* handle intrinsics */
NULL, /* before_abi */
TEMPLATE_prepare_graph,
TEMPLATE_before_ra,
TEMPLATE_finish_irg,
......
......@@ -223,7 +223,6 @@ static amd64_isa_t amd64_isa_template = {
3, /* power of two stack alignment for calls, 2^2 == 4 */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
false, /* no custom abi handling */
},
};
......@@ -254,6 +253,14 @@ static void amd64_end_codegeneration(void *self)
free(self);
}
static void amd64_init_graph(ir_graph *irg)
{
be_abi_introduce(irg);
if (be_options.dump_flags & DUMP_BE) {
dump_ir_graph(irg, "abi");
}
}
/**
* Get the between type for that call.
* @param self The callback object.
......@@ -445,7 +452,7 @@ const arch_isa_if_t amd64_isa_if = {
amd64_begin_codegeneration,
amd64_end_codegeneration,
NULL,
amd64_init_graph,
amd64_get_call_abi,
NULL, /* mark remat */
be_new_spill,
......@@ -453,7 +460,6 @@ const arch_isa_if_t amd64_isa_if = {
amd64_register_saved_by,
NULL, /* handle intrinsics */
NULL, /* before_abi */
amd64_prepare_graph,
amd64_before_ra,
amd64_finish_graph,
......
......@@ -375,7 +375,6 @@ static arm_isa_t arm_isa_template = {
2, /* power of two stack alignment for calls, 2^2 == 4 */
7, /* spill costs */
5, /* reload costs */
true, /* we do have custom abi handling */
},
ARM_FPU_ARCH_FPE, /* FPU architecture */
};
......@@ -523,7 +522,6 @@ const arch_isa_if_t arm_isa_if = {
NULL, /* register_saved_by */
arm_handle_intrinsics, /* handle_intrinsics */
NULL, /* before_abi */
arm_prepare_graph,
arm_before_ra,
arm_finish_irg,
......
......@@ -1479,6 +1479,8 @@ static void fix_call_state_inputs(ir_graph *const irg, be_abi_irg_t *const env)
void be_abi_introduce(ir_graph *irg)
{
be_timer_push(T_ABI);
ir_node *const old_frame = get_irg_frame(irg);
const arch_env_t *const arch_env = be_get_irg_arch_env(irg);
ir_entity *const entity = get_irg_entity(irg);
......@@ -1531,6 +1533,8 @@ void be_abi_introduce(ir_graph *irg)
exchange(old_frame, get_irg_frame(irg));
pmap_destroy(env.regs);
be_timer_pop(T_ABI);
}
unsigned be_get_n_allocatable_regs(const ir_graph *irg,
......
......@@ -464,11 +464,6 @@ struct arch_isa_if_t {
*/
void (*handle_intrinsics)(void);
/**
* Called before abi introduce.
*/
void (*before_abi)(ir_graph *irg);
/**
* Called, when the graph is being normalized.
*/
......@@ -516,9 +511,6 @@ struct arch_env_t {
int stack_alignment; /**< power of 2 stack alignment */
int spill_cost; /**< cost for a be_Spill node */
int reload_cost; /**< cost for a be_Reload node */
bool custom_abi : 1; /**< backend does all abi handling
and does not need the generic
stuff from beabi.h/.c */
};
static inline bool arch_irn_is_ignore(const ir_node *irn)
......
......@@ -606,18 +606,6 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
if (arch_env->impl->init_graph)
arch_env->impl->init_graph(irg);
/* some transformations need to be done before abi introduce */
if (arch_env->impl->before_abi != NULL)
arch_env->impl->before_abi(irg);
/* implement the ABI conventions. */
if (!arch_env->custom_abi) {
be_timer_push(T_ABI);
be_abi_introduce(irg);
be_timer_pop(T_ABI);
dump(DUMP_ABI, irg, "abi");
}
/* We can't have Bad-blocks or critical edges in the backend.
* Before removing Bads, we remove unreachable code. */
optimize_graph_df(irg);
......
......@@ -439,25 +439,6 @@ static const arch_irn_ops_t ia32_irn_ops = {
static int gprof = 0;
static void ia32_before_abi(ir_graph *irg)
{
if (gprof) {
static ir_entity *mcount = NULL;
if (mcount == NULL) {
ir_type *tp = new_type_method(0, 0);
ident *id = new_id_from_str("mcount");
mcount = new_entity(get_glob_type(), id, tp);
/* FIXME: enter the right ld_ident here */
set_entity_ld_ident(mcount, get_entity_ident(mcount));
set_entity_visibility(mcount, ir_visibility_external);
}
instrument_initcall(irg, mcount);
}
if (be_options.pic) {
ia32_adjust_pic(irg);
}
}
/**
* Transforms the standard firm graph into
* an ia32 firm graph
......@@ -1153,13 +1134,30 @@ static void ia32_init_graph(ir_graph *irg)
ia32_irg_data_t *irg_data = OALLOCZ(obst, ia32_irg_data_t);
irg_data->dump = (be_options.dump_flags & DUMP_BE) ? 1 : 0;
be_birg_from_irg(irg)->isa_link = irg_data;
if (gprof) {
/* Linux gprof implementation needs base pointer */
be_options.omit_fp = 0;
static ir_entity *mcount = NULL;
if (mcount == NULL) {
ir_type *tp = new_type_method(0, 0);
ident *id = new_id_from_str("mcount");
mcount = new_entity(get_glob_type(), id, tp);
/* FIXME: enter the right ld_ident here */
set_entity_ld_ident(mcount, get_entity_ident(mcount));
set_entity_visibility(mcount, ir_visibility_external);
}
instrument_initcall(irg, mcount);
}
if (be_options.pic) {
ia32_adjust_pic(irg);
}
be_birg_from_irg(irg)->isa_link = irg_data;
be_abi_introduce(irg);
if (irg_data->dump)
dump_ir_graph(irg, "abi");
}
static const tarval_mode_info mo_integer = {
......@@ -1536,7 +1534,6 @@ static ia32_isa_t ia32_isa_template = {
2, /* power of two stack alignment, 2^2 == 4 */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
false, /* no custom abi handling */
},
NULL, /* tv_ents */
IA32_FPU_ARCH_X87, /* FPU architecture */
......@@ -1934,7 +1931,6 @@ const arch_isa_if_t ia32_isa_if = {
ia32_register_saved_by,
ia32_handle_intrinsics,
ia32_before_abi, /* before abi introduce hook */
ia32_prepare_graph,
ia32_before_ra, /* before register allocation hook */
ia32_finish_graph, /* called before codegen */
......
......@@ -66,7 +66,6 @@ static sparc_isa_t sparc_isa_template = {
for calls */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
true, /* custom abi handling */
},
NULL, /* constants */
};
......@@ -643,7 +642,6 @@ const arch_isa_if_t sparc_isa_if = {
NULL, /* register_saved_by */
sparc_handle_intrinsics,
NULL, /* before_abi */
sparc_prepare_graph,
sparc_before_ra,
sparc_finish_graph,
......
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