Skip to content

Commit

Permalink
Work on build with support for SP or DP floating point (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jun 16, 2018
1 parent 2ff35cb commit 7e43ca3
Show file tree
Hide file tree
Showing 9 changed files with 1,805 additions and 522 deletions.
2 changes: 2 additions & 0 deletions CMake/ChibiOS_target_os.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
#define VERSION_BUILD @nanoFramework_VERSION_PATCH@U
#define VERSION_REVISION @nanoFramework_VERSION_TWEAK@U

#define DP_FLOATINGPOINT @TARGET_DP_FLOATINGPOINT@

#endif /* _TARGET_OS_H_ */
2 changes: 2 additions & 0 deletions CMake/ESP32_target_os.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define VERSION_BUILD @nanoFramework_VERSION_PATCH@U
#define VERSION_REVISION @nanoFramework_VERSION_TWEAK@U

#define DP_FLOATINGPOINT @TARGET_DP_FLOATINGPOINT@

// build timestamp
//#define __DATE__ "@BUILD_TIMESTAMP@"

Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ elseif("${USE_FPU}" STREQUAL "FALSE")
message(STATUS "Emulated Floating Point enabled")
endif()

#################################################################################
# chooses if double-point float point support is provided by the platform
# (default is OFF which means that single-precision floating point is effective)
option(DP_FLOATINGPOINT "option to enable support for double-precision floating point")

if(DP_FLOATINGPOINT)
set(TARGET_DP_FLOATINGPOINT TRUE CACHE INTERNAL "DP FP support")
message(STATUS "Double-precision floating point is effective")
else()
set(TARGET_DP_FLOATINGPOINT FALSE CACHE INTERNAL "DP FP support")
message(STATUS "Single-precision floating point is effective")
endif()

#################################################################
# True random number generation option supported by Target MCU
set(TARGET_MCU_SUPPORTS_RNG TRUE)
Expand Down
1 change: 1 addition & 0 deletions cmake-variants.TEMPLATE.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"ESP32_LIBS_PATH" : "<path-to-esp32-libraries-mind-the-forward-slash>/libs",
"TARGET_SERIES" : "<series-name-of-the-target-chip-----STM32F0xx-STM32F4xx-STM32F7xx-ESP32>",
"USE_FPU" : "<TRUE-for-using-hardware-floating-point-unit>",
"DP_FLOATINGPOINT" : "<OFF-default-ON-for-adding-support-for-double-precision-floating-point>",
"RTOS" : "<one-of-valid-rtos-options----CHIBIOS-FREERTOS>",
"CHIBIOS_SOURCE" : "<path-to-chibios-source-mind-the-forward-slash>",
"CHIBIOS_BOARD" : "<valid-chibios-board-name-from-boards-collection>",
Expand Down
43 changes: 36 additions & 7 deletions src/CLR/CorLib/corlib_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,33 +462,57 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_corlib_native_System_Math::Abs___STATIC__I4__I4,
Library_corlib_native_System_Math::Max___STATIC__I4__I4__I4,
Library_corlib_native_System_Math::Min___STATIC__I4__I4__I4,
Library_corlib_native_System_Math::Abs___STATIC__R8__R8,
Library_corlib_native_System_Math::Abs___STATIC__R4__R4,
Library_corlib_native_System_Math::Acos___STATIC__R8__R8,
Library_corlib_native_System_Math::Acos___STATIC__R4__R4,
Library_corlib_native_System_Math::Asin___STATIC__R8__R8,
Library_corlib_native_System_Math::Asin___STATIC__R4__R4,
Library_corlib_native_System_Math::Atan___STATIC__R8__R8,
Library_corlib_native_System_Math::Atan___STATIC__R4__R4,
Library_corlib_native_System_Math::Atan2___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Atan2___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Ceiling___STATIC__R8__R8,
Library_corlib_native_System_Math::Ceiling___STATIC__R4__R4,
Library_corlib_native_System_Math::Cos___STATIC__R8__R8,
Library_corlib_native_System_Math::Cos___STATIC__R4__R4,
Library_corlib_native_System_Math::Cosh___STATIC__R8__R8,
Library_corlib_native_System_Math::Cosh___STATIC__R4__R4,
Library_corlib_native_System_Math::IEEERemainder___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::IEEERemainder___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Exp___STATIC__R8__R8,
Library_corlib_native_System_Math::Exp___STATIC__R4__R4,
Library_corlib_native_System_Math::Floor___STATIC__R8__R8,
Library_corlib_native_System_Math::Floor___STATIC__R4__R4,
Library_corlib_native_System_Math::Log___STATIC__R8__R8,
Library_corlib_native_System_Math::Log___STATIC__R4__R4,
Library_corlib_native_System_Math::Log10___STATIC__R8__R8,
NULL,
NULL,
Library_corlib_native_System_Math::Log10___STATIC__R4__R4,
Library_corlib_native_System_Math::Max___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Max___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Min___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Min___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Pow___STATIC__R8__R8__R8,
Library_corlib_native_System_Math::Pow___STATIC__R4__R4__R4,
Library_corlib_native_System_Math::Round___STATIC__R8__R8,
Library_corlib_native_System_Math::Round___STATIC__R4__R4,
Library_corlib_native_System_Math::Sign___STATIC__I4__R8,
Library_corlib_native_System_Math::Sign___STATIC__I4__R4,
Library_corlib_native_System_Math::Sin___STATIC__R8__R8,
Library_corlib_native_System_Math::Sin___STATIC__R4__R4,
Library_corlib_native_System_Math::Sinh___STATIC__R8__R8,
Library_corlib_native_System_Math::Sinh___STATIC__R4__R4,
Library_corlib_native_System_Math::Sqrt___STATIC__R8__R8,
Library_corlib_native_System_Math::Sqrt___STATIC__R4__R4,
Library_corlib_native_System_Math::Tan___STATIC__R8__R8,
Library_corlib_native_System_Math::Tan___STATIC__R4__R4,
Library_corlib_native_System_Math::Tanh___STATIC__R8__R8,
Library_corlib_native_System_Math::Tanh___STATIC__R4__R4,
Library_corlib_native_System_Math::Truncate___STATIC__R8__R8,
Library_corlib_native_System_Math::Truncate___STATIC__R4__R4,
NULL,
NULL,
NULL,
Expand Down Expand Up @@ -850,6 +874,11 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT,
NULL,
NULL,
Expand Down Expand Up @@ -905,7 +934,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib =
{
"mscorlib",
0x315C7581,
0x9EB491C8,
method_lookup,
{ 1, 0, 0, 0 }
};
30 changes: 30 additions & 0 deletions src/CLR/CorLib/corlib_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,27 +499,57 @@ struct Library_corlib_native_System_Int64

struct Library_corlib_native_System_Math
{
NANOCLR_NATIVE_DECLARE(Abs___STATIC__I4__I4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__I4__I4__I4);
NANOCLR_NATIVE_DECLARE(Min___STATIC__I4__I4__I4);
NANOCLR_NATIVE_DECLARE(Abs___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Abs___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Acos___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Acos___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Asin___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Asin___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Atan___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Atan___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Atan2___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Atan2___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Ceiling___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Ceiling___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Cos___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Cos___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Cosh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Cosh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(IEEERemainder___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(IEEERemainder___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Exp___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Exp___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Floor___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Floor___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Log___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Log___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Log10___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Log10___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Max___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Max___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Min___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Min___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Pow___STATIC__R8__R8__R8);
NANOCLR_NATIVE_DECLARE(Pow___STATIC__R4__R4__R4);
NANOCLR_NATIVE_DECLARE(Round___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Round___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sign___STATIC__I4__R8);
NANOCLR_NATIVE_DECLARE(Sign___STATIC__I4__R4);
NANOCLR_NATIVE_DECLARE(Sin___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sin___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sinh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sinh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Sqrt___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Sqrt___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Tan___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Tan___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Tanh___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Tanh___STATIC__R4__R4);
NANOCLR_NATIVE_DECLARE(Truncate___STATIC__R8__R8);
NANOCLR_NATIVE_DECLARE(Truncate___STATIC__R4__R4);

//--//

Expand Down
Loading

0 comments on commit 7e43ca3

Please sign in to comment.