Commit 9f3909c0 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Factorise initialisation of backend info into the function be_info_init_irn().

parent 30b31aff
......@@ -70,24 +70,6 @@ TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
}
/**
* Initializes the nodes attributes.
*/
static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t **in_reqs,
int n_res)
{
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = get_irg_obstack(irg);
backend_info_t *info;
arch_set_irn_flags(node, flags);
arch_set_irn_register_reqs_in(node, in_reqs);
info = be_get_info(node);
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
{
TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
......
......@@ -112,23 +112,11 @@ static void amd64_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
}
}
static void init_be_info(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t **in_reqs, int n_res)
{
arch_set_irn_flags(node, flags);
arch_set_irn_register_reqs_in(node, in_reqs);
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = get_irg_obstack(irg);
backend_info_t *info = be_get_info(node);
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
static void init_amd64_attributes(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t **in_reqs,
int n_res, amd64_op_mode_t op_mode)
{
init_be_info(node, flags, in_reqs, n_res);
be_info_init_irn(node, flags, in_reqs, n_res);
amd64_attr_t *attr = get_amd64_attr(node);
attr->op_mode = op_mode;
}
......
......@@ -70,7 +70,7 @@ $default_copy_attr = "amd64_copy_attr";
."\tattr->insn_mode = insn_mode;\n"
."\tattr->addr = addr;",
amd64_binop_addr_attr_t =>
"init_be_info(res, irn_flags_, in_reqs, n_res);\n"
"be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n"
."\t*attr = *attr_init;",
amd64_switch_jmp_attr_t =>
"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
......@@ -82,7 +82,7 @@ $default_copy_attr = "amd64_copy_attr";
"init_amd64_attributes(res, irn_flags_, in_reqs, n_res, op_mode);\n"
."\tinit_amd64_movimm_attributes(res, insn_mode, entity, offset);",
amd64_shift_attr_t =>
"init_be_info(res, irn_flags_, in_reqs, n_res);\n"
"be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n"
."\t*attr = *attr_init;\n",
);
......
......@@ -288,15 +288,9 @@ static void init_arm_attributes(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t ** in_reqs,
int n_res)
{
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = get_irg_obstack(irg);
arm_attr_t *attr = get_arm_attr(node);
arch_set_irn_flags(node, flags);
arch_set_irn_register_reqs_in(node, in_reqs);
be_info_init_irn(node, flags, in_reqs, n_res);
arm_attr_t *const attr = get_arm_attr(node);
attr->is_load_store = false;
backend_info_t *info = be_get_info(node);
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
static void init_arm_load_store_attributes(ir_node *res, ir_mode *ls_mode,
......
......@@ -25,6 +25,16 @@
static copy_attr_func old_phi_copy_attr;
void be_info_init_irn(ir_node *const node, arch_irn_flags_t const flags, arch_register_req_t const **const in_reqs, unsigned const n_res)
{
ir_graph *const irg = get_irn_irg(node);
struct obstack *const obst = get_irg_obstack(irg);
backend_info_t *const info = be_get_info(node);
info->flags = flags;
info->in_reqs = in_reqs;
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
void be_info_new_node(ir_graph *irg, ir_node *node)
{
/* Projs need no be info, all info is fetched from their predecessor */
......
......@@ -49,6 +49,8 @@ void be_info_free(void);
void be_info_init_irg(ir_graph *irg);
void be_info_new_node(ir_graph *irg, ir_node *node);
void be_info_init_irn(ir_node *node, arch_irn_flags_t flags, arch_register_req_t const **in_reqs, unsigned n_res);
int attrs_equal_be_node(const ir_node *node1, const ir_node *node2);
#endif
......@@ -778,20 +778,12 @@ static void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t **in_reqs,
int n_res)
{
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = get_irg_obstack(irg);
backend_info_t *info;
arch_set_irn_flags(node, flags);
arch_set_irn_register_reqs_in(node, in_reqs);
be_info_init_irn(node, flags, in_reqs, n_res);
#ifndef NDEBUG
ia32_attr_t *attr = get_ia32_attr(node);
attr->attr_type |= IA32_ATTR_ia32_attr_t;
#endif
info = be_get_info(node);
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
static void init_ia32_x87_attributes(ir_node *res)
......
......@@ -46,7 +46,7 @@ if(!defined($default_attr_type)) {
}
if(! %init_attr) {
%init_attr = (
"$default_attr_type" => "\tinit_${arch}_attributes(res, irn_flags_, in_reqs, n_res);",
$default_attr_type => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);",
);
}
......
......@@ -228,22 +228,6 @@ const sparc_call_attr_t *get_sparc_call_attr_const(const ir_node *node)
return (const sparc_call_attr_t*)get_irn_generic_attr_const(node);
}
/**
* Initializes the nodes attributes.
*/
static void init_sparc_attributes(ir_node *node, arch_irn_flags_t flags,
const arch_register_req_t **in_reqs,
int n_res)
{
arch_set_irn_flags(node, flags);
arch_set_irn_register_reqs_in(node, in_reqs);
backend_info_t *info = be_get_info(node);
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = get_irg_obstack(irg);
info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
}
static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode,
ir_entity *entity, int32_t offset,
bool is_frame_entity,
......
......@@ -105,18 +105,18 @@ $default_attr_type = "sparc_attr_t";
$default_copy_attr = "sparc_copy_attr";
%init_attr = (
sparc_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
sparc_load_store_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
sparc_jmp_cond_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
sparc_switch_jmp_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
sparc_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);",
sparc_load_store_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);",
sparc_jmp_cond_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);",
sparc_switch_jmp_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_switch_jmp_attributes(res, table, jump_table);\n",
sparc_fp_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
sparc_fp_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_fp_attributes(res, fp_mode);\n",
sparc_fp_conv_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
sparc_fp_conv_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
sparc_asm_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
sparc_asm_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_asm_attributes(res, text, operands);",
sparc_call_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
sparc_call_attr_t => "be_info_init_irn(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_call_attributes(res, call_type);",
);
......
Supports Markdown
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