Commit 2a5aa91c authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: fix intrinsics on mac

[r28111]
parent 7ebf13d7
......@@ -39,6 +39,7 @@
#include "ia32_new_nodes.h"
#include "bearch_ia32_t.h"
#include "gen_ia32_regalloc_if.h"
#include "begnuas.h"
/** The array of all intrinsics that must be mapped. */
static i_record *intrinsics;
......@@ -676,6 +677,27 @@ 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_local);
set_entity_ld_ident(entity, id);
return entity;
}
/**
* Maps a Div. Change into a library call.
*/
......@@ -693,19 +715,14 @@ static int map_Div(ir_node *call, void *ctx)
/* 64bit signed Division */
ent = env->divdi3;
if (ent == NULL) {
/* create library entity */
ent = env->divdi3 = new_entity(get_glob_type(), ID("__divdi3"), method);
set_entity_visibility(ent, ir_visibility_external);
set_entity_ld_ident(ent, ID("__divdi3"));
ent = env->divdi3 = create_compiler_lib_entity("divdi3", method);
}
} else {
/* 64bit unsigned Division */
ent = env->udivdi3;
if (ent == NULL) {
/* create library entity */
ent = env->udivdi3 = new_entity(get_glob_type(), ID("__udivdi3"), method);
set_entity_visibility(ent, ir_visibility_external);
set_entity_ld_ident(ent, ID("__udivdi3"));
ent = env->udivdi3 = create_compiler_lib_entity("udivdi3", method);
}
}
......@@ -735,18 +752,14 @@ static int map_Mod(ir_node *call, void *ctx)
ent = env->moddi3;
if (ent == NULL) {
/* create library entity */
ent = env->moddi3 = new_entity(get_glob_type(), ID("__moddi3"), method);
set_entity_visibility(ent, ir_visibility_external);
set_entity_ld_ident(ent, ID("__moddi3"));
ent = env->moddi3 = create_compiler_lib_entity("moddi3", method);
}
} else {
/* 64bit signed Modulo */
ent = env->umoddi3;
if (ent == NULL) {
/* create library entity */
ent = env->umoddi3 = new_entity(get_glob_type(), ID("__umoddi3"), method);
set_entity_visibility(ent, ir_visibility_external);
set_entity_ld_ident(ent, ID("__umoddi3"));
ent = env->umoddi3 = create_compiler_lib_entity("umoddi3", method);
}
}
......
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