From: Manuel Mohr Date: Fri, 23 Sep 2011 10:49:38 +0000 (+0200) Subject: Consistently use new function to create compilerlib function entities. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=5cef66b85159c843a3a1a907568a86920d4a600b;p=libfirm Consistently use new function to create compilerlib function entities. --- diff --git a/ir/be/ia32/ia32_intrinsics.c b/ir/be/ia32/ia32_intrinsics.c index 050c663b4..e5b158151 100644 --- a/ir/be/ia32/ia32_intrinsics.c +++ b/ir/be/ia32/ia32_intrinsics.c @@ -32,6 +32,7 @@ #include "irnode_t.h" #include "ircons.h" #include "irprog_t.h" +#include "iroptimize.h" #include "lower_dw.h" #include "array.h" #include "error.h" @@ -408,27 +409,6 @@ static int map_Abs(ir_node *call, void *ctx) #define ID(x) new_id_from_chars(x, sizeof(x)-1) -static ir_entity *create_compiler_lib_entity(const char *name, ir_type *type) -{ - ir_type *glob = get_glob_type(); - ident *id = new_id_from_str(name); - ir_entity *entity; - - /* Hack: we need to know the type of runtime library we use. Strictly - speaking it's not the same as the object-file-format. But in practice - the following should be enough */ - if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O - || be_gas_object_file_format == OBJECT_FILE_FORMAT_COFF) { - id = id_mangle3("___", id, ""); - } else { - id = id_mangle3("__", id, ""); - } - entity = new_entity(glob, id, type); - set_entity_visibility(entity, ir_visibility_external); - set_entity_ld_ident(entity, id); - return entity; -} - /** * Maps a Div. Change into a library call. */ @@ -446,14 +426,17 @@ static int map_Div(ir_node *call, void *ctx) /* 64bit signed Division */ ent = env->divdi3; if (ent == NULL) { - ent = env->divdi3 = create_compiler_lib_entity("divdi3", method); + /* create library entity */ + ident *id = ID("__divdi3"); + ent = env->divdi3 = create_compilerlib_entity(id, method); } } else { /* 64bit unsigned Division */ ent = env->udivdi3; if (ent == NULL) { /* create library entity */ - ent = env->udivdi3 = create_compiler_lib_entity("udivdi3", method); + ident *id = ID("__udivdi3"); + ent = env->udivdi3 = create_compilerlib_entity(id, method); } } @@ -483,14 +466,16 @@ static int map_Mod(ir_node *call, void *ctx) ent = env->moddi3; if (ent == NULL) { /* create library entity */ - ent = env->moddi3 = create_compiler_lib_entity("moddi3", method); + ident *id = ID("__moddi3"); + ent = env->moddi3 = create_compilerlib_entity(id, method); } } else { /* 64bit signed Modulo */ ent = env->umoddi3; if (ent == NULL) { /* create library entity */ - ent = env->umoddi3 = create_compiler_lib_entity("umoddi3", method); + ident *id = ID("__umoddi3"); + ent = env->umoddi3 = create_compilerlib_entity(id, method); } } diff --git a/ir/lower/lower_builtins.c b/ir/lower/lower_builtins.c index c9c7a72ed..134a05ce8 100644 --- a/ir/lower/lower_builtins.c +++ b/ir/lower/lower_builtins.c @@ -32,6 +32,7 @@ #include "ircons_t.h" #include "irgmod.h" #include "irgwalk.h" +#include "iroptimize.h" #include "error.h" static pmap *entities; @@ -100,9 +101,7 @@ static void replace_with_call(ir_node *node) entity = pmap_get(entities, id); if (entity == NULL) { - ir_type *glob = get_glob_type(); - entity = new_entity(glob, id, mtp); - set_entity_visibility(entity, ir_visibility_external); + entity = create_compilerlib_entity(id, mtp); pmap_insert(entities, id, entity); } diff --git a/ir/lower/lower_softfloat.c b/ir/lower/lower_softfloat.c index b49a2be26..9455f6b78 100644 --- a/ir/lower/lower_softfloat.c +++ b/ir/lower/lower_softfloat.c @@ -37,6 +37,7 @@ #include "irgwalk.h" #include "irmode.h" #include "iropt_dbg.h" +#include "iroptimize.h" #include "irprog_t.h" #include "lower_softfloat.h" #include "lowering.h" @@ -317,10 +318,8 @@ static ir_node *create_softfloat_symconst(const ir_node *n, const char *name) else snprintf(buf, sizeof(buf), "__%s%s%s%s", name, first_param, second_param, result); - id = new_id_from_str(buf); - ent = new_entity(get_glob_type(), id, method); - - set_entity_ld_ident(ent, get_entity_ident(ent)); + id = new_id_from_str(buf); + ent = create_compilerlib_entity(id, method); sym.entity_p = ent; return new_r_SymConst(irg, mode_P_code, sym, symconst_addr_ent);