mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2026-03-14 21:19:43 +01:00
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
* Enable hard-float ABI support for pico_float and pico_double on m33 Resolves #2783 Signed-off-by: Andy Lin <andylinpersonal@gmail.com> * Add (non google) LLVM support, and replace calling convention check with #if defined(__ARM_PCS_VFP) * switch float.h to use static inline method for int2float() etc in VFP mode rather than #define * float/double test cleanup - particularly: - splitting out executable for each test type for pico_float/double_test - removing undefined behavior from custom_float_funcs_test.c, to de-confuse clang - add test of denormal->int Note some tests still fail on llvm libc (at least version 19) * fix some issues with newer llvm_libc/compiler as used by bazel build * keep check_configs happy * another bazel issue * introduce pico_double_pico_dcp for consistency * fixup debug output based on previous commit * remove unnecessary build guard from double_conv_m33.S * allow -1 for neg_denormal->int rounding towards minus infinity * Update test/pico_float_test/CMakeLists.txt Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com> * Update test/pico_float_test/CMakeLists.txt Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com> * - add fma/_fast functions to pico_float_test/pico_double_test - fix guard for TEST_SATURATION in pico_double_test - GCC doesn't clamp either * - double functions were only wrapped in pico_double_pico not pico_double_pico_dcp explicitly (i.e. explicitly setting double impl to pico_dcp was not selecting our versions) * avoid extra stack alignment push (per review comment) * fix fma return code in VFP mode (register transfer was the wrong way around) * separate PCS=VFP and non-PCS-VFP versions of fma_fast * remove saving_func_return (which is just bx lr) and fold the separate pop of lr, into a pop of pc * better fix for wrapping right libraries * rename some labels from _entry (which is an internal entry point) to _softfp to be clear that these are the function entry points which work with softfp calling conventions * Make bazel pico_float build not wrap SCI functions on RISC-V to match CMake build * Split out FMAF as a selectable wrapped item since we don't want to wrap it for VFP * fix typos * fix test --------- Signed-off-by: Andy Lin <andylinpersonal@gmail.com> Co-authored-by: Andy Lin <andylinpersonal@gmail.com> Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com>
137 lines
5.9 KiB
CMake
137 lines
5.9 KiB
CMake
if (NOT TARGET pico_float)
|
|
message("Skipping pico_float_test as pico_float is unavailable on this platform")
|
|
return()
|
|
endif()
|
|
|
|
PROJECT(pico_float_test)
|
|
|
|
set(FLOAT_TYPES "")
|
|
set(DOUBLE_TYPES "")
|
|
foreach (TYPE IN ITEMS compiler pico pico_vfp pico_dcp)
|
|
if (TARGET pico_float_${TYPE})
|
|
list(APPEND FLOAT_TYPES ${TYPE})
|
|
endif()
|
|
if (TARGET pico_double_${TYPE})
|
|
list(APPEND DOUBLE_TYPES ${TYPE})
|
|
endif()
|
|
endforeach()
|
|
|
|
if (PICO_RISCV)
|
|
# Separate, simpler test: currently we only have a few single-precision
|
|
# routines for RISC-V soft float (and the other tests are a bit
|
|
# AEABI-dependent)
|
|
add_executable(pico_float_test
|
|
pico_float_test_hazard3.c
|
|
)
|
|
target_link_libraries(pico_float_test PRIVATE pico_float pico_stdlib)
|
|
target_include_directories(pico_float_test PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
|
pico_add_extra_outputs(pico_float_test)
|
|
|
|
# pico_enable_stdio_usb(pico_float_test 1)
|
|
# pico_enable_stdio_uart(pico_float_test 0)
|
|
endif()
|
|
|
|
foreach (FLOAT_TYPE IN LISTS FLOAT_TYPES)
|
|
if (NOT PICO_RISCV)
|
|
# keep default as pico_float_test for backwards compatibility
|
|
if (FLOAT_TYPE STREQUAL "pico")
|
|
set(PICO_FLOAT_TEST "pico_float_test")
|
|
else()
|
|
set(PICO_FLOAT_TEST "pico_float_test_${FLOAT_TYPE}")
|
|
endif()
|
|
add_executable(${PICO_FLOAT_TEST}
|
|
pico_float_test.c
|
|
llvm/call_apsr.S
|
|
)
|
|
|
|
#todo split out variants with different flags
|
|
target_compile_definitions(${PICO_FLOAT_TEST} PRIVATE
|
|
# PICO_FLOAT_PROPAGATE_NANS=1
|
|
# PICO_DIVIDER_DISABLE_INTERRUPTS=1
|
|
)
|
|
|
|
# handy for testing we aren't pulling in extra stuff
|
|
#target_link_options(${PICO_FLOAT_TEST} PRIVATE -nodefaultlibs)
|
|
target_include_directories(${PICO_FLOAT_TEST} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/llvm)
|
|
target_link_libraries(${PICO_FLOAT_TEST} pico_float pico_stdlib m)
|
|
pico_add_extra_outputs(${PICO_FLOAT_TEST})
|
|
pico_set_float_implementation(${PICO_FLOAT_TEST} ${FLOAT_TYPE})
|
|
endif()
|
|
|
|
add_executable(custom_float_funcs_test_${FLOAT_TYPE} custom_float_funcs_test.c)
|
|
pico_set_float_implementation(custom_float_funcs_test_${FLOAT_TYPE} ${FLOAT_TYPE})
|
|
target_link_libraries(custom_float_funcs_test_${FLOAT_TYPE} PRIVATE pico_stdlib)
|
|
pico_add_extra_outputs(custom_float_funcs_test_${FLOAT_TYPE})
|
|
pico_set_printf_implementation(custom_float_funcs_test_${FLOAT_TYPE} compiler)
|
|
if (PICO_C_COMPILER_IS_CLANG)
|
|
# llvm by default will treat our out of range float->int conversions as undefined behavior
|
|
# and may just decide the function is too broken to bother even with the function epilogue, so we
|
|
# force it to accept out of range values (since we support them in our versions today)
|
|
target_compile_options(${PICO_FLOAT_TEST} PRIVATE -fno-strict-float-cast-overflow)
|
|
target_compile_options(custom_float_funcs_test_${FLOAT_TYPE} PRIVATE -fno-strict-float-cast-overflow)
|
|
endif()
|
|
endforeach ()
|
|
|
|
foreach (DOUBLE_TYPE IN LISTS DOUBLE_TYPES)
|
|
if (NOT PICO_RISCV)
|
|
# keep default as pico_float_test for backwards compatibility
|
|
if (DOUBLE_TYPE STREQUAL "pico")
|
|
set(PICO_DOUBLE_TEST "pico_double_test")
|
|
else()
|
|
set(PICO_DOUBLE_TEST "pico_double_test_${DOUBLE_TYPE}")
|
|
endif()
|
|
|
|
add_executable(${PICO_DOUBLE_TEST}
|
|
pico_double_test.c
|
|
llvm/call_apsr.S
|
|
)
|
|
|
|
target_include_directories(${PICO_DOUBLE_TEST} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/llvm)
|
|
target_link_libraries(${PICO_DOUBLE_TEST} pico_double pico_stdlib m)
|
|
pico_add_extra_outputs(${PICO_DOUBLE_TEST})
|
|
pico_set_double_implementation(${PICO_DOUBLE_TEST} ${DOUBLE_TYPE})
|
|
#todo split out variants with different flags
|
|
target_compile_definitions(${PICO_DOUBLE_TEST} PRIVATE
|
|
PICO_USE_CRT_PRINTF=1 # want full precision output
|
|
PICO_FLOAT_PROPAGATE_NANS=1
|
|
PICO_DOUBLE_PROPAGATE_NANS=1
|
|
#PICO_DIVIDER_DISABLE_INTERRUPTS=1
|
|
)
|
|
if (NOT PICO_CLIB STREQUAL "llvm_libc")
|
|
# raw compiler printf on llvm_libc doesn't currently have floating point
|
|
pico_set_printf_implementation(${PICO_DOUBLE_TEST} compiler) # want full precision output
|
|
endif()
|
|
|
|
add_executable(custom_double_funcs_test_${DOUBLE_TYPE} custom_double_funcs_test.c)
|
|
pico_set_double_implementation(custom_double_funcs_test_${DOUBLE_TYPE} ${DOUBLE_TYPE})
|
|
target_link_libraries(custom_double_funcs_test_${DOUBLE_TYPE} PRIVATE pico_stdlib)
|
|
pico_add_extra_outputs(custom_double_funcs_test_${DOUBLE_TYPE})
|
|
pico_set_printf_implementation(custom_double_funcs_test_${DOUBLE_TYPE} compiler)
|
|
|
|
if (PICO_C_COMPILER_IS_CLANG)
|
|
# llvm by default will treat our out of range float->int conversions as undefined behavior
|
|
# and may just decide the function is too broken to bother even with the function epilogue, so we
|
|
# force it to accept out of range values (since we support them in our versions today)
|
|
target_compile_options(${PICO_DOUBLE_TEST} PRIVATE -fno-strict-float-cast-overflow)
|
|
target_compile_options(custom_double_funcs_test_${DOUBLE_TYPE} PRIVATE -fno-strict-float-cast-overflow)
|
|
endif()
|
|
endif()
|
|
endforeach ()
|
|
|
|
if (PICO_RP2350 AND NOT PICO_RISCV)
|
|
add_executable(m33
|
|
m33.c
|
|
)
|
|
|
|
target_compile_definitions(m33 PRIVATE
|
|
PICO_USE_CRT_PRINTF=1 # want full precision output
|
|
PICO_FLOAT_PROPAGATE_NANS=1
|
|
PICO_DOUBLE_PROPAGATE_NANS=1
|
|
#PICO_DIVIDER_DISABLE_INTERRUPTS=1
|
|
)
|
|
pico_set_printf_implementation(m33 compiler) # want full precision output
|
|
pico_set_float_implementation(m33 pico)
|
|
pico_set_double_implementation(m33 pico)
|
|
target_link_libraries(m33 pico_double pico_stdlib)
|
|
pico_add_extra_outputs(m33)
|
|
endif()
|