Commit 491d0c9a authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Simplify the creation of instrinsic/runtime function entities a bit and avoid...

Simplify the creation of instrinsic/runtime function entities a bit and avoid creating duplicate types.
parent f856bce3
......@@ -103,50 +103,36 @@ static void lower64_mul(ir_node *node, ir_mode *mode)
static ir_entity *ldivmod;
static ir_entity *uldivmod;
static ir_entity *make_divmod(char const *const name, ir_type *const even, ir_type *const odd)
{
ir_type *const mtp = new_type_method(4, 4);
set_method_param_type(mtp, 0, even);
set_method_param_type(mtp, 1, odd);
set_method_param_type(mtp, 2, even);
set_method_param_type(mtp, 3, odd);
set_method_res_type(mtp, 0, even);
set_method_res_type(mtp, 1, odd);
set_method_res_type(mtp, 2, even);
set_method_res_type(mtp, 3, odd);
ident *const id = new_id_from_str(name);
ir_type *const glob = get_glob_type();
ir_entity *const ent = new_entity(glob, id, mtp);
set_entity_ld_ident(ent, id);
set_entity_visibility(ent, ir_visibility_external);
return ent;
}
static void create_divmod_intrinsics(ir_mode *mode_unsigned,
ir_mode *mode_signed)
{
ir_type *tp_unsigned = get_type_for_mode(mode_unsigned);
ir_type *mtp_unsigned = new_type_method(4, 4);
set_method_param_type(mtp_unsigned, 0, tp_unsigned);
set_method_param_type(mtp_unsigned, 1, tp_unsigned);
set_method_param_type(mtp_unsigned, 2, tp_unsigned);
set_method_param_type(mtp_unsigned, 3, tp_unsigned);
set_method_res_type(mtp_unsigned, 0, tp_unsigned);
set_method_res_type(mtp_unsigned, 1, tp_unsigned);
set_method_res_type(mtp_unsigned, 2, tp_unsigned);
set_method_res_type(mtp_unsigned, 3, tp_unsigned);
ident *id_uldivmod = new_id_from_str("__aeabi_uldivmod");
ir_type *glob = get_glob_type();
uldivmod = new_entity(glob, id_uldivmod, mtp_unsigned);
set_entity_ld_ident(uldivmod, id_uldivmod);
set_entity_visibility(uldivmod, ir_visibility_external);
ir_type *const tp_unsigned = get_type_for_mode(mode_unsigned);
uldivmod = make_divmod("__aeabi_uldivmod", tp_unsigned, tp_unsigned);
ir_type *tp_signed = get_type_for_mode(mode_signed);
ir_type *mtp_signed = new_type_method(4, 4);
if (arm_cg_config.big_endian) {
set_method_param_type(mtp_signed, 0, tp_signed);
set_method_param_type(mtp_signed, 1, tp_unsigned);
set_method_param_type(mtp_signed, 2, tp_signed);
set_method_param_type(mtp_signed, 3, tp_unsigned);
set_method_res_type(mtp_signed, 0, tp_signed);
set_method_res_type(mtp_signed, 1, tp_unsigned);
set_method_res_type(mtp_signed, 2, tp_signed);
set_method_res_type(mtp_signed, 3, tp_unsigned);
} else {
set_method_param_type(mtp_signed, 0, tp_unsigned);
set_method_param_type(mtp_signed, 1, tp_signed);
set_method_param_type(mtp_signed, 2, tp_unsigned);
set_method_param_type(mtp_signed, 3, tp_signed);
set_method_res_type(mtp_signed, 0, tp_unsigned);
set_method_res_type(mtp_signed, 1, tp_signed);
set_method_res_type(mtp_signed, 2, tp_unsigned);
set_method_res_type(mtp_signed, 3, tp_signed);
}
ident *id_ldivmod = new_id_from_str("__aeabi_ldivmod");
ldivmod = new_entity(glob, id_ldivmod, mtp_signed);
set_entity_ld_ident(ldivmod, id_ldivmod);
set_entity_visibility(ldivmod, ir_visibility_external);
ir_type *const tp_signed = get_type_for_mode(mode_signed);
ir_type *const even = arm_cg_config.big_endian ? tp_signed : tp_unsigned;
ir_type *const odd = arm_cg_config.big_endian ? tp_unsigned : tp_signed;
ldivmod = make_divmod("__aeabi_ldivmod", even, odd);
}
static void lower_divmod(ir_node *node, ir_node *left, ir_node *right,
......
......@@ -114,6 +114,15 @@ static void handle_intrinsic(ir_node *node, void *data)
}
}
static ir_type *make_divmod_type(ir_type *const tp)
{
ir_type *const mtp = new_type_method(2, 1);
set_method_param_type(mtp, 0, tp);
set_method_param_type(mtp, 1, tp);
set_method_res_type(mtp, 0, tp);
return mtp;
}
static void arm_create_runtime_entities(void)
{
if (divsi3 != NULL)
......@@ -128,29 +137,13 @@ static void arm_create_runtime_entities(void)
ir_type *int_tp = get_type_for_mode(mode_int);
ir_type *uint_tp = get_type_for_mode(mode_uint);
ir_type *tp_divsi3 = new_type_method(2, 1);
set_method_param_type(tp_divsi3, 0, int_tp);
set_method_param_type(tp_divsi3, 1, int_tp);
set_method_res_type(tp_divsi3, 0, int_tp);
divsi3 = create_compilerlib_entity(new_id_from_str("__divsi3"), tp_divsi3);
ir_type *tp_udivsi3 = new_type_method(2, 1);
set_method_param_type(tp_udivsi3, 0, uint_tp);
set_method_param_type(tp_udivsi3, 1, uint_tp);
set_method_res_type(tp_udivsi3, 0, uint_tp);
udivsi3 = create_compilerlib_entity(new_id_from_str("__udivsi3"), tp_udivsi3);
ir_type *tp_modsi3 = new_type_method(2, 1);
set_method_param_type(tp_modsi3, 0, int_tp);
set_method_param_type(tp_modsi3, 1, int_tp);
set_method_res_type(tp_modsi3, 0, int_tp);
modsi3 = create_compilerlib_entity(new_id_from_str("__modsi3"), tp_modsi3);
ir_type *tp_umodsi3 = new_type_method(2, 1);
set_method_param_type(tp_umodsi3, 0, uint_tp);
set_method_param_type(tp_umodsi3, 1, uint_tp);
set_method_res_type(tp_umodsi3, 0, uint_tp);
umodsi3 = create_compilerlib_entity(new_id_from_str("__umodsi3"), tp_umodsi3);
ir_type *const mtps = make_divmod_type(int_tp);
divsi3 = create_compilerlib_entity(new_id_from_str("__divsi3"), mtps);
modsi3 = create_compilerlib_entity(new_id_from_str("__modsi3"), mtps);
ir_type *const mtpu = make_divmod_type(uint_tp);
udivsi3 = create_compilerlib_entity(new_id_from_str("__udivsi3"), mtpu);
umodsi3 = create_compilerlib_entity(new_id_from_str("__umodsi3"), mtpu);
}
/**
......
......@@ -285,23 +285,26 @@ static void handle_intrinsic(ir_node *node, void *data)
}
}
static ir_type *make_mod_type(ir_type *const tp)
{
ir_type *const mtp = new_type_method(2, 1);
set_method_param_type(mtp, 0, tp);
set_method_param_type(mtp, 1, tp);
set_method_res_type(mtp, 0, tp);
return mtp;
}
static void sparc_create_runtime_entities(void)
{
if (rem != NULL)
return;
ir_type *int_tp = new_type_primitive(mode_Is);
ir_type *mod_tp = new_type_method(2, 1);
set_method_param_type(mod_tp, 0, int_tp);
set_method_param_type(mod_tp, 1, int_tp);
set_method_res_type(mod_tp, 0, int_tp);
ir_type *const int_tp = new_type_primitive(mode_Is);
ir_type *const mod_tp = make_mod_type(int_tp);
rem = create_compilerlib_entity(new_id_from_str(".rem"), mod_tp);
ir_type *umod_tp = new_type_method(2, 1);
ir_type *uint_tp = new_type_primitive(mode_Iu);
set_method_param_type(umod_tp, 0, uint_tp);
set_method_param_type(umod_tp, 1, uint_tp);
set_method_res_type(umod_tp, 0, uint_tp);
ir_type *const uint_tp = new_type_primitive(mode_Iu);
ir_type *const umod_tp = make_mod_type(uint_tp);
urem = create_compilerlib_entity(new_id_from_str(".urem"), umod_tp);
}
......
......@@ -2713,22 +2713,15 @@ void ir_lower_dw_ops(void)
set_method_res_type(binop_tp_u, 0, tp_l_u);
set_method_res_type(binop_tp_u, 1, tp_u);
ir_type *const even = env.p.big_endian ? tp_l_s : tp_l_u;
ir_type *const odd = env.p.big_endian ? tp_u : tp_s;
binop_tp_s = new_type_method(4, 2);
if (env.p.big_endian) {
set_method_param_type(binop_tp_s, 0, tp_l_s);
set_method_param_type(binop_tp_s, 1, tp_u);
set_method_param_type(binop_tp_s, 2, tp_l_s);
set_method_param_type(binop_tp_s, 3, tp_u);
set_method_res_type(binop_tp_s, 0, tp_l_s);
set_method_res_type(binop_tp_s, 1, tp_u);
} else {
set_method_param_type(binop_tp_s, 0, tp_l_u);
set_method_param_type(binop_tp_s, 1, tp_s);
set_method_param_type(binop_tp_s, 2, tp_l_u);
set_method_param_type(binop_tp_s, 3, tp_s);
set_method_res_type(binop_tp_s, 0, tp_l_u);
set_method_res_type(binop_tp_s, 1, tp_s);
}
set_method_param_type(binop_tp_s, 0, even);
set_method_param_type(binop_tp_s, 1, odd);
set_method_param_type(binop_tp_s, 2, even);
set_method_param_type(binop_tp_s, 3, odd);
set_method_res_type(binop_tp_s, 0, even);
set_method_res_type(binop_tp_s, 1, odd);
unop_tp_u = new_type_method(2, 2);
set_method_param_type(unop_tp_u, 0, tp_l_u);
......@@ -2737,17 +2730,10 @@ void ir_lower_dw_ops(void)
set_method_res_type(unop_tp_u, 1, tp_u);
unop_tp_s = new_type_method(2, 2);
if (env.p.big_endian) {
set_method_param_type(unop_tp_s, 0, tp_l_s);
set_method_param_type(unop_tp_s, 1, tp_u);
set_method_res_type(unop_tp_s, 0, tp_l_s);
set_method_res_type(unop_tp_s, 1, tp_u);
} else {
set_method_param_type(unop_tp_s, 0, tp_l_u);
set_method_param_type(unop_tp_s, 1, tp_s);
set_method_res_type(unop_tp_s, 0, tp_l_u);
set_method_res_type(unop_tp_s, 1, tp_s);
}
set_method_param_type(unop_tp_s, 0, even);
set_method_param_type(unop_tp_s, 1, odd);
set_method_res_type(unop_tp_s, 0, even);
set_method_res_type(unop_tp_s, 1, odd);
}
env.tv_mode_bytes = new_tarval_from_long(env.p.doubleword_size/(2*8),
......
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