From: Matthias Braun Date: Fri, 25 Jun 2010 11:57:12 +0000 (+0000) Subject: cleanup ia32 code (use private linkage where necessary, no need for a custom unique_id) X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=c03098df320995c78fb51798f1933368777e2b24;p=libfirm cleanup ia32 code (use private linkage where necessary, no need for a custom unique_id) [r27659] --- diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c index d12a7dd89..98557f0c4 100644 --- a/ir/be/begnuas.c +++ b/ir/be/begnuas.c @@ -1448,9 +1448,7 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti char const *be_gas_get_private_prefix(void) { - return - be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O ? "L" : - ".L"; + return be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O ? "L" : ".L"; } void be_gas_emit_entity(const ir_entity *entity) diff --git a/ir/be/ia32/ia32_common_transform.c b/ir/be/ia32/ia32_common_transform.c index 1aa217d77..2035d9dd7 100644 --- a/ir/be/ia32/ia32_common_transform.c +++ b/ir/be/ia32/ia32_common_transform.c @@ -74,90 +74,62 @@ static int check_immediate_constraint(long val, char immediate_constraint_type) } } -/* creates a unique ident by adding a number to a tag */ -ident *ia32_unique_id(const char *tag) -{ - static unsigned id = 0; - char str[256]; - - snprintf(str, sizeof(str), tag, ++id); - return new_id_from_str(str); -} - /** * Get a primitive type for a mode with alignment 16. */ static ir_type *ia32_get_prim_type(pmap *types, ir_mode *mode) { - pmap_entry *e = pmap_find(types, mode); - ir_type *res; + ir_type *res = pmap_get(types, mode); + if (res != NULL) + return res; - if (! e) { - res = new_type_primitive(mode); - if (get_mode_size_bits(mode) >= 80) { - set_type_alignment_bytes(res, 16); - } - pmap_insert(types, mode, res); + res = new_type_primitive(mode); + if (get_mode_size_bits(mode) >= 80) { + set_type_alignment_bytes(res, 16); } - else - res = e->value; + pmap_insert(types, mode, res); return res; } ir_entity *create_float_const_entity(ir_node *cnst) { - ia32_isa_t *isa = env_cg->isa; - tarval *key = get_Const_tarval(cnst); - pmap_entry *e = pmap_find(isa->tv_ent, key); - ir_entity *res; - ir_graph *rem; - - if (e == NULL) { - tarval *tv = key; - ir_mode *mode = get_tarval_mode(tv); - ir_type *tp; - - if (! ia32_cg_config.use_sse2) { - /* try to reduce the mode to produce smaller sized entities */ - if (mode != mode_F) { - if (tarval_ieee754_can_conv_lossless(tv, mode_F)) { - mode = mode_F; + ia32_isa_t *isa = env_cg->isa; + tarval *tv = get_Const_tarval(cnst); + ir_entity *res = pmap_get(isa->tv_ent, tv); + ir_initializer_t *initializer; + ir_mode *mode; + ir_type *tp; + + if (res != NULL) + return res; + + mode = get_tarval_mode(tv); + + if (! ia32_cg_config.use_sse2) { + /* try to reduce the mode to produce smaller sized entities */ + if (mode != mode_F) { + if (tarval_ieee754_can_conv_lossless(tv, mode_F)) { + mode = mode_F; + tv = tarval_convert_to(tv, mode); + } else if (mode != mode_D) { + if (tarval_ieee754_can_conv_lossless(tv, mode_D)) { + mode = mode_D; tv = tarval_convert_to(tv, mode); - } else if (mode != mode_D) { - if (tarval_ieee754_can_conv_lossless(tv, mode_D)) { - mode = mode_D; - tv = tarval_convert_to(tv, mode); - } } } } + } - if (mode == get_irn_mode(cnst)) { - /* mode was not changed */ - tp = get_Const_type(cnst); - if (tp == firm_unknown_type) - tp = ia32_get_prim_type(isa->types, mode); - } else - tp = ia32_get_prim_type(isa->types, mode); - - res = new_entity(get_glob_type(), ia32_unique_id(".LC%u"), tp); - - set_entity_ld_ident(res, get_entity_ident(res)); - set_entity_visibility(res, ir_visibility_local); - add_entity_linkage(res, IR_LINKAGE_CONSTANT); - - /* we create a new entity here: It's initialization must resist on the - const code irg */ - rem = current_ir_graph; - current_ir_graph = get_const_code_irg(); - set_atomic_ent_value(res, new_Const_type(tv, tp)); - current_ir_graph = rem; + tp = ia32_get_prim_type(isa->types, mode); + res = new_entity(get_glob_type(), id_unique("C%u"), tp); + set_entity_ld_ident(res, get_entity_ident(res)); + set_entity_visibility(res, ir_visibility_private); + add_entity_linkage(res, IR_LINKAGE_CONSTANT); - pmap_insert(isa->tv_ent, key, res); - } else { - res = e->value; - } + initializer = create_initializer_tarval(tv); + set_entity_initializer(res, initializer); + pmap_insert(isa->tv_ent, tv, res); return res; } diff --git a/ir/be/ia32/ia32_common_transform.h b/ir/be/ia32/ia32_common_transform.h index 94a49a238..0915fd070 100644 --- a/ir/be/ia32/ia32_common_transform.h +++ b/ir/be/ia32/ia32_common_transform.h @@ -112,12 +112,4 @@ int prevents_AM(ir_node *const block, ir_node *const am_candidate, ir_node *try_create_Immediate(ir_node *node, char immediate_constraint_type); -/** - * creates a unique ident by adding a number to a tag - * - * @param tag the tag string, must contain a %d if a number - * should be added - */ -ident *ia32_unique_id(const char *tag); - -#endif /* FIRM_BE_IA32_IA32_COMMON_TRANSFORM_H */ +#endif diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index 9ece016c2..570f2402e 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -81,11 +81,11 @@ #define DFP_INTMAX "9223372036854775807" #define ULL_BIAS "18446744073709551616" -#define ENT_SFP_SIGN ".LC_ia32_sfp_sign" -#define ENT_DFP_SIGN ".LC_ia32_dfp_sign" -#define ENT_SFP_ABS ".LC_ia32_sfp_abs" -#define ENT_DFP_ABS ".LC_ia32_dfp_abs" -#define ENT_ULL_BIAS ".LC_ia32_ull_bias" +#define ENT_SFP_SIGN "C_ia32_sfp_sign" +#define ENT_DFP_SIGN "C_ia32_dfp_sign" +#define ENT_SFP_ABS "C_ia32_sfp_abs" +#define ENT_DFP_ABS "C_ia32_dfp_abs" +#define ENT_ULL_BIAS "C_ia32_ull_bias" #define mode_vfp (ia32_reg_classes[CLASS_ia32_vfp].mode) #define mode_xmm (ia32_reg_classes[CLASS_ia32_xmm].mode) @@ -520,7 +520,7 @@ ir_entity *ia32_gen_fp_known_const(ia32_known_const_t kct) set_entity_ld_ident(ent, get_entity_ident(ent)); add_entity_linkage(ent, IR_LINKAGE_CONSTANT); - set_entity_visibility(ent, ir_visibility_local); + set_entity_visibility(ent, ir_visibility_private); if (kct == ia32_ULLBIAS) { ir_initializer_t *initializer = create_initializer_compound(2); @@ -3146,10 +3146,10 @@ static ir_entity *ia32_create_const_array(ir_node *c0, ir_node *c1, ir_mode **ne tp = ia32_create_float_type(mode, 4); tp = ia32_create_float_array(tp); - ent = new_entity(get_glob_type(), ia32_unique_id(".LC%u"), tp); + ent = new_entity(get_glob_type(), id_unique("C%u"), tp); set_entity_ld_ident(ent, get_entity_ident(ent)); - set_entity_visibility(ent, ir_visibility_local); + set_entity_visibility(ent, ir_visibility_private); add_entity_linkage(ent, IR_LINKAGE_CONSTANT); initializer = create_initializer_compound(2);