Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement longdouble as a wrapper around llvm::APFloat. #587

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(MSVC)
endif()

include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckLibraryExists)

#
Expand Down Expand Up @@ -243,22 +244,7 @@ list(REMOVE_ITEM FE_SRC
# Add/remove files for MSVC
if(MSVC)
list(APPEND FE_SRC
${PROJECT_SOURCE_DIR}/vcbuild/strtold.c
# See below why this don't work
# if(CMAKE_CL_64)
# ${PROJECT_SOURCE_DIR}/vcbuild/ldfpu.asm
# endif()
)
if(CMAKE_CL_64)
# MASM support does not work yet!
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ldfpu.obj
COMMAND ${CMAKE_ASM_MASM_COMPILER} /c /Fo${CMAKE_CURRENT_BINARY_DIR}/ldfpu.obj ${PROJECT_SOURCE_DIR}/vcbuild/ldfpu.asm
DEPENDS ${PROJECT_SOURCE_DIR}/vcbuild/ldfpu.asm
COMMENT "generate ldfpu.obj")
list(APPEND FE_SRC
${CMAKE_CURRENT_BINARY_DIR}/ldfpu.obj
)
endif()
${PROJECT_SOURCE_DIR}/vcbuild/strtold.c)
endif()
set(LDC_SOURCE_FILES
${LDC_GENERATED}
Expand Down Expand Up @@ -338,6 +324,26 @@ else()
set(EXTRA_CXXFLAGS "-fexceptions")
endif()

#
# check string functions
#
check_symbol_exists(memicmp "string.h" HAVE_MEMICMP)
check_symbol_exists(stricmp "string.h" HAVE_STRICMP)
check_symbol_exists(strupr "string.h" HAVE_STRUPR)

if(HAVE_MEMICMP)
add_definitions(-DHAVE_MEMICMP)
endif()

if(HAVE_STRICMP)
add_definitions(-DHAVE_STRICMP)
endif()

if(HAVE_STRUPR)
add_definitions(-DHAVE_STRUPR)
endif()


#
# Check endianess.
# There is no realiable way to delegate the work to the compiler.
Expand Down Expand Up @@ -472,7 +478,6 @@ get_target_property(GEN_GCCBUILTINS_LOC gen_gccbuiltins LOCATION)
#
# LDMD
#
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(_SC_ARG_MAX "unistd.h" HAVE_SC_ARG_MAX)
if (HAVE_SC_ARG_MAX)
add_definitions(-DHAVE_SC_ARG_MAX)
Expand Down
26 changes: 26 additions & 0 deletions dmd2/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Expression *eval_unimp(Loc loc, FuncDeclaration *fd, Expressions *arguments)
return NULL;
}

#if !IN_LLVM
Expression *eval_sin(Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
Expression *arg0 = (*arguments)[0];
Expand All @@ -63,6 +64,7 @@ Expression *eval_tan(Loc loc, FuncDeclaration *fd, Expressions *arguments)
assert(arg0->op == TOKfloat64);
return new RealExp(loc, tanl(arg0->toReal()), arg0->type);
}
#endif

Expression *eval_sqrt(Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
Expand Down Expand Up @@ -133,18 +135,30 @@ void builtin_init()
builtins._init(45);

// @safe pure nothrow real function(real)
#if IN_LLVM
add_builtin("_D4core4math3sinFNaNbNfeZe", &eval_unimp);
add_builtin("_D4core4math3cosFNaNbNfeZe", &eval_unimp);
add_builtin("_D4core4math3tanFNaNbNfeZe", &eval_unimp);
#else
add_builtin("_D4core4math3sinFNaNbNfeZe", &eval_sin);
add_builtin("_D4core4math3cosFNaNbNfeZe", &eval_cos);
add_builtin("_D4core4math3tanFNaNbNfeZe", &eval_tan);
#endif
add_builtin("_D4core4math4sqrtFNaNbNfeZe", &eval_sqrt);
add_builtin("_D4core4math4fabsFNaNbNfeZe", &eval_fabs);
add_builtin("_D4core4math5expm1FNaNbNfeZe", &eval_unimp);
add_builtin("_D4core4math4exp21FNaNbNfeZe", &eval_unimp);

// @trusted pure nothrow real function(real)
#if IN_LLVM
add_builtin("_D4core4math3sinFNaNbNeeZe", &eval_unimp);
add_builtin("_D4core4math3cosFNaNbNeeZe", &eval_unimp);
add_builtin("_D4core4math3tanFNaNbNeeZe", &eval_unimp);
#else
add_builtin("_D4core4math3sinFNaNbNeeZe", &eval_sin);
add_builtin("_D4core4math3cosFNaNbNeeZe", &eval_cos);
add_builtin("_D4core4math3tanFNaNbNeeZe", &eval_tan);
#endif
add_builtin("_D4core4math4sqrtFNaNbNeeZe", &eval_sqrt);
add_builtin("_D4core4math4fabsFNaNbNeeZe", &eval_fabs);
add_builtin("_D4core4math5expm1FNaNbNeeZe", &eval_unimp);
Expand All @@ -164,18 +178,30 @@ void builtin_init()
add_builtin("_D4core4math6rndtolFNaNbNfeZl", &eval_unimp);

// @safe pure nothrow real function(real)
#if IN_LLVM
add_builtin("_D3std4math3sinFNaNbNfeZe", &eval_unimp);
add_builtin("_D3std4math3cosFNaNbNfeZe", &eval_unimp);
add_builtin("_D3std4math3tanFNaNbNfeZe", &eval_unimp);
#else
add_builtin("_D3std4math3sinFNaNbNfeZe", &eval_sin);
add_builtin("_D3std4math3cosFNaNbNfeZe", &eval_cos);
add_builtin("_D3std4math3tanFNaNbNfeZe", &eval_tan);
#endif
add_builtin("_D3std4math4sqrtFNaNbNfeZe", &eval_sqrt);
add_builtin("_D3std4math4fabsFNaNbNfeZe", &eval_fabs);
add_builtin("_D3std4math5expm1FNaNbNfeZe", &eval_unimp);
add_builtin("_D3std4math4exp21FNaNbNfeZe", &eval_unimp);

// @trusted pure nothrow real function(real)
#if IN_LLVM
add_builtin("_D3std4math3sinFNaNbNeeZe", &eval_unimp);
add_builtin("_D3std4math3cosFNaNbNeeZe", &eval_unimp);
add_builtin("_D3std4math3tanFNaNbNeeZe", &eval_unimp);
#else
add_builtin("_D3std4math3sinFNaNbNeeZe", &eval_sin);
add_builtin("_D3std4math3cosFNaNbNeeZe", &eval_cos);
add_builtin("_D3std4math3tanFNaNbNeeZe", &eval_tan);
#endif
add_builtin("_D3std4math4sqrtFNaNbNeeZe", &eval_sqrt);
add_builtin("_D3std4math4fabsFNaNbNeeZe", &eval_fabs);
add_builtin("_D3std4math5expm1FNaNbNeeZe", &eval_unimp);
Expand Down
Loading